libnl
3.2.24-rc1
|
Collection of helper functions. More...
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. More... | |
Pretty Printing of Numbers | |
double | nl_cancel_down_bytes (unsigned long long l, char **unit) |
Cancel down a byte counter. More... | |
double | nl_cancel_down_bits (unsigned long long l, char **unit) |
Cancel down a bit counter. More... | |
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. More... | |
Generic Unit Translations | |
long | nl_size2int (const char *str) |
Convert a character string to a size. More... | |
char * | nl_size2str (const size_t size, char *buf, const size_t len) |
Convert a size toa character string. More... | |
long | nl_prob2int (const char *str) |
Convert a character string to a probability. More... | |
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. More... | |
uint32_t | nl_ticks2us (uint32_t ticks) |
Convert ticks to micro seconds. More... | |
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. More... | |
#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) |
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. More... | |
void | nl_dump (struct nl_dump_params *params, const char *fmt,...) |
Dump a formatted character string. More... | |
void | nl_dump_line (struct nl_dump_params *parms, const char *fmt,...) |
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 |
Probability Constants | |
#define | NL_PROB_MIN 0x0 |
Lower probability limit. | |
#define | NL_PROB_MAX 0xffffffff |
Upper probability limit nl_dump_type. | |
Collection of helper functions.
Run-time version information.
enum nl_dump_type |
double nl_cancel_down_bytes | ( | unsigned long long | l, |
char ** | unit | ||
) |
Cancel down a byte counter.
l | byte counter |
unit | destination 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
double nl_cancel_down_bits | ( | unsigned long long | l, |
char ** | unit | ||
) |
Cancel down a bit counter.
l | bit counter |
unit | destination 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
double nl_cancel_down_us | ( | uint32_t | l, |
char ** | unit | ||
) |
long nl_size2int | ( | const char * | str | ) |
Convert a character string to a size.
str | size encoded as character string |
Converts the specified size as character to the corresponding number of bytes.
Supported formats are:
This function assume 1000 bits in one kilobit and 1024 bytes in one kilobyte
char* nl_size2str | ( | const size_t | size, |
char * | buf, | ||
const size_t | len | ||
) |
Convert a size toa character string.
size | Size in number of bytes |
buf | Buffer to write character string to |
len | Size of buf |
This function converts a value in bytes to a human readable representation of it. The function uses IEC prefixes:
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:
long nl_prob2int | ( | const char * | str | ) |
Convert a character string to a probability.
str | probability encoded as character string |
Converts the specified probability as character to the corresponding probability number.
Supported formats are:
Definition at line 361 of file utils.c.
References NL_PROB_MAX.
uint32_t nl_us2ticks | ( | uint32_t | us | ) |
Convert micro seconds to ticks.
us | micro seconds |
Definition at line 483 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().
uint32_t nl_ticks2us | ( | uint32_t | ticks | ) |
Convert ticks to micro seconds.
ticks | number of ticks |
Definition at line 494 of file utils.c.
Referenced by rtnl_netem_get_delay(), and rtnl_netem_get_jitter().
char* nl_msec2str | ( | uint64_t | msec, |
char * | buf, | ||
size_t | len | ||
) |
Convert milliseconds to a character string.
msec | number of milliseconds |
buf | destination buffer |
len | buffer length |
Converts milliseconds to a character string split up in days, hours, minutes, seconds, and milliseconds and stores it in the specified destination buffer.
void nl_new_line | ( | struct nl_dump_params * | params | ) |
Handle a new line while dumping.
params | Dumping parameters |
This function must be called before dumping any onto a new line. It will ensure proper prefixing as specified by the dumping parameters.
Definition at line 866 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.
void nl_dump | ( | struct nl_dump_params * | params, |
const char * | fmt, | ||
... | |||
) |
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).