pdu

package
v0.0.0-...-dae29e7 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStringTooLong = errors.New("string too long for c octet string")

Functions

func TlvIntValue

func TlvIntValue[T constraints.Integer](tlv Tlv) (T, error)

func TlvStringValue

func TlvStringValue(tlv Tlv) (string, error)

Types

type BindBody

type BindBody struct {
	SystemId         string              `smpp:"system_id,c-octet-string,16"`
	Password         string              `smpp:"password,c-octet-string,9"`
	SystemType       string              `smpp:"system_type,c-octet-string,13"`
	InterfaceVersion InterfaceVersion    `smpp:"interface_version,integer"`
	AddrTon          TypeOfNumber        `smpp:"addr_ton,integer"`
	AddrNpi          NumberPlanIndicator `smpp:"addr_npi,integer"`
	AddressRange     string              `smpp:"address_range,c-octet-string,41"`
}

type BindResponseBody

type BindResponseBody struct {
	SystemId string `smpp:"system_id,c-octet-string,16"`
}

type CommandId

type CommandId uint32
const (
	CmdBindReceiver          CommandId = 0x00000001
	CmdBindTransmitter       CommandId = 0x00000002
	CmdQuerySm               CommandId = 0x00000003
	CmdSubmitSm              CommandId = 0x00000004
	CmdDeliverSm             CommandId = 0x00000005
	CmdUnbind                CommandId = 0x00000006
	CmdReplaceSm             CommandId = 0x00000007
	CmdCancelSm              CommandId = 0x00000008
	CmdBindTransceiver       CommandId = 0x00000009
	CmdOutbind               CommandId = 0x0000000B
	CmdEnquireLink           CommandId = 0x00000015
	CmdSubmitMulti           CommandId = 0x00000021
	CmdAlertNotification     CommandId = 0x00000102
	CmdDataSm                CommandId = 0x00000103
	CmdBroadcastSm           CommandId = 0x00000111
	CmdQueryBroadcastSm      CommandId = 0x00000112
	CmdCancelBroadcastSm     CommandId = 0x00000113
	CmdGenericNack           CommandId = 0x80000000
	CmdBindReceiverResp      CommandId = 0x80000001
	CmdBindTransmitterResp   CommandId = 0x80000002
	CmdQuerySmResp           CommandId = 0x80000003
	CmdSubmitSmResp          CommandId = 0x80000004
	CmdDeliverSmResp         CommandId = 0x80000005
	CmdUnbindResp            CommandId = 0x80000006
	CmdReplaceSmResp         CommandId = 0x80000007
	CmdCancelSmResp          CommandId = 0x80000008
	CmdBindTransceiverResp   CommandId = 0x80000009
	CmdEnquireLinkResp       CommandId = 0x80000015
	CmdSubmitMultiResp       CommandId = 0x80000021
	CmdDataSmResp            CommandId = 0x80000103
	CmdBroadcastSmResp       CommandId = 0x80000111
	CmdQueryBroadcastSmResp  CommandId = 0x80000112
	CmdCancelBroadcastSmResp CommandId = 0x80000113
)

func (CommandId) String

func (commandId CommandId) String() string

type CommandStatus

type CommandStatus uint32
const (
	StatusROK                 CommandStatus = 0x00000000
	StatusRINVMSGLEN          CommandStatus = 0x00000001
	StatusRINVCMDLEN          CommandStatus = 0x00000002
	StatusRINVCMDID           CommandStatus = 0x00000003
	StatusRINVBNDSTS          CommandStatus = 0x00000004
	StatusRALYBND             CommandStatus = 0x00000005
	StatusRINVPRTFLG          CommandStatus = 0x00000006
	StatusRINVREGDLVFLG       CommandStatus = 0x00000007
	StatusRSYSERR             CommandStatus = 0x00000008
	StatusRINVSRCADR          CommandStatus = 0x0000000A
	StatusRINVDSTADR          CommandStatus = 0x0000000B
	StatusRINVMSGID           CommandStatus = 0x0000000C
	StatusRBINDFAIL           CommandStatus = 0x0000000D
	StatusRINVPASWD           CommandStatus = 0x0000000E
	StatusRINVSYSID           CommandStatus = 0x0000000F
	StatusRCANCELFAIL         CommandStatus = 0x00000011
	StatusRREPLACEFAIL        CommandStatus = 0x00000013
	StatusRMSGQFUL            CommandStatus = 0x00000014
	StatusRINVSERTYP          CommandStatus = 0x00000015
	StatusRINVNUMDESTS        CommandStatus = 0x00000033
	StatusRINVDLNAME          CommandStatus = 0x00000034
	StatusRINVDESTFLAG        CommandStatus = 0x00000040
	StatusRINVSUBREP          CommandStatus = 0x00000042
	StatusRINVESMCLASS        CommandStatus = 0x00000043
	StatusRCNTSUBDL           CommandStatus = 0x00000044
	StatusRSUBMITFAIL         CommandStatus = 0x00000045
	StatusRINVSRCTON          CommandStatus = 0x00000048
	StatusRINVSRCNPI          CommandStatus = 0x00000049
	StatusRINVDSTTON          CommandStatus = 0x00000050
	StatusRINVDSTNPI          CommandStatus = 0x00000051
	StatusRINVSYSTYP          CommandStatus = 0x00000053
	StatusRINVREPFLAG         CommandStatus = 0x00000054
	StatusRINVNUMMSGS         CommandStatus = 0x00000055
	StatusRTHROTTLED          CommandStatus = 0x00000058
	StatusRINVSCHED           CommandStatus = 0x00000061
	StatusRINVEXPIRY          CommandStatus = 0x00000062
	StatusRINVDFTMSGID        CommandStatus = 0x00000063
	StatusRX_T_APPN           CommandStatus = 0x00000064
	StatusRX_P_APPN           CommandStatus = 0x00000065
	StatusRX_R_APPN           CommandStatus = 0x00000066
	StatusRQUERYFAIL          CommandStatus = 0x00000067
	StatusRINVTLVSTREAM       CommandStatus = 0x000000C0
	StatusRTLVNOTALLWD        CommandStatus = 0x000000C1
	StatusRINVTLVLEN          CommandStatus = 0x000000C2
	StatusRMISSINGTLV         CommandStatus = 0x000000C3
	StatusRINVTLVVAL          CommandStatus = 0x000000C4
	StatusRDELIVERYFAILURE    CommandStatus = 0x000000FE
	StatusRUNKNOWNERR         CommandStatus = 0x000000FF
	StatusRSERTYPUNAUTH       CommandStatus = 0x00000100
	StatusRPROHIBITED         CommandStatus = 0x00000101
	StatusRSERTYPUNAVAIL      CommandStatus = 0x00000102
	StatusRSERTYPDENIED       CommandStatus = 0x00000103
	StatusRINVDCS             CommandStatus = 0x00000104
	StatusRINVSRCADDRSUBUNIT  CommandStatus = 0x00000105
	StatusRINVDSTADDRSUBUNIT  CommandStatus = 0x00000106
	StatusRINVBCASTFREQINT    CommandStatus = 0x00000107
	StatusRINVBCASTALIAS_NAME CommandStatus = 0x00000108
	StatusRINVBCASTAREAFMT    CommandStatus = 0x00000109
	StatusRINVNUMBCAST_AREAS  CommandStatus = 0x0000010A
	StatusRINVBCASTCNTTYPE    CommandStatus = 0x0000010B
	StatusRINVBCASTMSGCLASS   CommandStatus = 0x0000010C
	StatusRBCASTFAIL          CommandStatus = 0x0000010D
	StatusRBCASTQUERYFAIL     CommandStatus = 0x0000010E
	StatusRBCASTCANCELFAIL    CommandStatus = 0x0000010F
	StatusRINVBCAST_REP       CommandStatus = 0x00000110
	StatusRINVBCASTSRVGRP     CommandStatus = 0x00000111
	StatusRINVBCASTCHANIND    CommandStatus = 0x00000112
)

func (CommandStatus) String

func (status CommandStatus) String() string

type DataCoding

type DataCoding byte
const (
	DataCodingDefault          DataCoding = 0b00000000
	DataCodingIA5              DataCoding = 0b00000001
	DataCodingBinary8BitA      DataCoding = 0b00000010
	DataCodingLatin1           DataCoding = 0b00000011
	DataCodingBinary8Bit       DataCoding = 0b00000100
	DataCodingJIS              DataCoding = 0b00000101
	DataCodingCyrillic         DataCoding = 0b00000110
	DataCodingLatinHebrew      DataCoding = 0b00000111
	DataCodingUCS2             DataCoding = 0b00001000
	DataCodingPictogram        DataCoding = 0b00001001
	DataCodingMusicCodes       DataCoding = 0b00001010
	DataCodingExtendedKanjiJIS DataCoding = 0b00001101
	DataCodingKSC5601          DataCoding = 0b00001110
)

func (DataCoding) String

func (dataCoding DataCoding) String() string

type DeliverSmBody

type DeliverSmBody struct {
	ServiceType           string              `smpp:"service_type,c-octet-string,6"`
	SourceAddressTon      TypeOfNumber        `smpp:"source_addr_ton,integer"`
	SourceAddressNpi      NumberPlanIndicator `smpp:"source_addr_npi,integer"`
	SourceAddress         string              `smpp:"source_addr,c-octet-string,21"`
	DestinationAddressTon TypeOfNumber        `smpp:"dest_addr_ton,integer"`
	DestinationAddressNpi NumberPlanIndicator `smpp:"dest_addr_npi,integer"`
	DestinationAddress    string              `smpp:"dest_addr,c-octet-string,21"`
	EsmClass              EsmClass            `smpp:"esm_class,integer"`
	ProtocolId            byte                `smpp:"protocol_id,integer"`
	PriorityFlag          byte                `smpp:"priority_flag,integer"`
	ScheduleDeliveryTime  string              `smpp:"schedule_delivery_time,c-octet-string,17"`
	ValidityPeriod        string              `smpp:"validity_period,c-octet-string,17"`
	RegisteredDelivery    RegisteredDelivery  `smpp:"registered_delivery,integer"`
	ReplaceIfPresent      ReplaceIfPresent    `smpp:"replace_if_present_flag,integer"`
	DataCoding            DataCoding          `smpp:"data_coding,integer"`
	SmDefaultMessageId    byte                `smpp:"sm_default_msg_id,integer"`
	SmLength              byte                `smpp:"sm_length,integer"`
	ShortMessage          []byte              `smpp:"short_message,octet-string,255,sm_length"`
}

type DeliverSmRespBody

type DeliverSmRespBody struct {
	MessageId string `smpp:"message_id,c-octet-string,65"`
}

type EmptyBody

type EmptyBody struct{}

type EsmClass

type EsmClass byte
const (
	EsmClassMessagingModeMask            EsmClass = 0b00000011
	EsmClassMessagingModeDefault         EsmClass = 0b00000000
	EsmClassMessagingModeDatagram        EsmClass = 0b00000001
	EsmClassMessagingModeForward         EsmClass = 0b00000010
	EsmClassMessagingModeStoreAndForward EsmClass = 0b00000011

	EsmClassMessageTypeMask                             EsmClass = 0b00111100
	EsmClassMessageTypeDefault                          EsmClass = 0b00000000
	EsmClassMessageTypeDeliveryReceipt                  EsmClass = 0b00000100
	EsmClassMessageTypeDeliveryAcknowledgement          EsmClass = 0b00001000
	EsmClassMessageTypeManualAcknowledgement            EsmClass = 0b00010000
	EsmClassMessageTypeIntermediateDeliveryNotification EsmClass = 0b00100000

	EsmClassGSMMask          EsmClass = 0b11000000
	EsmClassGSMNoFeatures    EsmClass = 0b00000000
	EsmClassGSMUDHIIndicator EsmClass = 0b01000000
	EsmClassGSMReplyPath     EsmClass = 0b10000000
)

type FieldMetadata

type FieldMetadata struct {
	FieldName     string
	FieldType     SmppFieldType
	FieldLen      int
	FieldIndex    int
	FieldLenIndex int
}

type InterfaceVersion

type InterfaceVersion byte
const (
	InterfaceVersion33 InterfaceVersion = 0x33
	InterfaceVersion34 InterfaceVersion = 0x34
	InterfaceVersion50 InterfaceVersion = 0x50
)

func (InterfaceVersion) String

func (version InterfaceVersion) String() string

type Metadata

type Metadata struct {
	Fields []*FieldMetadata
}

type MetadataReader

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

func (*MetadataReader) ReadMetadata

func (m *MetadataReader) ReadMetadata(t reflect.Type) (*Metadata, error)

type NumberPlanIndicator

type NumberPlanIndicator byte
const (
	NPIUnknown     NumberPlanIndicator = 0b00000000
	NPIISDN        NumberPlanIndicator = 0b00000001
	NPIData        NumberPlanIndicator = 0b00000011
	NPITelex       NumberPlanIndicator = 0b00000100
	NPILandMobile  NumberPlanIndicator = 0b00000110
	NPINational    NumberPlanIndicator = 0b00001000
	NPIPrivate     NumberPlanIndicator = 0b00001001
	NPIERMES       NumberPlanIndicator = 0b00001010
	NPIInternet    NumberPlanIndicator = 0b00001110
	NPIWAPClientId NumberPlanIndicator = 0b00010010
)

func (NumberPlanIndicator) String

func (npi NumberPlanIndicator) String() string

type OutbindBody

type OutbindBody struct {
	SystemId string `smpp:"system_id,c-octet-string,16"`
	Password string `smpp:"password,c-octet-string,9"`
}

type Pdu

type Pdu struct {
	Header *PduHeader
	Body   any
	Tlvs   []Tlv
}

func NewBindReceiver

func NewBindReceiver(bindBody *BindBody) *Pdu

func NewBindReceiverResponse

func NewBindReceiverResponse(bindResponseBody *BindResponseBody) *Pdu

func NewBindTransceiver

func NewBindTransceiver(bindBody *BindBody) *Pdu

func NewBindTransceiverResponse

func NewBindTransceiverResponse(bindResponseBody *BindResponseBody) *Pdu

func NewBindTransmitter

func NewBindTransmitter(bindBody *BindBody) *Pdu

func NewBindTransmitterResponse

func NewBindTransmitterResponse(bindResponseBody *BindResponseBody) *Pdu

func NewDeliverRespSm

func NewDeliverRespSm(body *DeliverSmRespBody) *Pdu

func NewDeliverSm

func NewDeliverSm(body *DeliverSmBody) *Pdu
func NewEnquireLink() *Pdu

func NewEnquireLinkResponse

func NewEnquireLinkResponse() *Pdu

func NewOutbind

func NewOutbind(outbindBody *OutbindBody) *Pdu

func NewSubmitRespSm

func NewSubmitRespSm(body *SubmitSmRespBody) *Pdu

func NewSubmitSm

func NewSubmitSm(body *SubmitSmBody) *Pdu

func NewUnbind

func NewUnbind() *Pdu

func NewUnbindResponse

func NewUnbindResponse() *Pdu

func (*Pdu) WithTlvs

func (pdu *Pdu) WithTlvs(tlvs []Tlv) *Pdu

type PduHeader

type PduHeader struct {
	CommandLength  uint32        `smpp:"command_length,integer"`
	CommandId      CommandId     `smpp:"command_id,integer"`
	CommandStatus  CommandStatus `smpp:"command_status,integer"`
	SequenceNumber uint32        `smpp:"sequence_number,integer"`
}

type RegisteredDelivery

type RegisteredDelivery byte
const (
	RegisteredDeliveryMCMask      RegisteredDelivery = 0b00000011
	RegisteredDeliveryMCNone      RegisteredDelivery = 0b00000000
	RegisteredDeliveryMCRequested RegisteredDelivery = 0b00000001
	RegisteredDeliveryMCFailure   RegisteredDelivery = 0b00000010
	RegisteredDeliveryMCSuccess   RegisteredDelivery = 0b00000011

	RegisteredDeliverySMEMask                             RegisteredDelivery = 0b00001100
	RegisteredDeliverySMENone                             RegisteredDelivery = 0b00000000
	RegisteredDeliverySMEDeliveryAcknowledgementRequested RegisteredDelivery = 0b00000100
	RegisteredDeliverySMEManualAcknowledgementRequested   RegisteredDelivery = 0b00001000

	RegisteredDeliveryIntermediateNotificationsMask      RegisteredDelivery = 0b00010000
	RegisteredDeliveryIntermediateNotificationsNone      RegisteredDelivery = 0b00000000
	RegisteredDeliveryIntermediateNotificationsRequested RegisteredDelivery = 0b00010000
)

type ReplaceIfPresent

type ReplaceIfPresent byte
const (
	DontReplace ReplaceIfPresent = 0
	Replace     ReplaceIfPresent = 1
)

func (ReplaceIfPresent) String

func (rip ReplaceIfPresent) String() string

type Serializer

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

func NewSerializer

func NewSerializer() *Serializer

func (*Serializer) FromBytes

func (s *Serializer) FromBytes(pduBytes []byte) (*Pdu, error)

func (*Serializer) ToBytes

func (s *Serializer) ToBytes(pdu *Pdu) ([]byte, error)

func (*Serializer) ToString

func (s *Serializer) ToString(pdu *Pdu) string

type ServiceType

type ServiceType string
const (
	ServiceTypeNull ServiceType = ""
	ServiceTypeCMT  ServiceType = "CMT"
	ServiceTypeCPT  ServiceType = "CPT"
	ServiceTypeVMN  ServiceType = "VMN"
	ServiceTypeVMA  ServiceType = "VMA"
	ServiceTypeWAP  ServiceType = "WAP"
	ServiceTypeUSSD ServiceType = "USSD"
	ServiceTypeCBS  ServiceType = "CBS"
	ServiceTypeGUTS ServiceType = "GUTS"
)

type SmppFieldType

type SmppFieldType string
const (
	Integer      SmppFieldType = "integer"
	COctetString SmppFieldType = "c-octet-string"
	OctetString  SmppFieldType = "octet-string"
)

type SmppTag

type SmppTag struct {
	TagName   string
	TagType   SmppFieldType
	TagLength int
}

type SubmitSmBody

type SubmitSmBody struct {
	ServiceType           string              `smpp:"service_type,c-octet-string,6"`
	SourceAddressTon      TypeOfNumber        `smpp:"source_addr_ton,integer"`
	SourceAddressNpi      NumberPlanIndicator `smpp:"source_addr_npi,integer"`
	SourceAddress         string              `smpp:"source_addr,c-octet-string,21"`
	DestinationAddressTon TypeOfNumber        `smpp:"dest_addr_ton,integer"`
	DestinationAddressNpi NumberPlanIndicator `smpp:"dest_addr_npi,integer"`
	DestinationAddress    string              `smpp:"dest_addr,c-octet-string,21"`
	EsmClass              EsmClass            `smpp:"esm_class,integer"`
	ProtocolId            byte                `smpp:"protocol_id,integer"`
	PriorityFlag          byte                `smpp:"priority_flag,integer"`
	ScheduleDeliveryTime  string              `smpp:"schedule_delivery_time,c-octet-string,17"`
	ValidityPeriod        string              `smpp:"validity_period,c-octet-string,17"`
	RegisteredDelivery    RegisteredDelivery  `smpp:"registered_delivery,integer"`
	ReplaceIfPresent      ReplaceIfPresent    `smpp:"replace_if_present_flag,integer"`
	DataCoding            DataCoding          `smpp:"data_coding,integer"`
	SmDefaultMessageId    byte                `smpp:"sm_default_msg_id,integer"`
	SmLength              byte                `smpp:"sm_length,integer"`
	ShortMessage          []byte              `smpp:"short_message,octet-string,255,sm_length"`
}

type SubmitSmRespBody

type SubmitSmRespBody struct {
	MessageId string `smpp:"message_id,c-octet-string,65"`
}

type Tlv

type Tlv struct {
	Tag    uint16 `smpp:"tag,integer"`
	Length uint16 `smpp:"length,integer"`
	Value  []byte `smpp:"value,octet-string,255,length"`
}

func NewTlv

func NewTlv[T constraints.Integer | string](tag uint16, value T) (Tlv, error)

type TypeOfNumber

type TypeOfNumber byte
const (
	TONUnknown          TypeOfNumber = 0b00000000
	TONInternational    TypeOfNumber = 0b00000001
	TONNational         TypeOfNumber = 0b00000010
	TONNetworkSpecific  TypeOfNumber = 0b00000011
	TONSubscriberNumber TypeOfNumber = 0b00000100
	TOnAlphanumeric     TypeOfNumber = 0b00000101
	TONAbbreviated      TypeOfNumber = 0b00000110
)

func (TypeOfNumber) String

func (ton TypeOfNumber) String() string

Jump to

Keyboard shortcuts

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