pdu

package
v0.0.0-...-92d0236 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: MIT Imports: 15 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 any) (n int64, err error)

func ReadSequence

func ReadSequence(packet any) int32

func Unmarshal

func Unmarshal(r io.Reader) (pdu any, err error)

func WriteSequence

func WriteSequence(packet any, 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
	SourceAddr Address
	ESMEAddr   Address
	Tags       Tags
}

AlertNotification see SMPP v5, section 4.1.3.1 (64p)

type BindReceiver

type BindReceiver struct {
	Header       Header
	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() any

type BindReceiverResp

type BindReceiverResp struct {
	Header   Header
	SystemID string
	Tags     Tags
}

BindReceiverResp see SMPP v5, section 4.1.1.4 (59p)

type BindTransceiver

type BindTransceiver struct {
	Header       Header
	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() any

type BindTransceiverResp

type BindTransceiverResp struct {
	Header   Header
	SystemID string
	Tags     Tags
}

BindTransceiverResp see SMPP v5, section 4.1.1.6 (60p)

type BindTransmitter

type BindTransmitter struct {
	Header       Header
	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() any

type BindTransmitterResp

type BindTransmitterResp struct {
	Header   Header
	SystemID string
	Tags     Tags
}

BindTransmitterResp see SMPP v5, section 4.1.1.2 (57p)

type BroadcastSM

type BroadcastSM struct {
	Header               Header
	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() any

type BroadcastSMResp

type BroadcastSMResp struct {
	Header    Header
	MessageID string
	Tags      Tags
}

BroadcastSMResp see SMPP v5, section 4.4.1.2 (96p)

type CancelBroadcastSM

type CancelBroadcastSM struct {
	Header      Header
	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() any

type CancelBroadcastSMResp

type CancelBroadcastSMResp struct {
	Header Header
}

CancelBroadcastSMResp see SMPP v5, section 4.6.2.3 (112p)

type CancelSM

type CancelSM struct {
	Header      Header
	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() any

type CancelSMResp

type CancelSMResp struct {
	Header Header
}

CancelSMResp 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 any) 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
	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() any

type DataSMResp

type DataSMResp struct {
	Header    Header
	MessageID string
	Tags      Tags
}

DataSMResp see SMPP v5, section 4.2.2.2 (70p)

type DeliverSM

type DeliverSM struct {
	Header               Header
	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() any

type DeliverSMResp

type DeliverSMResp struct {
	Header    Header
	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  byte // __ ____ **
	MessageType  byte // __ **** __
	UDHIndicator bool // _* ____ __
	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
	Tags   Tags
}

EnquireLink see SMPP v5, section 4.1.2.1 (63p)

func (*EnquireLink) Resp

func (p *EnquireLink) Resp() any

type EnquireLinkResp

type EnquireLinkResp struct {
	Header Header
}

EnquireLinkResp see SMPP v5, section 4.1.2.2 (63p)

type GenericNACK

type GenericNACK struct {
	Header Header
	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
)

func (InterfaceVersion) MarshalJSON

func (v InterfaceVersion) MarshalJSON() (data []byte, err error)

func (InterfaceVersion) String

func (v InterfaceVersion) String() string

func (*InterfaceVersion) UnmarshalJSON

func (v *InterfaceVersion) UnmarshalJSON(data []byte) (err error)

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
	SystemID string
	Password string
}

Outbind see SMPP v5, section 4.1.1.7 (61p)

type QueryBroadcastSM

type QueryBroadcastSM struct {
	Header     Header
	MessageID  string
	SourceAddr Address
	Tags       Tags
}

QueryBroadcastSM see SMPP v5, section 4.6.1.1 (107p)

func (*QueryBroadcastSM) Resp

func (p *QueryBroadcastSM) Resp() any

type QueryBroadcastSMResp

type QueryBroadcastSMResp struct {
	Header    Header
	MessageID string
	Tags      Tags
}

QueryBroadcastSMResp see SMPP v5, section 4.6.1.3 (108p)

type QuerySM

type QuerySM struct {
	Header     Header
	MessageID  string
	SourceAddr Address
}

QuerySM see SMPP v5, section 4.5.2.1 (101p)

func (*QuerySM) Resp

func (p *QuerySM) Resp() any

type QuerySMResp

type QuerySMResp struct {
	Header       Header
	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
	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() any

type ReplaceSMResp

type ReplaceSMResp struct {
	Header Header
}

ReplaceSMResp see SMPP v5, section 4.5.3.2 (106p)

type Responsable

type Responsable interface {
	Resp() any
}

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

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
	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() any

type SubmitMultiResp

type SubmitMultiResp struct {
	Header           Header
	MessageID        string
	UnsuccessfulSMEs UnsuccessfulRecords
	Tags             Tags
}

SubmitMultiResp see SMPP v5, section 4.2.3.2 (74p)

type SubmitSM

type SubmitSM struct {
	Header               Header
	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() any

type SubmitSMResp

type SubmitSMResp struct {
	Header    Header
	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
}

Unbind see SMPP v5, section 4.1.1.8 (61p)

func (*Unbind) Resp

func (p *Unbind) Resp() any

type UnbindResp

type UnbindResp struct {
	Header Header
}

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