networkclient
Print / parse functions

Functions

void nr_packet_print_hex (RADIUS_PACKET *packet)
 
size_t nr_vp_snprintf (char *buffer, size_t bufsize, const VALUE_PAIR *vp)
 
size_t nr_vp_snprintf_value (char *buffer, size_t bufsize, const VALUE_PAIR *vp)
 
void nr_vp_fprintf_list (FILE *fp, const VALUE_PAIR *vps)
 
int nr_vp_sscanf (const char *string, VALUE_PAIR **pvp)
 
ssize_t nr_vp_sscanf_value (VALUE_PAIR *vp, const char *value)
 

Detailed Description

These routines convert the internal data structures to a printable form, or parse them.

Function Documentation

void nr_packet_print_hex ( RADIUS_PACKET packet)

Pretty-prints a hex dump of a RADIUS packet.

This function is available only in debugging builds of the library. It is useful during development, but should not be used in a production system.

The packet headers are printed individually, and each attribute is printed as "type length data..."

Parameters
[in]packetThe RADIUS packet to print

References radius_packet::data, radius_packet::flags, radius_packet::length, NR_MAX_PACKET_CODE, nr_packet_codes, NR_PACKET_SIGNED, and NR_PACKET_VERIFIED.

Referenced by main().

void nr_vp_fprintf_list ( FILE *  fp,
const VALUE_PAIR vps 
)

Prints a list of :VALUE_PAIR structures to the given output.

Parameters
[in]fpWhere to print the results
[in]vpsLinked list of VALUE_PAIR to print

References value_pair::next, and nr_vp_snprintf().

Referenced by main().

Here is the call graph for this function:

size_t nr_vp_snprintf ( char *  buffer,
size_t  bufsize,
const VALUE_PAIR vp 
)

Pretty-print the entire VALUE_PAIR

All data is printed in ASCII format. The data type of "octets" is printed as a hex string (e.g. 0xabcdef01...). The data type of "ipaddr" is printed as a dotted-quad (e.g. 192.0.2.15).

The format is "Attribute-Name = value"

Parameters
[out]bufferWhere the printable version of the VALUE_PAIR is stored
[in]bufsizesize of the output buffer
[in]vpVALUE_PAIR to print
Returns
length of data in buffer

References value_pair::da, nr_dict_attr::name, and nr_vp_snprintf_value().

Referenced by nr_vp_fprintf_list().

Here is the call graph for this function:

size_t nr_vp_snprintf_value ( char *  buffer,
size_t  bufsize,
const VALUE_PAIR vp 
)

Pretty-print the VALUE_PAIR::data field

Prints the value of a VALUE_PAIR, without the name or "=" sign.

Parameters
[out]bufferWhere the printable version of the VALUE_PAIR is stored
[in]bufsizesize of the output buffer
[in]vpVALUE_PAIR to print
Returns
length of data in buffer

References value_pair::da, value_pair::length, NR_TYPE_BYTE, NR_TYPE_DATE, NR_TYPE_IFID, NR_TYPE_INTEGER, NR_TYPE_INTEGER64, NR_TYPE_IPADDR, NR_TYPE_IPV6ADDR, NR_TYPE_OCTETS, NR_TYPE_SHORT, NR_TYPE_STRING, return_NR_ERR, and nr_dict_attr::type.

Referenced by nr_vp_snprintf().

int nr_vp_sscanf ( const char *  string,
VALUE_PAIR **  pvp 
)

Scan a string into a VALUE_PAIR. The counterpart to nr_vp_snprintf_value()

Parameters
[in]stringPrintable version of the VALUE_PAIR
[out]pvpNewly allocated VALUE_PAIR
Returns
<0 on error, 0 for success.

References nr_debug_error, nr_dict_attr_byname(), nr_vp_alloc(), nr_vp_free(), nr_vp_sscanf_value(), and return_NR_ERR.

Here is the call graph for this function:

ssize_t nr_vp_sscanf_value ( VALUE_PAIR vp,
const char *  value 
)

Scan the data portion of a VALUE_PAIR. The counterpart to nr_vp_snprintf_value()

Parameters
[in,out]vpThe VALUE_PAIR where the data will be stored
[in]valueThe string version of the data to be parsed
Returns
<0 on error, >=0 for the number of characters parsed in value.

References value_pair::da, value_pair::length, nr_debug_error, NR_TYPE_BYTE, NR_TYPE_DATE, NR_TYPE_IFID, NR_TYPE_INTEGER, NR_TYPE_INTEGER64, NR_TYPE_IPADDR, NR_TYPE_IPV6ADDR, NR_TYPE_SHORT, NR_TYPE_STRING, return_NR_ERR, and nr_dict_attr::type.

Referenced by nr_vp_sscanf().