libnl 3.11.0

Data Structures

struct  nl_dump_params
 Dumping parameters. More...
 

Enumerations

enum  nl_dump_type {
  NL_DUMP_LINE ,
  NL_DUMP_DETAILS ,
  NL_DUMP_STATS ,
  __NL_DUMP_MAX
}
 Enumeration of dumping variations (dp_type) More...
 

Variables

int nl_debug = 0
 Global variable indicating the desired level of debugging output.
 

Generic Unit Translations

long nl_size2int (const char *str)
 Convert a character string to a size.
 
char * nl_size2str (const size_t size, char *buf, const size_t len)
 Convert a size toa character string.
 
long nl_prob2int (const char *str)
 Convert a character string to a probability.
 

Time Translations

int nl_get_user_hz (void)
 Return the value of HZ.
 
int nl_get_psched_hz (void)
 Return the value of packet scheduler HZ.
 
uint32_t nl_us2ticks (uint32_t us)
 Convert micro seconds to ticks.
 
uint32_t nl_ticks2us (uint32_t ticks)
 Convert ticks to micro seconds.
 
int nl_str2msec (const char *str, uint64_t *result)
 
char * nl_msec2str (uint64_t msec, char *buf, size_t len)
 Convert milliseconds to a character string.
 
#define USER_HZ   100
 

Netlink Family Translations

char * nl_nlfamily2str (int family, char *buf, size_t size)
 
int nl_str2nlfamily (const char *name)
 

Link Layer Protocol Translations

char * nl_llproto2str (int llproto, char *buf, size_t len)
 
int nl_str2llproto (const char *name)
 

Ethernet Protocol Translations

char * nl_ether_proto2str (int eproto, char *buf, size_t len)
 
int nl_str2ether_proto (const char *name)
 

Run-time version information

const int nl_ver_num = LIBNL_VER_NUM
 
const int nl_ver_maj = LIBNL_VER_MAJ
 
const int nl_ver_min = LIBNL_VER_MIN
 
const int nl_ver_mic = LIBNL_VER_MIC
 

Pretty Printing of Numbers

double nl_cancel_down_bytes (unsigned long long l, char **unit)
 Cancel down a byte counter.
 
double nl_cancel_down_bits (unsigned long long l, char **unit)
 Cancel down a bit counter.
 
int nl_rate2str (unsigned long long rate, int type, char *buf, size_t len)
 
double nl_cancel_down_us (uint32_t l, char **unit)
 Cancel down a micro second value.
 

IP Protocol Translations

char * nl_ip_proto2str (int proto, char *buf, size_t len)
 
int nl_str2ip_proto (const char *name)
 

Dumping Helpers

void nl_new_line (struct nl_dump_params *params)
 Handle a new line while dumping.
 
void nl_dump (struct nl_dump_params *params, const char *fmt,...)
 Dump a formatted character string.
 
void nl_dump_line (struct nl_dump_params *parms, const char *fmt,...)
 

Probability Constants

#define NL_PROB_MIN   0x0
 Lower probability limit.
 
#define NL_PROB_MAX   0xffffffff
 Upper probability limit nl_dump_type.
 

Detailed Description

Collection of helper functions

Header

#include <netlink/utils.h>

Run-time version information

Macro Definition Documentation

◆ USER_HZ

#define USER_HZ   100

Definition at line 473 of file utils.c.

◆ NL_PROB_MIN

#define NL_PROB_MIN   0x0

Lower probability limit.

Definition at line 31 of file utils.h.

◆ NL_PROB_MAX

#define NL_PROB_MAX   0xffffffff

Upper probability limit nl_dump_type.

Definition at line 37 of file utils.h.

Referenced by nl_prob2int().

Enumeration Type Documentation

◆ nl_dump_type

Enumeration of dumping variations (dp_type)

Enumerator
NL_DUMP_LINE 

Dump object briefly on one line.

NL_DUMP_DETAILS 

Dump all attributes but no statistics.

NL_DUMP_STATS 

Dump all attributes including statistics.

Definition at line 19 of file types.h.

Function Documentation

◆ nl_cancel_down_bytes()

double nl_cancel_down_bytes ( unsigned long long l,
char ** unit )

Cancel down a byte counter.

Parameters
lbyte counter
unitdestination unit pointer

Cancels down a byte counter until it reaches a reasonable unit. The chosen unit is assigned to unit. This function assume 1024 bytes in one kilobyte

Returns
The cancelled down byte counter in the new unit.

Definition at line 223 of file utils.c.

◆ nl_cancel_down_bits()

double nl_cancel_down_bits ( unsigned long long l,
char ** unit )

Cancel down a bit counter.

Parameters
lbit counter
unitdestination unit pointer

Cancels down bit counter until it reaches a reasonable unit. The chosen unit is assigned to unit. This function assume 1000 bits in one kilobit

Returns
The cancelled down bit counter in the new unit.

Definition at line 254 of file utils.c.

◆ nl_rate2str()

int nl_rate2str ( unsigned long long rate,
int type,
char * buf,
size_t len )

Definition at line 280 of file utils.c.

◆ nl_cancel_down_us()

double nl_cancel_down_us ( uint32_t l,
char ** unit )

Cancel down a micro second value.

Parameters
lmicro seconds
unitdestination unit pointer

Cancels down a microsecond counter until it reaches a reasonable unit. The chosen unit is assigned to unit.

Returns
The cancelled down microsecond in the new unit

Definition at line 311 of file utils.c.

◆ nl_size2int()

long nl_size2int ( const char * str)

Convert a character string to a size.

Parameters
strsize encoded as character string

Converts the specified size as character to the corresponding number of bytes.

Supported formats are:

  • b,kb/k,m/mb,gb/g for bytes
  • bit,kbit/mbit/gbit

This function assume 1000 bits in one kilobit and 1024 bytes in one kilobyte

Returns
The number of bytes or -1 if the string is unparseable

Definition at line 348 of file utils.c.

◆ nl_size2str()

char * nl_size2str ( const size_t size,
char * buf,
const size_t len )

Convert a size toa character string.

Parameters
sizeSize in number of bytes
bufBuffer to write character string to
lenSize of buf

This function converts a value in bytes to a human readable representation of it. The function uses IEC prefixes:

1024 bytes => 1 KiB
1048576 bytes => 1 MiB

The highest prefix is used which ensures a result of >= 1.0, the result is provided as floating point number with a maximum precision of 2 digits:

965176 bytes => 942.55 KiB
Returns
pointer to buf

Definition at line 411 of file utils.c.

◆ nl_prob2int()

long nl_prob2int ( const char * str)

Convert a character string to a probability.

Parameters
strprobability encoded as character string

Converts the specified probability as character to the corresponding probability number.

Supported formats are:

  • 0.0-1.0
  • 0%-100%
Returns
The probability relative to NL_PROB_MIN and NL_PROB_MAX

Definition at line 445 of file utils.c.

References NL_PROB_MAX.

◆ nl_get_user_hz()

int nl_get_user_hz ( void )

Return the value of HZ.

Definition at line 562 of file utils.c.

◆ nl_get_psched_hz()

int nl_get_psched_hz ( void )

Return the value of packet scheduler HZ.

Definition at line 571 of file utils.c.

◆ nl_us2ticks()

uint32_t nl_us2ticks ( uint32_t us)

Convert micro seconds to ticks.

Parameters
usmicro seconds
Returns
number of ticks

Definition at line 582 of file utils.c.

Referenced by rtnl_netem_set_delay(), rtnl_netem_set_jitter(), rtnl_qdisc_tbf_set_peakrate(), rtnl_qdisc_tbf_set_rate(), and rtnl_tc_build_rate_table().

+ Here is the caller graph for this function:

◆ nl_ticks2us()

uint32_t nl_ticks2us ( uint32_t ticks)

Convert ticks to micro seconds.

Parameters
ticksnumber of ticks
Returns
microseconds

Definition at line 594 of file utils.c.

Referenced by rtnl_netem_get_delay(), and rtnl_netem_get_jitter().

+ Here is the caller graph for this function:

◆ nl_str2msec()

int nl_str2msec ( const char * str,
uint64_t * result )

Definition at line 600 of file utils.c.

◆ nl_msec2str()

char * nl_msec2str ( uint64_t msec,
char * buf,
size_t len )

Convert milliseconds to a character string.

Parameters
msecnumber of milliseconds
bufdestination buffer
lenbuffer length

Converts milliseconds to a character string split up in days, hours, minutes, seconds, and milliseconds and stores it in the specified destination buffer.

Returns
The destination buffer.

Definition at line 648 of file utils.c.

◆ nl_nlfamily2str()

char * nl_nlfamily2str ( int family,
char * buf,
size_t size )

Definition at line 711 of file utils.c.

◆ nl_str2nlfamily()

int nl_str2nlfamily ( const char * name)

Definition at line 717 of file utils.c.

◆ nl_llproto2str()

char * nl_llproto2str ( int llproto,
char * buf,
size_t len )

Definition at line 812 of file utils.c.

◆ nl_str2llproto()

int nl_str2llproto ( const char * name)

Definition at line 817 of file utils.c.

◆ nl_ether_proto2str()

char * nl_ether_proto2str ( int eproto,
char * buf,
size_t len )

Definition at line 902 of file utils.c.

◆ nl_str2ether_proto()

int nl_str2ether_proto ( const char * name)

Definition at line 908 of file utils.c.

◆ nl_ip_proto2str()

char * nl_ip_proto2str ( int proto,
char * buf,
size_t len )

Definition at line 920 of file utils.c.

◆ nl_str2ip_proto()

int nl_str2ip_proto ( const char * name)

Definition at line 929 of file utils.c.

◆ nl_new_line()

void nl_new_line ( struct nl_dump_params * params)

Handle a new line while dumping.

Parameters
paramsDumping parameters

This function must be called before dumping any onto a new line. It will ensure proper prefixing as specified by the dumping parameters.

Note
This function will NOT dump any newlines itself

Definition at line 966 of file utils.c.

References nl_dump_params::dp_buf, nl_dump_params::dp_buflen, nl_dump_params::dp_fd, nl_dump_params::dp_nl_cb, and nl_dump_params::dp_prefix.

◆ nl_dump()

void nl_dump ( struct nl_dump_params * params,
const char * fmt,
... )

Dump a formatted character string.

Parameters
paramsDumping parameters
fmtprintf style formatting string
...Arguments to formatting string

Dumps a printf style formatting string to the output device as specified by the dumping parameters.

Definition at line 1015 of file utils.c.

◆ nl_dump_line()

void nl_dump_line ( struct nl_dump_params * parms,
const char * fmt,
... )

Definition at line 1024 of file utils.c.

Variable Documentation

◆ nl_debug

int nl_debug = 0

Global variable indicating the desired level of debugging output.

Level Messages Printed
0 Debugging output disabled
1 Warnings, important events and notifications
2 More or less important debugging messages
3 Repetitive events causing a flood of debugging messages
4 Even less important messages

If available, the variable will be initialized to the value of the environment variable NLDBG. The default value is 0 (disabled).

For more information, see section Debugging (Netlink Core Library Development Guide).

Definition at line 52 of file utils.c.

◆ []

double { ... } ::limit

Definition at line 378 of file utils.c.

◆ []

const char* { ... } ::unit

Definition at line 379 of file utils.c.

◆ nl_ver_num

const int nl_ver_num = LIBNL_VER_NUM

Definition at line 25 of file version.c.

◆ nl_ver_maj

const int nl_ver_maj = LIBNL_VER_MAJ

Definition at line 26 of file version.c.

◆ nl_ver_min

const int nl_ver_min = LIBNL_VER_MIN

Definition at line 27 of file version.c.

◆ nl_ver_mic

const int nl_ver_mic = LIBNL_VER_MIC

Definition at line 28 of file version.c.