move library packages to package/libs/
[openwrt/svn-archive/archive.git] / package / libs / libnl-tiny / src / include / netlink / 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-2008 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
19 extern "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
41 /* unit pretty-printing */
42 extern double nl_cancel_down_bytes(unsigned long long, char **);
43 extern double nl_cancel_down_bits(unsigned long long, char **);
44 extern double nl_cancel_down_us(uint32_t, char **);
45
46 /* generic unit translations */
47 extern long nl_size2int(const char *);
48 extern long nl_prob2int(const char *);
49
50 /* time translations */
51 extern int nl_get_hz(void);
52 extern uint32_t nl_us2ticks(uint32_t);
53 extern uint32_t nl_ticks2us(uint32_t);
54 extern int nl_str2msec(const char *, uint64_t *);
55 extern char * nl_msec2str(uint64_t, char *, size_t);
56
57 /* link layer protocol translations */
58 extern char * nl_llproto2str(int, char *, size_t);
59 extern int nl_str2llproto(const char *);
60
61 /* ethernet protocol translations */
62 extern char * nl_ether_proto2str(int, char *, size_t);
63 extern int nl_str2ether_proto(const char *);
64
65 /* IP protocol translations */
66 extern char * nl_ip_proto2str(int, char *, size_t);
67 extern int nl_str2ip_proto(const char *);
68
69 /* Dumping helpers */
70 extern void nl_new_line(struct nl_dump_params *);
71 extern void nl_dump(struct nl_dump_params *, const char *, ...);
72 extern void nl_dump_line(struct nl_dump_params *, const char *, ...);
73
74 #ifdef __cplusplus
75 }
76 #endif
77
78 #endif