netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
utils.c File Reference
#include <netlink-local.h>
#include <netlink/netlink.h>
#include <netlink/utils.h>
#include <linux/socket.h>
Include dependency graph for utils.c:

Macros

#define _SPLIT(idx, unit)   if ((split[idx] = msec / unit) > 0) msec %= unit
 

Functions

int __nl_read_num_str_file (const char *path, int(*cb)(long, const char *))
 
Unit Pretty-Printing
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...
 
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...
 
long nl_prob2int (const char *str)
 Convert a character string to a probability. More...
 
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,...)
 

Variables

int nl_debug = 0
 Debug level. More...
 
struct nl_dump_params nl_debug_dp
 

Time Translations

int nl_get_hz (void)
 Return the value of HZ. More...
 
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...
 

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)
 

Macro Definition Documentation

#define _SPLIT (   idx,
  unit 
)    if ((split[idx] = msec / unit) > 0) msec %= unit

Referenced by nl_msec2str().