pdufield

package
v0.0.0-...-5333dff Latest Latest
Warning

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

Go to latest
Published: May 5, 2019 License: MIT Imports: 6 Imported by: 0

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.

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 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