tpdu

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalid indicates the value of a field provided to an encoder is not valid.
	ErrInvalid = errors.New("invalid")
	// ErrOddUCS2Length indicates the length of a binary array containing UCS2
	// characters has an uneven length, and so has split a UCS2 character.
	ErrOddUCS2Length = errors.New("odd UCS2 length")
	// ErrOverlength indicates the binary provided contains more bytes than
	// expected by the TPDU decoder.
	ErrOverlength = errors.New("overlength")
	// ErrMissing indicates a field requiored to marshal an object is missing.
	ErrMissing = errors.New("missing")
	// ErrNonZero indicates a field which is expected to be zeroed, but contains
	// non-zero data.
	ErrNonZero = errors.New("non-zero fill")
	// ErrUnderflow indicates the binary provided does not contain
	// sufficient bytes to correctly decode the TPDU.
	ErrUnderflow = errors.New("underflow")
)

Functions

func DecodeError

func DecodeError(f string, o int, e error) error

DecodeError creates a decodeError which identifies the field being decoded, and the offset into the byte array where the field starts. If the provided error is a nested decodeError then the offset is updated to provide the offset from the beginning of the enclosing field, and the field names are combined in outer.inner format.

func EncodeError

func EncodeError(f string, e error) error

EncodeError creates an encodeError which identifies the field being encoded. If the provided error is a nested encodeError then the error is returned as is rather than wrapping it.

func RegisterCommandDecoder

func RegisterCommandDecoder(d *Decoder) error

RegisterCommandDecoder registers a decoder for the Command TPDU.

func RegisterDeliverDecoder

func RegisterDeliverDecoder(d *Decoder) error

RegisterDeliverDecoder registers a decoder for the Deliver TPDU.

func RegisterDeliverReportDecoder

func RegisterDeliverReportDecoder(d *Decoder) error

RegisterDeliverReportDecoder registers a decoder for the DeliverReport TPDU.

func RegisterReservedDecoder

func RegisterReservedDecoder(d *Decoder) error

RegisterReservedDecoder registers a decoder for the Deliver TPDU for the Reserved message type.

func RegisterStatusReportDecoder

func RegisterStatusReportDecoder(d *Decoder) error

RegisterStatusReportDecoder registers a decoder for the StatusReport TPDU.

func RegisterSubmitDecoder

func RegisterSubmitDecoder(d *Decoder) error

RegisterSubmitDecoder registers a decoder for the Submit TPDU.

func RegisterSubmitReportDecoder

func RegisterSubmitReportDecoder(d *Decoder) error

RegisterSubmitReportDecoder registers a decoder for the SubmitReport TPDU.

Types

type Address

type Address struct {
	TOA  byte
	Addr string
}

Address represents a phone number.

func NewAddress

func NewAddress() *Address

NewAddress creates an Address and initialises the TOA.

func (*Address) MarshalBinary

func (a *Address) MarshalBinary() (dst []byte, err error)

MarshalBinary marshals an Address into binary. It returns the marshalled address and any error detected while marshalling.

func (Address) Number

func (a Address) Number() string

Number returns the stringified number corresponding to the Address.

func (*Address) NumberingPlan

func (a *Address) NumberingPlan() NumberingPlan

NumberingPlan extracts the NPI field from the TOA.

func (*Address) SetNumberingPlan

func (a *Address) SetNumberingPlan(np NumberingPlan)

SetNumberingPlan sets the NPI field in the TOA.

func (*Address) SetTypeOfNumber

func (a *Address) SetTypeOfNumber(ton TypeOfNumber)

SetTypeOfNumber sets the TON field in the TOA.

func (*Address) TypeOfNumber

func (a *Address) TypeOfNumber() TypeOfNumber

TypeOfNumber extracts the TON field from the TOA.

func (*Address) UnmarshalBinary

func (a *Address) UnmarshalBinary(src []byte) (int, error)

UnmarshalBinary unmarshals an Address from a binary TPDU. It returns the number of bytes read from the source, and any error detected while unmarshalling.

type Alphabet

type Alphabet int

Alphabet defines the encoding of the SMS User Data, as defined in 3GPP TS 23.038 Section 4.

const (
	// Alpha7Bit indicates that the UD is encoded using GSM 7 bit encoding.
	// The character set used for the decoding is determined from the UDH.
	Alpha7Bit Alphabet = iota
	// Alpha8Bit indicates that the UD is encoded as raw 8bit data.
	Alpha8Bit
	// AlphaUCS2 indicates that the UD is encoded as UCS-2 (16bit) characters.
	AlphaUCS2
	// AlphaReserved indicates the alphabet is not defined.
	AlphaReserved
)

type Command

type Command struct {
	TPDU
	MR byte
	CT byte
	MN byte
	DA Address
}

Command represents an SMS Command TPDU as defined in 3GPP TS 23.040 Section 9.2.2.4.

func NewCommand

func NewCommand() *Command

NewCommand creates a Command TPDU and initialises non-zero fields.

func (*Command) MarshalBinary

func (c *Command) MarshalBinary() ([]byte, error)

MarshalBinary marshals an SMS-Command-Report TPDU.

func (*Command) UnmarshalBinary

func (c *Command) UnmarshalBinary(src []byte) error

UnmarshalBinary unmarshals an SMS-Command-Report TPDU.

type ConcreteDecoder

type ConcreteDecoder func([]byte) (interface{}, error)

ConcreteDecoder is a function that decodes a binary TPDU into a particular TPDU struct.

type DCS

type DCS byte

DCS represents the SMS Data Coding Scheme field as defined in 3GPP TS 23.040 Section 4.

func (DCS) Alphabet

func (d DCS) Alphabet() (Alphabet, error)

Alphabet returns the alphabet used to encode the User Data according to the DCS. The DCS is assumed to be defined as per 3GPP TS 23.038 Section 4.

func (DCS) Class

func (d DCS) Class() (MessageClass, error)

Class returns the MessageClass indicated by the DCS. The DCS is assumed to be defined as per 3GPP TS 23.038 Section 4.

func (DCS) Compressed

func (d DCS) Compressed() bool

Compressed indicates whether the text is compressed using the algorithm defined in 3GPP TS 23.024, as determined from the DCS. The DCS is assumed to be defined as per 3GPP TS 23.038 Section 4.

func (DCS) WithAlphabet

func (d DCS) WithAlphabet(a Alphabet) (DCS, error)

WithAlphabet sets the Alphabet bits of the DCS, given the state of the other bits. An error is returned if the state is incompatible with setting the alphabet.

func (DCS) WithClass

func (d DCS) WithClass(c MessageClass) (DCS, error)

WithClass sets the MessageClass bits of the DCS, given the state of the other bits. An error is returned if the state is incompatible with setting the message class.

type Decoder

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

Decoder converts binary TPDUs to the corresponding TPDU implementation.

func NewDecoder

func NewDecoder(opts ...DecoderOption) (*Decoder, error)

NewDecoder creates a new Decoder.

func (*Decoder) Decode

func (d *Decoder) Decode(src []byte, drn Direction) (interface{}, error)

Decode returns the TPDU decoded from the SMS TPDU in src. The direction of the SMS must be provided so the the decoder can correctly determine the type of TPDU from the MTI. (the same MTI is used for different TPDUs depending on whether the SMS is being sent to the MS, or is from the MS.)

The reverse of this operation is MarshalBinary on the returned TPDU.

func (*Decoder) RegisterDecoder

func (d *Decoder) RegisterDecoder(mt MessageType, drn Direction, f ConcreteDecoder) error

RegisterDecoder registers a decoder for the given MessageType and Direction.

type DecoderOption

type DecoderOption func(*Decoder) error

DecoderOption is function that modifies an existing Decoder.

type Deliver

type Deliver struct {
	TPDU
	OA Address
	// The SCTS timestamp indicates the time the SMS was sent.
	// The time is the originator's local time, the timezone of which may differ from the
	// receiver's.
	SCTS Timestamp
}

Deliver represents a SMS-Deliver PDU as defined in 3GPP TS 23.038 Section 9.2.2.1.

func NewDeliver

func NewDeliver() *Deliver

NewDeliver creates a Deliver TPDU and initialises non-zero fields.

func (*Deliver) MarshalBinary

func (d *Deliver) MarshalBinary() ([]byte, error)

MarshalBinary marshals a SMS-Deliver PDU into the corresponding byte array.

func (*Deliver) MaxUDL

func (d *Deliver) MaxUDL() int

MaxUDL returns the maximum number of octets that can be encoded into the UD. Note that for 7bit encoding this can result in up to 160 septets.

func (*Deliver) UnmarshalBinary

func (d *Deliver) UnmarshalBinary(src []byte) error

UnmarshalBinary unmarshals a SMS-Deliver PDU from the corresponding byte array. In the case of error the Deliver will be partially unmarshalled, up to the point that the decoding error was detected.

type DeliverReport

type DeliverReport struct {
	TPDU
	FCS byte
	PI  byte
}

DeliverReport represents a SMS-Deliver-Report PDU as defined in 3GPP TS 23.038 Section 9.2.2.1a.

func NewDeliverReport

func NewDeliverReport() *DeliverReport

NewDeliverReport creates a DeliverReport TPDU and initialises non-zero fields.

func (*DeliverReport) MarshalBinary

func (d *DeliverReport) MarshalBinary() ([]byte, error)

MarshalBinary marshals an SMS-Deliver-Report TPDU.

func (*DeliverReport) SetDCS

func (d *DeliverReport) SetDCS(dcs byte)

SetDCS sets the DeliverReport dcs field and the corresponding bit of the pi.

func (*DeliverReport) SetPID

func (d *DeliverReport) SetPID(pid byte)

SetPID sets the DeliverReport pid field and the corresponding bit of the pi.

func (*DeliverReport) SetUD

func (d *DeliverReport) SetUD(ud UserData)

SetUD sets the DeliverReport ud field and the corresponding bit of the pi.

func (*DeliverReport) SetUDH

func (d *DeliverReport) SetUDH(udh UserDataHeader)

SetUDH sets the User Data Header of the DeliverReport and the corresponding bit of the pi.

func (*DeliverReport) UnmarshalBinary

func (d *DeliverReport) UnmarshalBinary(src []byte) error

UnmarshalBinary unmarshals an SMS-Deliver-Report TPDU.

type Direction

type Direction int

Direction indicates the direction that the SMS TPDU is carried.

const (
	// MT indicates that the SMS TPDU is intended to be received by the MS.
	MT Direction = iota
	// MO indicates that the SMS TPDU is intended to be sent by the MS.
	MO
)

type EnhancedValidityPeriodFormat

type EnhancedValidityPeriodFormat byte

EnhancedValidityPeriodFormat identifies the subformat of the ValidityPeriod when encoded to binary in enhanced format, as per 3GPP TS 23.038 Section 9.2.3.12.3

const (
	// EvpfNotPresent indicates no VP is present.
	EvpfNotPresent EnhancedValidityPeriodFormat = iota
	// EvpfRelative indicates the VP is stored in relative format as per 3GPP TS 23.038 Section 9.2.3.12.1.
	EvpfRelative
	// EvpfRelativeSeconds indicates the VP is stored in relative format as an
	// integer number of seconds, from 0 to 255.
	EvpfRelativeSeconds
	// EvpfRelativeHHMMSS indicates the VP is stored in relative format as a period of
	// hours, minutes and seconds in semioctet format as per SCTS time.
	EvpfRelativeHHMMSS
)

type ErrUnsupportedMTI

type ErrUnsupportedMTI byte

ErrUnsupportedMTI indicates the MTI of the pdu being decoded is not unsupported by the decoder. This does not necessarily mean the MTI is invalid, only that no decoder has been defined that MTI and direction.

func (ErrUnsupportedMTI) Error

func (e ErrUnsupportedMTI) Error() string

type InformationElement

type InformationElement struct {
	ID   byte
	Data []byte
}

InformationElement represents one of the information elements contained in the User Data Header.

type MessageClass

type MessageClass int

MessageClass indicates the

const (
	// MClass0 is a flash message which is not to be stored in memory.
	MClass0 MessageClass = iota
	// MClass1 is an ME specific message.
	MClass1
	// MClass2 is a SIM/USIM specific message.
	MClass2
	// MClass3 is a TE specific message.
	MClass3
	// MClassUnknown indicates no message class is set.
	MClassUnknown
)

type MessageType

type MessageType int

MessageType identifies the type of TPDU encoded in a binary stream, as defined in 3GPP TS 23.040 Section 9.2.3.1. Note that the direction of the TPDU must also be known to determine how to interpret the TPDU.

const (
	// MtDeliver identifies the message as a SMS-Deliver or SMS-Deliver-Report TPDU.
	MtDeliver MessageType = iota
	// MtSubmit identifies the message as a SMS-Submit or SMS-Submit-Report TPDU.
	MtSubmit
	// MtCommand identifies the message as a SMS-Command or SMS-Status-Report TPDU.
	MtCommand
	// MtReserved identifies the message as an unknown type of SMS TPDU.
	MtReserved
)

type NumberingPlan

type NumberingPlan int

NumberingPlan corresponds to bits 4,3,2,1 of the Address TOA field. i.e. 1yyyxxxx as defined in 3GPP TS 23.040 Section 9.1.2.5

const (
	// NpUnknown indicates the numbering plan is unknown.
	NpUnknown NumberingPlan = iota
	// NpISDN indicates the number is in ISDN/E.164 format.
	NpISDN

	// NpData indicates a data numbering plan (X.121).
	NpData
	// NpTelex indicates a telex numbering plan.
	NpTelex
	// NpScSpecificA indicates a service center specific numbering plan.
	NpScSpecificA
	// NpScSpecificB indicates a service center specific numbering plan.
	NpScSpecificB

	// NpNational indicates a national numbering plan.
	NpNational
	// NpPrivate indicates a private numbering plan.
	NpPrivate
	// NpErmes indicates the ERMES (ETSI DE/PS 3 01-3) numbering plan.
	NpErmes
	// NpExtension is reserved for future extensions.
	NpExtension = 0x0f
)

type StatusReport

type StatusReport struct {
	TPDU
	MR   byte
	RA   Address
	SCTS Timestamp
	DT   Timestamp
	ST   byte
	PI   byte
}

StatusReport represents a SMS-Status-Report PDU as defined in 3GPP TS 23.038 Section 9.2.2.3.

func NewStatusReport

func NewStatusReport() *StatusReport

NewStatusReport creates a StatusReport TPDU and initialises non-zero fields.

func (*StatusReport) MarshalBinary

func (s *StatusReport) MarshalBinary() ([]byte, error)

MarshalBinary marshals an SMS-Status-Report TPDU.

func (*StatusReport) SetDCS

func (s *StatusReport) SetDCS(dcs byte)

SetDCS sets the StatusReport dcs field and the corresponding bit of the pi.

func (*StatusReport) SetPID

func (s *StatusReport) SetPID(pid byte)

SetPID sets the StatusReport pid field and the corresponding bit of the pi.

func (*StatusReport) SetUD

func (s *StatusReport) SetUD(ud UserData)

SetUD sets the StatusReport ud field and the corresponding bit of the pi.

func (*StatusReport) SetUDH

func (s *StatusReport) SetUDH(udh UserDataHeader)

SetUDH sets the User Data Header of the StatusReport and the corresponding bit of the pi.

func (*StatusReport) UnmarshalBinary

func (s *StatusReport) UnmarshalBinary(src []byte) error

UnmarshalBinary unmarshals an SMS-Status-Report TPDU.

type Submit

type Submit struct {
	TPDU
	MR byte
	DA Address
	VP ValidityPeriod
}

Submit represents a SMS-Submit PDU as defined in 3GPP TS 23.038 Section 9.2.2.2.

func NewSubmit

func NewSubmit() *Submit

NewSubmit creates a Submit TPDU and initialises non-zero fields.

func (*Submit) MarshalBinary

func (s *Submit) MarshalBinary() ([]byte, error)

MarshalBinary marshals an SMS-Submit TPDU.

func (*Submit) MaxUDL

func (s *Submit) MaxUDL() int

MaxUDL returns the maximum number of octets that can be encoded into the UD. Note that for 7bit encoding this can result in up to 160 septets.

func (*Submit) SetVP

func (s *Submit) SetVP(vp ValidityPeriod)

SetVP sets the validity period and the corresponding VPF bits in the firstOctet.

func (*Submit) UnmarshalBinary

func (s *Submit) UnmarshalBinary(src []byte) error

UnmarshalBinary unmarshals an SMS-Submit TPDU. In the case of error the Submit will be partially unmarshalled, up to the point that the decoding error was detected.

type SubmitReport

type SubmitReport struct {
	TPDU
	FCS  byte
	PI   byte
	SCTS Timestamp
}

SubmitReport represents a SMS-Submit-Report PDU as defined in 3GPP TS 23.038 Section 9.2.2.2a.

func NewSubmitReport

func NewSubmitReport() *SubmitReport

NewSubmitReport creates a SubmitReport TPDU and initialises non-zero fields.

func (*SubmitReport) MarshalBinary

func (s *SubmitReport) MarshalBinary() ([]byte, error)

MarshalBinary marshals an SMS-Submit-Report TPDU.

func (*SubmitReport) SetDCS

func (s *SubmitReport) SetDCS(dcs byte)

SetDCS sets the SubmitReport dcs field and the corresponding bit of the pi.

func (*SubmitReport) SetPID

func (s *SubmitReport) SetPID(pid byte)

SetPID sets the SubmitReport pid field and the corresponding bit of the pi.

func (*SubmitReport) SetUD

func (s *SubmitReport) SetUD(ud UserData)

SetUD sets the SubmitReport ud field and the corresponding bit of the pi.

func (*SubmitReport) SetUDH

func (s *SubmitReport) SetUDH(udh UserDataHeader)

SetUDH sets the User Data Header of the SubmitReport and the corresponding bit of the pi.

func (*SubmitReport) UnmarshalBinary

func (s *SubmitReport) UnmarshalBinary(src []byte) error

UnmarshalBinary unmarshals an SMS-Submit-Report TPDU.

type TPDU

type TPDU struct {
	FirstOctet byte
	PID        byte
	DCS        byte
	UDH        UserDataHeader
	// UD contains the short message from the User Data.
	// It does not include the User Data Header, which is provided in udh.
	// The interpretation of UD depends on the Alphabet.
	// For Alpha7Bit, UD is an array of GSM7 septets, each septet stored in the lower 7 bits of a byte.
	//  These have NOT been converted to the corresponding UTF8.
	//  Use the gsm7 package to convert to UTF8.
	// For AlphaUCS2, UD is an array of UCS2 characters packed into a byte array in Big Endian.
	//  These have NOT been converted to the corresponding UTF8.
	//  Use the usc2 package to convert to UTF8.
	// For Alpha8Bit, UD contains the raw octets.
	UD UserData
}

TPDU is the base type for SMS TPDUs.

func (*TPDU) Alphabet

func (p *TPDU) Alphabet() (Alphabet, error)

Alphabet returns the alphabet field from the DCS of the SMS TPDU.

func (*TPDU) MTI

func (p *TPDU) MTI() MessageType

MTI returns the MessageType from the first octet of the SMS TPDU.

func (*TPDU) SetUDH

func (p *TPDU) SetUDH(udh UserDataHeader)

SetUDH sets the User Data Header of the TPDU.

func (*TPDU) UDHI

func (p *TPDU) UDHI() bool

UDHI returns the User Data Header Indicator bit from the SMS TPDU first octet. This is generally the same as testing the length of the udh - unless the dcs has been intentionally overwritten to create an inconsistency.

type Timestamp

type Timestamp struct {
	time.Time
}

Timestamp represents a SCTS timestamp, as defined in 3GPP TS 23.040 Section 9.2.3.11.

func (*Timestamp) MarshalBinary

func (t *Timestamp) MarshalBinary() (dst []byte, err error)

MarshalBinary encodes the SCTS timestamp into binary.

func (*Timestamp) UnmarshalBinary

func (t *Timestamp) UnmarshalBinary(src []byte) error

UnmarshalBinary decodes the SCTS timestamp.

type TypeOfNumber

type TypeOfNumber int

TypeOfNumber corresponds to bits 6,5,4 of the Address TOA field. i.e. 1xxxyyyy, as defined in 3GPP TS 23.040 Section 9.1.2.5.

const (
	// TonUnknown indicates the type of the number is unknown.
	TonUnknown TypeOfNumber = iota
	// TonInternational indicates the number is international.
	TonInternational
	// TonNational indicates the number is national.
	TonNational
	// TonNetworkSpecific indicates the number is specific to the carrier network.
	TonNetworkSpecific
	// TonSubscriberNumber indicates the number is a subscriber number.
	TonSubscriberNumber
	// TonAlphanumeric indicates the number is in alphanumeric format.
	TonAlphanumeric
	// TonAbbreviated indicates the number is in abbreviated format.
	TonAbbreviated
	// TonExtension is reserved for future extension.
	TonExtension
)

type UDDecoder

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

UDDecoder converts TPDU UD to UTF8. By default the translator only supports the default character set. Additional character sets can be added using the AddLockingCharset and AddShiftCharset methods.

func NewUDDecoder

func NewUDDecoder() (*UDDecoder, error)

NewUDDecoder creates a new UD Decoder.

func (*UDDecoder) AddAllCharsets

func (d *UDDecoder) AddAllCharsets()

AddAllCharsets makes all possible character sets available to Decode. This is equivalent to calling AddLockingCharset and AddShiftCharset for all possible NationalLanguageIdentifiers.

func (*UDDecoder) AddLockingCharset

func (d *UDDecoder) AddLockingCharset(nli charset.NationalLanguageIdentifier)

AddLockingCharset adds a locking character set to the sets available to Decode.

func (*UDDecoder) AddShiftCharset

func (d *UDDecoder) AddShiftCharset(nli charset.NationalLanguageIdentifier)

AddShiftCharset adds a shift character set to the sets available to Decode.

func (*UDDecoder) Decode

func (d *UDDecoder) Decode(ud UserData, udh UserDataHeader, alpha Alphabet) ([]byte, error)

Decode converts TPDU UD into the corresponding UTF8 message. The UD is expected to be unpacked, as stored in TPDU UD. If the UD is GSM7 encoded then it is translated to UTF8 with the default character set, or with the character set specified in the UDH, assuming the corresponding language has been registered with the UDDecoder. If the UDH specifies a character set that has not been registered then the translation will fall back to the default character set.

type UDEncoder

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

UDEncoder converts TPDU UD into the corresponding binary UD. By default the translator only supports the default character set. Additional character sets can be added using the AddLockingCharset and AddShiftCharset methods.

func NewUDEncoder

func NewUDEncoder() (*UDEncoder, error)

NewUDEncoder creates a new UDEncoder.

func (*UDEncoder) AddAllCharsets

func (e *UDEncoder) AddAllCharsets()

AddAllCharsets makes all possible character sets available to Encode. This is equivalent to calling AddLockingCharset and AddShiftCharset for all possible NationalLanguageIdentifiers, in increasing order.

func (*UDEncoder) AddLockingCharset

func (e *UDEncoder) AddLockingCharset(nli charset.NationalLanguageIdentifier)

AddLockingCharset adds a locking character set to the sets available to Encode.

func (*UDEncoder) AddShiftCharset

func (e *UDEncoder) AddShiftCharset(nli charset.NationalLanguageIdentifier)

AddShiftCharset adds a shift character set to the sets available to Encode.

func (*UDEncoder) Encode

func (e *UDEncoder) Encode(msg string) (UserData, UserDataHeader, Alphabet, error)

Encode converts a UTF8 message into corresponding TPDU User Data. Note that the UD size is not limited to the szie available in a single TPDU, and so may need to be segmented into several concatenated messages. Encode attempts to pick the most compact alphabet for the given message. It assumes GSM7 is the most compact, and, if the default character set is insufficient, tries combinations of supported language character sets, in the order they were added to the UDEncoder. It is not optimal as it performs language selection on the whole message, rather than determining the best for each segment in turn. (which is totally allowed as stated in 3GPP TS 23.040 9.2.3.24.15 + 16) But this may be a safer approach - to allow for the decoder being non-compliant, and the benefit of per-segment language encoding is minimal. In most cases there is no benefit at all.

Failing GSM7 conversion it falls back to UCS2/UTF16.

type UserData

type UserData []byte

UserData represents the User Data field as defined in 3GPP TS 23.040 Section 9.2.3.24. The UserData is comprised of an optional User Data Header and a short message field.

type UserDataHeader

type UserDataHeader []InformationElement

UserDataHeader represents the header section of the User Data as defined in 3GPP TS 23.040 Section 9.2.3.24.

func (UserDataHeader) ConcatInfo

func (udh UserDataHeader) ConcatInfo() (segments, seqno, mref int, ok bool)

ConcatInfo extracts the segmentation info contained in the provided User Data Header. If the UDH contains no segmentation information then ok is false and zero values are returned. The returned values do not distinguish between 8bit and 16bit message reference numbers.

func (UserDataHeader) ConcatInfo16

func (udh UserDataHeader) ConcatInfo16() (segments, seqno, mref int, ok bool)

ConcatInfo16 extracts the segmentation info contained in the provided User Data Header, for the 16bit message reference case. If the UDH contains no segmentation information then ok is false and zero values are returned.

func (UserDataHeader) ConcatInfo8

func (udh UserDataHeader) ConcatInfo8() (segments, seqno, mref int, ok bool)

ConcatInfo8 extracts the segmentation info contained in the provided User Data Header, for the 8bit message reference case. If the UDH contains no segmentation information then ok is false and zero values are returned.

func (UserDataHeader) IE

IE returns the last instance of the GetIE with the given id in the UDH. If no such GetIE is found then the function returns false.

func (UserDataHeader) IEs

func (udh UserDataHeader) IEs(id byte) []InformationElement

IEs returns all instances of the GetIEs with the given id in the UDH.

func (UserDataHeader) MarshalBinary

func (udh UserDataHeader) MarshalBinary() ([]byte, error)

MarshalBinary marshals the User Data Header, including the UDHL, into binary.

func (UserDataHeader) UDHL

func (udh UserDataHeader) UDHL() int

UDHL returns the encoded length of the UDH, not including the UDHL itself.

func (*UserDataHeader) UnmarshalBinary

func (udh *UserDataHeader) UnmarshalBinary(src []byte) (int, error)

UnmarshalBinary reads the InformationElements from the binary User Data Haeder. The src contains the complete UDH, including the UDHL and all IEs. The function returns the number of bytes read from src, and any error detected while unmarshalling.

type ValidityPeriod

type ValidityPeriod struct {
	Format   ValidityPeriodFormat
	Time     Timestamp     // for VpfAbsolute
	Duration time.Duration // for VpfRelative and VpfEnhanced
	EFI      byte          // enhanced functionality indicator - first octet of enhanced format
}

ValidityPeriod represents the validity period as defined in 3GPP TS 34.040 Section 9.2.3.12.

func (*ValidityPeriod) MarshalBinary

func (v *ValidityPeriod) MarshalBinary() ([]byte, error)

MarshalBinary marshals a ValidityPeriod.

func (*ValidityPeriod) SetAbsolute

func (v *ValidityPeriod) SetAbsolute(t Timestamp)

SetAbsolute seth the validity period to an absolute time.

func (*ValidityPeriod) SetEnhanced

func (v *ValidityPeriod) SetEnhanced(d time.Duration, efi byte)

SetEnhanced sets the validity period to an enhnaced format as determined from the functionality identifier (efi).

func (*ValidityPeriod) SetRelative

func (v *ValidityPeriod) SetRelative(d time.Duration)

SetRelative sets the validity period to a relative time.

func (*ValidityPeriod) UnmarshalBinary

func (v *ValidityPeriod) UnmarshalBinary(src []byte, vpf ValidityPeriodFormat) (int, error)

UnmarshalBinary unmarshals a ValidityPeriod stored in the given format. Returns the number of bytes read from the src, and any error detected during the unmarshalling.

type ValidityPeriodFormat

type ValidityPeriodFormat byte

ValidityPeriodFormat identifies the format of the ValidityPeriod when encoded to binary.

const (
	// VpfNotPresent indicates no VP is present.
	VpfNotPresent ValidityPeriodFormat = iota
	// VpfEnhanced indicates the VP is stored in enhanced format as per 3GPP TS 23.038 Section 9.2.3.12.3.
	VpfEnhanced
	// VpfRelative indicates the VP is stored in relative format as per 3GPP TS 23.038 Section 9.2.3.12.1.
	VpfRelative
	// VpfAbsolute indicates the VP is stored in absolute format as per 3GPP TS 23.038 Section 9.2.3.12.2.
	// The absolute format is the same format as the SCTS.
	VpfAbsolute
)

Jump to

Keyboard shortcuts

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