networkclient
Portability Functions

Files

file  porting.txt
 

Macros

#define NR_MD5_CTX   MD5_CTX
 
#define nr_MD5Init   MD5_Init
 
#define nr_MD5Update   MD5_Update
 
#define nr_MD5Final   MD5_Final
 
#define nr_MD5Transform   MD5_Transform
 
#define NR_MAX_PACKET_LEN   (4096)
 
#define NR_MAX_ATTRIBUTES   (200)
 

Functions

ssize_t nr_rand_bytes (uint8_t *data, size_t data_len)
 
uint32_t nr_rand (void)
 
void nr_timeval_add (struct timeval *t, unsigned int seconds, unsigned int usec)
 
int nr_timeval_cmp (const struct timeval *a, const struct timeval *b)
 

Detailed Description

These functions and definitions should be modified for your local system. See the individual definitions for details.

Macro Definition Documentation

#define NR_MAX_ATTRIBUTES   (200)

The maximum number of attributes that the library will allow in a packet.

Packets which contain more than NR_MAX_ATTRIBUTES will generate an error. This value is configurable because there may be a need to accept a large mumber of attributes.

This value is ignored when packets are sent. The library will send as many attributes as it is told to send.

Referenced by nr_packet_decode().

#define NR_MAX_PACKET_LEN   (4096)

The maximum size of a packet that the library will send or receive.

The RFC requirement is to handle at least 4K packets. However, if you expect to only do username/password authentication, this value can be set to a smaller value, such as 256.

Be warned that any packets larger than this value will be ignored and silently discarded.

Referenced by nr_packet_ok_raw(), nr_socket_recv(), and nr_track_id_packet_alloc().

#define NR_MD5_CTX   MD5_CTX

Define for compile-time selection of the MD5 functions. Defaults to using the OpenSSL functions.

Referenced by nr_hmac_md5(), nr_packet_sign(), nr_password_encrypt(), nr_tunnelpw_decrypt(), and nr_tunnelpw_encrypt().

#define nr_MD5Final   MD5_Final

Define for compile-time selection of the MD5 functions. Defaults to using the OpenSSL functions.

Referenced by nr_hmac_md5(), nr_packet_sign(), nr_password_encrypt(), nr_tunnelpw_decrypt(), and nr_tunnelpw_encrypt().

#define nr_MD5Init   MD5_Init

Define for compile-time selection of the MD5 functions. Defaults to using the OpenSSL functions.

Referenced by nr_hmac_md5(), nr_packet_sign(), nr_password_encrypt(), nr_tunnelpw_decrypt(), and nr_tunnelpw_encrypt().

#define nr_MD5Transform   MD5_Transform

Define for compile-time selection of the MD5 functions. Defaults to using the OpenSSL functions.

#define nr_MD5Update   MD5_Update

Define for compile-time selection of the MD5 functions. Defaults to using the OpenSSL functions.

Referenced by nr_hmac_md5(), nr_packet_sign(), nr_password_encrypt(), nr_tunnelpw_decrypt(), and nr_tunnelpw_encrypt().

Function Documentation

uint32_t nr_rand ( void  )

Return a random 32-bit integer.

This function should be replaced by one that is specific to your system. The version supplied here just calls nr_rand_bytes() each time, which is slow.

This is a wrapper function which enables the library to be more portable.

Returns
An unsigned 32-bit random integer.

References nr_rand_bytes().

Referenced by main(), and nr_tunnelpw_encrypt().

Here is the call graph for this function:

ssize_t nr_rand_bytes ( uint8_t *  data,
size_t  data_len 
)

Return the given number of random bytes.

This function should be replaced by one that is specific to your system.

This is a wrapper function which enables the library to be more portable.

Parameters
[in]dataLocation where the random bytes will be stored
[in]data_lenNumber of bytes to store
Returns
<0 on error, or the total number of bytes stored.

References nr_strerror_printf().

Referenced by nr_rand().

Here is the call graph for this function:

void nr_timeval_add ( struct timeval *  t,
unsigned int  seconds,
unsigned int  usec 
)

Add a time to the given struct timeval.

This is a wrapper function which enables the library to be more portable.

Parameters
[in,out]tThe timeval to which the time is added.
[in]secondsTime in seconds to add
[in]usecTime in microseconds to add

References USEC.

int nr_timeval_cmp ( const struct timeval *  a,
const struct timeval *  b 
)

Compare two times.

This is a wrapper function which enables the library to be more portable.

Parameters
[in]aOne timeval
[in]bAnother one
Returns
a <=> b