Documentation
¶
Overview ¶
Package utils provides some utilities which might be useful specifically for GTP(or other telco protocols).
Index ¶
- func DecodePLMN(b []byte) (mcc, mnc string, err error)
- func EncodePLMN(mcc, mnc string) ([]byte, error)
- func StrToSwappedBytes(s, filler string) ([]byte, error)
- func SwappedBytesToStr(raw []byte, cutLastDigit bool) string
- func Uint24To32(b []byte) uint32
- func Uint32To24(n uint32) []byte
- func Uint40To64(b []byte) uint64
- func Uint64To40(n uint64) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodePLMN ¶
DecodePLMN decodes BCD-encoded bytes into MCC and MNC.
func EncodePLMN ¶
EncodePLMN encodes MCC and MNC as BCD-encoded bytes.
func StrToSwappedBytes ¶
StrToSwappedBytes returns swapped bits from a byte. It is used for some values where some values are represented in swapped format.
The second parameter is the hex character(0-f) to fill the last digit when handling a odd number. "f" is used In most cases.
func SwappedBytesToStr ¶
SwappedBytesToStr decodes raw swapped bytes into string. It is used for some values where some values are represented in swapped format.
The second parameter is to decide whether to cut the last digit or not.
func Uint24To32 ¶
Uint24To32 converts 24bits-length []byte value into the uint32 with 8bits of zeros as prefix. This function is used for the fields with 3 octets.
func Uint32To24 ¶
Uint32To24 converts the uint32 value into 24bits-length []byte. The values in 25-32 bit are cut off. This function is used for the fields with 3 octets.
func Uint40To64 ¶
Uint40To64 converts 40bits-length []byte value into the uint64 with 8bits of zeros as prefix. This function is used for the fields with 3 octets.
func Uint64To40 ¶
Uint64To40 converts the uint64 value into 40bits-length []byte. The values in 25-64 bit are cut off. This function is used for the fields with 3 octets.
Types ¶
This section is empty.