pdufield

package
v0.0.0-...-54098fd Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2017 License: MIT Imports: 6 Imported by: 4

Documentation

Overview

Package pdufield provides PDU field codecs and utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body interface {
	Len() int
	Raw() interface{}
	String() string
	Bytes() []byte
	SerializeTo(w io.Writer) error
}

Body is an interface for manipulating binary PDU field data.

func New

func New(n Name, data []byte) Body

New parses the given binary data and returns a Data object, or nil if the field Name is unknown.

type DeliverySetting

type DeliverySetting uint8

DeliverySetting is used to configure registered delivery for short messages.

const (
	NoDeliveryReceipt      DeliverySetting = 0x00
	FinalDeliveryReceipt   DeliverySetting = 0x01
	FailureDeliveryReceipt DeliverySetting = 0x02
)

Supported delivery settings.

type DestSme

type DestSme struct {
	Flag     Fixed
	Ton      Fixed
	Npi      Fixed
	DestAddr Variable
}

DestSme is a PDU field used for an sme addreses.

func (*DestSme) Bytes

func (ds *DestSme) Bytes() []byte

Bytes implements the Data interface.

func (*DestSme) Len

func (ds *DestSme) Len() int

Len implements the Data interface.

func (*DestSme) Raw

func (ds *DestSme) Raw() interface{}

Raw implements the Data interface.

func (*DestSme) SerializeTo

func (ds *DestSme) SerializeTo(w io.Writer) error

SerializeTo implements the Data interface.

func (*DestSme) String

func (ds *DestSme) String() string

String implements the Data interface.

type DestSmeList

type DestSmeList struct {
	Data []DestSme
}

DestSmeList contains a list of DestSme

func (*DestSmeList) Bytes

func (dsl *DestSmeList) Bytes() []byte

Bytes implements the Data interface.

func (*DestSmeList) Len

func (dsl *DestSmeList) Len() int

Len implements the Data interface.

func (*DestSmeList) Raw

func (dsl *DestSmeList) Raw() interface{}

Raw implements the Data interface.

func (*DestSmeList) SerializeTo

func (dsl *DestSmeList) SerializeTo(w io.Writer) error

SerializeTo implements the Data interface.

func (*DestSmeList) String

func (dsl *DestSmeList) String() string

String implements the Data interface.

type Fixed

type Fixed struct {
	Data uint8
}

Fixed is a PDU of fixed length.

func (*Fixed) Bytes

func (f *Fixed) Bytes() []byte

Bytes implements the Data interface.

func (*Fixed) Len

func (f *Fixed) Len() int

Len implements the Data interface.

func (*Fixed) Raw

func (f *Fixed) Raw() interface{}

Raw implements the Data interface.

func (*Fixed) SerializeTo

func (f *Fixed) SerializeTo(w io.Writer) error

SerializeTo implements the Data interface.

func (*Fixed) String

func (f *Fixed) String() string

String implements the Data interface.

type List

type List []Name

List is a list of PDU fields.

func (List) Decode

func (l List) Decode(r *bytes.Buffer) (Map, error)

Decode decodes binary data in the given buffer to build a Map.

If the ShortMessage field is present, and DataCoding as well, we attempt to decode text automatically. See pdutext package for more information.

func (List) DecodeTLV

func (l List) DecodeTLV(r *bytes.Buffer) (TLVMap, error)

DecodeTLV scans the given byte slice to build a TLVMap from binary data.

type Map

type Map map[Name]Body

Map is a collection of PDU field data indexed by name.

func (Map) Set

func (m Map) Set(k Name, v interface{}) error

Set updates the PDU map with the given key and value, and returns error if the value cannot be converted to type Data.

This is a shortcut for m[k] = New(k, v) converting v properly.

If k is ShortMessage and v is of type pdutext.Codec, text is encoded and data_coding PDU and sm_length PDUs are set.

type Name

type Name string

Name is the name of a PDU field.

const (
	AddrNPI              Name = "addr_npi"
	AddrTON              Name = "addr_ton"
	AddressRange         Name = "address_range"
	DataCoding           Name = "data_coding"
	DestAddrNPI          Name = "dest_addr_npi"
	DestAddrTON          Name = "dest_addr_ton"
	DestinationAddr      Name = "destination_addr"
	DestinationList      Name = "dest_addresses"
	ESMClass             Name = "esm_class"
	ErrorCode            Name = "error_code"
	FinalDate            Name = "final_date"
	InterfaceVersion     Name = "interface_version"
	MessageID            Name = "message_id"
	MessageState         Name = "message_state"
	NumberDests          Name = "number_of_dests"
	NoUnsuccess          Name = "no_unsuccess"
	Password             Name = "password"
	PriorityFlag         Name = "priority_flag"
	ProtocolID           Name = "protocol_id"
	RegisteredDelivery   Name = "registered_delivery"
	ReplaceIfPresentFlag Name = "replace_if_present_flag"
	SMDefaultMsgID       Name = "sm_default_msg_id"
	SMLength             Name = "sm_length"
	ScheduleDeliveryTime Name = "schedule_delivery_time"
	ServiceType          Name = "service_type"
	ShortMessage         Name = "short_message"
	SourceAddr           Name = "source_addr"
	SourceAddrNPI        Name = "source_addr_npi"
	SourceAddrTON        Name = "source_addr_ton"
	SystemID             Name = "system_id"
	SystemType           Name = "system_type"
	UDHLength            Name = "gsm_sms_ud.udh.len"
	GSMUserData          Name = "gsm_sms_ud.udh"
	UnsuccessSme         Name = "unsuccess_sme"
	ValidityPeriod       Name = "validity_period"
)

Supported PDU field names.

type SM

type SM struct {
	Data []byte
}

SM is a PDU field used for Short Messages.

func (*SM) Bytes

func (sm *SM) Bytes() []byte

Bytes implements the Data interface.

func (*SM) Len

func (sm *SM) Len() int

Len implements the Data interface.

func (*SM) Raw

func (sm *SM) Raw() interface{}

Raw implements the Data interface.

func (*SM) SerializeTo

func (sm *SM) SerializeTo(w io.Writer) error

SerializeTo implements the Data interface.

func (*SM) String

func (sm *SM) String() string

String implements the Data interface.

type TLVBody

type TLVBody struct {
	Tag TLVType
	Len uint16
	// contains filtered or unexported fields
}

TLVBody represents data of a TLV field.

func (*TLVBody) Bytes

func (tlv *TLVBody) Bytes() []byte

Bytes return raw TLV binary data.

func (*TLVBody) SerializeTo

func (tlv *TLVBody) SerializeTo(w io.Writer) error

SerializeTo serializes TLV data to its binary form.

type TLVMap

type TLVMap map[TLVType]*TLVBody

TLVMap is a collection of PDU TLV field data indexed by type.

type TLVType

type TLVType uint16

TLVType is the Tag Length Value.

const (
	DestAddrSubunit          TLVType = 0x0005
	DestNetworkType          TLVType = 0x0006
	DestBearerType           TLVType = 0x0007
	DestTelematicsID         TLVType = 0x0008
	SourceAddrSubunit        TLVType = 0x000D
	SourceNetworkType        TLVType = 0x000E
	SourceBearerType         TLVType = 0x000F
	SourceTelematicsID       TLVType = 0x0010
	QosTimeToLive            TLVType = 0x0017
	PayloadType              TLVType = 0x0019
	AdditionalStatusInfoText TLVType = 0x001D
	ReceiptedMessageID       TLVType = 0x001E
	MsMsgWaitFacilities      TLVType = 0x0030
	PrivacyIndicator         TLVType = 0x0201
	SourceSubaddress         TLVType = 0x0202
	DestSubaddress           TLVType = 0x0203
	UserMessageReference     TLVType = 0x0204
	UserResponseCode         TLVType = 0x0205
	SourcePort               TLVType = 0x020A
	DestinationPort          TLVType = 0x020B
	SarMsgRefNum             TLVType = 0x020C
	LanguageIndicator        TLVType = 0x020D
	SarTotalSegments         TLVType = 0x020E
	SarSegmentSeqnum         TLVType = 0x020F
	CallbackNumPresInd       TLVType = 0x0302
	CallbackNumAtag          TLVType = 0x0303
	NumberOfMessages         TLVType = 0x0304
	CallbackNum              TLVType = 0x0381
	DpfResult                TLVType = 0x0420
	SetDpf                   TLVType = 0x0421
	MsAvailabilityStatus     TLVType = 0x0422
	NetworkErrorCode         TLVType = 0x0423
	MessagePayload           TLVType = 0x0424
	DeliveryFailureReason    TLVType = 0x0425
	MoreMessagesToSend       TLVType = 0x0426
	MessageStateOption       TLVType = 0x0427
	UssdServiceOp            TLVType = 0x0501
	DisplayTime              TLVType = 0x1201
	SmsSignal                TLVType = 0x1203
	MsValidity               TLVType = 0x1204
	AlertOnMessageDelivery   TLVType = 0x130C
	ItsReplyType             TLVType = 0x1380
	ItsSessionInfo           TLVType = 0x1383
)

TLV Tags

type UDH

type UDH struct {
	IEI      Fixed
	IELength Fixed
	IEData   Variable
}

UDH is a PDU field used for user data header.

func (*UDH) Bytes

func (udh *UDH) Bytes() []byte

Bytes implements the Data interface.

func (*UDH) Len

func (udh *UDH) Len() int

Len implements the Data interface.

func (*UDH) Raw

func (udh *UDH) Raw() interface{}

Raw implements the Data interface.

func (*UDH) SerializeTo

func (udh *UDH) SerializeTo(w io.Writer) error

SerializeTo implements the Data interface.

func (*UDH) String

func (udh *UDH) String() string

String implements the Data interface.

type UDHList

type UDHList struct {
	Data []UDH
}

UDHList contains a list of UDH.

func (*UDHList) Bytes

func (udhl *UDHList) Bytes() []byte

Bytes implements the Data interface.

func (*UDHList) Len

func (udhl *UDHList) Len() int

Len implements the Data interface.

func (*UDHList) Raw

func (udhl *UDHList) Raw() interface{}

Raw implements the Data interface.

func (*UDHList) SerializeTo

func (udhl *UDHList) SerializeTo(w io.Writer) error

SerializeTo implements the Data interface.

func (*UDHList) String

func (udhl *UDHList) String() string

String implements the Data interface.

type UnSme

type UnSme struct {
	Ton      Fixed
	Npi      Fixed
	DestAddr Variable
	ErrCode  Variable
}

UnSme is a PDU field used for unsuccess sme addreses.

func (*UnSme) Bytes

func (us *UnSme) Bytes() []byte

Bytes implements the Data interface.

func (*UnSme) Len

func (us *UnSme) Len() int

Len implements the Data interface.

func (*UnSme) Raw

func (us *UnSme) Raw() interface{}

Raw implements the Data interface.

func (*UnSme) SerializeTo

func (us *UnSme) SerializeTo(w io.Writer) error

SerializeTo implements the Data interface.

func (*UnSme) String

func (us *UnSme) String() string

String implements the Data interface.

type UnSmeList

type UnSmeList struct {
	Data []UnSme
}

UnSmeList contains a list of UnSme

func (*UnSmeList) Bytes

func (usl *UnSmeList) Bytes() []byte

Bytes implements the Data interface.

func (*UnSmeList) Len

func (usl *UnSmeList) Len() int

Len implements the Data interface.

func (*UnSmeList) Raw

func (usl *UnSmeList) Raw() interface{}

Raw implements the Data interface.

func (*UnSmeList) SerializeTo

func (usl *UnSmeList) SerializeTo(w io.Writer) error

SerializeTo implements the Data interface.

func (*UnSmeList) String

func (usl *UnSmeList) String() string

String implements the Data interface.

type Variable

type Variable struct {
	Data []byte
}

Variable is a PDU field of variable length.

func (*Variable) Bytes

func (v *Variable) Bytes() []byte

Bytes implements the Data interface.

func (*Variable) Len

func (v *Variable) Len() int

Len implements the Data interface.

func (*Variable) Raw

func (v *Variable) Raw() interface{}

Raw implements the Data interface.

func (*Variable) SerializeTo

func (v *Variable) SerializeTo(w io.Writer) error

SerializeTo implements the Data interface.

func (*Variable) String

func (v *Variable) String() string

String implements the Data interface.

Jump to

Keyboard shortcuts

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