params

package
v0.0.0-...-1c86a79 Latest Latest
Warning

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

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

Documentation

Overview

Package params provides the protocol definition and encoding/decoding feature of M3UA Common Paratemeters and M3UA-specific parameters.

All the parameters are in the same type: *param.Param, which helps handle any kind of parameters in the same way.

Specification: https://tools.ietf.org/html/rfc4666#section-3.2

Index

Constants

View Source
const (
	SuccessfullyDeregistered uint32 = iota
	DeregStatusUnknown
	DeregInvalidRoutingContext
	DeregPermissionDenied
	DeregNotRegistered
	DeregASPActiveForRoutingContext
)

Deregistration Status definitions.

View Source
const (
	ErrInvalidVersion uint32

	ErrUnsupportedMessageClass
	ErrUnsupportedMessageType
	ErrUnsupportedTrafficModeType
	ErrUnexpectedMessage
	ErrProtocolError

	ErrInvalidStreamIdentifier

	ErrRefusedManagementBlocking
	ErrAspIdentifierRequired
	ErrInvalidAspIdentifier

	ErrInvalidParameterValue
	ErrParameterFieldError
	ErrUnexpectedParameter
	ErrDestinationStatusUnknown
	ErrInvalidNetworkAppearance
	ErrMissingParameter

	ErrInvalidRoutingContext
	ErrNoConfiguredAsForAsp
)

Error Code definitions.

View Source
const (
	InfoString uint16

	RoutingContext
	DiagnosticInformation

	HeartbeatData

	TrafficModeType
	ErrorCode
	Status

	AspIdentifier
	AffectedPointCode
	CorrelationID
)

Common Parameter Tag definitions.

View Source
const (
	NetworkAppearance uint16 = uint16(0x200 | iota)

	UserCause
	CongestionIndications
	ConcernedDestination
	RoutingKey           // specific: later
	RegistrationResult   // specific: later
	DeregistrationResult // specific: later
	LocalRoutingKeyIdentifier
	DestinationPointCode
	ServiceIndicators

	OriginatingPointCodeList

	ProtocolData

	RegistrationStatus
	DeregistrationStatus
)

M3UA-specific Parameter Tag definitions.

View Source
const (
	ServiceIndUnused uint8 = iota

	ServiceIndSCCP
	ServiceIndTUP
	ServiceIndISUP

	ServiceIndBroadbandISUP
	ServiceIndSatelliteISUP

	ServiceIndAALType2Signalling
	ServiceIndBICC
	ServiceIndGatewayControlProtocol
)

ServiceIndicator definitions.

View Source
const (
	SuccessfullyRegistered uint32 = iota
	RegistrationStatusUnknown
	InvalidDPC
	InvalidNetworkAppearance
	InvalidRoutingKey
	PermissionDenied
	CannotSupportUniqueRouting
	RoutingKeynotCurrentlyProvisioned
	InsufficientResources
	UnsupportedRKparameterField
	UnsupportedTrafficHandlingMode
	RoutingKeyChangeRefused
	RoutingKeyAlreadyRegistered
)

Registration Status definitions.

View Source
const (
	AsStateChange uint16 = iota + 1
	Other
)

Status Type definitions.

View Source
const (
	AsStateInactive uint32
	AsStateActive
	AsStatePending
)

Status Information definitions (StatusType==AsStateChange). Note that this contains the type.

View Source
const (
	InsufficientAspResources uint32 = uint32((0x02 << 16) | iota + 1)
	AlternateAspActive
	AspFailure
)

Status Information definitions (StatusType==Other). Note that this contains the type.

View Source
const (
	TrafficModeOverride uint32
	TrafficModeLoadshare
	TrafficModeBroadcast
)

TrafficModeType definitions.

View Source
const (
	UserIdentityUnknown uint16 = iota
	Unequipped
	Inaccessible
)

User Identity definitions.

View Source
const (
	SCCP uint16
	TUP
	ISUP

	BroadbandISUP
	SatelliteISUP

	AAL2Signalling
	BICC
	GatewayControlProtocol
)

Unavailability Cause definitions.

Variables

View Source
var (
	ErrInvalidType             = errors.New("got invalid type in parameter")
	ErrInvalidLength           = errors.New("parameter has invalid length value")
	ErrTooShortToMarshalBinary = errors.New("insufficient buffer to serialize parameter to")
	ErrTooShortToParse         = errors.New("too short to decode as parameter")
)

Error definitions.

Functions

func MarshalMultiParams

func MarshalMultiParams(params []*Param) ([]byte, error)

MarshalMultiParams creates the byte sequence from multiple Param instances.

func SerializeMultiParams

func SerializeMultiParams(params []*Param) ([]byte, error)

SerializeMultiParams creates the byte sequence from multiple Param instances.

DEPRECATED: use MarshalMultiParams instead.

Types

type DeregResultPayload

type DeregResultPayload struct {
	RoutingContext, DeregistrationStatus *Param
}

DeregResultPayload is the payload of DeregistrationResult.

func DecodeDeregResultPayload

func DecodeDeregResultPayload(b []byte) (*DeregResultPayload, error)

DecodeDeregResultPayload decodes given byte sequence as a DeregResultPayload.

DEPRECATED: use ParseDeregResultPayload instead.

func NewDeregResultPayload

func NewDeregResultPayload(rtCtx, deregStatus *Param) *DeregResultPayload

NewDeregResultPayload creates a new DeregResultPayload.

func ParseDeregResultPayload

func ParseDeregResultPayload(b []byte) (*DeregResultPayload, error)

ParseDeregResultPayload decodes given byte sequence as a DeregResultPayload.

func (*DeregResultPayload) DecodeFromBytes

func (d *DeregResultPayload) DecodeFromBytes(b []byte) error

DecodeFromBytes sets the values retrieved from byte sequence in a Param.

DEPRECATED: use UnmarshalBinary instead.

func (*DeregResultPayload) UnmarshalBinary

func (d *DeregResultPayload) UnmarshalBinary(b []byte) error

UnmarshalBinary sets the values retrieved from byte sequence in a Param.

type Param

type Param struct {
	Tag    uint16
	Length uint16
	Data   []byte
}

Param is a M3UA Param.

func Decode

func Decode(b []byte) (*Param, error)

Decode decodes given byte sequence as a Param.

DEPRECATED: use Parse instead.

func DecodeMultiParams

func DecodeMultiParams(b []byte) ([]*Param, error)

DecodeMultiParams decodes multiple Params at a time.

This is easy and useful but slower than decoding one by one. When you don't know the number of Params, this is the only way to decode them. See benchmarks in diameter_test.go for the detail.

DEPRECATED: use ParseMultiParams instead.

func NewAffectedPointCode

func NewAffectedPointCode(apcs ...uint32) *Param

NewAffectedPointCode creates the AffectedPointCode Parameter. Multiple number of AffectedPointCode will be accepted, but the mask for each point code should be included inside arguments. TODO: Handle masks and point codes separately. Note that this returns *Param, as no specific structure in this parameter.

func NewAspIdentifier

func NewAspIdentifier(aspID uint32) *Param

NewAspIdentifier creates the AspIdentifier Parameter. Note that this returns *Param, as no specific structure in this parameter.

func NewConcernedDestination

func NewConcernedDestination(cd uint32) *Param

NewConcernedDestination creates the ConcernedDestination Parameter. Note that this returns *Param, as no specific structure in this parameter.

func NewCongestionIndications

func NewCongestionIndications(congLv uint8) *Param

NewCongestionIndications creates the CongestionIndications Parameter. Note that this returns *Param, as no specific structure in this parameter.

func NewCorrelationID

func NewCorrelationID(corrID uint32) *Param

NewCorrelationID creates the CorrelationID Parameter. Note that this returns *Param, as no specific structure in this parameter.

func NewDeregistrationResult

func NewDeregistrationResult(dr *DeregResultPayload) *Param

NewDeregistrationResult creates a new DeregistrationResult. Note that this returns *Param, as no specific structure in this parameter.

func NewDeregistrationStatus

func NewDeregistrationStatus(deregStatus uint32) *Param

NewDeregistrationStatus creates the DeregistrationStatus Parameter. Note that this returns *Param, as no specific structure in this parameter.

func NewDestinationPointCode

func NewDestinationPointCode(dpc uint32) *Param

NewDestinationPointCode creates the DestinationPointCode Parameter. Note that this returns *Param, as no specific structure in this parameter.

func NewDiagnosticInformation

func NewDiagnosticInformation(di []byte) *Param

NewDiagnosticInformation creates the DiagnosticInformation Parameter. Note that this returns *Param, as no specific structure in this parameter.

func NewErrorCode

func NewErrorCode(ec uint32) *Param

NewErrorCode creates the ErrorCode Parameter. Note that this returns *Param, as no specific structure in this parameter.

func NewHeartbeatData

func NewHeartbeatData(data []byte) *Param

NewHeartbeatData creates the HeartbeatData Parameter. Note that this returns *Param, as no specific structure in this parameter.

func NewInfoString

func NewInfoString(infoStr string) *Param

NewInfoString creates the InfoString Parameter. Note that this returns *Param, as no specific structure in this parameter.

func NewLocalRoutingKeyIdentifier

func NewLocalRoutingKeyIdentifier(rkID uint32) *Param

NewLocalRoutingKeyIdentifier creates the LocalRoutingKeyIdentifier Parameter. Note that this returns *Param, as no specific structure in this parameter.

func NewNetworkAppearance

func NewNetworkAppearance(nwApr uint32) *Param

NewNetworkAppearance creates the NetworkAppearance Parameter. Note that this returns *Param, as no specific structure in this parameter.

func NewOriginatingPointCodeList

func NewOriginatingPointCodeList(opcs ...uint32) *Param

NewOriginatingPointCodeList creates the OriginatingPointCodeList Parameter. Multiple number of OriginatingPointCodeList will be accepted, but the mask for each point code should be included inside arguments. TODO: Handle masks and point codes separately. Note that this returns *Param, as no specific structure in this parameter.

func NewParam

func NewParam(tag int, data []byte) *Param

NewParam creates a new Param. This is for generic use. NewXXX(ParamName) functions are available to create the parameters defined in RFC4666.

func NewProtocolData

func NewProtocolData(opc, dpc uint32, si, ni, mp, sls uint8, data []byte) *Param

NewProtocolData creates a new ProtocolData. Note that this returns *Param, as no specific structure in this parameter. Also, Payload will be serialized and not accessible until calling ProtocolData() func.

func NewRegistrationResult

func NewRegistrationResult(rr *RegistrationResultPayload) *Param

NewRegistrationResult creates a new RegistrationResult. Note that this returns *Param, as no specific structure in this parameter.

func NewRegistrationStatus

func NewRegistrationStatus(regStatus uint32) *Param

NewRegistrationStatus creates the RegistrationStatus Parameter. Note that this returns *Param, as no specific structure in this parameter.

func NewRoutingContext

func NewRoutingContext(rtCxts ...uint32) *Param

NewRoutingContext creates the RoutingContext Parameter. Multiple number of RoutingContext will be accepted. Note that this returns *Param, as no specific structure in this parameter.

func NewRoutingKey

func NewRoutingKey(rk *RoutingKeyPayload) *Param

NewRoutingKey creates a new RoutingKey. Note that this returns *Param, as no specific structure in this parameter.

func NewServiceIndicators

func NewServiceIndicators(si ...uint8) *Param

NewServiceIndicators creates the ServiceIndicators Parameter. Note that this returns *Param, as no specific structure in this parameter.

func NewStatus

func NewStatus(typeInfo uint32) *Param

NewStatus creates the Status Parameter. Note that this returns *Param, as no specific structure in this parameter. The argument typeInfo can be chosen from Status Information definitions above.

func NewTrafficModeType

func NewTrafficModeType(tmType uint32) *Param

NewTrafficModeType creates the TrafficModeType Parameter. Note that this returns *Param, as no specific structure in this parameter.

func NewUserCause

func NewUserCause(user, cause uint16) *Param

NewUserCause creates the User/Cause Parameter. Note that this returns *Param, as no specific structure in this parameter.

func Parse

func Parse(b []byte) (*Param, error)

Parse decodes given byte sequence as a M3UA Param.

func ParseMultiParams

func ParseMultiParams(b []byte) ([]*Param, error)

ParseMultiParams decodes multiple Params at a time.

This is easy and useful but slower than decoding one by one. When you don't know the number of Params, this is the only way to decode them. See benchmarks in diameter_test.go for the detail.

func (*Param) AffectedPointCode

func (p *Param) AffectedPointCode() uint32

AffectedPointCode returns single AffectedPointCode from Param.

func (*Param) AffectedPointCodes

func (p *Param) AffectedPointCodes() []uint32

AffectedPointCodes returns multiple AffectedPointCode from Param.

func (*Param) AspIdentifier

func (p *Param) AspIdentifier() uint32

AspIdentifier returns multiple AspIdentifier from Param.

func (*Param) ConcernedDestination

func (p *Param) ConcernedDestination() uint32

ConcernedDestination returns multiple ConcernedDestination from Param.

func (*Param) CongestionLevel

func (p *Param) CongestionLevel() uint32

CongestionLevel returns multiple CongestionLevel from Param.

func (*Param) CorrelationID

func (p *Param) CorrelationID() uint32

CorrelationID returns multiple CorrelationID from Param.

func (*Param) DecodeFromBytes

func (p *Param) DecodeFromBytes(b []byte) error

DecodeFromBytes sets the values retrieved from byte sequence in a M3UA common header.

DEPRECATED: use UnmarshalBinary instead.

func (*Param) DeregistrationResult

func (p *Param) DeregistrationResult() (*DeregResultPayload, error)

DeregistrationResult returns DeregResultPayload.

func (*Param) DeregistrationStatus

func (p *Param) DeregistrationStatus() uint32

DeregistrationStatus returns multiple DeregistrationStatus from Param.

func (*Param) DestinationPointCode

func (p *Param) DestinationPointCode() uint32

DestinationPointCode returns multiple DestinationPointCode from Param.

func (*Param) DiagnosticInformation

func (p *Param) DiagnosticInformation() []byte

DiagnosticInformation returns multiple DiagnosticInformation from Param.

func (*Param) ErrorCode

func (p *Param) ErrorCode() uint32

ErrorCode returns multiple ErrorCode from Param.

func (*Param) HeartbeatData

func (p *Param) HeartbeatData() []byte

HeartbeatData returns multiple HeartbeatData from Param.

func (*Param) InfoString

func (p *Param) InfoString() string

InfoString returns multiple InfoString from Param.

func (*Param) Len

func (p *Param) Len() int

Len returns the serial length of Param.

DEPRECATED: use MarshalLen instead.

func (*Param) LocalRoutingKeyIdentifier

func (p *Param) LocalRoutingKeyIdentifier() uint32

LocalRoutingKeyIdentifier returns multiple LocalRoutingKeyIdentifier from Param.

func (*Param) MarshalBinary

func (p *Param) MarshalBinary() ([]byte, error)

MarshalBinary creates the byte sequence generated from a M3UA Param instance.

func (*Param) MarshalLen

func (p *Param) MarshalLen() int

MarshalLen returns serial length in integer.

func (*Param) MarshalTo

func (p *Param) MarshalTo(b []byte) error

MarshalTo puts the byte sequence in the byte array given as b.

func (*Param) NetworkAppearance

func (p *Param) NetworkAppearance() uint32

NetworkAppearance returns multiple NetworkAppearance from Param.

func (*Param) OriginatingPointCodeList

func (p *Param) OriginatingPointCodeList() []uint32

OriginatingPointCodeList returns multiple OriginatingPointCode from Param.

func (*Param) Padding

func (p *Param) Padding() int

Padding creates the padded length of a M3UA Param.

func (*Param) ProtocolData

func (p *Param) ProtocolData() (*ProtocolDataPayload, error)

ProtocolData returns ProtocolDataPayload

func (*Param) RegistrationResult

func (p *Param) RegistrationResult() (*RegistrationResultPayload, error)

RegistrationResult returns RegistrationResultPayload.

func (*Param) RegistrationStatus

func (p *Param) RegistrationStatus() uint32

RegistrationStatus returns multiple RegistrationStatus from Param.

func (*Param) RoutingContext

func (p *Param) RoutingContext() uint32

RoutingContext returns single RoutingContext from Param.

func (*Param) RoutingContexts

func (p *Param) RoutingContexts() []uint32

RoutingContexts returns multiple RoutingContexts from Param.

func (*Param) RoutingKey

func (p *Param) RoutingKey() (*RoutingKeyPayload, error)

RoutingKey returns RoutingKeyPayload.

func (*Param) Serialize

func (p *Param) Serialize() ([]byte, error)

Serialize returns the byte sequence generated from a Param.

DEPRECATED: use MarshalBinary instead.

func (*Param) SerializeTo

func (p *Param) SerializeTo(b []byte) error

SerializeTo puts the byte sequence in the byte array given as b.

DEPRECATED: use MarshalTo instead.

func (*Param) ServiceIndicators

func (p *Param) ServiceIndicators() []uint8

ServiceIndicators returns multiple ServiceIndicators from Param.

func (*Param) SetLength

func (p *Param) SetLength()

SetLength sets the length in Length field.

func (*Param) Status

func (p *Param) Status() uint32

Status returns multiple Status from Param.

func (*Param) StatusInfo

func (p *Param) StatusInfo() uint16

StatusInfo returns multiple StatusInfo from Param.

func (*Param) StatusType

func (p *Param) StatusType() uint16

StatusType returns multiple StatusType from Param.

func (*Param) String

func (p *Param) String() string

String creates the M3UA header values in human readable format.

func (*Param) TrafficModeType

func (p *Param) TrafficModeType() uint32

TrafficModeType returns multiple TrafficModeType from Param.

func (*Param) UnavailabilityCause

func (p *Param) UnavailabilityCause() uint16

UnavailabilityCause returns multiple UnavailabilityCause from Param.

func (*Param) UnmarshalBinary

func (p *Param) UnmarshalBinary(b []byte) error

UnmarshalBinary sets the values retrieved from byte sequence in a M3UA Param.

func (*Param) UserCause

func (p *Param) UserCause() uint32

UserCause returns multiple UserCause from Param.

func (*Param) UserIdentity

func (p *Param) UserIdentity() uint16

UserIdentity returns multiple UserIdentity from Param.

type ProtocolDataPayload

type ProtocolDataPayload struct {
	OriginatingPointCode   uint32
	DestinationPointCode   uint32
	ServiceIndicator       uint8
	NetworkIndicator       uint8
	MessagePriority        uint8
	SignalingLinkSelection uint8
	Data                   []byte
}

ProtocolDataPayload is a M3UA ProtocolDataPayload.

func DecodeProtocolDataPayload

func DecodeProtocolDataPayload(b []byte) (*ProtocolDataPayload, error)

DecodeProtocolDataPayload decodes given byte sequence as a ProtocolDataPayload.

DEPRECATED: use ParseProtocolDataPayload instead.

func NewProtocolDataPayload

func NewProtocolDataPayload(opc, dpc uint32, si, ni, mp, sls uint8, data []byte) *ProtocolDataPayload

NewProtocolDataPayload creates a new ProtocolDataPayload payload. Note that this does not contain the Tag and Length inside. You need to create new Param using serialized ProtocolDataPayload.

func ParseProtocolDataPayload

func ParseProtocolDataPayload(b []byte) (*ProtocolDataPayload, error)

ParseProtocolDataPayload decodes given byte sequence as a M3UA ProtocolDataPayload.

func (*ProtocolDataPayload) DecodeFromBytes

func (p *ProtocolDataPayload) DecodeFromBytes(b []byte) error

DecodeFromBytes sets the values retrieved from byte sequence in a M3UA common header.

DEPRECATED: use UnmarshalBinary instead.

func (*ProtocolDataPayload) Len

func (p *ProtocolDataPayload) Len() int

Len returns the serial length of ProtocolDataPayload.

DEPRECATED: use MarshalLen instead.

func (*ProtocolDataPayload) MarshalBinary

func (p *ProtocolDataPayload) MarshalBinary() ([]byte, error)

MarshalBinary returns the byte sequence generated from a M3UA ProtocolDataPayload instance.

func (*ProtocolDataPayload) MarshalLen

func (p *ProtocolDataPayload) MarshalLen() int

MarshalLen returns serial length in integer.

func (*ProtocolDataPayload) MarshalTo

func (p *ProtocolDataPayload) MarshalTo(b []byte) error

MarshalTo puts the byte sequence in the byte array given as b.

func (*ProtocolDataPayload) Serialize

func (p *ProtocolDataPayload) Serialize() ([]byte, error)

Serialize returns the byte sequence generated from a ProtocolDataPayload.

DEPRECATED: use MarshalBinary instead.

func (*ProtocolDataPayload) SerializeTo

func (p *ProtocolDataPayload) SerializeTo(b []byte) error

SerializeTo puts the byte sequence in the byte array given as b.

DEPRECATED: use MarshalTo instead.

func (*ProtocolDataPayload) String

func (p *ProtocolDataPayload) String() string

String returns the M3UA header values in human readable format.

func (*ProtocolDataPayload) UnmarshalBinary

func (p *ProtocolDataPayload) UnmarshalBinary(b []byte) error

UnmarshalBinary sets the values retrieved from byte sequence in a M3UA ProtocolDataPayload.

type RegistrationResultPayload

type RegistrationResultPayload struct {
	LocalRoutingKeyIdentifier, RegistrationStatus, RoutingContext *Param
}

RegistrationResultPayload is the payload of RegistrationResult.

func DecodeRegistrationResultPayload

func DecodeRegistrationResultPayload(b []byte) (*RegistrationResultPayload, error)

DecodeRegistrationResultPayload decodes given byte sequence as a RegistrationResultPayload.

DEPRECATED: use ParseRegistrationResultPayload instead.

func NewRegistrationResultPayload

func NewRegistrationResultPayload(rkID, deregStatus, rtCtx *Param) *RegistrationResultPayload

NewRegistrationResultPayload creates a new RegistrationResultPayload.

func ParseRegistrationResultPayload

func ParseRegistrationResultPayload(b []byte) (*RegistrationResultPayload, error)

ParseRegistrationResultPayload decodes given byte sequence as a RegistrationResultPayload.

func (*RegistrationResultPayload) DecodeFromBytes

func (d *RegistrationResultPayload) DecodeFromBytes(b []byte) error

DecodeFromBytes sets the values retrieved from byte sequence in a Param.

DEPRECATED: use UnmarshalBinary instead.

func (*RegistrationResultPayload) UnmarshalBinary

func (d *RegistrationResultPayload) UnmarshalBinary(b []byte) error

UnmarshalBinary sets the values retrieved from byte sequence in a Param.

type RoutingKeyPayload

type RoutingKeyPayload struct {
	LocalRoutingKeyIdentifier, RoutingContext, TrafficModeType, DestinationPointCode, NetworkAppearance, ServiceIndicators, OriginatingPointCodeList *Param
}

RoutingKeyPayload is the payload of RoutingKey.

func DecodeRoutingKeyPayload

func DecodeRoutingKeyPayload(b []byte) (*RoutingKeyPayload, error)

DecodeRoutingKeyPayload decodes given byte sequence as a RoutingKeyPayload.

DEPRECATED: use ParseRoutingKeyPayload instead.

func NewRoutingKeyPayload

func NewRoutingKeyPayload(rkID, rtCtx, tmType, dpc, nwApr, si, opcs *Param) *RoutingKeyPayload

NewRoutingKeyPayload creates a new RoutingKeyPayload.

func ParseRoutingKeyPayload

func ParseRoutingKeyPayload(b []byte) (*RoutingKeyPayload, error)

ParseRoutingKeyPayload decodes given byte sequence as a RoutingKeyPayload.

func (*RoutingKeyPayload) DecodeFromBytes

func (r *RoutingKeyPayload) DecodeFromBytes(b []byte) error

DecodeFromBytes sets the values retrieved from byte sequence in a Param.

DEPRECATED: use UnmarshalBinary instead.

func (*RoutingKeyPayload) UnmarshalBinary

func (r *RoutingKeyPayload) UnmarshalBinary(b []byte) error

UnmarshalBinary sets the values retrieved from byte sequence in a Param.

Jump to

Keyboard shortcuts

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