ucp

package
v0.0.0-...-d8e5f13 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package ucp provides UCP primitives.

References:

http://documents.swisscom.com/product/1000174-Internet/Documents/Landingpage-Mobile-Mehrwertdienste/UCP_R4.7.pdf
https://wiki.wireshark.org/UCP
https://www.wireshark.org/docs/dfref/u/ucp.html

Index

Constants

View Source
const (
	STX                      = 2
	ETX                      = 3
	ALERT_OP                 = "31"
	SUBMIT_SHORT_MESSAGE_OP  = "51"
	DELIVER_SHORT_MESSAGE_OP = "52"
	DELIVER_NOTIFICATION_OP  = "53"
	SESSION_MANAGEMENT_OP    = "60"
)

Variables

View Source
var (
	// Suffix is a unique identifier for the current running server
	Suffix = uuid.NewV1().String()
	// CountersKey is a redis key for atomic counters
	CountersKey = "counters_" + Suffix
	// SmField is a redis field for submit_sm
	SmField = "submit_sm_" + Suffix
	// DrField is a redis field for deliver_sm
	DrField = "deliver_sm_" + Suffix
	// TpsKey is a redis key for tps
	TpsKey = "tps_" + Suffix
	// ActiveConnection is a redis key for sorted set of active connections
	ActiveConnection = "active_conn_" + Suffix
	// ReqPacket is a redis key for incoming tcp packet
	ReqPacket = "req_packet_" + Suffix
	// ResPacket is a redis key for outgoing tcp packet
	ResPacket = "res_packet_" + Suffix
	// MsgList is a redis key for message list
	MsgList = "msg_list_" + Suffix
	// Cost is a redis key for the total message cost
	Cost = "cost_" + Suffix
	// RefNum is a redis key for a long message with a reference number
	RefNum string
	// IpSrcDstMsg is a redis key for storing messages sent by an IP addr
	IpSrcDstMsg string = "ip_src_dst_msg_" + Suffix

	KeepAliveTimeout = 0
)
View Source
var DeliverSMCh = make(chan DeliverSM, 10)

Functions

func GetKeepAliveTimeout

func GetKeepAliveTimeout() int

func SetKeepAliveTimeout

func SetKeepAliveTimeout(n int)

Types

type Alert

type Alert struct {
	AdC []byte
	PID []byte
	// contains filtered or unexported fields
}

Alert is an Alert Operation(31).

func NewAlert

func NewAlert(pdu *PDU) *Alert

NewAlert creates a new Alert PDU.

func (*Alert) Result

func (a *Alert) Result() []byte

Result returns an Alert Operation Result.

type DeliverNotification

type DeliverNotification struct {
	AdC   []byte
	OAdC  []byte
	AC    []byte
	NRq   []byte
	NAdC  []byte
	NT    []byte
	NPID  []byte
	LRq   []byte
	LRAd  []byte
	LPID  []byte
	DD    []byte
	DDT   []byte
	VP    []byte
	RPID  []byte
	SCTS  []byte
	Dst   []byte
	Rsn   []byte
	DSCTS []byte
	MT    []byte
	NB    []byte
	Msg   []byte
	MMS   []byte
	PR    []byte
	DCs   []byte
	MCLs  []byte
	RPI   []byte
	CPg   []byte
	RPLy  []byte
	OTOA  []byte
	HPLMN []byte
	Xser  []byte
	RES4  []byte
	RES5  []byte
	// contains filtered or unexported fields
}

DeliverNotification is a Deliver Notification Operation(53).

func NewDeliverNotification

func NewDeliverNotification(pdu *PDU, AdC, OAdC, SCTS string) *DeliverNotification

NewDeliverNotification creates a new Deliver Notification PDU.

func (*DeliverNotification) Result

func (d *DeliverNotification) Result() []byte

Result returns a Deliver Notification Result.

type DeliverSM

type DeliverSM struct {
	AdC   []byte
	OAdC  []byte
	AC    []byte
	NRq   []byte
	NAdC  []byte
	NT    []byte
	NPID  []byte
	LRq   []byte
	LRAd  []byte
	LPID  []byte
	DD    []byte
	DDT   []byte
	VP    []byte
	RPID  []byte
	SCTS  []byte
	Dst   []byte
	Rsn   []byte
	DSCTS []byte
	MT    []byte
	NB    []byte
	Msg   []byte
	MMS   []byte
	PR    []byte
	DCs   []byte
	MCLs  []byte
	RPI   []byte
	CPg   []byte
	RPLy  []byte
	OTOA  []byte
	HPLMN []byte
	Xser  []byte
	RES4  []byte
	RES5  []byte
}

func (*DeliverSM) Result

func (d *DeliverSM) Result() []byte

type ExtraService

type ExtraService string

ExtraService field allows the specification of one or more additional services, all in the format TTLLDD, where TT field specifies the type of service, LL indicates the length of data and DD indicates zero or more data elements

const (
	// User Data Header
	UDH ExtraService = "01"
	//BillingIdentifier enables the client to send additional billing information to the server
	BillingIdentifier ExtraService = "0C"
)

type PDU

type PDU struct {
	sync.Mutex

	// Transaction Reference Number
	TransRefNum []byte
	// PDU length
	Len []byte
	// Operation type or Result type
	Type []byte
	// Operation Identifier
	Operation []byte
	// Operation data
	Data []byte
	// PDU checksum
	Checksum []byte
	// contains filtered or unexported fields
}

PDU is a UCP protocol data unit.

func New

func New(r net.Conn) (pdu *PDU, err error)

New creates a new PDU object.

func (*PDU) Decode

func (pdu *PDU) Decode(conf util.Config)

Decode sends a result PDU to the client.

func (*PDU) Stats

func (pdu *PDU) Stats()

Stats updates the Stats display in the web UI.

func (*PDU) String

func (pdu *PDU) String() string

String returns the string representation of a PDU.

type Session

type Session struct {
	OAdC []byte
	OTON []byte
	ONPI []byte
	STYP []byte
	PWD  []byte
	NPWD []byte
	VERS []byte
	LAdC []byte
	LTON []byte
	LNPI []byte
	OPID []byte
	RES1 []byte
	// contains filtered or unexported fields
}

Session is a Session Management Operation(60).

func NewSession

func NewSession(pdu *PDU) *Session

NewSession creates a new Session Management Operation PDU.

func (*Session) Error

func (s *Session) Error() []byte

Error returns a Negative Acknowledgement Result.

func (*Session) GetOAdc

func (s *Session) GetOAdc() string

func (*Session) GetONPI

func (s *Session) GetONPI() string

func (*Session) GetOTON

func (s *Session) GetOTON() string

func (*Session) GetPassword

func (s *Session) GetPassword() string

func (*Session) GetStyp

func (s *Session) GetStyp() string

func (*Session) Result

func (s *Session) Result() []byte

Result returns a Session Management Operation Result.

type Submit

type Submit struct {
	AdC   []byte
	OAdC  []byte
	AC    []byte
	NRq   []byte
	NAdC  []byte
	NT    []byte
	NPID  []byte
	LRq   []byte
	LRAd  []byte
	LPID  []byte
	DD    []byte
	DDT   []byte
	VP    []byte
	RPID  []byte
	SCTS  []byte
	Dst   []byte
	Rsn   []byte
	DSCTS []byte
	MT    []byte
	NB    []byte
	Msg   []byte
	MMS   []byte
	PR    []byte
	DCs   []byte
	MCLs  []byte
	RPI   []byte
	CPg   []byte
	RPLy  []byte
	OTOA  []byte
	HPLMN []byte
	Xser  []byte
	RES4  []byte
	RES5  []byte
	// contains filtered or unexported fields
}

Submit is a Submit Short Message Operation(51).

func NewSubmit

func NewSubmit(pdu *PDU) *Submit

NewSubmit creates a new Submit Short Message Operation PDU.

func (*Submit) GetMessage

func (submit *Submit) GetMessage() string

GetMessage returns the decoded message

func (*Submit) GetRecipient

func (submit *Submit) GetRecipient() string

GetRecipient returns the recipient of the messsage

func (*Submit) GetSCTS

func (submit *Submit) GetSCTS() string

GetSCTS returns the Service Center Timestamp

func (*Submit) IsNotifRequested

func (submit *Submit) IsNotifRequested() bool

IsNotifRequested returns true if a delivery notification is requested

func (*Submit) ParseXser

func (s *Submit) ParseXser() map[ExtraService]string

ParseXser returns a map of Extra Services

func (*Submit) Result

func (a *Submit) Result() []byte

Result returns a Submit Short Message Result

Jump to

Keyboard shortcuts

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