datatype

package
v3.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package datatype provides data types for Diameter AVPs.

Index

Constants

This section is empty.

Variables

View Source
var Available = map[string]TypeID{
	"Address":          AddressType,
	"DiameterIdentity": DiameterIdentityType,
	"DiameterURI":      DiameterURIType,
	"Enumerated":       EnumeratedType,
	"Float32":          Float32Type,
	"Float64":          Float64Type,
	"Grouped":          GroupedType,
	"IPFilterRule":     IPFilterRuleType,
	"IPv4":             IPv4Type,
	"Integer32":        Integer32Type,
	"Integer64":        Integer64Type,
	"OctetString":      OctetStringType,
	"QoSFilterRule":    QoSFilterRuleType,
	"Time":             TimeType,
	"UTF8String":       UTF8StringType,
	"Unsigned32":       Unsigned32Type,
	"Unsigned64":       Unsigned64Type,
}

Available is a map of data types available, indexed by name.

View Source
var Decoder = map[TypeID]DecoderFunc{
	UnknownType:          DecodeUnknown,
	AddressType:          DecodeAddress,
	DiameterIdentityType: DecodeDiameterIdentity,
	DiameterURIType:      DecodeDiameterURI,
	EnumeratedType:       DecodeEnumerated,
	Float32Type:          DecodeFloat32,
	Float64Type:          DecodeFloat64,
	GroupedType:          DecodeGrouped,
	IPFilterRuleType:     DecodeIPFilterRule,
	IPv4Type:             DecodeIPv4,
	Integer32Type:        DecodeInteger32,
	Integer64Type:        DecodeInteger64,
	OctetStringType:      DecodeOctetString,
	TimeType:             DecodeTime,
	UTF8StringType:       DecodeUTF8String,
	Unsigned32Type:       DecodeUnsigned32,
	Unsigned64Type:       DecodeUnsigned64,
}

Decoder is a map of AVP data types indexed by TypeID.

Functions

This section is empty.

Types

type Address

type Address []byte

Address data type.

func (Address) Len

func (addr Address) Len() int

Len implements the Type interface.

func (Address) Padding

func (addr Address) Padding() int

Padding implements the Type interface.

func (Address) Serialize

func (addr Address) Serialize() []byte

Serialize implements the Type interface.

func (Address) String

func (addr Address) String() string

String implements the Type interface.

func (Address) Type

func (addr Address) Type() TypeID

Type implements the Type interface.

type DecoderFunc

type DecoderFunc func([]byte) (Type, error)

DecoderFunc is an adapter to decode a byte array to an AVP data type.

type DiameterIdentity

type DiameterIdentity OctetString

DiameterIdentity data type.

func (DiameterIdentity) Len

func (s DiameterIdentity) Len() int

Len implements the Type interface.

func (DiameterIdentity) Padding

func (s DiameterIdentity) Padding() int

Padding implements the Type interface.

func (DiameterIdentity) Serialize

func (s DiameterIdentity) Serialize() []byte

Serialize implements the Type interface.

func (DiameterIdentity) String

func (s DiameterIdentity) String() string

String implements the Type interface.

func (DiameterIdentity) Type

func (s DiameterIdentity) Type() TypeID

Type implements the Type interface.

type DiameterURI

type DiameterURI OctetString

DiameterURI data type.

func (DiameterURI) Len

func (s DiameterURI) Len() int

Len implements the Type interface.

func (DiameterURI) Padding

func (s DiameterURI) Padding() int

Padding implements the Type interface.

func (DiameterURI) Serialize

func (s DiameterURI) Serialize() []byte

Serialize implements the Type interface.

func (DiameterURI) String

func (s DiameterURI) String() string

String implements the Type interface.

func (DiameterURI) Type

func (s DiameterURI) Type() TypeID

Type implements the Type interface.

type Enumerated

type Enumerated Integer32

Enumerated data type.

func (Enumerated) Len

func (n Enumerated) Len() int

Len implements the Type interface.

func (Enumerated) Padding

func (n Enumerated) Padding() int

Padding implements the Type interface.

func (Enumerated) Serialize

func (n Enumerated) Serialize() []byte

Serialize implements the Type interface.

func (Enumerated) String

func (n Enumerated) String() string

String implements the Type interface.

func (Enumerated) Type

func (n Enumerated) Type() TypeID

Type implements the Type interface.

type Float32

type Float32 float32

Float32 data type.

func (Float32) Len

func (n Float32) Len() int

Len implements the Type interface.

func (Float32) Padding

func (n Float32) Padding() int

Padding implements the Type interface.

func (Float32) Serialize

func (n Float32) Serialize() []byte

Serialize implements the Type interface.

func (Float32) String

func (n Float32) String() string

String implements the Type interface.

func (Float32) Type

func (n Float32) Type() TypeID

Type implements the Type interface.

type Float64

type Float64 float64

Float64 data type.

func (Float64) Len

func (n Float64) Len() int

Len implements the Type interface.

func (Float64) Padding

func (n Float64) Padding() int

Padding implements the Type interface.

func (Float64) Serialize

func (n Float64) Serialize() []byte

Serialize implements the Type interface.

func (Float64) String

func (n Float64) String() string

String implements the Type interface.

func (Float64) Type

func (n Float64) Type() TypeID

Type implements the Type interface.

type Grouped

type Grouped []byte

Grouped data type.

func (Grouped) Len

func (g Grouped) Len() int

Len implements the Type interface.

func (Grouped) Padding

func (g Grouped) Padding() int

Padding implements the Type interface.

func (Grouped) Serialize

func (g Grouped) Serialize() []byte

Serialize implements the Type interface.

func (Grouped) String

func (g Grouped) String() string

String implements the Type interface.

func (Grouped) Type

func (g Grouped) Type() TypeID

Type implements the Type interface.

type IPFilterRule

type IPFilterRule OctetString

IPFilterRule data type.

func (IPFilterRule) Len

func (s IPFilterRule) Len() int

Len implements the Type interface.

func (IPFilterRule) Padding

func (s IPFilterRule) Padding() int

Padding implements the Type interface.

func (IPFilterRule) Serialize

func (s IPFilterRule) Serialize() []byte

Serialize implements the Type interface.

func (IPFilterRule) String

func (s IPFilterRule) String() string

String implements the Type interface.

func (IPFilterRule) Type

func (s IPFilterRule) Type() TypeID

Type implements the Type interface.

type IPv4

type IPv4 net.IP

IPv4 data type for Framed-IP-Address AVP.

func (IPv4) Len

func (ip IPv4) Len() int

Len implements the Type interface.

func (IPv4) Padding

func (ip IPv4) Padding() int

Padding implements the Type interface.

func (IPv4) Serialize

func (ip IPv4) Serialize() []byte

Serialize implements the Type interface.

func (IPv4) String

func (ip IPv4) String() string

String implements the Type interface.

func (IPv4) Type

func (ip IPv4) Type() TypeID

Type implements the Type interface.

type Integer32

type Integer32 int32

Integer32 data type.

func (Integer32) Len

func (n Integer32) Len() int

Len implements the Type interface.

func (Integer32) Padding

func (n Integer32) Padding() int

Padding implements the Type interface.

func (Integer32) Serialize

func (n Integer32) Serialize() []byte

Serialize implements the Type interface.

func (Integer32) String

func (n Integer32) String() string

String implements the Type interface.

func (Integer32) Type

func (n Integer32) Type() TypeID

Type implements the Type interface.

type Integer64

type Integer64 int64

Integer64 data type.

func (Integer64) Len

func (n Integer64) Len() int

Len implements the Type interface.

func (Integer64) Padding

func (n Integer64) Padding() int

Padding implements the Type interface.

func (Integer64) Serialize

func (n Integer64) Serialize() []byte

Serialize implements the Type interface.

func (Integer64) String

func (n Integer64) String() string

String implements the Type interface.

func (Integer64) Type

func (n Integer64) Type() TypeID

Type implements the Type interface.

type OctetString

type OctetString string

OctetString data type.

func (OctetString) Len

func (s OctetString) Len() int

Len implements the Type interface.

func (OctetString) Padding

func (s OctetString) Padding() int

Padding implements the Type interface.

func (OctetString) Serialize

func (s OctetString) Serialize() []byte

Serialize implements the Type interface.

func (OctetString) String

func (s OctetString) String() string

String implements the Type interface.

func (OctetString) Type

func (s OctetString) Type() TypeID

Type implements the Type interface.

type QoSFilterRule

type QoSFilterRule OctetString

QoSFilterRule data type.

func (QoSFilterRule) Len

func (s QoSFilterRule) Len() int

Len implements the Type interface.

func (QoSFilterRule) Padding

func (s QoSFilterRule) Padding() int

Padding implements the Type interface.

func (QoSFilterRule) Serialize

func (s QoSFilterRule) Serialize() []byte

Serialize implements the Type interface.

func (QoSFilterRule) String

func (s QoSFilterRule) String() string

String implements the Type interface.

func (QoSFilterRule) Type

func (s QoSFilterRule) Type() TypeID

Type implements the Type interface.

type Time

type Time time.Time

Time data type.

func (Time) Len

func (t Time) Len() int

Len implements the Type interface.

func (Time) Padding

func (t Time) Padding() int

Padding implements the Type interface.

func (Time) Serialize

func (t Time) Serialize() []byte

Serialize implements the Type interface.

func (Time) String

func (t Time) String() string

String implements the Type interface.

func (Time) Type

func (t Time) Type() TypeID

Type implements the Type interface.

type Type

type Type interface {
	Serialize() []byte
	Len() int
	Padding() int
	Type() TypeID
	String() string
}

Type is an interface to support Diameter AVP data types.

func Decode

func Decode(Type TypeID, b []byte) (Type, error)

Decode decodes a specific AVP data type from byte array to a DataType.

func DecodeAddress

func DecodeAddress(b []byte) (Type, error)

DecodeAddress decodes an Address data type from byte array.

func DecodeDiameterIdentity

func DecodeDiameterIdentity(b []byte) (Type, error)

DecodeDiameterIdentity decodes a DiameterIdentity from byte array.

func DecodeDiameterURI

func DecodeDiameterURI(b []byte) (Type, error)

DecodeDiameterURI decodes a DiameterURI from byte array.

func DecodeEnumerated

func DecodeEnumerated(b []byte) (Type, error)

DecodeEnumerated decodes an Enumerated data type from byte array.

func DecodeFloat32

func DecodeFloat32(b []byte) (Type, error)

DecodeFloat32 decodes a Float32 data type from a byte array.

func DecodeFloat64

func DecodeFloat64(b []byte) (Type, error)

DecodeFloat64 decodes a Float64 data type from byte array.

func DecodeGrouped

func DecodeGrouped(b []byte) (Type, error)

DecodeGrouped decodes a Grouped data type from byte array.

func DecodeIPFilterRule

func DecodeIPFilterRule(b []byte) (Type, error)

DecodeIPFilterRule decodes an IPFilterRule data type from byte array.

func DecodeIPv4

func DecodeIPv4(b []byte) (Type, error)

DecodeIPv4 decodes an IPv4 data type from byte array.

func DecodeInteger32

func DecodeInteger32(b []byte) (Type, error)

DecodeInteger32 decodes an Integer32 data type from byte array.

func DecodeInteger64

func DecodeInteger64(b []byte) (Type, error)

DecodeInteger64 decodes an Integer64 data type from byte array.

func DecodeOctetString

func DecodeOctetString(b []byte) (Type, error)

DecodeOctetString decodes an OctetString from byte array.

func DecodeQoSFilterRule

func DecodeQoSFilterRule(b []byte) (Type, error)

DecodeQoSFilterRule decodes an QoSFilterRule data type from byte array.

func DecodeTime

func DecodeTime(b []byte) (Type, error)

DecodeTime decodes a Time data type from byte array.

func DecodeUTF8String

func DecodeUTF8String(b []byte) (Type, error)

DecodeUTF8String decodes an UTF8String data type from byte array.

func DecodeUnknown

func DecodeUnknown(b []byte) (Type, error)

DecodeUnknown decodes an Unknown from byte array.

func DecodeUnsigned32

func DecodeUnsigned32(b []byte) (Type, error)

DecodeUnsigned32 decodes an Unsigned32 data type from byte array.

func DecodeUnsigned64

func DecodeUnsigned64(b []byte) (Type, error)

DecodeUnsigned64 decodes an Unsigned64 data type from byte array.

type TypeID

type TypeID int

TypeID is the identifier of an AVP data type.

const (
	UnknownType TypeID = iota
	AddressType
	DiameterIdentityType
	DiameterURIType
	EnumeratedType
	Float32Type
	Float64Type
	GroupedType
	IPFilterRuleType
	IPv4Type
	Integer32Type
	Integer64Type
	OctetStringType
	QoSFilterRuleType
	TimeType
	UTF8StringType
	Unsigned32Type
	Unsigned64Type
)

List of available AVP data types.

type UTF8String

type UTF8String OctetString

UTF8String data type.

func (UTF8String) Len

func (s UTF8String) Len() int

Len implements the Type interface.

func (UTF8String) Padding

func (s UTF8String) Padding() int

Padding implements the Type interface.

func (UTF8String) Serialize

func (s UTF8String) Serialize() []byte

Serialize implements the Type interface.

func (UTF8String) String

func (s UTF8String) String() string

String implements the Type interface.

func (UTF8String) Type

func (s UTF8String) Type() TypeID

Type implements the Type interface.

type Unknown

type Unknown []byte

Unknown data type.

func (Unknown) Len

func (u Unknown) Len() int

Len implements the Type interface.

func (Unknown) Padding

func (u Unknown) Padding() int

Padding implements the Type interface.

func (Unknown) Serialize

func (u Unknown) Serialize() []byte

Serialize implements the Type interface.

func (Unknown) String

func (u Unknown) String() string

String implements the Type interface.

func (Unknown) Type

func (u Unknown) Type() TypeID

Type implements the Type interface.

type Unsigned32

type Unsigned32 uint32

Unsigned32 data type.

func (Unsigned32) Len

func (n Unsigned32) Len() int

Len implements the Type interface.

func (Unsigned32) Padding

func (n Unsigned32) Padding() int

Padding implements the Type interface.

func (Unsigned32) Serialize

func (n Unsigned32) Serialize() []byte

Serialize implements the Type interface.

func (Unsigned32) String

func (n Unsigned32) String() string

String implements the Type interface.

func (Unsigned32) Type

func (n Unsigned32) Type() TypeID

Type implements the Type interface.

type Unsigned64

type Unsigned64 uint64

Unsigned64 data type.

func (Unsigned64) Len

func (n Unsigned64) Len() int

Len implements the Type interface.

func (Unsigned64) Padding

func (n Unsigned64) Padding() int

Padding implements the Type interface.

func (Unsigned64) Serialize

func (n Unsigned64) Serialize() []byte

Serialize implements the Type interface.

func (Unsigned64) String

func (n Unsigned64) String() string

String implements the Type interface.

func (Unsigned64) Type

func (n Unsigned64) Type() TypeID

Type implements the Type interface.

Jump to

Keyboard shortcuts

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