sms

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: MIT Imports: 12 Imported by: 1

README

sms

TPDU (3GPP TS23.040), RPDU and CPDU (3GPP TS24.011) message encoding implementation by Golang.

GoDoc

About SMS

SMS is a text messaging service component of mobile device systems.

Project Status

This project is still WIP.

Getting Started

Installation

go get -u github.com/fkgi/teldata
go get -u github.com/fkgi/sms

Running examples

Encode TP-DELIVER as below.

p := sms.Deliver{
	MMS: true,
	LP:  false,
	SRI: false,
	RP:  false,
	OA:  sms.Address{TON: 0, NPI: 0},
	PID: 0,
	DCS: &sms.GeneralDataCoding{
		AutoDelete: false,
		Compressed: false,
		MsgClass:   sms.NoMessageClass,
		MsgCharset: sms.CharsetUCS2},
	SCTS: time.Date(
		2011, time.March, 22, 14, 25, 40, 0,
		time.FixedZone("unknown", 9*60*60)),
	UD: sms.UserData{Text: "あいうえお"}}
p.UD.UDH = append(p.UD.UDH, sms.ConcatenatedSM{
	RefNum: 0x84, MaxNum: 0x0a, SeqNum: 0x01})
p.OA.Addr, _ = teldata.ParseTBCD("1234")

b := p.MarshalTP()
fmt.Printf("% x", b)

Decode TP-DELIVER as below.

bytedata := []byte{
	0x40, 0x04, 0x80, 0x21, 0x43, 0x00, 0x08, 0x11,
	0x30, 0x22, 0x41, 0x52, 0x04, 0x63, 0x10, 0x05,
	0x00, 0x03, 0x87, 0x02, 0x01, 0x30, 0x42, 0x30,
	0x44, 0x30, 0x46, 0x30, 0x48, 0x30, 0x4a}
p, e := sms.UnmarshalTPMT(bytedata)
if e != nil {
	fmt.Printf("encode failed: %s", e)
}
fmt.Println(p.String())

Refer each _test.go files to see each message decoding/encoding.

LICENSE

MIT

Documentation

Index

Constants

View Source
const (
	// TypeUnknown of TON
	TypeUnknown byte = 0
	// TypeInternational of TON
	TypeInternational byte = 1
	// TypeNational of TON
	TypeNational byte = 2
	// TypeNetworkSpecific of TON
	TypeNetworkSpecific byte = 3
	// TypeSubscriber of TON
	TypeSubscriber byte = 4
	// TypeAlphanumeric of TON
	TypeAlphanumeric byte = 5
	// TypeAbbreviated of TON
	TypeAbbreviated byte = 6

	// PlanUnknown of NPI
	PlanUnknown byte = 0
	// PlanISDNTelephone of NPI
	PlanISDNTelephone byte = 1
	// PlanData of NPI
	PlanData byte = 3
	// PlanTelex of NPI
	PlanTelex byte = 4
	// PlanSCSpecific1 of NPI
	PlanSCSpecific1 byte = 5
	// PlanSCSpecific2 of NPI
	PlanSCSpecific2 byte = 6
	// PlanNational of NPI
	PlanNational byte = 8
	// PlanPrivate of NPI
	PlanPrivate byte = 9
	// PlanERMES of NPI
	PlanERMES byte = 10
)
View Source
const (
	// NoMessageClass means no message class
	NoMessageClass msgClass = 0x00
	// MessageClass0 means message class 0
	MessageClass0 msgClass = 0x10
	// MessageClass1 means message class 1
	MessageClass1 msgClass = 0x11
	// MessageClass2 means message class 2
	MessageClass2 msgClass = 0x12
	// MessageClass3 means message class 3
	MessageClass3 msgClass = 0x13

	// CharsetGSM7bit means GSM 7 bit default alphabet charset
	CharsetGSM7bit Charset = 0x00
	// Charset8bitData means 8 bit data charset
	Charset8bitData Charset = 0x04
	// CharsetUCS2 means UCS2 charset
	CharsetUCS2 Charset = 0x08
)
View Source
const (
	// VoicemailMessageWaiting means waiting type
	VoicemailMessageWaiting waitType = 0x00
	// FaxMessageWaiting means waiting type
	FaxMessageWaiting waitType = 0x01
	// ElectronicMailMessageWaiting means waiting type
	ElectronicMailMessageWaiting waitType = 0x02
	// OtherMessageWaiting means waiting type
	OtherMessageWaiting waitType = 0x03

	// DiscardMessageGSM7bit means discard the contents
	DiscardMessageGSM7bit waitBehavior = 0x00
	// StoreMessageGSM7bit means store the contents GSM 7bit alphabet
	StoreMessageGSM7bit waitBehavior = 0x10
	// StoreMessageUCS2 means store the contents UCS2
	StoreMessageUCS2 waitBehavior = 0x20
)

Variables

View Source
var (
	// ErrInvalidLength show invalid length for SMS PDU data
	ErrInvalidLength = errors.New("invalid data length")

	// ErrExtraData show extra data for SMS PDU
	ErrExtraData = errors.New("extra data")
)
View Source
var (

	// Indent for String() output for each TPDU
	Indent = " | "
)
View Source
var (
	// TR1M timer waiting time
	TR1M = time.Duration(35 * time.Second)
)

Functions

func MakeSeparatedText

func MakeSeparatedText(s string, id byte) (ud []UserData, cs Charset)

MakeSeparatedText generate splited data

func MarshalUDHs

func MarshalUDHs(h []UserDataHdr) []byte

MarshalUDHs ganerate binary data of this UDHs

func NextMsgReference

func NextMsgReference() byte

NextMsgReference make Message Reference ID

func NextTranssactionID

func NextTranssactionID() byte

NextTranssactionID make Message Transaction ID

Types

type AbsentDiag

type AbsentDiag int

AbsentDiag indicate Absent-User-Diagnostic-SM

const (
	// NoAbsentDiag is "no diag data"
	NoAbsentDiag AbsentDiag = iota
	// NoPagingRespMSC is "no paging response via the MSC"
	NoPagingRespMSC
	// IMSIDetached is "IMSI detached"
	IMSIDetached
	// RoamingRestrict is "roaming restriction"
	RoamingRestrict
	// DeregisteredNonGPRS is "deregistered in the HLR for non GPRS"
	DeregisteredNonGPRS
	// PurgedNonGPRS is "MS purged for non GPRS"
	PurgedNonGPRS
	// NoPagingRespSGSN is "no paging response via the SGSN"
	NoPagingRespSGSN
	// GPRSDetached is "GPRS detached"
	GPRSDetached
	// DeregisteredGPRS is "deregistered in the HLR for GPRS"
	DeregisteredGPRS
	// PurgedGPRS is "MS purged for GPRS"
	PurgedGPRS
	// UnidentifiedSubsMSC is "Unidentified subscriber via the MSC"
	UnidentifiedSubsMSC
	// UnidentifiedSubsSGSN is "Unidentified subscriber via the SGSN"
	UnidentifiedSubsSGSN
	// DeregisteredIMS is "deregistered in the HSS/HLR for IMS"
	DeregisteredIMS
	// NoRespIPSMGW is "no response via the IP-SM-GW"
	NoRespIPSMGW
	// TempUnavailable is "the MS is temporarily unavailable"
	TempUnavailable
)

func B2AbsDiag

func B2AbsDiag(b byte) AbsentDiag

B2AbsDiag make AbsentDiag data from byte value

func (AbsentDiag) Byte

func (a AbsentDiag) Byte() byte

Byte make byte digit value

func (AbsentDiag) String

func (a AbsentDiag) String() string

type Address

type Address struct {
	TON  byte      `json:"ton"`
	NPI  byte      `json:"npi"`
	Addr addrValue `json:"addr"`
}

Address is SMS originator/destination address

func UnmarshalAddress

func UnmarshalAddress(l byte, b []byte) (a Address)

UnmarshalAddress make Address from binary data and semi-octet length

func (Address) Equal

func (a Address) Equal(b Address) bool

Equal reports a and b are same

func (Address) Marshal

func (a Address) Marshal() (l byte, b []byte)

Marshal generate binary data and semi-octet length of this Address

func (Address) MarshalJSON

func (a Address) MarshalJSON() ([]byte, error)

MarshalJSON provide custom marshaller

func (Address) RegexpMatch

func (a Address) RegexpMatch(re *regexp.Regexp) bool

RegexpMatch check matching text of address

func (Address) String

func (a Address) String() string

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(b []byte) (e error)

UnmarshalJSON provide custom marshaller

type CPDU

type CPDU interface {
	MarshalCP() []byte
	fmt.Stringer
}

CPDU represents a SMS CP PDU

func UnmarshalCPMO

func UnmarshalCPMO(b []byte) (CPDU, error)

UnmarshalCPMO parse byte data to CPDU.

func UnmarshalCPMT

func UnmarshalCPMT(b []byte) (CPDU, error)

UnmarshalCPMT parse byte data to CPDU.

type Charset

type Charset byte

Charset is UD text data charset

type Command

type Command struct {
	SRR bool `json:"srr"` // O / Status Report Request

	TMR byte     `json:"tmr"`          // M / Message Reference for TP
	PID byte     `json:"pid"`          // M / Protocol Identifier
	CT  byte     `json:"ct"`           // M / Command Type
	MN  byte     `json:"mn"`           // M / Message Number
	DA  Address  `json:"da"`           // M / Destination Address
	CD  UserData `json:"cd,omitempty"` // O / Command Data
	// contains filtered or unexported fields
}

Command is TPDU message from MS to SC

func UnmarshalCommand

func UnmarshalCommand(b []byte) (d Command, e error)

UnmarshalCommand decode Submit from bytes

func (Command) MarshalCP

func (d Command) MarshalCP() []byte

MarshalCP output byte data of this CPDU

func (Command) MarshalJSON

func (d Command) MarshalJSON() ([]byte, error)

MarshalJSON provide custom marshaller

func (Command) MarshalRP

func (d Command) MarshalRP() []byte

MarshalRP output byte data of this RPDU

func (Command) MarshalTP

func (d Command) MarshalTP() []byte

MarshalTP output byte data of this TPDU

func (Command) String

func (d Command) String() string

func (*Command) UnmarshalCP

func (d *Command) UnmarshalCP(b []byte) (e error)

UnmarshalCP get data of this CPDU

func (*Command) UnmarshalJSON

func (d *Command) UnmarshalJSON(b []byte) error

UnmarshalJSON provide custom marshaller

func (*Command) UnmarshalRP

func (d *Command) UnmarshalRP(b []byte) (e error)

UnmarshalRP get data of this RPDU

func (*Command) UnmarshalTP

func (d *Command) UnmarshalTP(b []byte) (e error)

UnmarshalTP get data of this TPDU

type ConcatenatedSM

type ConcatenatedSM struct {
	RefNum byte
	MaxNum byte
	SeqNum byte
}

ConcatenatedSM is User Data Header

func UnmarshalConcatenatedSM

func UnmarshalConcatenatedSM(b []byte) (h ConcatenatedSM)

UnmarshalConcatenatedSM make ConcatenatedSM UDH

func (ConcatenatedSM) Equal

func (h ConcatenatedSM) Equal(b UserDataHdr) bool

Equal reports a and b are same

func (ConcatenatedSM) Key

func (h ConcatenatedSM) Key() byte

Key of this IEI

func (ConcatenatedSM) Marshal

func (h ConcatenatedSM) Marshal() []byte

Marshal generate binary data of this UDH

func (ConcatenatedSM) String

func (h ConcatenatedSM) String() string

func (ConcatenatedSM) Value

func (h ConcatenatedSM) Value() []byte

Value of this IEI

type ConcatenatedSM16bit

type ConcatenatedSM16bit struct {
	RefNum uint16
	MaxNum byte
	SeqNum byte
}

ConcatenatedSM16bit is User Data Header

func UnmarshalConcatenatedSM16bit

func UnmarshalConcatenatedSM16bit(b []byte) (h ConcatenatedSM16bit)

UnmarshalConcatenatedSM16bit make ConcatenatedSM16bit UDH

func (ConcatenatedSM16bit) Equal

Equal reports a and b are same

func (ConcatenatedSM16bit) Key

func (h ConcatenatedSM16bit) Key() byte

Key of this IEI

func (ConcatenatedSM16bit) Marshal

func (h ConcatenatedSM16bit) Marshal() []byte

Marshal generate binary data of this UDH

func (ConcatenatedSM16bit) String

func (h ConcatenatedSM16bit) String() string

func (ConcatenatedSM16bit) Value

func (h ConcatenatedSM16bit) Value() []byte

Value of this IEI

type CpAck

type CpAck struct {
	TI byte `json:"ti"` // M / Transaction identifier
}

CpAck is CP-ACK CPDU

func UnmarshalAck

func UnmarshalAck(b []byte) (a CpAck, e error)

UnmarshalAck decode Ack MT from bytes

func (CpAck) MarshalCP

func (d CpAck) MarshalCP() []byte

MarshalCP output byte data of this CPDU

func (CpAck) String

func (d CpAck) String() string

func (*CpAck) UnmarshalCP

func (d *CpAck) UnmarshalCP(b []byte) (e error)

UnmarshalCP get data of this CPDU

type CpError

type CpError struct {
	TI byte `json:"ti"` // M / Transaction identifier
	CS byte `json:"cs"` // M / Cause
}

CpError is CP-ERROR CPDU

func UnmarshalError

func UnmarshalError(b []byte) (a CpError, e error)

UnmarshalError decode Ack MT from bytes

func (CpError) Error

func (d CpError) Error() string

func (CpError) MarshalCP

func (d CpError) MarshalCP() []byte

MarshalCP output byte data of this CPDU

func (CpError) String

func (d CpError) String() string

func (*CpError) UnmarshalCP

func (d *CpError) UnmarshalCP(b []byte) (e error)

UnmarshalCP get data of this CPDU

type DataCoding

type DataCoding interface {
	Marshal() byte
	Equal(DataCoding) bool
	fmt.Stringer
	Charset() Charset
}

DataCoding indicate Data Coding Scheme

func UnmarshalDataCoding

func UnmarshalDataCoding(b byte) DataCoding

UnmarshalDataCoding make DataCoding from byte data

type DataCodingMessage

type DataCodingMessage struct {
	IsData   bool
	MsgClass msgClass
}

DataCodingMessage is group of SMS Data Coding Scheme

func (DataCodingMessage) Charset

func (c DataCodingMessage) Charset() Charset

Charset returns text data charset

func (DataCodingMessage) Equal

func (c DataCodingMessage) Equal(b DataCoding) bool

Equal reports a and b are same

func (DataCodingMessage) Marshal

func (c DataCodingMessage) Marshal() (b byte)

Marshal make byte data

func (DataCodingMessage) String

func (c DataCodingMessage) String() string

type Deliver

type Deliver struct {
	MMS bool `json:"mms"` // M / More Messages to Send (true=more messages)
	LP  bool `json:"lp"`  // O / Loop Prevention
	SRI bool `json:"sri"` // O / Status Report Indication (true=status report shall be returned)
	RP  bool `json:"rp"`  // M / Reply Path

	OA   Address    `json:"oa"`           // M / Originating Address
	PID  byte       `json:"pid"`          // M / Protocol Identifier
	DCS  DataCoding `json:"dcs"`          // M / Data Coding Scheme
	SCTS time.Time  `json:"scts"`         // M / Service Centre Time Stamp
	UD   UserData   `json:"ud,omitempty"` // O / User Data
	// contains filtered or unexported fields
}

Deliver is TPDU message from SC to MS

func UnmarshalDeliver

func UnmarshalDeliver(b []byte) (d Deliver, e error)

UnmarshalDeliver decode Deliver from bytes

func (Deliver) MarshalCP

func (d Deliver) MarshalCP() []byte

MarshalCP output byte data of this CPDU

func (Deliver) MarshalJSON

func (d Deliver) MarshalJSON() ([]byte, error)

MarshalJSON provide custom marshaller

func (Deliver) MarshalRP

func (d Deliver) MarshalRP() []byte

MarshalRP output byte data of this RPDU

func (Deliver) MarshalTP

func (d Deliver) MarshalTP() []byte

MarshalTP output byte data of this TPDU

func (Deliver) String

func (d Deliver) String() string

func (*Deliver) UnmarshalCP

func (d *Deliver) UnmarshalCP(b []byte) (e error)

UnmarshalCP get data of this CPDU

func (*Deliver) UnmarshalJSON

func (d *Deliver) UnmarshalJSON(b []byte) error

UnmarshalJSON provide custom marshaller

func (*Deliver) UnmarshalRP

func (d *Deliver) UnmarshalRP(b []byte) (e error)

UnmarshalRP get data of this RPDU

func (*Deliver) UnmarshalTP

func (d *Deliver) UnmarshalTP(b []byte) (e error)

UnmarshalTP get data of this TPDU

type DeliverReport

type DeliverReport struct {
	RMR  byte  `json:"rmr"`            // M / Message Reference
	CS   byte  `json:"cs"`             // M / Cause
	DIAG *byte `json:"diag,omitempty"` // O / Diagnostics

	FCS byte       `json:"fcs,omitempty"` // C / Failure Cause
	PID *byte      `json:"pid,omitempty"` // O / Protocol Identifier
	DCS DataCoding `json:"dcs,omitempty"` // O / Data Coding Scheme
	UD  UserData   `json:"ud,omitempty"`  // O / User Data
	// contains filtered or unexported fields
}

DeliverReport is TPDU message from MS to SC

func UnmarshalDeliverReport

func UnmarshalDeliverReport(b []byte) (d DeliverReport, e error)

UnmarshalDeliverReport decode DeliverReport from bytes

func (DeliverReport) MarshalCP

func (d DeliverReport) MarshalCP() []byte

MarshalCP output byte data of this CPDU

func (DeliverReport) MarshalJSON

func (d DeliverReport) MarshalJSON() ([]byte, error)

MarshalJSON provide custom marshaller

func (DeliverReport) MarshalRP

func (d DeliverReport) MarshalRP() []byte

MarshalRP output byte data of this RPDU

func (DeliverReport) MarshalTP

func (d DeliverReport) MarshalTP() []byte

MarshalTP output byte data of this TPDU

func (DeliverReport) String

func (d DeliverReport) String() string

func (*DeliverReport) UnmarshalCP

func (d *DeliverReport) UnmarshalCP(b []byte) (e error)

UnmarshalCP get data of this CPDU

func (*DeliverReport) UnmarshalJSON

func (d *DeliverReport) UnmarshalJSON(b []byte) error

UnmarshalJSON provide custom marshaller

func (*DeliverReport) UnmarshalRP

func (d *DeliverReport) UnmarshalRP(b []byte) (e error)

UnmarshalRP get data of this RPDU

func (*DeliverReport) UnmarshalTP

func (d *DeliverReport) UnmarshalTP(b []byte) (e error)

UnmarshalTP get data of this TPDU

type GSM7bitString

type GSM7bitString []rune

GSM7bitString is GSM 7-bit default alphabet of 3GPP TS23.038

func StringToGSM7bit

func StringToGSM7bit(s string) (GSM7bitString, error)

StringToGSM7bit generate GSM7bitString from string

func UnmarshalGSM7bitString

func UnmarshalGSM7bitString(o, l int, b []byte) GSM7bitString

UnmarshalGSM7bitString generate GSM7bitString from byte slice with offset

func (GSM7bitString) Bytes

func (s GSM7bitString) Bytes() []byte

Bytes return byte data

func (GSM7bitString) Equal

func (s GSM7bitString) Equal(b GSM7bitString) bool

Equal reports a and b are same

func (GSM7bitString) Length

func (s GSM7bitString) Length() int

Length return length of the GSM 7bit String

func (GSM7bitString) Marshal

func (s GSM7bitString) Marshal(o int) []byte

Marshal return byte data with offset shift

func (GSM7bitString) String

func (s GSM7bitString) String() string

type GeneralDataCoding

type GeneralDataCoding struct {
	AutoDelete bool
	Compressed bool
	MsgClass   msgClass
	MsgCharset Charset
}

GeneralDataCoding is group of SMS Data Coding Scheme

func (GeneralDataCoding) Charset

func (c GeneralDataCoding) Charset() Charset

Charset returns text data charset

func (GeneralDataCoding) Equal

func (c GeneralDataCoding) Equal(b DataCoding) bool

Equal reports a and b are same

func (GeneralDataCoding) Marshal

func (c GeneralDataCoding) Marshal() (b byte)

Marshal make byte data

func (GeneralDataCoding) String

func (c GeneralDataCoding) String() string

type GenericIEI

type GenericIEI struct {
	K byte   `json:"key"`
	V []byte `json:"value"`
}

GenericIEI is User Data Header

func UnmarshalGeneric

func UnmarshalGeneric(b []byte) (h GenericIEI)

UnmarshalGeneric make Generic UDH

func (GenericIEI) Equal

func (h GenericIEI) Equal(b UserDataHdr) bool

Equal reports a and b are same

func (GenericIEI) Key

func (h GenericIEI) Key() byte

Key of this IEI

func (GenericIEI) Marshal

func (h GenericIEI) Marshal() []byte

Marshal generate binary data of this UDH

func (GenericIEI) String

func (h GenericIEI) String() string

func (GenericIEI) Value

func (h GenericIEI) Value() []byte

Value of this IEI

type MemoryAvailable

type MemoryAvailable struct {
	RMR byte `json:"rmr"` // M / Message Reference
	// contains filtered or unexported fields
}

MemoryAvailable is RP-SMMA RPDU

func UnmarshalMemoryAvailable

func UnmarshalMemoryAvailable(b []byte) (a MemoryAvailable, e error)

UnmarshalMemoryAvailable decode MemoryAvailable MO from bytes

func (MemoryAvailable) MarshalCP

func (d MemoryAvailable) MarshalCP() []byte

MarshalCP output byte data of this CPDU

func (MemoryAvailable) MarshalRP

func (d MemoryAvailable) MarshalRP() []byte

MarshalRP output byte data of this RPDU

func (MemoryAvailable) String

func (d MemoryAvailable) String() string

func (*MemoryAvailable) UnmarshalCP

func (d *MemoryAvailable) UnmarshalCP(b []byte) (e error)

UnmarshalCP get data of this CPDU

func (*MemoryAvailable) UnmarshalRP

func (d *MemoryAvailable) UnmarshalRP(b []byte) (e error)

UnmarshalRP get data of this RPDU

type MessageWaiting

type MessageWaiting struct {
	Behavior    waitBehavior
	Active      bool
	WaitingType waitType
}

MessageWaiting is group of SMS Data Coding Scheme

func (MessageWaiting) Charset

func (c MessageWaiting) Charset() Charset

Charset returns text data charset

func (MessageWaiting) Equal

func (c MessageWaiting) Equal(b DataCoding) bool

Equal reports a and b are same

func (MessageWaiting) Marshal

func (c MessageWaiting) Marshal() (b byte)

Marshal make byte data

func (MessageWaiting) String

func (c MessageWaiting) String() string

type RPDU

type RPDU interface {
	CPDU
	MarshalRP() []byte
}

RPDU represents a SMS RP PDU

func UnmarshalRPMO

func UnmarshalRPMO(b []byte) (RPDU, error)

UnmarshalRPMO parse byte data to TPDU as SC.

func UnmarshalRPMT

func UnmarshalRPMT(b []byte) (RPDU, error)

UnmarshalRPMT parse byte data to TPDU as MS.

type RpAck

type RpAck struct {
	RMR byte `json:"rmr"` // M / Message Reference
	// contains filtered or unexported fields
}

RpAck is RP-ACK RPDU

func (RpAck) String

func (d RpAck) String() string

type RpAckMO

type RpAckMO RpAck

RpAckMO is MO RP-ACK RPDU

func UnmarshalRpAckMO

func UnmarshalRpAckMO(b []byte) (a RpAckMO, e error)

UnmarshalRpAckMO decode Ack MO from bytes

func (RpAckMO) MarshalCP

func (d RpAckMO) MarshalCP() []byte

MarshalCP output byte data of this CPDU

func (RpAckMO) MarshalRP

func (d RpAckMO) MarshalRP() []byte

MarshalRP output byte data of this RPDU

func (RpAckMO) String

func (d RpAckMO) String() string

func (*RpAckMO) UnmarshalCP

func (d *RpAckMO) UnmarshalCP(b []byte) (e error)

UnmarshalCP get data of this CPDU

func (*RpAckMO) UnmarshalRP

func (d *RpAckMO) UnmarshalRP(b []byte) (e error)

UnmarshalRP get data of this RPDU

type RpAckMT

type RpAckMT RpAck

RpAckMT is MT RP-ACK RPDU

func UnmarshalRpAckMT

func UnmarshalRpAckMT(b []byte) (a RpAckMT, e error)

UnmarshalRpAckMT decode Ack MT from bytes

func (RpAckMT) MarshalCP

func (d RpAckMT) MarshalCP() []byte

MarshalCP output byte data of this CPDU

func (RpAckMT) MarshalRP

func (d RpAckMT) MarshalRP() []byte

MarshalRP output byte data of this RPDU

func (RpAckMT) String

func (d RpAckMT) String() string

func (*RpAckMT) UnmarshalCP

func (d *RpAckMT) UnmarshalCP(b []byte) (e error)

UnmarshalCP get data of this CPDU

func (*RpAckMT) UnmarshalRP

func (d *RpAckMT) UnmarshalRP(b []byte) (e error)

UnmarshalRP get data of this RPDU

type RpError

type RpError struct {
	RMR  byte  `json:"rmr"`            // M / Message Reference
	CS   byte  `json:"cs"`             // M / Cause
	DIAG *byte `json:"diag,omitempty"` // O / Diagnostics
	// contains filtered or unexported fields
}

RpError is RP-ERROR RPDU

func (RpError) Error

func (d RpError) Error() string

func (RpError) String

func (d RpError) String() string

type RpErrorMO

type RpErrorMO RpError

RpErrorMO is MO RP-ERROR RPDU

func UnmarshalRpErrorMO

func UnmarshalRpErrorMO(b []byte) (a RpErrorMO, e error)

UnmarshalRpErrorMO decode Error MO from bytes

func (RpErrorMO) MarshalCP

func (d RpErrorMO) MarshalCP() []byte

MarshalCP output byte data of this CPDU

func (RpErrorMO) MarshalRP

func (d RpErrorMO) MarshalRP() []byte

MarshalRP output byte data of this RPDU

func (RpErrorMO) String

func (d RpErrorMO) String() string

func (*RpErrorMO) UnmarshalCP

func (d *RpErrorMO) UnmarshalCP(b []byte) (e error)

UnmarshalCP get data of this CPDU

func (*RpErrorMO) UnmarshalRP

func (d *RpErrorMO) UnmarshalRP(b []byte) (e error)

UnmarshalRP get data of this RPDU

type RpErrorMT

type RpErrorMT RpError

RpErrorMT is MT RP-ERROR RPDU

func UnmarshalRpErrorMT

func UnmarshalRpErrorMT(b []byte) (a RpErrorMT, e error)

UnmarshalRpErrorMT decode Error MO from bytes

func (RpErrorMT) MarshalCP

func (d RpErrorMT) MarshalCP() []byte

MarshalCP output byte data of this CPDU

func (RpErrorMT) MarshalRP

func (d RpErrorMT) MarshalRP() []byte

MarshalRP output byte data of this RPDU

func (RpErrorMT) String

func (d RpErrorMT) String() string

func (*RpErrorMT) UnmarshalCP

func (d *RpErrorMT) UnmarshalCP(b []byte) (e error)

UnmarshalCP get data of this CPDU

func (*RpErrorMT) UnmarshalRP

func (d *RpErrorMT) UnmarshalRP(b []byte) (e error)

UnmarshalRP get data of this RPDU

type SMC

type SMC struct {
	SCAddress Address

	CtrlReq     func(CPDU)
	TranspInd   func(TPDU) (TPDU, error)
	MemAvailInd func() error
	// contains filtered or unexported fields
}

SMC is SM-CP handler

func (SMC) CtrlInd

func (smc SMC) CtrlInd(pdu CPDU)

CtrlInd handle CP-DATA/CP-ACK/CP-ERROR

func (SMC) TranspReq

func (smc SMC) TranspReq(pdu TPDU) (TPDU, error)

TranspReq handle TP-DATA

type SMR

type SMR struct {
	SCAddress Address

	RelayReq    func(RPDU) error
	TranspInd   func(TPDU) (TPDU, error)
	MemAvailInd func() error
	// contains filtered or unexported fields
}

SMR is SM-RP handler

func (SMR) RelayInd

func (smr SMR) RelayInd(r RPDU) (RPDU, error)

RelayInd handle RP-DATA/SMMA

func (SMR) TranspReq

func (smr SMR) TranspReq(r TPDU) (TPDU, error)

TranspReq handle TP-DATA

type StatusReport

type StatusReport struct {
	MMS bool `json:"mms"` // M / More Messages to Send (true=more messages)
	LP  bool `json:"lp"`  // O / Loop Prevention
	SRQ bool `json:"srq"` // M / Status Report Qualifier (true=status report shall be returned)

	TMR  byte       `json:"tmr"`           // M / Message Reference
	RA   Address    `json:"ra"`            // M / Destination Address
	SCTS time.Time  `json:"scts"`          // M / Service Centre Time Stamp
	DT   time.Time  `json:"dt"`            // M / Discharge Time
	ST   byte       `json:"st"`            // M / Status
	PID  *byte      `json:"pid,omitempty"` // O / Protocol Identifier
	DCS  DataCoding `json:"dcs,omitempty"` // O / Data Coding Scheme
	UD   UserData   `json:"ud,omitempty"`  // O / User Data
	// contains filtered or unexported fields
}

StatusReport is TPDU message from SC to MS

func UnmarshalStatusReport

func UnmarshalStatusReport(b []byte) (d StatusReport, e error)

UnmarshalStatusReport decode StatusReport from bytes

func (StatusReport) MarshalCP

func (d StatusReport) MarshalCP() []byte

MarshalCP output byte data of this CPDU

func (StatusReport) MarshalJSON

func (d StatusReport) MarshalJSON() ([]byte, error)

MarshalJSON provide custom marshaller

func (StatusReport) MarshalRP

func (d StatusReport) MarshalRP() []byte

MarshalRP output byte data of this RPDU

func (StatusReport) MarshalTP

func (d StatusReport) MarshalTP() []byte

MarshalTP output byte data of this TPDU

func (StatusReport) String

func (d StatusReport) String() string

func (*StatusReport) UnmarshalCP

func (d *StatusReport) UnmarshalCP(b []byte) (e error)

UnmarshalCP get data of this CPDU

func (*StatusReport) UnmarshalJSON

func (d *StatusReport) UnmarshalJSON(b []byte) error

UnmarshalJSON provide custom marshaller

func (*StatusReport) UnmarshalRP

func (d *StatusReport) UnmarshalRP(b []byte) (e error)

UnmarshalRP get data of this RPDU

func (*StatusReport) UnmarshalTP

func (d *StatusReport) UnmarshalTP(b []byte) (e error)

UnmarshalTP get data of this TPDU

type Submit

type Submit struct {
	RD  bool `json:"rd"`  // M / Reject Duplicates
	SRR bool `json:"srr"` // O / Status Report Request
	RP  bool `json:"rp"`  // M / Reply Path

	TMR byte           `json:"tmr"`          // M / Message Reference for TP
	DA  Address        `json:"da"`           // M / Destination Address
	PID byte           `json:"pid"`          // M / Protocol Identifier
	DCS DataCoding     `json:"dcs"`          // M / Data Coding Scheme
	VP  ValidityPeriod `json:"vp,omitempty"` // O / Validity Period
	UD  UserData       `json:"ud,omitempty"` // O / User Data
	// contains filtered or unexported fields
}

Submit is TPDU message from MS to SC

func UnmarshalSubmit

func UnmarshalSubmit(b []byte) (d Submit, e error)

UnmarshalSubmit decode Submit from bytes

func (Submit) MarshalCP

func (d Submit) MarshalCP() []byte

MarshalCP output byte data of this CPDU

func (Submit) MarshalJSON

func (d Submit) MarshalJSON() ([]byte, error)

MarshalJSON provide custom marshaller

func (Submit) MarshalRP

func (d Submit) MarshalRP() []byte

MarshalRP output byte data of this RPDU

func (Submit) MarshalTP

func (d Submit) MarshalTP() []byte

MarshalTP output byte data of this TPDU

func (Submit) String

func (d Submit) String() string

func (*Submit) UnmarshalCP

func (d *Submit) UnmarshalCP(b []byte) (e error)

UnmarshalCP get data of this CPDU

func (*Submit) UnmarshalJSON

func (d *Submit) UnmarshalJSON(b []byte) error

UnmarshalJSON provide custom marshaller

func (*Submit) UnmarshalRP

func (d *Submit) UnmarshalRP(b []byte) (e error)

UnmarshalRP get data of this RPDU

func (*Submit) UnmarshalTP

func (d *Submit) UnmarshalTP(b []byte) (e error)

UnmarshalTP get data of this TPDU

type SubmitReport

type SubmitReport struct {
	RMR  byte  `json:"rmr"`            // M / Message Reference
	CS   byte  `json:"cs"`             // M / Cause
	DIAG *byte `json:"diag,omitempty"` // O / Diagnostics

	FCS  byte       `json:"fcs,omitempty"` // C / Failure Cause
	SCTS time.Time  `json:"scts"`          // M / Service Centre Time Stamp
	PID  *byte      `json:"pid,omitempty"` // O / Protocol Identifier
	DCS  DataCoding `json:"dcs,omitempty"` // O / Data Coding Scheme
	UD   UserData   `json:"uid,omitempty"` // O / User Data
	// contains filtered or unexported fields
}

SubmitReport is TPDU message from SC to MS

func UnmarshalSubmitReport

func UnmarshalSubmitReport(b []byte) (d SubmitReport, e error)

UnmarshalSubmitReport decode SubmitReport from bytes

func (SubmitReport) MarshalCP

func (d SubmitReport) MarshalCP() []byte

MarshalCP output byte data of this CPDU

func (SubmitReport) MarshalJSON

func (d SubmitReport) MarshalJSON() ([]byte, error)

MarshalJSON provide custom marshaller

func (SubmitReport) MarshalRP

func (d SubmitReport) MarshalRP() []byte

MarshalRP output byte data of this RPDU

func (SubmitReport) MarshalTP

func (d SubmitReport) MarshalTP() []byte

MarshalTP output byte data of this TPDU

func (SubmitReport) String

func (d SubmitReport) String() string

func (*SubmitReport) UnmarshalCP

func (d *SubmitReport) UnmarshalCP(b []byte) (e error)

UnmarshalCP get data of this CPDU

func (*SubmitReport) UnmarshalJSON

func (d *SubmitReport) UnmarshalJSON(b []byte) error

UnmarshalJSON provide custom marshaller

func (*SubmitReport) UnmarshalRP

func (d *SubmitReport) UnmarshalRP(b []byte) (e error)

UnmarshalRP get data of this RPDU

func (*SubmitReport) UnmarshalTP

func (d *SubmitReport) UnmarshalTP(b []byte) (e error)

UnmarshalTP get data of this TPDU

type TPDU

type TPDU interface {
	RPDU
	MarshalTP() []byte
}

TPDU represents a SMS TP PDU

func UnmarshalTPMO

func UnmarshalTPMO(b []byte) (TPDU, error)

UnmarshalTPMO parse byte data to TPDU as SC.

func UnmarshalTPMT

func UnmarshalTPMT(b []byte) (t TPDU, e error)

UnmarshalTPMT parse byte data to TPDU as MS.

type UnexpectedInformationElementError

type UnexpectedInformationElementError struct {
	Expected, Actual byte
}

UnexpectedInformationElementError show invalid SMS IE

func (UnexpectedInformationElementError) Error

type UnexpectedMessageTypeError

type UnexpectedMessageTypeError struct {
	Expected, Actual byte
}

UnexpectedMessageTypeError show invalid SMS PDU type

func (UnexpectedMessageTypeError) Error

type UnknownDataCodingError

type UnknownDataCodingError struct {
	DCS byte
}

UnknownDataCodingError show invalid DCS

func (UnknownDataCodingError) Error

func (e UnknownDataCodingError) Error() string

type UnknownGSM7bitRuneError

type UnknownGSM7bitRuneError struct {
	R rune
}

UnknownGSM7bitRuneError show invalid rune for GSM 7bit string

func (UnknownGSM7bitRuneError) Error

func (e UnknownGSM7bitRuneError) Error() string

type UnknownMessageTypeError

type UnknownMessageTypeError struct {
	Actual byte
}

UnknownMessageTypeError show invalid SMS PDU type

func (UnknownMessageTypeError) Error

func (e UnknownMessageTypeError) Error() string

type UnmarshalerCP

type UnmarshalerCP interface {
	UnmarshalCP([]byte) error
}

UnmarshalerCP is the interface implemented by types that can unmarshal a CPDU

type UnmarshalerRP

type UnmarshalerRP interface {
	UnmarshalRP([]byte) error
}

UnmarshalerRP is the interface implemented by types that can unmarshal a RPDU

type UnmarshalerTP

type UnmarshalerTP interface {
	UnmarshalTP([]byte) error
}

UnmarshalerTP is the interface implemented by types that can unmarshal a TPDU

type UserData

type UserData struct {
	Text string        `json:"text,omitempty"`
	UDH  []UserDataHdr `json:"hdr,omitempty"`
}

UserData is TP-UD

func (UserData) Equal

func (u UserData) Equal(b UserData) bool

Equal reports a and b are same

func (UserData) Get8bitData

func (u UserData) Get8bitData() ([]byte, error)

Get8bitData set binary data as UD

func (UserData) MarshalJSON

func (u UserData) MarshalJSON() ([]byte, error)

MarshalJSON provide custom marshaller

func (*UserData) Set8bitData

func (u *UserData) Set8bitData(d []byte)

Set8bitData set binary data as UD

func (UserData) String

func (u UserData) String() string

func (*UserData) UnmarshalJSON

func (u *UserData) UnmarshalJSON(b []byte) (e error)

UnmarshalJSON provide custom marshaller

type UserDataHdr

type UserDataHdr interface {
	Marshal() []byte
	// unmarshal([]byte)
	fmt.Stringer
	Key() byte
	Value() []byte
	Equal(UserDataHdr) bool
}

UserDataHdr is user data header

func UnmarshalUDHs

func UnmarshalUDHs(b []byte) (h []UserDataHdr)

UnmarshalUDHs make UDHs

type VPAbsolute

type VPAbsolute [7]byte

VPAbsolute is absolute format VP value

func (VPAbsolute) Duration

func (f VPAbsolute) Duration() time.Duration

Duration return duration to expire time

func (VPAbsolute) Equal

func (f VPAbsolute) Equal(b ValidityPeriod) bool

Equal reports a and b are same

func (VPAbsolute) ExpireTime

func (f VPAbsolute) ExpireTime(t time.Time) time.Time

ExpireTime return expire time

func (VPAbsolute) SingleAttempt

func (f VPAbsolute) SingleAttempt() bool

SingleAttempt return single attempt is required or not

func (VPAbsolute) String

func (f VPAbsolute) String() string

type VPEnhanced

type VPEnhanced [7]byte

VPEnhanced is enhanced format VP value

func (VPEnhanced) Duration

func (f VPEnhanced) Duration() time.Duration

Duration return duration to expire time

func (VPEnhanced) Equal

func (f VPEnhanced) Equal(b ValidityPeriod) bool

Equal reports a and b are same

func (VPEnhanced) ExpireTime

func (f VPEnhanced) ExpireTime(t time.Time) time.Time

ExpireTime return expire time

func (VPEnhanced) SingleAttempt

func (f VPEnhanced) SingleAttempt() bool

SingleAttempt return single attempt is required or not

func (VPEnhanced) String

func (f VPEnhanced) String() string

type VPRelative

type VPRelative byte

VPRelative is relative format VP value

func (VPRelative) Duration

func (f VPRelative) Duration() time.Duration

Duration return duration to expire time

func (VPRelative) Equal

func (f VPRelative) Equal(b ValidityPeriod) bool

Equal reports a and b are same

func (VPRelative) ExpireTime

func (f VPRelative) ExpireTime(t time.Time) time.Time

ExpireTime return expire time

func (VPRelative) SingleAttempt

func (f VPRelative) SingleAttempt() bool

SingleAttempt return single attempt is required or not

func (VPRelative) String

func (f VPRelative) String() string

type ValidityPeriod

type ValidityPeriod interface {
	fmt.Stringer
	ExpireTime(t time.Time) time.Time
	Duration() time.Duration
	SingleAttempt() bool
	Equal(ValidityPeriod) bool
}

ValidityPeriod is type of validity period

func ValidityPeriodOf

func ValidityPeriodOf(t time.Duration, s bool) ValidityPeriod

ValidityPeriodOf returns VP from deadend time and single-attempt flag

Jump to

Keyboard shortcuts

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