Documentation ¶
Overview ¶
Package dict provides a Diameter dictionary parser.
Index ¶
- type AVP
- type App
- type Command
- type CommandRule
- type Data
- type Enum
- type File
- type Parser
- func (p *Parser) Apps() []*App
- func (p *Parser) Enum(appid, code uint32, n uint8) (*Enum, error)
- func (p *Parser) FindAVP(appid uint32, code interface{}) (*AVP, error)
- func (p *Parser) FindCommand(appid, code uint32) (*Command, error)
- func (p *Parser) Load(r io.Reader) error
- func (p *Parser) LoadFile(filename string) error
- func (p *Parser) Rule(appid, code uint32, n string) (*Rule, error)
- func (p *Parser) ScanAVP(code interface{}) (*AVP, error)
- func (p *Parser) String() string
- type Rule
- type Vendor
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 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 (*Parser) Apps ¶
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 ¶
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 ¶
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 ¶
FindCommand returns a pre-loaded Command from the Parser.
FindCommand must never be called concurrently with LoadFile or Load.
func (*Parser) Rule ¶
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 ¶
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.