networkclient
Attribute manipulation

Data Structures

union  value_pair_data
 
struct  value_pair
 

Typedefs

typedef union value_pair_data VALUE_PAIR_DATA
 
typedef struct value_pair VALUE_PAIR
 

Functions

VALUE_PAIRnr_vp_alloc (const DICT_ATTR *da)
 
void nr_vp_free (VALUE_PAIR **head)
 
VALUE_PAIRnr_vp_init (VALUE_PAIR *vp, const DICT_ATTR *da)
 
VALUE_PAIRnr_vp_alloc_raw (unsigned int attr, unsigned int vendor)
 
int nr_vp_set_data (VALUE_PAIR *vp, const void *data, size_t data_len)
 
int nr_vp_set_raw_data (VALUE_PAIR *vp, const void *data, size_t data_len)
 
VALUE_PAIRnr_vp_create (int attr, int vendor, const void *data, size_t data_len)
 
void nr_vps_append (VALUE_PAIR **head, VALUE_PAIR *vp)
 
VALUE_PAIRnr_vps_find (VALUE_PAIR *head, unsigned int attr, unsigned int vendor)
 

Detailed Description

These routines manage structures which map to attributes.

Typedef Documentation

typedef struct value_pair VALUE_PAIR

C structure version of a RADIUS attribute.

The library APIs use this structure to avoid depending on the details of the protocol.

Union holding all possible types of data for a VALUE_PAIR.

Function Documentation

VALUE_PAIR* nr_vp_alloc ( const DICT_ATTR da)

Allocate a VALUE_PAIR which refers to a DICT_ATTR.

This returned VALUE_PAIR has no data associated with it. The nr_vp_set_data() function must be called before placing the VALUE_PAIR in a RADIUS_PACKET.

Parameters
[in]daThe DICT_ATTR associated with the VALUE_PAIR
Returns
The created VALUE_PAIR, or NULL on error.

References nr_strerror_printf(), and nr_vp_init().

Referenced by nr_vp_create(), and nr_vp_sscanf().

Here is the call graph for this function:

VALUE_PAIR* nr_vp_alloc_raw ( unsigned int  attr,
unsigned int  vendor 
)

Allocate a VALUE_PAIR which refers to an unknown attribute.

It is used when an attribute is received, and that attribute does not exist in the dictionaries.

The returned VALUE_PAIR has no data (i.e. VALUE_PAIR::length is zero). The nr_vp_set_data() function must be called before placing the VALUE_PAIR in a RADIUS_PACKET.

Parameters
[in]attrThe attribute number, 0..2^16
[in]vendorThe vendor number, 0..2^16
Returns
The created VALUE_PAIR, or NULL on error.

References da, nr_dict_attr_2struct(), and nr_strerror_printf().

Here is the call graph for this function:

VALUE_PAIR* nr_vp_create ( int  attr,
int  vendor,
const void *  data,
size_t  data_len 
)

Create a VALUE_PAIR and set its data.

Parameters
[in]attrThe attribute number of the VALUE_PAIR to create
[in]vendorThe vendor number of the VALUE_PAIR to create
[in]dataData to set inside of the VALUE_PAIR
[in]data_lenLength of the data field
Returns
The created VALUE_PAIR, or NULL on error.

References nr_dict_attr_byvalue(), nr_vp_alloc(), nr_vp_free(), and nr_vp_set_data().

Here is the call graph for this function:

void nr_vp_free ( VALUE_PAIR **  head)

Free a VALUE_PAIR.

This function frees the VALUE_PAIR, and sets the head pointer to NULL. If head refers to a VALUE_PAIR list, then all of the structures in the list are freed.

Parameters
[in,out]headThe pointer to a VALUE_PAIR, or a VALUE_PAIR list.

References da, attr_flags::encrypt, nr_dict_attr::flags, and next.

Referenced by main(), nr_attr2vp_vsa(), nr_packet_decode(), nr_track_id_packet_free(), nr_vp_create(), and nr_vp_sscanf().

VALUE_PAIR* nr_vp_init ( VALUE_PAIR vp,
const DICT_ATTR da 
)

Initializes a VALUE_PAIR from a DICT_ATTR

This function assumes that the VALUE_PAIR points to existing and writable memory.

Parameters
[in,out]vpThe VALUE_PAIR to be initialized
[in]daThe DICT_ATTR used to initialize the VALUE_PAIR
Returns
The initialized VALUE_PAIR, or NULL on error.

References da, nr_dict_attr::flags, attr_flags::length, and length.

Referenced by nr_packet_attr_append(), and nr_vp_alloc().

int nr_vp_set_data ( VALUE_PAIR vp,
const void *  data,
size_t  data_len 
)

Set the data associated with a previously allocated VALUE_PAIR.

The data (e.g. integers) is in host byte order. This function should be called by an application when converting application data to VALUE_PAIR structures.

If this function succeeds, VALUE_PAIR::length is no longer zero, and the structure contains the data.

Parameters
[in,out]vpThe VALUE_PAIR to update
[in]dataData to set inside of the VALUE_PAIR
[in]data_lenLength of the data field
Returns
<0 on error, 0 for "data was truncated" >0 for "data successfully added"

References da, length, NR_TYPE_BYTE, NR_TYPE_DATE, NR_TYPE_INTEGER, NR_TYPE_IPADDR, NR_TYPE_OCTETS, NR_TYPE_SHORT, NR_TYPE_STRING, return_NR_ERR, and nr_dict_attr::type.

Referenced by nr_packet_attr_append(), nr_vp_create(), and nr_vp_set_raw_data().

int nr_vp_set_raw_data ( VALUE_PAIR vp,
const void *  data,
size_t  data_len 
)

Set the data associated with a previously allocated VALUE_PAIR.

The data (e.g. integers) is in network byte order. This function should be called when converting raw RADIUS packets to VALUE_PAIR structures. Most applications will not need to call this function.

If this function succeeds, VALUE_PAIR::length is no longer zero, and the structure contains the data.

Parameters
[in,out]vpThe VALUE_PAIR to update
[in]dataData to set inside of the VALUE_PAIR
[in]data_lenLength of the data field
Returns
<0 on error, 0 for "data was truncated" >0 for "data successfully added"

References da, NR_TYPE_DATE, NR_TYPE_INTEGER, NR_TYPE_IPADDR, NR_TYPE_SHORT, nr_vp_set_data(), return_NR_ERR, and nr_dict_attr::type.

Here is the call graph for this function:

void nr_vps_append ( VALUE_PAIR **  head,
VALUE_PAIR vp 
)

Append a VALUE_PAIR to the end of a VALUE_PAIR list.

Parameters
[in,out]headThe head of the VALUE_PAIR list. May not be NULL.
[in]vpThe VALUE_PAIR to append to the list.
VALUE_PAIR* nr_vps_find ( VALUE_PAIR head,
unsigned int  attr,
unsigned int  vendor 
)

Search a VALUE_PAIR list for one of a given number.

Parameters
[in]headThe head of the VALUE_PAIR list to search.
[in]attrThe attribute number of the VALUE_PAIR to find
[in]vendorThe vendor number of the VALUE_PAIR to find
Returns
The found VALUE_PAIR, or NULL if it was not found.

References nr_dict_attr::attr, da, next, and nr_dict_attr::vendor.