libnl 1.1.4
utils.h
1/*
2 * netlink/utils.h Utility Functions
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation version 2.1
7 * of the License.
8 *
9 * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
10 */
11
12#ifndef NETLINK_UTILS_H_
13#define NETLINK_UTILS_H_
14
15#include <netlink/netlink.h>
16#include <netlink/list.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22/**
23 * @name Probability Constants
24 * @{
25 */
26
27/**
28 * Lower probability limit
29 * @ingroup utils
30 */
31#define NL_PROB_MIN 0x0
32
33/**
34 * Upper probability limit
35 * @ingroup utils
36 */
37#define NL_PROB_MAX 0xffffffff
38
39/** @} */
40
41extern char * nl_geterror(void);
42extern int nl_get_errno(void);
43extern void nl_perror(const char *);
44
45/* unit pretty-printing */
46extern double nl_cancel_down_bytes(unsigned long long, char **);
47extern double nl_cancel_down_bits(unsigned long long, char **);
48extern double nl_cancel_down_us(uint32_t, char **);
49
50/* generic unit translations */
51extern long nl_size2int(const char *);
52extern long nl_prob2int(const char *);
53
54/* time translations */
55extern int nl_get_hz(void);
56extern uint32_t nl_us2ticks(uint32_t);
57extern uint32_t nl_ticks2us(uint32_t);
58extern char * nl_msec2str(uint64_t, char *, size_t);
59
60/* link layer protocol translations */
61extern char * nl_llproto2str(int, char *, size_t);
62extern int nl_str2llproto(const char *);
63
64/* ethernet protocol translations */
65extern char * nl_ether_proto2str(int, char *, size_t);
66extern int nl_str2ether_proto(const char *);
67
68/* IP protocol translations */
69extern char * nl_ip_proto2str(int, char *, size_t);
70extern int nl_str2ip_proto(const char *);
71
72/* Dumping helpers */
73extern void nl_new_line(struct nl_dump_params *, int);
74extern void nl_dump(struct nl_dump_params *, const char *, ...);
75extern void nl_dump_line(struct nl_dump_params *, int, const char *, ...);
76
77#ifdef __cplusplus
78}
79#endif
80
81#endif
double nl_cancel_down_us(uint32_t, char **)
Cancel down a micro second value.
Definition: utils.c:256
double nl_cancel_down_bits(unsigned long long, char **)
Cancel down a bit counter.
Definition: utils.c:220
long nl_size2int(const char *)
Convert a character string to a size.
Definition: utils.c:293
char * nl_geterror(void)
Return error message for an error code.
Definition: utils.c:142
void nl_dump(struct nl_dump_params *, const char *,...)
Dump a formatted character string.
Definition: utils.c:762
double nl_cancel_down_bytes(unsigned long long, char **)
Cancel down a byte counter.
Definition: utils.c:189
long nl_prob2int(const char *)
Convert a character string to a probability.
Definition: utils.c:335
void nl_perror(const char *)
Print a libnl error message.
Definition: utils.c:163
void nl_new_line(struct nl_dump_params *, int)
Handle a new line while dumping.
Definition: utils.c:735
int nl_get_hz(void)
Return the value of HZ.
Definition: utils.c:428
uint32_t nl_ticks2us(uint32_t)
Convert ticks to micro seconds.
Definition: utils.c:450
uint32_t nl_us2ticks(uint32_t)
Convert micro seconds to ticks.
Definition: utils.c:439
char * nl_msec2str(uint64_t, char *, size_t)
Convert milliseconds to a character string.
Definition: utils.c:488
Dumping parameters.
Definition: types.h:37