networkclient
Dictionary Lookup Functions

Data Structures

struct  nr_dict_attr
 
struct  nr_dict_value
 
struct  nr_dict_vendor
 

Macros

#define NR_MAX_PACKET_CODE   46
 
#define NR_MAX_VENDOR   (1 << 24)
 

Typedefs

typedef enum nr_attr_type_t nr_attr_type_t
 
typedef struct nr_dict_attr DICT_ATTR
 
typedef struct nr_dict_value DICT_VALUE
 
typedef struct nr_dict_vendor DICT_VENDOR
 

Enumerations

enum  nr_attr_type_t {
  NR_TYPE_INVALID = 0, NR_TYPE_STRING, NR_TYPE_INTEGER, NR_TYPE_IPADDR,
  NR_TYPE_DATE, NR_TYPE_OCTETS, NR_TYPE_IFID, NR_TYPE_IPV6ADDR,
  NR_TYPE_IPV6PREFIX, NR_TYPE_BYTE, NR_TYPE_SHORT, NR_TYPE_INTEGER64
}
 

Functions

const DICT_ATTRnr_dict_attr_byvalue (unsigned int attr, unsigned int vendor)
 
const DICT_ATTRnr_dict_attr_byname (const char *name)
 
int nr_dict_attr_2struct (DICT_ATTR *da, unsigned int attr, unsigned int vendor, char *buffer, size_t bufsize)
 
const DICT_VALUEnr_dict_value_byattr (unsigned int attr, unsigned int vendor, int value)
 
const DICT_VALUEnr_dict_value_byname (unsigned int attr, unsigned int vendor, const char *name)
 
int nr_dict_vendor_byname (const char *name)
 
const DICT_VENDORnr_dict_vendor_byvalue (unsigned int vendor)
 

Variables

const DICT_VENDOR nr_dict_vendors []
 
const int nr_dict_num_attrs
 
const DICT_ATTR nr_dict_attrs []
 
const int nr_dict_num_names
 
DICT_ATTR const * nr_dict_attr_names []
 
const char * nr_packet_codes [NR_MAX_PACKET_CODE+1]
 

Detailed Description

See also
doc/dictionaries.txt

The RADIUS dictionaries perform name to number mappings. The names are used only for administrator convenience, for parsing configuration files, and printing humanly-readable output. The numbers are used when encoding data in a packet.

When attributes are decoded from a packet, the numbers are used to look up the associated name, which is then placed into a data structure.

When the data structures are encoded into a packet, the numbers are used to create RFC and VSA format attributes.

Attention
The definitions, structures, and functions given below are useful only for implementing "low level" RADIUS functionality. There is usually no need to refer to them in a client application. The library should be used at a higher level, which exposes a much simpler API.

Macro Definition Documentation

#define NR_MAX_PACKET_CODE   46

The maximum RADIUS_PACKET::code which we can accept.

Attention
This should not be changed, as it is used by other structures such as nr_packet_codes.

Referenced by nr_packet_can_encode(), nr_packet_init(), nr_packet_ok_raw(), nr_packet_print_hex(), and nr_track_id_init().

#define NR_MAX_VENDOR   (1 << 24)

The maximum vendor number which is permitted.

The RFCs require that the Vendor Id or Private Enterprise Number be encoded as 32 bits, with the upper 8 bits being zero.

Referenced by nr_vp2attr(), and nr_vp2vsa().

Typedef Documentation

typedef struct nr_dict_attr DICT_ATTR

Defines an dictionary mapping for an attribute.

The RADIUS dictionaries map humanly readable names to protocol numbers. The protocol numbers are used to encode/decode the attributes in a packet.

typedef struct nr_dict_value DICT_VALUE

Defines a dictionary mapping for a named enumeration.

This structure is currently not used.

typedef struct nr_dict_vendor DICT_VENDOR

Defines an dictionary mapping for a vendor.

The RADIUS dictionaries map humanly readable vendor names to a Vendor-Id (or Private Enterprise Code) assigned by IANA. The Vendor-Id is used to encode/decode Vendor-Specific attributes in a packet.

Data Type Definitions.

Enumeration Type Documentation

Data Type Definitions.

Enumerator
NR_TYPE_INVALID 

Invalid data type

NR_TYPE_STRING 

printable-text

NR_TYPE_INTEGER 

a 32-bit unsigned integer

NR_TYPE_IPADDR 

an IPv4 address

NR_TYPE_DATE 

a 32-bit date, of seconds since January 1, 1970

NR_TYPE_OCTETS 

a sequence of binary octets

NR_TYPE_IFID 

an Interface Id

NR_TYPE_IPV6ADDR 

an IPv6 address

NR_TYPE_IPV6PREFIX 

an IPv6 prefix

NR_TYPE_BYTE 

an 8-bit integer

NR_TYPE_SHORT 

a 16-bit integer

NR_TYPE_INTEGER64 

a 64-bit integer

Function Documentation

int nr_dict_attr_2struct ( DICT_ATTR da,
unsigned int  attr,
unsigned int  vendor,
char *  buffer,
size_t  bufsize 
)

Converts raw data to a DICT_ATTR structure.

It is called when the library is asked to decode an attribute which is not in the pre-defined dictionaries.

Attention
There is usually no need to call this function.
Parameters
[in,out]daThe DICT_ATTR structure to initialize
[in]attrThe attribute number
[in]vendorThe vendor number
[in]bufferThe buffer where the name of the attribute is stored
[in]bufsizeSize of the buffer
Returns
<0 for error, 0 for success

References nr_dict_attr::attr, nr_dict_attr::flags, nr_dict_attr::name, NR_TYPE_OCTETS, return_NR_ERR, nr_dict_attr::type, attr_flags::unknown, and nr_dict_attr::vendor.

Referenced by nr_vp_alloc_raw().

const DICT_ATTR* nr_dict_attr_byname ( const char *  name)

Look up an attribute in the dictionaries.

The dictionary mapping contains information about the attribute, such as printable name, data type (ipaddr, integer, etc), and various other things used to encode/decode the attribute in a packet.

Attention
There is usually no need to call this function.
Parameters
[in]nameName of the attribute
Returns
NULL for "not found", or a pointer to the attribute mapping.

References nr_dict_attr_names, and nr_dict_num_names.

Referenced by nr_vp_sscanf().

const DICT_ATTR* nr_dict_attr_byvalue ( unsigned int  attr,
unsigned int  vendor 
)

Look up an attribute in the dictionaries.

The dictionary mapping contains information about the attribute, such as printable name, data type (ipaddr, integer, etc), and various other things used to encode/decode the attribute in a packet.

Attention
There is usually no need to call this function. Use the NR_DA_* definitions instead.
Parameters
[in]attrValue of the attribute
[in]vendorValue of the vendor
Returns
NULL for "not found", or a pointer to the attribute mapping.

References nr_dict_attr::attr, nr_dict_attrs, and nr_dict_num_attrs.

Referenced by nr_attr2vp(), and nr_vp_create().

const DICT_VALUE* nr_dict_value_byattr ( unsigned int  attr,
unsigned int  vendor,
int  value 
)

Unused.

const DICT_VALUE* nr_dict_value_byname ( unsigned int  attr,
unsigned int  vendor,
const char *  name 
)

Unused.

int nr_dict_vendor_byname ( const char *  name)

Look up a vendor in the dictionaries.

The dictionary mapping contains information about the vendor, such as printable name, VSA encoding method, etc.

Attention
There is usually no need to call this function. Applications do not need access to low-level RADIUS protocol information.
Parameters
[in]nameName of the vendor.
Returns
NULL for "not found", or a pointer to the vendor mapping.

References nr_dict_vendor::name, nr_dict_vendors, and nr_dict_vendor::vendor.

const DICT_VENDOR* nr_dict_vendor_byvalue ( unsigned int  vendor)

Look up an vendor in the dictionaries.

The dictionary mapping contains information about the vendor, such as printable name, VSA encoding method, etc.

Attention
There is usually no need to call this function.
Parameters
[in]vendorVendor-Id (or Private Enterprise code) for the vendor.
Returns
NULL for "not found", or a pointer to the vendor mapping.

References nr_dict_vendor::name, nr_dict_vendors, and nr_dict_vendor::vendor.

Referenced by nr_attr2data(), nr_attr2vp_vsa(), and nr_packet_walk().

Variable Documentation

DICT_ATTR const* nr_dict_attr_names[]

The list of attribute definitions, organized by name.

The attributes are orderd by name (case insensitive), in increasing order. This allows the dictionary lookups to find attributes by a binary search.

Attention
This variable should only be accessed by internal RADIUS library functions.

Referenced by nr_dict_attr_byname().

const DICT_ATTR nr_dict_attrs[]

The list of attribute definitions.

The "standard" RFC attributes are located in the first 256 entries. Standard attributes without a dictionary definition are given an empty entry.

The attributes are orderd by (vendor, attribute), in increasing order. This allows the dictionary lookups to find attributes by a binary search.

Attention
This variable should only be accessed by internal RADIUS library functions.

Referenced by nr_dict_attr_byvalue().

const int nr_dict_num_attrs

The number of attribute definitions in the dictionary.

This number is guaranteed to be at least 256, for speed.

Attention
This variable should only be accessed by internal RADIUS library functions.

Referenced by nr_dict_attr_byvalue().

const int nr_dict_num_names

The number of attributes with names.

Attention
This variable should only be accessed by internal RADIUS library functions.

Referenced by nr_dict_attr_byname().

const DICT_VENDOR nr_dict_vendors[]

Static array of known vendors.

Attention
This structure should only be accessed by internal RADIUS library functions.

Referenced by nr_dict_vendor_byname(), and nr_dict_vendor_byvalue().

const char* nr_packet_codes[NR_MAX_PACKET_CODE+1]

Static array containing names the RADIUS_PACKET::code field.

The names are hard-coded and not in any dictionary because they do not change.

The names are exported because they may be useful in your application. Packet codes which are not handled by the library have NULL for their names.

Referenced by nr_packet_can_encode(), nr_packet_ok_raw(), and nr_packet_print_hex().