utils

package
v0.0.0-...-9ad1fc4 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: MIT Imports: 1 Imported by: 1

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 DecodePLMN

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

DecodePLMN decodes BCD-encoded bytes into MCC and MNC.

func EncodePLMN

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

EncodePLMN encodes MCC and MNC as BCD-encoded bytes.

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