Documentation ¶
Overview ¶
Package sms allows to encode and decode SMS messages into/from PDU format as described in 3GPP TS 23.040.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnknownEncoding = errors.New("sms: unsupported encoding") ErrUnknownMessageType = errors.New("sms: unsupported message type") ErrIncorrectSize = errors.New("sms: decoded incorrect size of field") ErrNonRelative = errors.New("sms: non-relative validity period support is not implemented yet") ErrIncorrectUserDataHeaderLength = errors.New("sms: incorrect user data header length ") ErrUnsupportedTypeOfNumber = errors.New("sms: unsupported type-of-number") )
Common errors.
var Encodings = struct { Gsm7Bit Encoding UCS2 Encoding Gsm7Bit_2 Encoding }{ 0x00, 0x08, 0x11, }
Encodings represent the possible encodings of message's text data.
var MessageTypes = struct { Deliver MessageType DeliverReport MessageType StatusReport MessageType Command MessageType Submit MessageType SubmitReport MessageType }{ 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, }
MessageTypes represent the possible message's types (3GPP TS 23.040).
var NumberingPlans = struct { Unknown NumberingPlan E164 NumberingPlan // ISDN/telephone numbering plan X121 NumberingPlan // Data numbering plan Telex NumberingPlan ServiceCentreSpecificA NumberingPlan // used to indicate a numbering plan specific to ESME attached to the SMSC ServiceCentreSpecificB NumberingPlan // used to indicate a numbering plan specific to ESME attached to the SMSC National NumberingPlan Private NumberingPlan ERMES NumberingPlan Reserved NumberingPlan // for future extension }{ Unknown: 0b0000, E164: 0b0001, X121: 0b0011, Telex: 0b0100, ServiceCentreSpecificA: 0b0101, ServiceCentreSpecificB: 0b0110, National: 0b1000, Private: 0b1001, ERMES: 0b1010, Reserved: 0b1111, }
NumberingPlans are all known NumberingPlan valus. Other values are reserved.
var PhoneNumberTypes = struct { Unknown PhoneNumberType International PhoneNumberType National PhoneNumberType NetworkSpecific PhoneNumberType Subscriber PhoneNumberType Alphanumeric PhoneNumberType Abbreviated PhoneNumberType Reserved PhoneNumberType // for future extension }{ Unknown: 0 << 4, International: 1 << 4, National: 2 << 4, NetworkSpecific: 3 << 4, Subscriber: 4 << 4, Alphanumeric: 5 << 4, Abbreviated: 6 << 4, Reserved: 7 << 4, }
PhoneNumberTypes are all known PhoneNumberType values.
var StatusCategories = struct { Complete StatusCategory // Short message transaction completed TemporaryError StatusCategory // Temporary error, SC still trying to transfer SM PermanentError StatusCategory // Permanent error, SC is not making any more transfer attempts FinalError StatusCategory // Temporary error, SC is not making any more transfer attempts Unknown StatusCategory // Status code is either reserved or SC-specific }{ 0x00, 0x01, 0x02, 0x03, 0x80, }
var StatusCodes = struct { // Transaction complete status codes CompletedReceived Status CompletedForwared Status CompletedReplaced Status // Temporary error, service center still tries delivery TemporaryCongestion Status TemporaryBusy Status TemporaryNoResponseFromRecipient Status TemporaryServiceRejected Status TemporaryQualityOfServiceNotAvailable Status TemporaryErrorInRecipient Status // Permanent error, SC is not making any more transfer attempts PermanentRemoteProcedureError Status PermanentIncompatibleDestination Status PermanentConnectionRejected Status PermanentNotObtainable Status PermanentQualityOfServiceNotAvailable Status PermanentNoInterworkingAvailable Status PermanentValidityPeriodExpired Status PermanentDeletedBeSender Status PermanentDeletedByAdministration Status PermanentUnknownMessage Status // Temporary error, SC is not making any more transfer attempts FinalCongestion Status FinalBusy Status FinalNoResponseFromRecipient Status FinalServiceRejected Status FinalQualityOfServiceNotAvailable Status FinalErrorInRecipient Status }{ 0b0000_0000, 0b0000_0001, 0b0000_0010, 0b0010_0000, 0b0010_0001, 0b0010_0010, 0b0010_0011, 0b0010_0100, 0b0010_0101, 0b0100_0000, 0b0100_0001, 0b0100_0010, 0b0100_0011, 0b0100_0100, 0b0100_0101, 0b0100_0110, 0b0100_0111, 0b0100_1000, 0b0100_1001, 0b0110_0000, 0b0110_0001, 0b0110_0010, 0b0110_0011, 0b0110_0100, 0b0110_0101, }
StatusCodes represents possible values for the Status field in SMS-STATUS-REPORT TPDUs.
var ValidityPeriodFormats = struct { FieldNotPresent ValidityPeriodFormat Relative ValidityPeriodFormat Enhanced ValidityPeriodFormat Absolute ValidityPeriodFormat }{ 0x00, 0x02, 0x01, 0x03, }
ValidityPeriodFormats represent the possible formats of message's validity period (3GPP TS 23.040).
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message struct { Type MessageType Encoding Encoding VP ValidityPeriod VPFormat ValidityPeriodFormat ServiceCenterTime Timestamp DischargeTime Timestamp ServiceCenterAddress PhoneNumber Address PhoneNumber Text string UserDataHeader UserDataHeader // Advanced MessageReference byte Status Status ReplyPathExists bool UserDataStartsWithHeader bool StatusReportIndication bool StatusReportRequest bool StatusReportQualificator bool MoreMessagesToSend bool LoopPrevention bool RejectDuplicates bool }
Message represents an SMS message, including some advanced fields. This is a user-friendly high-level representation that should be used around. Complies with 3GPP TS 23.040.
type NumberingPlan ¶
type NumberingPlan byte
NumberingPlan represents Numbering-plan-identification, as specified in 3GPP TS 23.040 version 16.0.0 release 16, section 9.1.2.5.
type PhoneNumber ¶
type PhoneNumber string
PhoneNumber represents the address in either local or international format.
func (PhoneNumber) PDU ¶
func (p PhoneNumber) PDU() (int, []byte, error)
PDU returns the number of digits in address and octets of semi-octet encoded address.
func (*PhoneNumber) ReadFrom ¶
func (p *PhoneNumber) ReadFrom(octets []byte) error
ReadFrom constructs an address from the semi-decoded version in the supplied byte slice.
func (PhoneNumber) Type ¶
func (p PhoneNumber) Type() byte
Type returns the type of address (a combination of type-of-number and numbering-plan-identification). Currently, only national and international E.164 numbers are understood. While ReadFrom() can parse alphanumeric numbers, Type() doesn't recognize it.
type PhoneNumberType ¶
type PhoneNumberType byte
PhoneNumberType represents Type-of-Number, as specified in 3GPP TS 23.040 version 16.0.0 release 16, section 9.1.2.5.
type Status ¶
type Status byte
Status represents the status of a SMS-STATUS-REPORT TPDU, as specified in 3GPP TS 23.040 version 16.0.0 release 16, section 9.2.3.15.
func (Status) Category ¶
func (s Status) Category() StatusCategory
Catogory returns the kind of status, laid out in 3GPP TS 23.040 version 16.0.0 release 16, section 9.2.3.15.
If s represents a reserved or Service Centre-specific status, Category will return StatusCategories.Unknown.
type Timestamp ¶
Timestamp represents message's timestamp.
func (Timestamp) PDU ¶
PDU returns bytes of semi-octet encoded timestamp, as specified in 3GPP TS 23.040 version 16.0.0 release 16, section 9.2.3.11.
TP-Service-Centre-Time-Stamp (TP-SCTS)
| | Year | Month | Day | Hour | Minute | Second | Time Zone | |-------------|------|-------|-----|------|--------|--------|-----------| | Semi-octets | 2 | 2 | 2 | 2 | 2 | 2 | 2 |
The Time Zone indicates the difference, expressed in quarters of an hour, between the local time and GMT. In the first of the two semi-octets, the first bit (bit 3 of the seventh octet of the TP-Service-CentreTime-Stamp field) represents the algebraic sign of this difference (0: positive, 1: negative).
type UserDataHeader ¶
func (*UserDataHeader) ReadFrom ¶
func (udh *UserDataHeader) ReadFrom(octets []byte) error
type ValidityPeriod ¶
ValidityPeriod represents the validity period of message.
func (ValidityPeriod) Octet ¶
func (v ValidityPeriod) Octet() byte
Octet return a one-byte representation of the validity period.
func (*ValidityPeriod) ReadFrom ¶
func (v *ValidityPeriod) ReadFrom(oct byte)
ReadFrom reads the validity period form the given byte.
type ValidityPeriodFormat ¶
type ValidityPeriodFormat byte
ValidityPeriodFormat represents the format of message's validity period.