libnl 1.1
|
00001 /* 00002 * netlink/utils.h Utility Functions 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation version 2.1 00007 * of the License. 00008 * 00009 * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> 00010 */ 00011 00012 #ifndef NETLINK_UTILS_H_ 00013 #define NETLINK_UTILS_H_ 00014 00015 #include <netlink/netlink.h> 00016 #include <netlink/list.h> 00017 00018 #ifdef __cplusplus 00019 extern "C" { 00020 #endif 00021 00022 /** 00023 * @name Probability Constants 00024 * @{ 00025 */ 00026 00027 /** 00028 * Lower probability limit 00029 * @ingroup utils 00030 */ 00031 #define NL_PROB_MIN 0x0 00032 00033 /** 00034 * Upper probability limit 00035 * @ingroup utils 00036 */ 00037 #define NL_PROB_MAX 0xffffffff 00038 00039 /** @} */ 00040 00041 extern char * nl_geterror(void); 00042 extern int nl_get_errno(void); 00043 extern void nl_perror(const char *); 00044 00045 /* unit pretty-printing */ 00046 extern double nl_cancel_down_bytes(unsigned long long, char **); 00047 extern double nl_cancel_down_bits(unsigned long long, char **); 00048 extern double nl_cancel_down_us(uint32_t, char **); 00049 00050 /* generic unit translations */ 00051 extern long nl_size2int(const char *); 00052 extern long nl_prob2int(const char *); 00053 00054 /* time translations */ 00055 extern int nl_get_hz(void); 00056 extern uint32_t nl_us2ticks(uint32_t); 00057 extern uint32_t nl_ticks2us(uint32_t); 00058 extern char * nl_msec2str(uint64_t, char *, size_t); 00059 00060 /* link layer protocol translations */ 00061 extern char * nl_llproto2str(int, char *, size_t); 00062 extern int nl_str2llproto(const char *); 00063 00064 /* ethernet protocol translations */ 00065 extern char * nl_ether_proto2str(int, char *, size_t); 00066 extern int nl_str2ether_proto(const char *); 00067 00068 /* IP protocol translations */ 00069 extern char * nl_ip_proto2str(int, char *, size_t); 00070 extern int nl_str2ip_proto(const char *); 00071 00072 /* Dumping helpers */ 00073 extern void nl_new_line(struct nl_dump_params *, int); 00074 extern void nl_dump(struct nl_dump_params *, const char *, ...); 00075 extern void nl_dump_line(struct nl_dump_params *, int, const char *, ...); 00076 00077 #ifdef __cplusplus 00078 } 00079 #endif 00080 00081 #endif