sar

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package sar provides capabilties to segment large messages into a set of concatenated Submit TPDUs for transmit, and to collect the set of Deliver TPDUs corresponding to a received message.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrClosed indicates that the collector has been closed and is no longer
	// accepting PDUs.
	ErrClosed = errors.New("closed")
	// ErrDuplicateSegment indicates a segment has arrived for a reassembly
	// that already has that segment.
	// The segments are duplicates in terms of their concatentation information.
	// They may differ in other fields, particularly UD, but those fields cannot
	// be used to determine which of the two may better fit the reassembly, so
	// the first is kept and the second discarded.
	ErrDuplicateSegment = errors.New("duplcate segment")
	// ErrReassemblyInconsistency indicates a segment has arrived for a reassembly
	// that has a seqno greater than the number of segments in the reassembly.
	ErrReassemblyInconsistency = errors.New("reassembly inconsistency")
)

Functions

This section is empty.

Types

type Collector

type Collector struct {
	sync.Mutex // covers pipes and closing closed
	// contains filtered or unexported fields
}

Collector contains reassembly pipes that buffer concatenated TPDUs until a full set is available to be concatenated.

func NewCollector

func NewCollector(d time.Duration, asyncError func(error)) *Collector

NewCollector creates a Collector. The asyncError function is called when a reassembly fails asynchronously. The asyncError function must be safe to be called from multiple goroutines.

func (*Collector) Close

func (c *Collector) Close()

Close shuts down the Collector and all active pipes.

func (*Collector) Collect

func (c *Collector) Collect(pdu *tpdu.Deliver) (d []*tpdu.Deliver, err error)

Collect adds a TPDU to the collection. If all the components of a concatenated TPDU are available then they are returned.

type ErrExpired

type ErrExpired struct {
	T []*tpdu.Deliver
}

ErrExpired indicates that a reassembly has timed out. The segments of the aborted reassembly are returned in the error.

func (ErrExpired) Error

func (e ErrExpired) Error() string

type Segmenter

type Segmenter struct {
	// contains filtered or unexported fields
}

Segmenter segments a large outgoing message into the set of Submit TPDUs required to contain it.

func NewSegmenter

func NewSegmenter() *Segmenter

NewSegmenter creates a Segmenter.

func (*Segmenter) Segment

func (s *Segmenter) Segment(msg []byte, t *tpdu.Submit) []tpdu.Submit

Segment returns the set of SMS-Submit TPDUs required to transmit the message using the given alphabet. A template for the SMS-Submit TPDUs is passed in, and provides all the fields in the resulting TPDUs, other than the UD, which is populated using the message. For multi-part messages, the UDH provided in the template is extended with a concatenation IE. The template UDH must not contain a concatenation IE (ID 0) or the resulting TPDUs will be non-conformant.

func (*Segmenter) SetWide

func (s *Segmenter) SetWide(w bool)

SetWide sets the Segmenter wide flag. If true then the segmenter will use 16bit message references instead of 8bit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL