smparser

package
v0.0.21 Latest Latest
Warning

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

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

Documentation

Overview

Package smparser provides message parsers for the state machine.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingResultCode is returned by Parse when
	// the message does nt contain a Result-Code AVP.
	ErrMissingResultCode = errors.New("missing Result-Code")

	// ErrMissingOriginHost is returned by Parse when
	// the message does not contain an Origin-Host AVP.
	ErrMissingOriginHost = errors.New("missing Origin-Host")

	// ErrMissingOriginRealm is returned by Parse when
	// the message does not contain an Origin-Realm AVP.
	ErrMissingOriginRealm = errors.New("missing Origin-Realm")

	// ErrMissingApplication is returned by Parse when
	// the CER does not contain any Acct-Application-Id or
	// Auth-Application-Id, or their embedded versions in
	// the Vendor-Specific-Application-Id AVP.
	ErrMissingApplication = errors.New("missing application")

	// ErrNoCommonSecurity is returned by Parse when
	// the CER contains the Inband-Security-Id.
	// We currently don't support that.
	ErrNoCommonSecurity = errors.New("no common security")

	// ErrNoCommonApplication is returned by Parse when the
	// application IDs in the CER don't match the applications
	// defined in our dictionary.
	ErrNoCommonApplication = errors.New("no common application")
)

Functions

This section is empty.

Types

type Application

type Application struct {
	AcctApplicationID           []*diam.AVP
	AuthApplicationID           []*diam.AVP
	VendorSpecificApplicationID []*diam.AVP
	// contains filtered or unexported fields
}

Application validates accounting, auth, and vendor specific application IDs.

func (*Application) ID

func (app *Application) ID() []uint32

ID returns a list of supported application IDs. Must be called after Parse, otherwise it returns an empty array.

func (*Application) Parse

func (app *Application) Parse(d *dict.Parser, localRole Role) (failedAVP *diam.AVP, err error)

Parse ensures at least one common acct or auth applications in the CE exist in this server's dictionary.

type CEA

type CEA struct {
	ResultCode                  uint32                    `avp:"Result-Code"`
	OriginHost                  datatype.DiameterIdentity `avp:"Origin-Host"`
	OriginRealm                 datatype.DiameterIdentity `avp:"Origin-Realm"`
	OriginStateID               uint32                    `avp:"Origin-State-Id"`
	AcctApplicationID           []*diam.AVP               `avp:"Acct-Application-Id"`
	AuthApplicationID           []*diam.AVP               `avp:"Auth-Application-Id"`
	VendorSpecificApplicationID []*diam.AVP               `avp:"Vendor-Specific-Application-Id"`
	FailedAVP                   []*diam.AVP               `avp:"Failed-AVP"`
	ErrorMessage                string                    `avp:"Error-Message"`
	// contains filtered or unexported fields
}

CEA is a Capabilities-Exchange-Answer message. See RFC 6733 section 5.3.2 for details.

func (*CEA) Applications

func (cea *CEA) Applications() []uint32

Applications return a list of supported Application IDs.

func (*CEA) Parse

func (cea *CEA) Parse(m *diam.Message, localRole Role) (err error)

Parse parses and validates the given message.

type CER

type CER struct {
	OriginHost                  datatype.DiameterIdentity `avp:"Origin-Host"`
	OriginRealm                 datatype.DiameterIdentity `avp:"Origin-Realm"`
	OriginStateID               *diam.AVP                 `avp:"Origin-State-Id"`
	InbandSecurityID            *diam.AVP                 `avp:"Inband-Security-Id"`
	AcctApplicationID           []*diam.AVP               `avp:"Acct-Application-Id"`
	AuthApplicationID           []*diam.AVP               `avp:"Auth-Application-Id"`
	VendorSpecificApplicationID []*diam.AVP               `avp:"Vendor-Specific-Application-Id"`
	// contains filtered or unexported fields
}

CER is a Capabilities-Exchange-Request message. See RFC 6733 section 5.3.1 for details.

func (*CER) Applications

func (cer *CER) Applications() []uint32

Applications return a list of supported Application IDs.

func (*CER) Parse

func (cer *CER) Parse(m *diam.Message, localRole Role) (failedAVP *diam.AVP, err error)

Parse parses and validates the given message, and returns nil when all AVPs are ok, and all accounting or authentication applications in the CER match the applications in our dictionary. If one or more mandatory AVPs are missing, it returns a nil failedAVP and a proper error. If all mandatory AVPs are present but no common application is found, then it returns the failedAVP (with the application that we don't support in our dictionary) and an error. Another cause for error is the presence of Inband Security, we don't support that.

type DWA

type DWA struct {
	ResultCode    uint32 `avp:"Result-Code"`
	OriginStateID uint32 `avp:"Origin-State-Id"`
}

DWA is a Device-Watchdog-Answer message. See RFC 6733 section 5.5.2 for details.

func (*DWA) Parse

func (dwa *DWA) Parse(m *diam.Message) error

Parse parses the given message.

type DWR

type DWR struct {
	OriginHost    datatype.DiameterIdentity `avp:"Origin-Host"`
	OriginRealm   datatype.DiameterIdentity `avp:"Origin-Realm"`
	OriginStateID *diam.AVP                 `avp:"Origin-State-Id"`
}

DWR is a Device-Watchdog-Request message. See RFC 6733 section 5.5.1 for details.

func (*DWR) Parse

func (dwr *DWR) Parse(m *diam.Message) error

Parse parses and validates the given message, and returns nil when all AVPs are ok.

type ErrFailedResultCode

type ErrFailedResultCode struct {
	*CEA
}

ErrFailedResultCode is returned by Dial or DialTLS when the handshake answer (CEA) contains a Result-Code AVP that is not success (2001).

func (ErrFailedResultCode) Error

func (e ErrFailedResultCode) Error() string

Error implements the error interface.

type ErrUnexpectedAVP

type ErrUnexpectedAVP struct {
	AVP *diam.AVP
}

ErrUnexpectedAVP is returned by Parse when the code of the AVP passed as AcctApplicationID, AuthApplicationID or VendorSpecificApplicationID and its embedded AVPs do not match their names.

func (*ErrUnexpectedAVP) Error

func (e *ErrUnexpectedAVP) Error() string

Error implements the error interface.

type Role

type Role uint8

Role stores information whether SM is initialized as a Client or a Server

const (
	Server Role = iota + 1
	Client
)

ServerRole and ClientRole enums are passed to smparser for proper CER/CEA verification

Jump to

Keyboard shortcuts

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