pyrad.dictionary – RADIUS dictionary

RADIUS uses dictionaries to define the attributes that can be used in packets. The Dictionary class stores the attribute definitions from one or more dictionary files.

Dictionary files are textfiles with one command per line. Comments are specified by starting with a # character, and empty lines are ignored.

The commands supported are:

ATTRIBUTE <attribute> <code> <type> [<vendor>]
specify an attribute and its type

VALUE <attribute> <valuename> <value>
specify a value attribute

VENDOR <name> <id>
specify a vendor ID

BEGIN-VENDOR <vendorname>
begin definition of vendor attributes

END-VENDOR <vendorname>
end definition of vendor attributes

The datatypes currently supported are:

type description
string ASCII string
ipaddr IPv4 address
date 32 bits UNIX
octets arbitrary binary data
abinary ascend binary data
ipv6addr 16 octets in network byte order
ipv6prefix 18 octets in network byte order
integer 32 bits unsigned number
signed 32 bits signed number
short 16 bits unsigned number
byte 8 bits unsigned number

These datatypes are parsed but not supported:

type description
ifid 8 octets in network byte order
ether 6 octets of hh:hh:hh:hh:hh:hh where ‘h’ is hex digits, upper or lowercase.
class pyrad.dictionary.ParseError(msg=None, **data)[source]

Dictionary parser exceptions.

Variables:
  • msg – Error message
  • linenumber – Line number on which the error occured
class pyrad.dictionary.Dictionary(dict=None, *dicts)[source]

RADIUS dictionary class. This class stores all information about vendors, attributes and their values as defined in RADIUS dictionary files.

Variables:
  • vendors – bidict mapping vendor name to vendor code
  • attrindex – bidict mapping
  • attributes – bidict mapping attribute name to attribute class
ReadDictionary(file)[source]

Parse a dictionary file. Reads a RADIUS dictionary file and merges its contents into the class instance.

Parameters:file (string or file-like object) – Name of dictionary file to parse or a file-like object