networkclient
Error handling

Typedefs

typedef enum nr_error_t nr_error_t
 

Enumerations

enum  nr_error_t {
  NR_ERR_INVALID_ARG = 1, NR_ERR_PACKET_TOO_SMALL, NR_ERR_PACKET_TOO_LARGE, NR_ERR_PACKET_CODE_UNKNOWN,
  NR_ERR_ATTR_OVERFLOW, NR_ERR_ATTR_TOO_SMALL, NR_ERR_ATTR_TOO_LARGE, NR_ERR_ATTR_UNKNOWN,
  NR_ERR_ATTR_BAD_NAME, NR_ERR_ATTR_VALUE_MALFORMED, NR_ERR_ATTR_INVALID, NR_ERR_TOO_MANY_ATTRS,
  NR_ERR_ATTR_TYPE_UNKNOWN, NR_ERR_MSG_AUTH_LEN, NR_ERR_MSG_AUTH_WRONG, NR_ERR_REQUEST_REQUIRED,
  NR_ERR_REQUEST_CODE_INVALID, NR_ERR_AUTH_VECTOR_WRONG, NR_ERR_RESPONSE_CODE_INVALID, NR_ERR_RESPONSE_ID_INVALID,
  NR_ERR_RESPONSE_SRC_INVALID, NR_ERR_SYSTEM, NR_ERR_NO_PACKET_DATA, NR_ERR_VENDOR_UNKNOWN,
  NR_ERR_INTERNAL_FAILURE, NR_ERR_UNSUPPORTED, NR_ERR_NO_FREE_ID, NR_ERR_NO_MEM,
  NR_ERR_IN_USE, NR_ERR_PACKET_UNSIGNED
}
 

Functions

const char * nr_strerror (int error)
 
void nr_strerror_printf (const char *fmt,...)
 

Detailed Description

These definitions and routines manage errors.

Typedef Documentation

typedef enum nr_error_t nr_error_t

Error codes

The numerical value of these definitions may change from version to version of the library.

Enumeration Type Documentation

enum nr_error_t

Error codes

The numerical value of these definitions may change from version to version of the library.

Enumerator
NR_ERR_INVALID_ARG 

Invalid argument

NR_ERR_PACKET_TOO_SMALL 

Insufficient data to decode the packet

NR_ERR_PACKET_TOO_LARGE 

The packet header says it is larger than the received data

NR_ERR_PACKET_CODE_UNKNOWN 

The packet code is unknown

NR_ERR_ATTR_OVERFLOW 

the attribute overflows the packet

NR_ERR_ATTR_TOO_SMALL 

the attribute header "length" field is too small

NR_ERR_ATTR_TOO_LARGE 

the attribute is more than 256 octets long

NR_ERR_ATTR_UNKNOWN 

the attribute is unknown

NR_ERR_ATTR_BAD_NAME 

the attribute name is improperly formatted

NR_ERR_ATTR_VALUE_MALFORMED 

the attribute value could not be parsed

NR_ERR_ATTR_INVALID 

the attribute "type" is invalid

NR_ERR_TOO_MANY_ATTRS 

the packet has too many attributes

NR_ERR_ATTR_TYPE_UNKNOWN 

the attribute has an unsupported data type

NR_ERR_MSG_AUTH_LEN 

the Message-Authenticator has the wrong length

NR_ERR_MSG_AUTH_WRONG 

the Message-Authenticator is wrong

NR_ERR_REQUEST_REQUIRED 

we need a request packet to calculate something in the response

NR_ERR_REQUEST_CODE_INVALID 

the request code is unsupported

NR_ERR_AUTH_VECTOR_WRONG 

the Authentication Vector is wrong

NR_ERR_RESPONSE_CODE_INVALID 

the response code is unsupported

NR_ERR_RESPONSE_ID_INVALID 

the response ID field is invalid

NR_ERR_RESPONSE_SRC_INVALID 

the response is not from the correct source IP/port

NR_ERR_SYSTEM 

Look at "errno" for the error

NR_ERR_NO_PACKET_DATA 

We cannot encode the packet because of invalid arguments

NR_ERR_VENDOR_UNKNOWN 

the vendor is unknown

NR_ERR_INTERNAL_FAILURE 

an internal sanity check failed

NR_ERR_UNSUPPORTED 

the caller requested an unsupported featuer

NR_ERR_NO_FREE_ID 

we were unable to allocate an ID

NR_ERR_NO_MEM 

we were unable to allocate memory

NR_ERR_IN_USE 

Resource is in use

NR_ERR_PACKET_UNSIGNED 

Packet is not signed

Function Documentation

const char* nr_strerror ( int  error)

Return a printable error message.

This function returns a string describing the last error that occurred. These messages are intended for developers, and are not suitable for display to an end user. The application using this library should instead produce a "summary" message when an error occurs. e.g. "Failed to receive a response", is better than messages produced by this function, which contain text like "invalid response authentication vector". The first is understandable, the second is not.

Parameters
[in]errorThe error code (can be less than zero)
Returns
A printable string describing the error.

References NR_ERR_ATTR_BAD_NAME, NR_ERR_ATTR_INVALID, NR_ERR_ATTR_OVERFLOW, NR_ERR_ATTR_TOO_LARGE, NR_ERR_ATTR_TOO_SMALL, NR_ERR_ATTR_TYPE_UNKNOWN, NR_ERR_ATTR_UNKNOWN, NR_ERR_ATTR_VALUE_MALFORMED, NR_ERR_AUTH_VECTOR_WRONG, NR_ERR_IN_USE, NR_ERR_INTERNAL_FAILURE, NR_ERR_INVALID_ARG, NR_ERR_MSG_AUTH_LEN, NR_ERR_MSG_AUTH_WRONG, NR_ERR_NO_FREE_ID, NR_ERR_NO_MEM, NR_ERR_NO_PACKET_DATA, NR_ERR_PACKET_CODE_UNKNOWN, NR_ERR_PACKET_TOO_LARGE, NR_ERR_PACKET_TOO_SMALL, NR_ERR_PACKET_UNSIGNED, NR_ERR_REQUEST_CODE_INVALID, NR_ERR_REQUEST_REQUIRED, NR_ERR_RESPONSE_CODE_INVALID, NR_ERR_RESPONSE_ID_INVALID, NR_ERR_RESPONSE_SRC_INVALID, NR_ERR_SYSTEM, NR_ERR_TOO_MANY_ATTRS, NR_ERR_UNSUPPORTED, and NR_ERR_VENDOR_UNKNOWN.

Referenced by main().

void nr_strerror_printf ( const char *  fmt,
  ... 
)

Record a humanly readable error message.

Attention
This structure should only be accessed by internal RADIUS library functions.
Parameters
[in]fmtThe format to use.

Referenced by nr_rand_bytes(), nr_socket_open(), nr_vp_alloc(), and nr_vp_alloc_raw().