pdu

package
v0.0.0-...-648c0fa Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxShortMessageLength = 140
)

Variables

View Source
var (
	ErrUnmarshalPDUFailed   = errors.New("pdu: unmarshal pdu failed")
	ErrUnknownDataCoding    = errors.New("pdu: unknown data coding")
	ErrInvalidSequence      = errors.New("pdu: invalid sequence (should be 31 bit integer)")
	ErrItemTooMany          = errors.New("pdu: item too many")
	ErrDataTooLarge         = errors.New("pdu: data too large")
	ErrUnparseableTime      = errors.New("pdu: unparseable time")
	ErrShortMessageTooLarge = errors.New("pdu: encoded short message data exceeds size of 140 bytes")
	ErrMultipartTooMuch     = errors.New("pdu: multipart sms too much (max 254 segments)")
)

Functions

func CombineMultipartDeliverSM

func CombineMultipartDeliverSM(on func([]*DeliverSM)) func(*DeliverSM)

func Marshal

func Marshal(w io.Writer, packet interface{}) (n int64, err error)

func ReadPDU

func ReadPDU(r io.Reader) (pdu interface{}, err error)

func ReadSequence

func ReadSequence(packet interface{}) int32

func WriteSequence

func WriteSequence(packet interface{}, sequence int32)

Types

type Address

type Address struct {
	TON byte // see SMPP v5, section 4.7.1 (113p)
	NPI byte // see SMPP v5, section 4.7.2 (113p)
	No  string
}

func (*Address) ReadFrom

func (p *Address) ReadFrom(r io.Reader) (n int64, err error)

func (Address) String

func (p Address) String() string

func (Address) WriteTo

func (p Address) WriteTo(w io.Writer) (n int64, err error)

type AlertNotification

type AlertNotification struct {
	Header     Header `id:"00000102"`
	SourceAddr Address
	ESMEAddr   Address
	Tags       Tags
}

AlertNotification see SMPP v5, section 4.1.3.1 (64p)

type BindReceiver

type BindReceiver struct {
	Header       Header `id:"00000001"`
	SystemID     string
	Password     string
	SystemType   string
	Version      InterfaceVersion
	AddressRange Address // see section 4.7.3.1
}

BindReceiver see SMPP v5, section 4.1.1.3 (58p)

func (*BindReceiver) Resp

func (p *BindReceiver) Resp() interface{}

type BindReceiverResp

type BindReceiverResp struct {
	Header   Header `id:"80000001"`
	SystemID string
	Tags     Tags
}

BindReceiverResp see SMPP v5, section 4.1.1.4 (59p)

type BindTransceiver

type BindTransceiver struct {
	Header       Header `id:"00000009"`
	SystemID     string
	Password     string
	SystemType   string
	Version      InterfaceVersion
	AddressRange Address // see section 4.7.3.1
}

BindTransceiver see SMPP v5, section 4.1.1.5 (59p)

func (*BindTransceiver) Resp

func (p *BindTransceiver) Resp() interface{}

type BindTransceiverResp

type BindTransceiverResp struct {
	Header   Header `id:"80000009"`
	SystemID string
	Tags     Tags
}

BindTransceiverResp see SMPP v5, section 4.1.1.6 (60p)

type BindTransmitter

type BindTransmitter struct {
	Header       Header `id:"00000002"`
	SystemID     string
	Password     string
	SystemType   string
	Version      InterfaceVersion
	AddressRange Address // see section 4.7.3.1
}

BindTransmitter see SMPP v5, section 4.1.1.1 (56p)

func (*BindTransmitter) Resp

func (p *BindTransmitter) Resp() interface{}

type BindTransmitterResp

type BindTransmitterResp struct {
	Header   Header `id:"80000002"`
	SystemID string
	Tags     Tags
}

BindTransmitter see SMPP v5, section 4.1.1.2 (57p)

type BroadcastSM

type BroadcastSM struct {
	Header               Header `id:"00000112"`
	ServiceType          string
	SourceAddr           Address
	MessageID            string
	PriorityFlag         byte
	ScheduleDeliveryTime string
	ValidityPeriod       string
	ReplaceIfPresent     bool
	DataCoding           DataCoding
	DefaultMessageID     byte
	Tags                 Tags
}

BroadcastSM see SMPP v5, section 4.4.1.1 (92p)

func (*BroadcastSM) Resp

func (p *BroadcastSM) Resp() interface{}

type BroadcastSMResp

type BroadcastSMResp struct {
	Header    Header `id:"80000112"`
	MessageID string
	Tags      Tags
}

BroadcastSMResp see SMPP v5, section 4.4.1.2 (96p)

type CancelBroadcastSM

type CancelBroadcastSM struct {
	Header      Header `id:"00000113"`
	ServiceType string
	MessageID   string
	SourceAddr  Address
	Tags        Tags
}

CancelBroadcastSM see SMPP v5, section 4.6.2.1 (110p)

func (*CancelBroadcastSM) Resp

func (p *CancelBroadcastSM) Resp() interface{}

type CancelBroadcastSMResp

type CancelBroadcastSMResp struct {
	Header Header `id:"80000113"`
}

CancelBroadcastSMResp see SMPP v5, section 4.6.2.3 (112p)

type CancelSM

type CancelSM struct {
	Header      Header `id:"00000008"`
	ServiceType string
	MessageID   string
	SourceAddr  Address
	DestAddr    Address
}

CancelSM see SMPP v5, section 4.5.1.1 (100p)

func (*CancelSM) Resp

func (p *CancelSM) Resp() interface{}

type CancelSMResp

type CancelSMResp struct {
	Header Header `id:"80000008"`
}

CancelSM see SMPP v5, section 4.5.1.2 (101p)

type CommandID

type CommandID uint32

CommandID see SMPP v5, section 4.7.5 (115p)

func (CommandID) String

func (c CommandID) String() string

type CommandStatus

type CommandStatus uint32

CommandStatus see SMPP v5, section 4.7.6 (116p)

const (
	ErrInvalidCommandLength CommandStatus = 0x002
	ErrInvalidCommandID     CommandStatus = 0x003
	ErrInvalidDestCount     CommandStatus = 0x033
	ErrInvalidDestFlag      CommandStatus = 0x040
	ErrInvalidTagLength     CommandStatus = 0x0C2
	ErrUnknownError         CommandStatus = 0x0FF
)

func ReadCommandStatus

func ReadCommandStatus(packet interface{}) CommandStatus

func (CommandStatus) Error

func (c CommandStatus) Error() string

func (CommandStatus) String

func (c CommandStatus) String() string

type ConcatenatedHeader

type ConcatenatedHeader struct {
	Reference  uint16
	TotalParts byte
	Sequence   byte
}

func (ConcatenatedHeader) Len

func (h ConcatenatedHeader) Len() int

func (ConcatenatedHeader) Set

type DataSM

type DataSM struct {
	Header             Header `id:"00000103"`
	ServiceType        string
	SourceAddr         Address
	DestAddr           Address
	ESMClass           ESMClass
	RegisteredDelivery RegisteredDelivery
	DataCoding         DataCoding
	Tags               Tags
}

DataSM see SMPP v5, section 4.2.2.1 (69p)

func (*DataSM) Resp

func (p *DataSM) Resp() interface{}

type DataSMResp

type DataSMResp struct {
	Header    Header `id:"80000103"`
	MessageID string
	Tags      Tags
}

DataSM see SMPP v5, section 4.2.2.2 (70p)

type DeliverSM

type DeliverSM struct {
	Header               Header `id:"00000005"`
	ServiceType          string
	SourceAddr           Address
	DestAddr             Address
	ESMClass             ESMClass
	ProtocolID           byte
	PriorityFlag         byte
	ScheduleDeliveryTime string
	ValidityPeriod       string
	RegisteredDelivery   RegisteredDelivery
	ReplaceIfPresent     bool
	Message              ShortMessage
	Tags                 Tags
}

DeliverSM see SMPP v5, section 4.3.1.1 (85p)

func (*DeliverSM) Resp

func (p *DeliverSM) Resp() interface{}

type DeliverSMResp

type DeliverSMResp struct {
	Header    Header `id:"80000005"`
	MessageID string
	Tags      Tags
}

DeliverSMResp see SMPP v5, section 4.3.1.1 (87p)

type DestinationAddresses

type DestinationAddresses struct {
	Addresses        []Address
	DistributionList []string
}

func (*DestinationAddresses) ReadFrom

func (p *DestinationAddresses) ReadFrom(r io.Reader) (n int64, err error)

func (DestinationAddresses) WriteTo

func (p DestinationAddresses) WriteTo(w io.Writer) (n int64, err error)

type Duration

type Duration struct{ time.Duration }

Duration see SMPP v5, section 4.7.23.5 (132p)

func (*Duration) From

func (p *Duration) From(input string) (err error)

func (Duration) String

func (p Duration) String() string

type ESMClass

type ESMClass struct {
	MessageMode, MessageType byte
	UDHIndicator, ReplyPath  bool
}

ESMClass see SMPP v5, section 4.7.12 (125p)

func (ESMClass) ReadByte

func (e ESMClass) ReadByte() (c byte, err error)

func (ESMClass) String

func (e ESMClass) String() string

func (*ESMClass) WriteByte

func (e *ESMClass) WriteByte(c byte) error
type EnquireLink struct {
	Header Header `id:"00000015"`
	Tags   Tags
}

EnquireLink see SMPP v5, section 4.1.2.1 (63p)

func (*EnquireLink) Resp

func (p *EnquireLink) Resp() interface{}

type EnquireLinkResp

type EnquireLinkResp struct {
	Header Header `id:"80000015"`
}

EnquireLink see SMPP v5, section 4.1.2.2 (63p)

type GenericNACK

type GenericNACK struct {
	Header Header `id:"80000000"`
	Tags   Tags
}

GenericNACK see SMPP v5, section 4.1.4.1 (65p)

type Header struct {
	CommandLength uint32
	CommandID     CommandID
	CommandStatus CommandStatus
	Sequence      int32
}

type InterfaceVersion

type InterfaceVersion byte

InterfaceVersion see SMPP v5, section 4.7.13 (126p)

const (
	SMPPVersion33 InterfaceVersion = 0x33
	SMPPVersion34 InterfaceVersion = 0x34
	SMPPVersion50 InterfaceVersion = 0x50
)

type MessageState

type MessageState byte

MessageState see SMPP v5, section 4.7.15 (127p)

func (MessageState) String

func (m MessageState) String() string

type Outbind

type Outbind struct {
	Header   Header `id:"0000000B"`
	SystemID string
	Password string
}

Outbind see SMPP v5, section 4.1.1.7 (61p)

type QueryBroadcastSM

type QueryBroadcastSM struct {
	Header     Header `id:"00000111"`
	MessageID  string
	SourceAddr Address
	Tags       Tags
}

QueryBroadcastSM see SMPP v5, section 4.6.1.1 (107p)

func (*QueryBroadcastSM) Resp

func (p *QueryBroadcastSM) Resp() interface{}

type QueryBroadcastSMResp

type QueryBroadcastSMResp struct {
	Header    Header `id:"80000111"`
	MessageID string
	Tags      Tags
}

QueryBroadcastSMResp see SMPP v5, section 4.6.1.3 (108p)

type QuerySM

type QuerySM struct {
	Header     Header `id:"00000003"`
	MessageID  string
	SourceAddr Address
}

QuerySM see SMPP v5, section 4.5.2.1 (101p)

func (*QuerySM) Resp

func (p *QuerySM) Resp() interface{}

type QuerySMResp

type QuerySMResp struct {
	Header       Header `id:"80000003"`
	MessageID    string
	FinalDate    string
	MessageState MessageState
	ErrorCode    CommandStatus
}

QuerySMResp see SMPP v5, section 4.5.2.2 (103p)

type RegisteredDelivery

type RegisteredDelivery struct {
	MCDeliveryReceipt           byte
	SMEOriginatedAcknowledgment byte
	IntermediateNotification    bool
	Reserved                    byte
}

RegisteredDelivery see SMPP v5, section 4.7.21 (130p)

func (RegisteredDelivery) ReadByte

func (r RegisteredDelivery) ReadByte() (c byte, err error)

func (RegisteredDelivery) String

func (r RegisteredDelivery) String() string

func (*RegisteredDelivery) WriteByte

func (r *RegisteredDelivery) WriteByte(c byte) error

type ReplaceSM

type ReplaceSM struct {
	Header               Header `id:"00000007"`
	MessageID            string
	SourceAddr           Address
	ScheduleDeliveryTime string
	ValidityPeriod       string
	RegisteredDelivery   RegisteredDelivery
	Message              ShortMessage
	Tags                 Tags
}

ReplaceSM see SMPP v5, section 4.5.3.1 (104p)

func (*ReplaceSM) Resp

func (p *ReplaceSM) Resp() interface{}

type ReplaceSMResp

type ReplaceSMResp struct {
	Header Header `id:"80000007"`
}

ReplaceSMResp see SMPP v5, section 4.5.3.2 (106p)

type Responsable

type Responsable interface {
	Resp() interface{}
}

type ShortMessage

type ShortMessage struct {
	DefaultMessageID byte // see SMPP v5, section 4.7.27 (134p)
	DataCoding       DataCoding
	UDHeader         UserDataHeader
	Message          []byte
}

func ComposeMultipartShortMessage

func ComposeMultipartShortMessage(input string, coding DataCoding, reference uint16) (parts []ShortMessage, err error)

func (*ShortMessage) Compose

func (p *ShortMessage) Compose(input string) (err error)

func (*ShortMessage) Parse

func (p *ShortMessage) Parse() (message string, err error)

func (*ShortMessage) Prepare

func (p *ShortMessage) Prepare(pdu interface{})

func (*ShortMessage) ReadFrom

func (p *ShortMessage) ReadFrom(r io.Reader) (n int64, err error)

func (ShortMessage) WriteTo

func (p ShortMessage) WriteTo(w io.Writer) (n int64, err error)

type SubmitMulti

type SubmitMulti struct {
	Header               Header `id:"00000021"`
	ServiceType          string
	SourceAddr           Address
	DestAddrList         DestinationAddresses
	ESMClass             ESMClass
	ProtocolID           byte
	PriorityFlag         byte
	ScheduleDeliveryTime string
	ValidityPeriod       string
	RegisteredDelivery   RegisteredDelivery
	ReplaceIfPresent     bool
	Message              ShortMessage
	Tags                 Tags
}

SubmitMulti see SMPP v5, section 4.2.3.1 (71p)

func (*SubmitMulti) Resp

func (p *SubmitMulti) Resp() interface{}

type SubmitMultiResp

type SubmitMultiResp struct {
	Header           Header `id:"80000021"`
	MessageID        string
	UnsuccessfulSMEs UnsuccessfulRecords
	Tags             Tags
}

SubmitMulti see SMPP v5, section 4.2.3.2 (74p)

type SubmitSM

type SubmitSM struct {
	Header               Header `id:"00000004"`
	ServiceType          string
	SourceAddr           Address
	DestAddr             Address
	ESMClass             ESMClass
	ProtocolID           byte
	PriorityFlag         byte
	ScheduleDeliveryTime string
	ValidityPeriod       string
	RegisteredDelivery   RegisteredDelivery
	ReplaceIfPresent     bool
	Message              ShortMessage
	Tags                 Tags
}

SubmitSM see SMPP v5, section 4.2.1.1 (66p)

func (*SubmitSM) Resp

func (p *SubmitSM) Resp() interface{}

type SubmitSMResp

type SubmitSMResp struct {
	Header    Header `id:"80000004"`
	MessageID string
}

SubmitSMResp see SMPP v5, section 4.2.1.2 (68p)

type Tags

type Tags map[uint16][]byte

func (*Tags) ReadFrom

func (t *Tags) ReadFrom(r io.Reader) (n int64, err error)

func (Tags) WriteTo

func (t Tags) WriteTo(w io.Writer) (n int64, err error)

type Time

type Time struct{ time.Time }

Time see SMPP v5, section 4.7.23.4 (132p)

func (*Time) From

func (t *Time) From(input string) (err error)

func (Time) String

func (t Time) String() string

type Unbind

type Unbind struct {
	Header Header `id:"00000006"`
}

Unbind see SMPP v5, section 4.1.1.8 (61p)

func (*Unbind) Resp

func (p *Unbind) Resp() interface{}

type UnbindResp

type UnbindResp struct {
	Header Header `id:"80000006"`
}

UnbindResp see SMPP v5, section 4.1.1.9 (62p)

type UnsuccessfulRecord

type UnsuccessfulRecord struct {
	DestAddr        Address
	ErrorStatusCode CommandStatus
}

func (UnsuccessfulRecord) String

func (i UnsuccessfulRecord) String() string

type UnsuccessfulRecords

type UnsuccessfulRecords []UnsuccessfulRecord

func (*UnsuccessfulRecords) ReadFrom

func (p *UnsuccessfulRecords) ReadFrom(r io.Reader) (n int64, err error)

func (UnsuccessfulRecords) WriteTo

func (p UnsuccessfulRecords) WriteTo(w io.Writer) (n int64, err error)

type UserDataHeader

type UserDataHeader map[byte][]byte

func (UserDataHeader) ConcatenatedHeader

func (h UserDataHeader) ConcatenatedHeader() *ConcatenatedHeader

func (UserDataHeader) Len

func (h UserDataHeader) Len() (length int)

func (*UserDataHeader) ReadFrom

func (h *UserDataHeader) ReadFrom(r io.Reader) (n int64, err error)

func (UserDataHeader) WriteTo

func (h UserDataHeader) WriteTo(w io.Writer) (n int64, err error)

Jump to

Keyboard shortcuts

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