networkclient
Request / response handling

Data Structures

struct  nr_retransmit_config_t
 

Typedefs

typedef enum nr_transmit_state_t nr_transmit_state_t
 
typedef struct nr_retransmit_config_t nr_retransmit_config_t
 

Enumerations

enum  nr_transmit_state_t {
  NR_TRANSMIT_NONE = 0, NR_TRANSMIT_INITIAL, NR_TRANSMIT_TIMEOUT, NR_TRANSMIT_HAVE_RESPONSE,
  NR_TRANSMIT_SEND, NR_TRANSMIT_CONTINUE, NR_TRANSMIT_RESPONSE_OK, NR_TRANSMIT_NO_RESPONSE
}
 

Functions

int nr_transmit_init (nr_track_id_t *s, RADIUS_PACKET *request)
 
int nr_transmit (nr_track_id_t *s, struct timeval *when, RADIUS_PACKET *request, RADIUS_PACKET *response)
 

Detailed Description

These routines manage RADIUS retransmits, multiple simultaneous packets, etc. These routines are not part of the BSD licensed RADIUS library.

Typedef Documentation

Configuration for retransmitting a request.

See RFC 5080 Section 2.2.1 for the meaning of the individual fields. The times given in these fields are used as a basis for the calculations, and are not fixed (i.e. absolute) values. The RFC requires that "jitter" be added, so that retransmissions do not "clump" together.

The functions that take this structure as an argument also accept a NULL pointer instead of a pointer to this structure. In that case, those functions use "default" values. You should nearly always use NULL, as changing the default values is not recommended.

If you do need to change these value, we recommend first changing only nr_transmit_config_t::mrd, to set the maximum retransmit duration. Set the other values to the defaults recommended below.

It is possible to change the nr_transmit_config_t::mrc field, but we recommend always leaving it at the default value.

The nr_transmit_config_t::irt and nr_retransmit_config_t::mrt fields should never be changed from the defaults. They are here solely for completeness of the API.

The state of a packet being sent from a client to a server.

Enumeration Type Documentation

The state of a packet being sent from a client to a server.

Enumerator
NR_TRANSMIT_NONE 
NR_TRANSMIT_INITIAL 

The initial state

NR_TRANSMIT_TIMEOUT 

We timed out waiting for a packet

NR_TRANSMIT_HAVE_RESPONSE 

We (may) have a response

NR_TRANSMIT_SEND 

The caller should (re) send the packet

NR_TRANSMIT_CONTINUE 

The caller should continue waiting

NR_TRANSMIT_RESPONSE_OK 

The response is a valid one

NR_TRANSMIT_NO_RESPONSE 

Timeout out waiting for a response

Function Documentation

int nr_transmit ( nr_track_id_t s,
struct timeval *  when,
RADIUS_PACKET request,
RADIUS_PACKET response 
)

Transmits a request om a client to a server, and updates timers to wait for the reply.

The RADIUS_PACKET::state field should be set before this function is called. It should be examined when the function returns. For RADIUS over TCP, reading from the socket will return 0 bytes when the server has closed the TCP connection. That condition can happens when RADIUS_PACKET::state is NR_TRANSMIT_CONTINUE, and the function returns 0. It returns 1 when it re-sends a request.

We strongly recommend using this API to get tranmission timers. It follows the relevant RFCs, and is intended to be robust and simple. All other "ad hoc" methods are more fragile and cause problems.

Parameters
[in]sThe transmission tracking structure.
[in,out]whenOn input, the time of "now". On output, the next time that nr_transmit() should be called.
[in]requestThe packet to transmit
[in]responseThe response which was received.
Returns
<0 on error, >= for success.

References NR_TRANSMIT_HAVE_RESPONSE, NR_TRANSMIT_INITIAL, NR_TRANSMIT_TIMEOUT, return_NR_ERR, and radius_packet::state.

int nr_transmit_init ( nr_track_id_t s,
RADIUS_PACKET request 
)

Initialize a RADIUS_PACKET structure for sending.

Parameters
[in]sThe server to which we send packets.
[in]requestThe packet to transmit
Returns
<0 on error, 0 for success

References radius_packet::attempts, radius_packet::delay, NR_TRANSMIT_INITIAL, return_NR_ERR, radius_packet::secret, nr_track_id_t::secret, radius_packet::sizeof_secret, nr_track_id_t::sizeof_secret, and radius_packet::state.

Referenced by main().