networkclient
|
Data Structures | |
struct | nr_track_id_t |
Typedefs | |
typedef struct nr_track_id_t | nr_track_id_t |
Functions | |
int | nr_track_id_init (nr_track_id_t *s, int code, const char *secret) |
int | nr_track_id_close (const nr_track_id_t *s) |
int | nr_track_id_alloc (nr_track_id_t *s, RADIUS_PACKET *packet) |
int | nr_track_id_realloc (nr_track_id_t *s, RADIUS_PACKET *packet) |
int | nr_track_id_release (nr_track_id_t *s, RADIUS_PACKET *packet) |
int | nr_track_id_packet_alloc (nr_track_id_t *s, RADIUS_PACKET **packet_p, RADIUS_PACKET *original, size_t sizeof_data) |
These routines manage RADIUS ID allocation.
typedef struct nr_track_id_t nr_track_id_t |
Track packets sent to a server.
This data structure tracks Identifiers which are used to communicate with a particular destination server. The application should call nr_track_id_init() to initialize it. If necessary, the application should then call nr_track_id_set_ipv4() to open an IPv4 socket to the server.
If the RADIUS packets are being transported over an encapsulation layer (e.g. RADIUS over TLS), then nr_track_id_set_ipv4() does not need to be called. The nr_track_id_t structure should instead be associated wih the TLS session / socket.
int nr_track_id_alloc | ( | nr_track_id_t * | s, |
RADIUS_PACKET * | packet | ||
) |
Allocate a RADIUS_PACKET::id value for sending a packet to a server.
This function allocates a RADIUS_PACKET::id from the nr_track_id_t structure. It also fills in the RADIUS_PACKET::sockfd, RADIUS_PACKET::code, and RADIUS_PACKET::dst fields.
[in] | s | The server structure which tracks the ID |
[in] | packet | The packet which needs an ID |
References radius_packet::code, nr_track_id_t::code, radius_packet::dst, nr_track_id_t::dst, radius_packet::id, nr_track_id_t::ids, return_NR_ERR, radius_packet::sockfd, nr_track_id_t::sockfd, radius_packet::src, nr_track_id_t::src, and nr_track_id_t::used.
Referenced by main(), and nr_track_id_packet_alloc().
int nr_track_id_close | ( | const nr_track_id_t * | s | ) |
Closes an nr_track_id_t data structure.
Ensures that all IDs are free, and closes the socket.
[in] | s | The server structure to close. |
References return_NR_ERR, nr_track_id_t::sockfd, and nr_track_id_t::used.
Referenced by main().
int nr_track_id_init | ( | nr_track_id_t * | s, |
int | code, | ||
const char * | secret | ||
) |
Initializes an nr_track_id_t.
This function performs some simple initialization. See nr_track_id_socket() for initialization of the nr_track_id_t::src and nr_track_id_t::dst fields, if needed.
[in,out] | s | The nr_track_id_t to initialize |
[in] | code | The packet code used for packets sent to this server |
[in] | secret | The shared secret used for packet sent to this server |
References nr_track_id_t::code, nr_track_id_t::ctx, nr_track_id_t::dst, NR_MAX_PACKET_CODE, nr_track_id_t::packet_send, PW_ACCOUNTING_REQUEST, return_NR_ERR, nr_track_id_t::secret, nr_track_id_t::sizeof_secret, nr_track_id_t::sockfd, nr_track_id_t::src, and nr_track_id_t::timers.
Referenced by main().
int nr_track_id_packet_alloc | ( | nr_track_id_t * | s, |
RADIUS_PACKET ** | packet_p, | ||
RADIUS_PACKET * | original, | ||
size_t | sizeof_data | ||
) |
Allocates a packet using malloc(), and initializes it.
It also allocates an ID for the packet.
[in] | s | The server structure |
[in,out] | packet_p | Pointer to the RADIUS_PACKET to be allocated |
[in] | original | Pointer to the original packet (if any) |
[in] | sizeof_data | Maximum expected size of packet. (0 menans NR_MAX_PACKET_LEN) |
References nr_track_id_t::code, NR_MAX_PACKET_LEN, nr_packet_init(), nr_track_id_alloc(), PW_ACCESS_ACCEPT, PW_ACCESS_REQUEST, PW_ACCOUNTING_REQUEST, PW_ACCOUNTING_RESPONSE, PW_COA_ACK, PW_COA_REQUEST, PW_DISCONNECT_ACK, PW_DISCONNECT_REQUEST, return_NR_ERR, and nr_track_id_t::secret.
Referenced by main().
int nr_track_id_realloc | ( | nr_track_id_t * | s, |
RADIUS_PACKET * | packet | ||
) |
Re-allocate a RADIUS_PACKET::id value for sending a packet to a server.
It is used when retransmitting an Accounting-Request packet to a server, after updating the Acct-Delay-Time field. The "realloc" name means that the new ID is allocated, and is different from the old one.
Note that after the ID has been allocated, the nr_packet_sign() function MUST be called in order to update the packet signature.
[in] | s | The server structure which tracks the ID |
[in] | packet | The packet which needs a new ID |
References radius_packet::id, nr_track_id_t::ids, and return_NR_ERR.
int nr_track_id_release | ( | nr_track_id_t * | s, |
RADIUS_PACKET * | packet | ||
) |
Releases a RADIUS_PACKET::id value after sending a packet to a server.
[in] | s | The server structure which tracks the ID |
[in] | packet | The packet which has an ID, and wants to free it |
References radius_packet::id, nr_track_id_t::ids, return_NR_ERR, radius_packet::sockfd, and nr_track_id_t::used.
Referenced by nr_track_id_packet_free().