dict

package
v3.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2015 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package dict provides a Diameter dictionary parser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AVP

type AVP struct {
	Name       string `xml:"name,attr"`
	Code       uint32 `xml:"code,attr"`
	Must       string `xml:"must,attr"`
	May        string `xml:"may,attr"`
	MustNot    string `xml:"must-not,attr"`
	MayEncrypt string `xml:"may-encrypt,attr"`
	Data       Data   `xml:"data"`
	App        *App   `xml:"none"` // Link back to diameter application
}

AVP represents a dictionary AVP that is loaded from XML.

type App

type App struct {
	ID      uint32     `xml:"id,attr"`   // Application Id
	Type    string     `xml:"type,attr"` // Application type
	Name    string     `xml:"name,attr"` // Application name
	Vendor  []*Vendor  `xml:"vendor"`    // Support for multiple vendors
	Command []*Command `xml:"command"`   // Diameter commands
	AVP     []*AVP     `xml:"avp"`       // Each application support multiple AVPs
}

App defines a diameter application in XML and its multiple AVPs.

type Command

type Command struct {
	Code    uint32      `xml:"code,attr"`
	Name    string      `xml:"name,attr"`
	Short   string      `xml:"short,attr"`
	Request CommandRule `xml:"request"`
	Answer  CommandRule `xml:"answer"`
}

Command defines a diameter command (CE, CC, etc)

type CommandRule

type CommandRule struct {
	Rule []*Rule `xml:"rule"`
}

CommandRule contains rules for a given command.

type Data

type Data struct {
	Type     datatype.TypeID `xml:"-"`
	TypeName string          `xml:"type,attr"`
	Enum     []*Enum         `xml:"item"` // In case of Enumerated AVP data
	Rule     []*Rule         `xml:"rule"` // In case of Grouped AVPs
}

Data of an AVP can be EnumItem or a Parser of multiple AVPs.

type Enum

type Enum struct {
	Code uint8  `xml:"code,attr"`
	Name string `xml:"name,attr"`
}

Enum contains the code and name of Enumerated items.

type File

type File struct {
	XMLName xml.Name `xml:"diameter"`
	App     []*App   `xml:"application"` // Support for multiple applications
}

File is the dictionary root element of a XML file. See diam_base.xml.

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser is the root element for dictionaries and supports multiple XML dictionary files loaded together. Diameter applications use dictionaries to parse messages received from peers as well as to encode crafted messages before sending them over the wire.

Parser can load multiple XML dictionary files, which in turn support multiple applications that are composed by multiple AVPs.

The Parser element has an index to make pre-loaded AVPs searcheable per App.

var Default *Parser

Default is a Parser object with pre-loaded Base Protocol and Credit Control dictionaries.

func NewParser

func NewParser(filename ...string) (*Parser, error)

NewParser allocates a new Parser optionally loading dictionary XML files.

func (*Parser) Apps

func (p *Parser) Apps() []*App

Apps return a list of all applications loaded in the Parser instance. Apps must never be called concurrently with LoadFile or Load.

func (*Parser) Enum

func (p *Parser) Enum(appid, code uint32, n uint8) (*Enum, error)

Enum is a helper function that returns a pre-loaded Enum item for the given AVP appid, code and n. (n is the enum code in the dictionary)

Enum must never be called concurrently with LoadFile or Load.

func (*Parser) FindAVP

func (p *Parser) FindAVP(appid uint32, code interface{}) (*AVP, error)

FindAVP is a helper function that returns a pre-loaded AVP from the Parser. If the AVP code is not found for the given appid it tries with appid=0 before returning an error. Code can be either the AVP code (int, uint32) or name (string).

FindAVP must never be called concurrently with LoadFile or Load.

func (*Parser) FindCommand

func (p *Parser) FindCommand(appid, code uint32) (*Command, error)

FindCommand returns a pre-loaded Command from the Parser.

FindCommand must never be called concurrently with LoadFile or Load.

func (*Parser) Load

func (p *Parser) Load(r io.Reader) error

Load loads a dictionary from byte array. May be used multiple times.

func (*Parser) LoadFile

func (p *Parser) LoadFile(filename string) error

LoadFile loads a dictionary XML file. May be used multiple times.

func (*Parser) Rule

func (p *Parser) Rule(appid, code uint32, n string) (*Rule, error)

Rule is a helper function that returns a pre-loaded Rule item for the given AVP code and name.

Rule must never be called concurrently with LoadFile or Load.

func (*Parser) ScanAVP

func (p *Parser) ScanAVP(code interface{}) (*AVP, error)

ScanAVP is a helper function that returns a pre-loaded AVP from the Dict. It's similar to FindAPI except that it scans the list of available AVPs instead of looking into one specific appid.

ScanAVP is 20x or more slower than FindAVP. Use with care. Code can be either the AVP code (uint32) or name (string).

ScanAVP must never be called concurrently with LoadFile or Load.

func (*Parser) String

func (p *Parser) String() string

String returns the Parser represented in a human readable form.

type Rule

type Rule struct {
	AVP      string `xml:"avp,attr"` // AVP Name
	Required bool   `xml:"required,attr"`
	Min      int    `xml:"min,attr"`
	Max      int    `xml:"max,attr"`
}

Rule defines the usage rules of an AVP.

type Vendor

type Vendor struct {
	ID   uint32 `xml:"id,attr"`
	Name string `xml:"name,attr"`
}

Vendor defines diameter vendors in XML, that can be used to translate the VendorId AVP of incoming messages.

Jump to

Keyboard shortcuts

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