Documentation ¶
Overview ¶
Diameter dictionary parser. Part of go-diameter.
Index ¶
- Variables
- type AVP
- type App
- type CMD
- type CMDRule
- 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) FindCMD(appid, code uint32) (*CMD, 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 ¶
var DefaultXML = []byte(`<?xml version="1.0" encoding="UTF-8"?>
<diameter>
<application id="0"> <!-- Diameter Common Messages -->
<vendor id="10415" name="3GPP"/>
<command code="257" short="CE" name="Capabilities-Exchange">
<request>
<rule avp="Origin-Host" required="true" max="1"/>
<rule avp="Origin-Realm" required="true" max="1"/>
<rule avp="Host-IP-Address" required="true" max="1"/>
<rule avp="Vendor-Id" required="true" max="1"/>
<rule avp="Product-Name" required="true" max="1"/>
<rule avp="Origin-State-Id" required="false" max="1"/>
<rule avp="Supported-Vendor-Id" required="False"/>
<rule avp="Auth-Application-Id" required="False"/>
<rule avp="Inband-Security-Id" required="False"/>
<rule avp="Acct-Application-Id" required="False"/>
<rule avp="Vendor-Specific-Application-Id" required="False"/>
<rule avp="Firmware-Revision" required="False" max="1"/>
</request>
<answer>
<rule avp="Result-Code" required="true" max="1"/>
<rule avp="Origin-Host" required="true" max="1"/>
<rule avp="Origin-Realm" required="true" max="1"/>
<rule avp="Host-IP-Address" required="true" max="1"/>
<rule avp="Vendor-Id" required="true" max="1"/>
<rule avp="Product-Name" required="true" max="1"/>
<rule avp="Origin-State-Id" required="false" max="1"/>
<rule avp="Error-Message" required="false" max="1"/>
<rule avp="Failed-AVP" required="false" max="1"/>
<rule avp="Supported-Vendor-Id" required="False"/>
<rule avp="Auth-Application-Id" required="False"/>
<rule avp="Inband-Security-Id" required="False"/>
<rule avp="Acct-Application-Id" required="False"/>
<rule avp="Vendor-Specific-Application-Id" required="False"/>
<rule avp="Firmware-Revision" required="False" max="1"/>
</answer>
</command>
<command code="258" short="RA" name="Re-Auth">
<request>
<rule avp="Session-Id" required="true" max="1"/>
<rule avp="Origin-Host" required="true" max="1"/>
<rule avp="Origin-Realm" required="true" max="1"/>
<rule avp="Destination-Realm" required="true" max="1"/>
<rule avp="Destination-Host" required="true" max="1"/>
<rule avp="Auth-Application-Id" required="true" max="1"/>
<rule avp="Re-Auth-Request-Type" required="true" max="1"/>
<rule avp="User-Name" required="false" max="1"/>
<rule avp="Origin-State-Id" required="false" max="1"/>
<rule avp="Proxy-Info" required="false"/>
<rule avp="Route-Record" required="false"/>
</request>
<answer>
<rule avp="Session-Id" required="true" max="1"/>
<rule avp="Result-Code" required="true" max="1"/>
<rule avp="Origin-Host" required="true" max="1"/>
<rule avp="Origin-Realm" required="true" max="1"/>
<rule avp="User-Name" required="false" max="1"/>
<rule avp="Origin-State-Id" required="false" max="1"/>
<rule avp="Error-Message" required="false" max="1"/>
<rule avp="Error-Reporting-Host" required="false" max="1"/>
<rule avp="Failed-AVP" required="false" max="1"/>
<rule avp="Redirect-Host" required="false"/>
<rule avp="Redirect-Host-Usage" required="false" max="1"/>
<rule avp="Redirect-Max-Cache-Time" required="false" max="1"/>
<rule avp="Proxy-Info" required="false"/>
</answer>
</command>
<command code="271" short="AC" name="Accounting">
<request>
<rule avp="Session-Id" required="true" max="1"/>
<rule avp="Origin-Host" required="true" max="1"/>
<rule avp="Origin-Realm" required="true" max="1"/>
<rule avp="Destination-Realm" required="true" max="1"/>
<rule avp="Accounting-Record-Type" required="true" max="1"/>
<rule avp="Accounting-Record-Number" required="true" max="1"/>
<rule avp="Acct-Application-Id" required="false" max="1"/>
<rule avp="Vendor-Specific-Application-Id" required="false" max="1"/>
<rule avp="User-Name" required="false" max="1"/>
<rule avp="Destination-Host" required="false" max="1"/>
<rule avp="Accounting-Sub-Session-Id" required="false" max="1"/>
<rule avp="Acct-Session-Id" required="false" max="1"/>
<rule avp="Acct-Multi-Session-Id" required="false" max="1"/>
<rule avp="Acct-Interim-Interval" required="false" max="1"/>
<rule avp="Accounting-Realtime-Required" required="false" max="1"/>
<rule avp="Origin-State-Id" required="false" max="1"/>
<rule avp="Event-Timestamp" required="false" max="1"/>
<rule avp="Proxy-Info" required="false"/>
<rule avp="Route-Record" required="false"/>
</request>
<answer>
<rule avp="Session-Id" required="true" max="1"/>
<rule avp="Result-Code" required="true" max="1"/>
<rule avp="Origin-Host" required="true" max="1"/>
<rule avp="Origin-Realm" required="true" max="1"/>
<rule avp="Accounting-Record-Type" required="true" max="1"/>
<rule avp="Accounting-Record-Number" required="true" max="1"/>
<rule avp="Acct-Application-Id" required="false" max="1"/>
<rule avp="Vendor-Specific-Application-Id" required="false" max="1"/>
<rule avp="User-Name" required="false" max="1"/>
<rule avp="Accounting-Sub-Session-Id" required="false" max="1"/>
<rule avp="Acct-Session-Id" required="false" max="1"/>
<rule avp="Acct-Multi-Session-Id" required="false" max="1"/>
<rule avp="Error-Message" required="false" max="1"/>
<rule avp="Error-Reporting-Host" required="false" max="1"/>
<rule avp="Failed-AVP" required="false" max="1"/>
<rule avp="Acct-Interim-Interval" required="false" max="1"/>
<rule avp="Accounting-Realtime-Required" required="false" max="1"/>
<rule avp="Origin-State-Id" required="false" max="1"/>
<rule avp="Event-Timestamp" required="false" max="1"/>
<rule avp="Proxy-Info" required="false"/>
</answer>
</command>
<command code="274" short="AS" name="Abort-Session">
<request>
<rule avp="Session-Id" required="true" max="1"/>
<rule avp="Origin-Host" required="true" max="1"/>
<rule avp="Origin-Realm" required="true" max="1"/>
<rule avp="Destination-Realm" required="true" max="1"/>
<rule avp="Destination-Host" required="true" max="1"/>
<rule avp="Auth-Application-Id" required="true" max="1"/>
<rule avp="User-Name" required="false" max="1"/>
<rule avp="Origin-State-Id" required="false" max="1"/>
<rule avp="Proxy-Info" required="false"/>
<rule avp="Route-Record" required="false"/>
</request>
<answer>
<rule avp="Session-Id" required="true" max="1"/>
<rule avp="Result-Code" required="true" max="1"/>
<rule avp="Origin-Host" required="true" max="1"/>
<rule avp="Origin-Realm" required="true" max="1"/>
<rule avp="User-Name" required="false" max="1"/>
<rule avp="Origin-State-Id" required="false" max="1"/>
<rule avp="Error-Message" required="false" max="1"/>
<rule avp="Error-Reporting-Host" required="false" max="1"/>
<rule avp="Failed-AVP" required="false" max="1"/>
<rule avp="Redirect-Host" required="false"/>
<rule avp="Redirect-Host-Usage" required="false" max="1"/>
<rule avp="Redirect-Max-Cache-Time" required="false" max="1"/>
<rule avp="Proxy-Info" required="false"/>
</answer>
</command>
<command code="275" short="ST" name="Session-Termination">
<request>
<rule avp="Session-Id" required="true" max="1"/>
<rule avp="Origin-Host" required="true" max="1"/>
<rule avp="Origin-Realm" required="true" max="1"/>
<rule avp="Destination-Realm" required="true" max="1"/>
<rule avp="Auth-Application-Id" required="true" max="1"/>
<rule avp="Termination-Cause" required="true" max="1"/>
<rule avp="User-Name" required="false" max="1"/>
<rule avp="Destination-Host" required="false" max="1"/>
<rule avp="Class" required="false"/>
<rule avp="Origin-State-Id" required="false" max="1"/>
<rule avp="Proxy-Info" required="false"/>
<rule avp="Route-Record" required="false"/>
</request>
<answer>
<rule avp="Session-Id" required="true" max="1"/>
<rule avp="Result-Code" required="true" max="1"/>
<rule avp="Origin-Host" required="true" max="1"/>
<rule avp="Origin-Realm" required="true" max="1"/>
<rule avp="User-Name" required="false" max="1"/>
<rule avp="Class" required="false"/>
<rule avp="Error-Message" required="false" max="1"/>
<rule avp="Error-Reporting-Host" required="false" max="1"/>
<rule avp="Failed-AVP" required="false" max="1"/>
<rule avp="Origin-State-Id" required="false" max="1"/>
<rule avp="Redirect-Host" required="false"/>
<rule avp="Redirect-Host-Usage" required="false" max="1"/>
<rule avp="Redirect-Max-Cache-Time" required="false" max="1"/>
<rule avp="Proxy-Info" required="false"/>
</answer>
</command>
<command code="280" short="DW" name="Device-Watchdog">
<request>
<rule avp="Origin-Host" required="true" max="1"/>
<rule avp="Origin-Realm" required="true" max="1"/>
<rule avp="Origin-State-Id" required="false" max="1"/>
</request>
<answer>
<rule avp="Result-Code" required="true" max="1"/>
<rule avp="Origin-Host" required="true" max="1"/>
<rule avp="Origin-Realm" required="true" max="1"/>
<rule avp="Error-Message" required="false" max="1"/>
<rule avp="Failed-AVP" required="false" max="1"/>
<rule avp="Origin-State-Id" required="false" max="1"/>
</answer>
</command>
<command code="282" short="DP" name="Disconnect-Peer">
<request>
<rule avp="Origin-Host" required="true" max="1"/>
<rule avp="Origin-Realm" required="true" max="1"/>
<rule avp="Disconnect-Cause" required="false" max="1"/>
</request>
<answer>
<rule avp="Result-Code" required="true" max="1"/>
<rule avp="Origin-Host" required="true" max="1"/>
<rule avp="Origin-Realm" required="true" max="1"/>
<rule avp="Error-Message" required="false" max="1"/>
<rule avp="Failed-AVP" required="false" max="1"/>
</answer>
</command>
<avp name="Acct-Interim-Interval" code="85" must="M" may="P" must-not="V" may-encrypt="Y">
<data type="Unsigned32"/>
</avp>
<avp name="Accounting-Realtime-Required" code="483" must="M" may="P" must-not="V" may-encrypt="Y">
<data type="Enumerated">
<item code="1" name="DELIVER_AND_GRANT"/>
<item code="2" name="GRANT_AND_STORE"/>
<item code="3" name="GRANT_AND_LOSE"/>
</data>
</avp>
<avp name="Acct-Multi-Session-Id" code="50" must="M" may="P" must-not="V" may-encrypt="Y">
<data type="UTF8String"/>
</avp>
<avp name="Accounting-Record-Number" code="485" must="M" may="P" must-not="V" may-encrypt="Y">
<data type="Unsigned32"/>
</avp>
<avp name="Accounting-Record-Type" code="480" must="M" may="P" must-not="V" may-encrypt="Y">
<data type="Enumerated">
<item code="1" name="EVENT_RECORD"/>
<item code="2" name="START_RECORD"/>
<item code="3" name="INTERIM_RECORD"/>
<item code="4" name="STOP_RECORD"/>
</data>
</avp>
<avp name="Accounting-Session-Id" code="44" must="M" may="P" must-not="V" may-encrypt="Y">
<data type="OctetString"/>
</avp>
<avp name="Accounting-Sub-Session-Id" code="287" must="M" may="P" must-not="V" may-encrypt="Y">
<data type="Unsigned64"/>
</avp>
<avp name="Acct-Application-Id" code="259" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Unsigned32"/>
</avp>
<avp name="Auth-Application-Id" code="258" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Unsigned32"/>
</avp>
<avp name="Auth-Request-Type" code="274" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Enumerated">
<item code="1" name="AUTHENTICATE_ONLY"/>
<item code="2" name="AUTHORIZE_ONLY"/>
<item code="3" name="AUTHORIZE_AUTHENTICATE"/>
</data>
</avp>
<avp name="Authorization-Lifetime" code="291" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Unsigned32"/>
</avp>
<avp name="Auth-Grace-Period" code="276" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Unsigned32"/>
</avp>
<avp name="Auth-Session-State" code="277" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Enumerated">
<item code="0" name="STATE_MAINTAINED"/>
<item code="1" name="NO_STATE_MAINTAINED"/>
</data>
</avp>
<avp name="Re-Auth-Request-Type" code="285" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Enumerated">
<item code="0" name="AUTHORIZE_ONLY"/>
<item code="1" name="AUTHORIZE_AUTHENTICATE"/>
</data>
</avp>
<avp name="Class" code="25" must="M" may="P" must-not="V" may-encrypt="Y">
<data type="OctetString"/>
</avp>
<avp name="Destination-Host" code="293" must="M" may="P" must-not="V" may-encrypt="-">
<data type="DiameterIdentity"/>
</avp>
<avp name="Destination-Realm" code="283" must="M" may="P" must-not="V" may-encrypt="-">
<data type="DiameterIdentity"/>
</avp>
<avp name="Disconnect-Cause" code="273" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Enumerated">
<item code="0" name="REBOOTING"/>
<item code="1" name="BUSY"/>
<item code="2" name="DO_NOT_WANT_TO_TALK_TO_YOU"/>
</data>
</avp>
<avp name="Error-Message" code="281" must="-" may="P" must-not="V,M" may-encrypt="-">
<data type="UTF8String"/>
</avp>
<avp name="Error-Reporting-Host" code="294" must="-" may="P" must-not="V,M" may-encrypt="-">
<data type="DiameterIdentity"/>
</avp>
<avp name="Event-Timestamp" code="55" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Time"/>
</avp>
<avp name="Experimental-Result" code="297" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Grouped">
<rule avp="Vendor-Id" required="true" max="1"/>
<rule avp="Experimental-Result-Code" required="true" max="1"/>
</data>
</avp>
<avp name="Experimental-Result-Code" code="298" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Unsigned32"/>
</avp>
<avp name="Failed-AVP" code="279" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Grouped"/>
</avp>
<avp name="Firmware-Revision" code="267" must="-" may="-" must-not="P,V,M" may-encrypt="-">
<data type="Unsigned32"/>
</avp>
<avp name="Host-IP-Address" code="257" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Address"/>
</avp>
<avp name="Inband-Security-Id" code="299" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Unsigned32"/>
</avp>
<avp name="Multi-Round-Time-Out" code="272" must="M" may="P" must-not="V" may-encrypt="Y">
<data type="Unsigned32"/>
</avp>
<avp name="Origin-Host" code="264" must="M" may="P" must-not="V" may-encrypt="-">
<data type="DiameterIdentity"/>
</avp>
<avp name="Origin-Realm" code="296" must="M" may="P" must-not="V" may-encrypt="-">
<data type="DiameterIdentity"/>
</avp>
<avp name="Origin-State-Id" code="278" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Unsigned32"/>
</avp>
<avp name="Product-Name" code="269" must="-" may="-" must-not="P,V,M" may-encrypt="-">
<data type="UTF8String"/>
</avp>
<avp name="Proxy-Host" code="280" must="M" may="-" must-not="P,V" may-encrypt="-">
<data type="DiameterIdentity"/>
</avp>
<avp name="Proxy-Info" code="284" must="M" may="-" must-not="P,V" may-encrypt="-">
<data type="Grouped">
<rule avp="Proxy-Host" required="true" max="1"/>
<rule avp="Proxy-State" required="true" max="1"/>
</data>
</avp>
<avp name="Proxy-State" code="33" must="M" may="-" must-not="P,V" may-encrypt="-">
<data type="OctetString"/>
</avp>
<avp name="Redirect-Host" code="292" must="M" may="P" must-not="V" may-encrypt="-">
<data type="DiameterURI"/>
</avp>
<avp name="Redirect-Host-Usage" code="261" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Enumerated">
<item code="0" name="DONT_CACHE"/>
<item code="1" name="ALL_SESSION"/>
<item code="2" name="ALL_REALM"/>
<item code="3" name="REALM_AND_APPLICATION"/>
<item code="4" name="ALL_APPLICATION"/>
<item code="5" name="ALL_HOST"/>
<item code="6" name="ALL_USER"/>
</data>
</avp>
<avp name="Redirect-Max-Cache-Time" code="262" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Unsigned32"/>
</avp>
<avp name="Result-Code" code="268" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Unsigned32"/>
</avp>
<avp name="Route-Record" code="282" must="M" may="-" must-not="P,V" may-encrypt="-">
<data type="DiameterIdentity"/>
</avp>
<avp name="Session-Id" code="263" must="M" may="P" must-not="V" may-encrypt="Y">
<data type="UTF8String"/>
</avp>
<avp name="Session-Timeout" code="27" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Unsigned32"/>
</avp>
<avp name="Session-Binding" code="270" must="M" may="P" must-not="V" may-encrypt="Y">
<data type="Unsigned32"/>
</avp>
<avp name="Session-Server-Failover" code="271" must="M" may="P" must-not="V" may-encrypt="Y">
<data type="Enumerated">
<item code="0" name="REFUSE_SERVICE"/>
<item code="1" name="TRY_AGAIN"/>
<item code="2" name="ALLOW_SERVICE"/>
<item code="3" name="TRY_AGAIN_ALLOW_SERVICE"/>
</data>
</avp>
<avp name="Supported-Vendor-Id" code="265" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Unsigned32"/>
</avp>
<avp name="Termination-Cause" code="295" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Enumerated">
<item code="1" name="DIAMETER_LOGOUT"/>
<item code="2" name="DIAMETER_SERVICE_NOT_PROVIDED"/>
<item code="3" name="DIAMETER_BAD_ANSWER"/>
<item code="4" name="DIAMETER_ADMINISTRATIVE"/>
<item code="5" name="DIAMETER_LINK_BROKEN"/>
<item code="6" name="DIAMETER_AUTH_EXPIRED"/>
<item code="7" name="DIAMETER_USER_MOVED"/>
<item code="8" name="DIAMETER_SESSION_TIMEOUT"/>
</data>
</avp>
<avp name="User-Name" code="1" must="M" may="P" must-not="V" may-encrypt="Y">
<data type="UTF8String"/>
</avp>
<avp name="Vendor-Id" code="266" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Unsigned32"/>
</avp>
<avp name="Vendor-Specific-Application-Id" code="260" must="M" may="P" must-not="V" may-encrypt="-">
<data type="Grouped">
<rule avp="Vendor-Id" required="false" max="1"/>
<rule avp="Auth-Application-Id" required="true" max="1"/>
<rule avp="Acct-Application-Id" required="true" max="1"/>
</data>
</avp>
</application>
</diameter>`)
DefaultXML is an embedded version of the Diameter Base Protocol.
Copy of diam_base.xml
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 CMD []*CMD `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 CMD ¶
type CMD struct { Code uint32 `xml:"code,attr"` Name string `xml:"name,attr"` Short string `xml:"short,attr"` Request CMDRule `xml:"request"` Answer CMDRule `xml:"answer"` }
CMD defines a diameter command (CE, CC, etc)
type Data ¶
type Data struct { Type datatypes.DataTypeId `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 static Parser with a pre-loaded Base Protocol.
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)
func (Parser) FindAVP ¶
FindAVP is a helper function that returns a pre-loaded AVP from the Dict. If the AVP code is not found in the given appid it tries with appid=0 before returning an error. @code can be either the AVP code (int, uint32) or name (string).
func (Parser) Rule ¶
Rule is a helper function that returns a pre-loaded Rule item for the given AVP code and name.