networkclient
|
Encoding and decoding packets. More...
#include <networkradius-devel/client.h>
Macros | |
#define | _allow(_x) (((uint64_t) 1) << _x) |
#define | append_ma(_x) (0) |
Functions | |
int | nr_packet_ok_raw (const uint8_t *data, size_t sizeof_data) |
int | nr_packet_ok (RADIUS_PACKET *packet) |
int | nr_packet_verify (RADIUS_PACKET *packet, const RADIUS_PACKET *original) |
int | nr_packet_decode (RADIUS_PACKET *packet, const RADIUS_PACKET *original) |
int | nr_packet_sign (RADIUS_PACKET *packet, const RADIUS_PACKET *original) |
int | nr_packet_can_encode (RADIUS_PACKET *packet, const RADIUS_PACKET *original) |
ssize_t | nr_packet_encode (RADIUS_PACKET *packet, const RADIUS_PACKET *original) |
int | nr_packet_walk (RADIUS_PACKET *packet, void *ctx, nr_packet_walk_func_t callback) |
int | nr_packet_init (RADIUS_PACKET *packet, const RADIUS_PACKET *original, const char *secret, int code, void *data, size_t sizeof_data) |
ssize_t | nr_packet_attr_append (RADIUS_PACKET *packet, const RADIUS_PACKET *original, const DICT_ATTR *da, const void *data, size_t data_len) |
ssize_t | nr_packet_vps_append (RADIUS_PACKET *packet, const RADIUS_PACKET *original, const VALUE_PAIR *vps) |
int | nr_packet_response_ok (RADIUS_PACKET const *packet, RADIUS_PACKET const *response) |
Variables | |
const char * | nr_packet_codes [NR_MAX_PACKET_CODE+1] |
Encoding and decoding packets.
#define _allow | ( | _x | ) | (((uint64_t) 1) << _x) |
#define append_ma | ( | _x | ) | (0) |
Referenced by nr_packet_encode().
ssize_t nr_packet_attr_append | ( | RADIUS_PACKET * | packet, |
const RADIUS_PACKET * | original, | ||
const DICT_ATTR * | da, | ||
const void * | data, | ||
size_t | data_len | ||
) |
Add one attribute to the packet.
This function can be used to add "raw" data to a packet. It allows the caller to extend the RADIUS packet without using a VALUE_PAIR data structure.
Some attributes are handled specially by this function.
EAP-Message. This attribute is automatically split into 253-octet chunks.
User-Password, CHAP-Password, and Message-Authenticator. These attributes are automatically encrypted, as is done by nr_packet_encode().
[in] | packet | The packet to edit |
[in] | original | The original request (if any) |
[in] | da | Pointer to the attribute definition |
[in] | data | Data to append to the packet |
[in] | data_len | Length of data to append to the packet |
References nr_dict_attr::attr, radius_packet::data, nr_dict_attr::flags, radius_packet::flags, attr_flags::length, radius_packet::length, NR_PACKET_ENCODED, NR_TYPE_STRING, nr_vp2attr(), nr_vp_init(), nr_vp_set_data(), PW_EAP_MESSAGE, return_NR_ERR, radius_packet::sizeof_data, nr_dict_attr::type, and nr_dict_attr::vendor.
Referenced by main().
int nr_packet_init | ( | RADIUS_PACKET * | packet, |
const RADIUS_PACKET * | original, | ||
const char * | secret, | ||
int | code, | ||
void * | data, | ||
size_t | sizeof_data | ||
) |
Initialize a packet
If original is specified, the packet is initialized as a response to the original request.
[in,out] | packet | The packet to initialize |
[in] | original | The original request (if any) to use as a template |
[in] | secret | Shared secret |
[in] | code | RADIUS Code field. |
[in] | data | Buffer where packets will be stored (RADIUS_PACKET::data) |
[in] | sizeof_data | Size of buffer (RADIUS_PACKET::sizeof_data) |
References radius_packet::code, radius_packet::data, radius_packet::id, radius_packet::length, NR_MAX_PACKET_CODE, nr_packet_can_encode(), return_NR_ERR, radius_packet::secret, radius_packet::sizeof_data, and radius_packet::sizeof_secret.
Referenced by main(), and nr_track_id_packet_alloc().
ssize_t nr_packet_vps_append | ( | RADIUS_PACKET * | packet, |
const RADIUS_PACKET * | original, | ||
const VALUE_PAIR * | vps | ||
) |
Add many VALUE_PAIR structures to a packet
Some attributes are handled specially by this function.
User-Password, CHAP-Password, and Message-Authenticator. These attributes are automatically encrypted, as is done by nr_packet_encode().
[in] | packet | The packet to edit |
[in] | original | The original request (if any) |
[in] | vps | The VALUE_PAIR list to append to the packet |
References radius_packet::data, radius_packet::flags, radius_packet::length, NR_PACKET_ENCODED, nr_vp2attr(), return_NR_ERR, and radius_packet::sizeof_data.
Referenced by nr_packet_encode().