networkclient
Low-level attribute encode/decoding

Functions

ssize_t nr_vp2attr (const RADIUS_PACKET *packet, const RADIUS_PACKET *original, const VALUE_PAIR **pvp, uint8_t *data, size_t room)
 
ssize_t nr_vp2rfc (const RADIUS_PACKET *packet, const RADIUS_PACKET *original, const VALUE_PAIR **pvp, uint8_t *data, size_t room)
 
ssize_t nr_attr2vp (const RADIUS_PACKET *packet, const RADIUS_PACKET *original, const uint8_t *data, size_t length, VALUE_PAIR **pvp)
 
ssize_t nr_attr2vp_rfc (const RADIUS_PACKET *packet, const RADIUS_PACKET *original, const uint8_t *data, size_t length, VALUE_PAIR **pvp)
 
ssize_t nr_attr2vp_vsa (const RADIUS_PACKET *packet, const RADIUS_PACKET *original, const uint8_t *data, size_t length, VALUE_PAIR **pvp)
 
ssize_t nr_attr2vp_raw (const RADIUS_PACKET *packet, const RADIUS_PACKET *original, const uint8_t *data, size_t length, VALUE_PAIR **pvp)
 
ssize_t nr_attr2data (const RADIUS_PACKET *packet, ssize_t start, unsigned int attr, unsigned int vendor, const uint8_t **pdata, size_t *plength)
 

Detailed Description

These routines perform "low level" encoding, decoding, sending, and reception of RADIUS attributes. They are called by the Packet manipulation functions.

Attention
The 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.

Function Documentation

ssize_t nr_attr2data ( const RADIUS_PACKET packet,
ssize_t  start,
unsigned int  attr,
unsigned int  vendor,
const uint8_t **  pdata,
size_t *  plength 
)

Returns raw data from the RADIUS packet, for a given attribute.

This function can be called repeatedly to find all instances of a given attribute. The first time it is called, the "start" parameter should be zero. If the function returns a non-zero positive number, it means that there may be more attributes available. The returned value should be then passed via the "start" option in any subsequent calls to the function.

This function should be called by an application when it wants access to data which is not in the pre-defined dictionaries.

Parameters
[in]packetThe packet containing the attribute.
[in]startWhere in the packet we start searching for the attribute.
[in]attrValue of the attribute to search for
[in]vendorValue of the vendor (use 0 for IETF attributes)
[out]pdataPointer to the data. If no data was found, the pointer is unchanged.
[out]plengthLength of the data. If no data was found, the value pointed to is unchanged.
Returns
<0 for error, 0 for "no attribute found, stop searching" >0 offset where the attribute was found.

References radius_packet::data, nr_dict_vendor::length, radius_packet::length, nr_debug_error, nr_dict_vendor_byvalue(), PW_VENDOR_SPECIFIC, return_NR_ERR, and nr_dict_vendor::type.

Here is the call graph for this function:

ssize_t nr_attr2vp ( const RADIUS_PACKET packet,
const RADIUS_PACKET original,
const uint8_t *  data,
size_t  length,
VALUE_PAIR **  pvp 
)

Decodes any attribute into a VALUE_PAIR.

Attention
This function should not be called.
Parameters
[in]packetThe packet containing the attribute to be decoded.
[in]originalThe original request (optional), if "packet" is a response
[out]pvpWhere to place the decoded VALUE_PAIR. On any return >=0, it is updated to point to the VALUE_PAIR which was decoded from the packet.
[in]dataWhere the attribute is to be encoded.
[in]lengthHow many octets are available for attribute decoding.
Returns
<0 for error, or the number of octets used to decode the attribute.

References nr_attr2vp_rfc(), nr_attr2vp_vsa(), nr_dict_attr_byvalue(), PW_VENDOR_SPECIFIC, and return_NR_ERR.

Referenced by nr_packet_decode().

Here is the call graph for this function:

ssize_t nr_attr2vp_raw ( const RADIUS_PACKET packet,
const RADIUS_PACKET original,
const uint8_t *  data,
size_t  length,
VALUE_PAIR **  pvp 
)

Decodes an attribute with an unexpected length into a VALUE_PAIR.

Attention
This function should not be called.
Parameters
[in]packetThe packet containing the attribute to be decoded.
[in]originalThe original request (optional), if "packet" is a response
[out]pvpWhere to place the decoded VALUE_PAIR. On any return >=0, it is updated to point to the VALUE_PAIR which was decoded from the packet.
[in]dataWhere the attribute is to be encoded.
[in]lengthHow many octets are available for attribute decoding.
Returns
<0 for error, or the number of octets used to decode the attribute.

References return_NR_ERR.

Referenced by nr_attr2vp_vsa().

ssize_t nr_attr2vp_rfc ( const RADIUS_PACKET packet,
const RADIUS_PACKET original,
const uint8_t *  data,
size_t  length,
VALUE_PAIR **  pvp 
)

Decodes an RFC "standard" attribute into a VALUE_PAIR.

Attention
This function should not be called.
Parameters
[in]packetThe packet containing the attribute to be decoded.
[in]originalThe original request (optional), if "packet" is a response
[out]pvpWhere to place the decoded VALUE_PAIR. On any return >=0, it is updated to point to the VALUE_PAIR which was decoded from the packet.
[in]dataWhere the attribute is to be encoded.
[in]lengthHow many octets are available for attribute decoding.
Returns
<0 for error, or the number of octets used to decode the attribute.

References return_NR_ERR.

Referenced by nr_attr2vp(), and nr_attr2vp_vsa().

ssize_t nr_attr2vp_vsa ( const RADIUS_PACKET packet,
const RADIUS_PACKET original,
const uint8_t *  data,
size_t  length,
VALUE_PAIR **  pvp 
)

Decodes a Vendor-Specific attribute into a VALUE_PAIR.

Attention
This function should not be called.
Parameters
[in]packetThe packet containing the attribute to be decoded.
[in]originalThe original request (optional), if "packet" is a response
[out]pvpWhere to place the decoded VALUE_PAIR. On any return >=0, it is updated to point to the VALUE_PAIR which was decoded from the packet.
[in]dataWhere the attribute is to be encoded.
[in]lengthHow many octets are available for attribute decoding.
Returns
<0 for error, or the number of octets used to decode the attribute.

References nr_dict_vendor::length, nr_attr2vp_raw(), nr_attr2vp_rfc(), nr_debug_error, nr_dict_vendor_byvalue(), nr_tlv_ok(), nr_vp_free(), PW_VENDOR_SPECIFIC, return_NR_ERR, and nr_dict_vendor::type.

Referenced by nr_attr2vp().

Here is the call graph for this function:

ssize_t nr_vp2attr ( const RADIUS_PACKET packet,
const RADIUS_PACKET original,
const VALUE_PAIR **  pvp,
uint8_t *  data,
size_t  room 
)

Encodes any VALUE_PAIR into an attribute.

This function can be called for any VALUE_PAIR. It will examine that structure, and call one of nr_vp2rfc() or nr_vp2vsa() as necessary.

Attention
This function should not be called.
Parameters
[in]packetWhere to place the encoded attribute.
[in]originalThe original request (optional), if "packet" is a response
[in,out]pvpThe VALUE_PAIR to encode. On any return >=0, it is updated to point to the "next" VALUE_PAIR which should be encoded.
[in]dataWhere the attribute is to be encoded.
[in]roomHow many octets are available for attribute encoding.
Returns
<0 for error, or the number of octets used to encode the attribute.

References nr_dict_attr::attr, value_pair::da, value_pair::length, value_pair::next, NR_DA_CHAP_PASSWORD, NR_DA_MESSAGE_AUTHENTICATOR, nr_debug_error, NR_MAX_VENDOR, nr_vp2rfc(), nr_vp2vsa(), return_NR_ERR, and nr_dict_attr::vendor.

Referenced by nr_packet_attr_append(), and nr_packet_vps_append().

Here is the call graph for this function:

ssize_t nr_vp2rfc ( const RADIUS_PACKET packet,
const RADIUS_PACKET original,
const VALUE_PAIR **  pvp,
uint8_t *  data,
size_t  room 
)

Encodes an RFC "standard" VALUE_PAIR into an attribute.

Attention
This function should not be called.
Parameters
[in]packetWhere to place the encoded attribute.
[in]originalThe original request (optional), if "packet" is a response
[in,out]pvpThe VALUE_PAIR to encode. On any return >=0, it is updated to point to the "next" VALUE_PAIR which should be encoded.
[in]dataWhere the attribute is to be encoded.
[in]roomHow many octets are available for attribute encoding.
Returns
<0 for error, or the number of octets used to encode the attribute.

References nr_dict_attr::attr, value_pair::da, value_pair::length, value_pair::next, NR_DA_CHARGEABLE_USER_IDENTITY, nr_debug_error, return_NR_ERR, and nr_dict_attr::vendor.

Referenced by nr_vp2attr().