pdu

package
v0.0.0-...-3c0c265 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2018 License: MIT Imports: 9 Imported by: 4

Documentation

Overview

Package pdu provide codecs for binary PDU data.

Index

Constants

View Source
const HeaderLen = 16

HeaderLen is the PDU header length.

View Source
const MaxSize = 4096

MaxSize is the maximum size allowed for a PDU.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bind

type Bind struct{ *Codec }

Bind PDU.

type BindResp

type BindResp struct{ *Codec }

BindResp PDU.

type Body

type Body interface {
	// Header returns the PDU header, decoded. Header fields
	// can be updated (e.g. Seq) before re-serializing the PDU.
	Header() *Header

	// Len returns the length of the PDU binary data, in bytes.
	Len() int

	// FieldList returns a list of mandatory PDU fields for
	// encoding or decoding the PDU. The order in the list
	// dictates how PDUs are decoded and serialized.
	FieldList() pdufield.List

	// Fields return a decoded map of PDU fields. The returned
	// map can be modified before re-serializing the PDU.
	Fields() pdufield.Map

	// Fields return a decoded map of PDU TLV fields.
	TLVFields() pdutlv.Map

	// SerializeTo encodes the PDU to its binary form, including
	// the header and all fields.
	SerializeTo(w io.Writer) error
}

Body is an abstract Protocol Data Unit (PDU) interface for manipulating PDUs.

func Decode

func Decode(r io.Reader) (Body, error)

Decode decodes binary PDU data. It returns a new PDU object, e.g. Bind, with header and all fields decoded. The returned PDU can be modified and re-serialized to its binary form.

func NewBindReceiver

func NewBindReceiver() Body

NewBindReceiver creates a new Bind PDU.

func NewBindReceiverResp

func NewBindReceiverResp() Body

NewBindReceiverResp creates and initializes a new BindResp PDU.

func NewBindReceiverRespSeq

func NewBindReceiverRespSeq(seq uint32) Body

NewBindReceiverRespSeq creates and initializes a new BindResp PDU.

func NewBindTransceiver

func NewBindTransceiver() Body

NewBindTransceiver creates a new Bind PDU.

func NewBindTransceiverResp

func NewBindTransceiverResp() Body

NewBindTransceiverResp creates and initializes a new BindResp PDU.

func NewBindTransceiverRespSeq

func NewBindTransceiverRespSeq(seq uint32) Body

NewBindTransceiverRespSeq creates and initializes a new BindResp PDU.

func NewBindTransmitter

func NewBindTransmitter() Body

NewBindTransmitter creates a new Bind PDU.

func NewBindTransmitterResp

func NewBindTransmitterResp() Body

NewBindTransmitterResp creates and initializes a new BindResp PDU.

func NewBindTransmitterRespSeq

func NewBindTransmitterRespSeq(seq uint32) Body

NewBindTransmitterRespSeq creates and initializes a new BindResp PDU.

func NewDeliverSM

func NewDeliverSM() Body

NewDeliverSM creates and initializes a new DeliverSM PDU.

func NewDeliverSMResp

func NewDeliverSMResp() Body

NewDeliverSMResp creates and initializes a new DeliverSMResp PDU.

func NewDeliverSMRespSeq

func NewDeliverSMRespSeq(seq uint32) Body

NewDeliverSMRespSeq creates and initializes a new DeliverSMResp PDU for a specific seq.

func NewEnquireLink() Body

NewEnquireLink creates and initializes a EnquireLink PDU.

func NewEnquireLinkResp

func NewEnquireLinkResp() Body

NewEnquireLinkResp creates and initializes a EnquireLinkResp PDU.

func NewEnquireLinkRespSeq

func NewEnquireLinkRespSeq(seq uint32) Body

NewEnquireLinkRespSeq creates and initializes a EnquireLinkResp PDU for a specific seq.

func NewGenericNACK

func NewGenericNACK() Body

NewGenericNACK creates and initializes a GenericNACK PDU.

func NewQuerySM

func NewQuerySM() Body

NewQuerySM creates and initializes a new QuerySM PDU.

func NewQuerySMResp

func NewQuerySMResp() Body

NewQuerySMResp creates and initializes a new QuerySMResp PDU.

func NewQuerySMRespSeq

func NewQuerySMRespSeq(seq uint32) Body

NewQuerySMRespSeq creates and initializes a new QuerySMResp PDU.

func NewSubmitMulti

func NewSubmitMulti() Body

NewSubmitMulti creates and initializes a new SubmitMulti PDU.

func NewSubmitMultiResp

func NewSubmitMultiResp() Body

NewSubmitMultiResp creates and initializes a new SubmitMultiResp PDU.

func NewSubmitMultiRespSeq

func NewSubmitMultiRespSeq(seq uint32) Body

NewSubmitMultiRespSeq creates and initializes a new SubmitMultiResp PDU.

func NewSubmitSM

func NewSubmitSM() Body

NewSubmitSM creates and initializes a new SubmitSM PDU.

func NewSubmitSMResp

func NewSubmitSMResp() Body

NewSubmitSMResp creates and initializes a new SubmitSMResp PDU.

func NewSubmitSMRespSeq

func NewSubmitSMRespSeq(seq uint32) Body

NewSubmitSMRespSeq creates and initializes a new SubmitSMResp PDU.

func NewUnbind

func NewUnbind() Body

NewUnbind creates and initializes a Unbind PDU.

func NewUnbindResp

func NewUnbindResp() Body

NewUnbindResp creates and initializes a UnbindResp PDU.

func NewUnbindRespSeq

func NewUnbindRespSeq(seq uint32) Body

NewUnbindRespSeq creates and initializes a UnbindResp PDU.

type Codec

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

Codec is the base type of all PDUs. It implements the PDU interface and provides a generic encoder.

func (*Codec) FieldList

func (pdu *Codec) FieldList() pdufield.List

FieldList implements the PDU interface.

func (*Codec) Fields

func (pdu *Codec) Fields() pdufield.Map

Fields implement the PDU interface.

func (*Codec) Header

func (pdu *Codec) Header() *Header

Header implements the PDU interface.

func (*Codec) Len

func (pdu *Codec) Len() int

Len implements the PDU interface.

func (*Codec) MarshalJSON

func (c *Codec) MarshalJSON() ([]byte, error)

func (*Codec) SerializeTo

func (pdu *Codec) SerializeTo(w io.Writer) error

SerializeTo implements the PDU interface.

func (*Codec) TLVFields

func (pdu *Codec) TLVFields() pdutlv.Map

Fields implement the PDU interface.

func (*Codec) UnmarshalJSON

func (c *Codec) UnmarshalJSON(b []byte) error

Since Codec is a private struct, we expose the Unmarshal function for other packages to use it

type CodecJSON

type CodecJSON struct {
	Header    *Header       `json:"header"`
	FieldList pdufield.List `json:"fieldList"`
	Fields    pdufield.Map  `json:"fields"`
	TLVFields pdutlv.Map    `json:"tlvFields"`
}

type DeliverSM

type DeliverSM struct{ *Codec }

DeliverSM PDU.

type DeliverSMResp

type DeliverSMResp struct{ *Codec }

DeliverSMResp PDU.

type EnquireLink struct{ *Codec }

EnquireLink PDU.

type EnquireLinkResp

type EnquireLinkResp struct{ *Codec }

EnquireLinkResp PDU.

type Factory

type Factory interface {
	CreatePDU(id ID) (Body, error)
	CreatePDUResp(id ID, seq uint32) (Body, error)
}

Factory is used to instantiate PDUs in a more controllable fashion. Its main purpose is to handle sequence number generation in a contained way and without it being a global variable in the package

func NewFactory

func NewFactory() Factory

type GenericNACK

type GenericNACK struct{ *Codec }

GenericNACK PDU.

type Header struct {
	Len    uint32
	ID     ID
	Status Status
	Seq    uint32 // Sequence number.
}

Header is a PDU header.

func DecodeHeader

func DecodeHeader(r io.Reader) (*Header, error)

DecodeHeader decodes binary PDU header data.

func (*Header) SerializeTo

func (h *Header) SerializeTo(w io.Writer) error

SerializeTo serializes the Header to its binary form to the given writer.

type ID

type ID uint32

ID of the PDU header.

const (
	GenericNACKID         ID = 0x80000000
	BindReceiverID        ID = 0x00000001
	BindReceiverRespID    ID = 0x80000001
	BindTransmitterID     ID = 0x00000002
	BindTransmitterRespID ID = 0x80000002
	QuerySMID             ID = 0x00000003
	QuerySMRespID         ID = 0x80000003
	SubmitSMID            ID = 0x00000004
	SubmitSMRespID        ID = 0x80000004
	DeliverSMID           ID = 0x00000005
	DeliverSMRespID       ID = 0x80000005
	UnbindID              ID = 0x00000006
	UnbindRespID          ID = 0x80000006
	ReplaceSMID           ID = 0x00000007
	ReplaceSMRespID       ID = 0x80000007
	CancelSMID            ID = 0x00000008
	CancelSMRespID        ID = 0x80000008
	BindTransceiverID     ID = 0x00000009
	BindTransceiverRespID ID = 0x80000009
	OutbindID             ID = 0x0000000B
	EnquireLinkID         ID = 0x00000015
	EnquireLinkRespID     ID = 0x80000015
	SubmitMultiID         ID = 0x00000021
	SubmitMultiRespID     ID = 0x80000021
	AlertNotificationID   ID = 0x00000102
	DataSMID              ID = 0x00000103
	DataSMRespID          ID = 0x80000103
)

PDU Types.

func (ID) String

func (id ID) String() string

String returns the PDU type as a string.

type QuerySM

type QuerySM struct{ *Codec }

QuerySM PDU.

type QuerySMResp

type QuerySMResp struct{ *Codec }

QuerySMResp PDU.

type Status

type Status uint32

Status is a property of the PDU header.

const (
	OK                               Status = 0x00000000
	InvalidMessageLength             Status = 0x00000001
	InvalidCommandLength             Status = 0x00000002
	InvalidCommandID                 Status = 0x00000003
	IncorrectBindStatus              Status = 0x00000004
	AlreadyInBoundState              Status = 0x00000005
	InvalidPriorityFlag              Status = 0x00000006
	InvalidRegisteredDeliveryFlag    Status = 0x00000007
	SystemError                      Status = 0x00000008
	InvalidSourceAddress             Status = 0x0000000a
	InvalidDestinationAddress        Status = 0x0000000b
	InvalidMessagID                  Status = 0x0000000c
	BindFailed                       Status = 0x0000000d
	InvalidPassword                  Status = 0x0000000e
	InvalidSystemID                  Status = 0x0000000f
	CancelSMFailed                   Status = 0x00000011
	ReplaceSMFailed                  Status = 0x00000013
	MessageQueueFull                 Status = 0x00000014
	InvalidServiceType               Status = 0x00000015
	InvalidNumberDestinations        Status = 0x00000033
	InvalidDistributionListName      Status = 0x00000034
	InvalidDestinationFlag           Status = 0x00000040
	InvalidSubmitWithReplaceRequest  Status = 0x00000042
	InvalidESMEClassFieldData        Status = 0x00000043
	CannotSubmitToDistributionList   Status = 0x00000044
	SubmitSMFailed                   Status = 0x00000045
	InvalidSourceAddressTon          Status = 0x00000048
	InvalidSourceAddressNpi          Status = 0x00000049
	InvalidDestinationAddressTon     Status = 0x00000050
	InvalidDestinationAddressNpi     Status = 0x00000051
	InvalidSytsemTypeField           Status = 0x00000053
	InvalidReplaceIFPresentFlag      Status = 0x00000054
	InvalidNumberOfMessages          Status = 0x00000055
	ThrottlingError                  Status = 0x00000058
	InvalidScheduledDeliveryTime     Status = 0x00000061
	InvalidMessageValidityPeriord    Status = 0x00000062
	PredefinedMessageInvalid         Status = 0x00000063
	ESMEReceiverTemporaryAppError    Status = 0x00000064
	ESMEReceiverPermanetAPPError     Status = 0x00000065
	ESMEReceiberRejectMessageError   Status = 0x00000066
	QuerySMRequestFailed             Status = 0x00000067
	ErrorOptionalPartPDUBody         Status = 0x000000c0
	OptionalParameterNotAllowed      Status = 0x000000c1
	InvalidParameterLength           Status = 0x000000c2
	ExpectedOptionalParameterMissing Status = 0x000000c3
	InvalidOptionalParameterValue    Status = 0x000000c4
	DeliveryFailure                  Status = 0x000000fe
	UnkownError                      Status = 0x000000ff
)

func (Status) Error

func (s Status) Error() string

Error implements the Error interface.

type SubmitMulti

type SubmitMulti struct{ *Codec }

SubmitMulti PDU.

type SubmitMultiResp

type SubmitMultiResp struct{ *Codec }

SubmitMultiResp PDU.

type SubmitSM

type SubmitSM struct{ *Codec }

SubmitSM PDU.

type SubmitSMResp

type SubmitSMResp struct{ *Codec }

SubmitSMResp PDU.

type Unbind

type Unbind struct{ *Codec }

Unbind PDU.

type UnbindResp

type UnbindResp struct{ *Codec }

UnbindResp PDU.

Directories

Path Synopsis
Package pdufield provides PDU field codecs and utilities.
Package pdufield provides PDU field codecs and utilities.
Package pdutext provides text conversion for PDU fields.
Package pdutext provides text conversion for PDU fields.

Jump to

Keyboard shortcuts

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