utils

package
v0.8.12 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package utils provides some utilities which might be useful specifically for GTP(or other telco protocols).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeFQDN added in v0.8.9

func DecodeFQDN(b []byte) string

DecodeFQDN decodes the given Name Syntax-encoded []byte as a string.

func DecodeMCC added in v0.7.23

func DecodeMCC(b []byte) string

DecodeMNC decodes BCD-encoded MNC as it occurs in CGI/SAI/RAI

func DecodeMNC added in v0.7.23

func DecodeMNC(b []byte) string

DecodeMCC decodes BCD-encoded MCC as it occurs in CGI/SAI/RAI.

func DecodePLMN

func DecodePLMN(b []byte) (mcc, mnc string, err error)

DecodePLMN decodes BCD-encoded bytes into MCC and MNC.

func EncodeFQDN added in v0.8.9

func EncodeFQDN(fqdn string) []byte

EncodeFQDN encodes the given string as the Name Syntax defined in RFC 2181, RFC 1035 and RFC 1123.

func EncodePLMN

func EncodePLMN(mcc, mnc string) ([]byte, error)

EncodePLMN encodes MCC and MNC as BCD-encoded bytes.

func ParseECI added in v0.6.3

func ParseECI(eci uint32) (enbID uint32, cellID uint8, err error)

ParseECI decodes ECI uint32 into e-NodeB ID and Cell ID.

func StrToSwappedBytes

func StrToSwappedBytes(s, filler string) ([]byte, error)

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

func SwappedBytesToStr(raw []byte, cutLastDigit bool) string

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

func Uint24To32(b []byte) uint32

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

func Uint32To24(n uint32) []byte

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

func Uint40To64(b []byte) uint64

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

func Uint64To40(n uint64) []byte

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.

Jump to

Keyboard shortcuts

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