1
0

utils.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. #ifndef NETLINK_UTILS_H_
  12. #define NETLINK_UTILS_H_
  13. #include <netlink/netlink.h>
  14. #include <netlink/list.h>
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. /**
  19. * @name Probability Constants
  20. * @{
  21. */
  22. /**
  23. * Lower probability limit
  24. * @ingroup utils
  25. */
  26. #define NL_PROB_MIN 0x0
  27. /**
  28. * Upper probability limit
  29. * @ingroup utils
  30. */
  31. #define NL_PROB_MAX 0xffffffff
  32. /** @} */
  33. /* unit pretty-printing */
  34. extern double nl_cancel_down_bytes(unsigned long long, char **);
  35. extern double nl_cancel_down_bits(unsigned long long, char **);
  36. extern double nl_cancel_down_us(uint32_t, char **);
  37. /* generic unit translations */
  38. extern long nl_size2int(const char *);
  39. extern long nl_prob2int(const char *);
  40. /* time translations */
  41. extern int nl_get_hz(void);
  42. extern uint32_t nl_us2ticks(uint32_t);
  43. extern uint32_t nl_ticks2us(uint32_t);
  44. extern int nl_str2msec(const char *, uint64_t *);
  45. extern char * nl_msec2str(uint64_t, char *, size_t);
  46. /* link layer protocol translations */
  47. extern char * nl_llproto2str(int, char *, size_t);
  48. extern int nl_str2llproto(const char *);
  49. /* ethernet protocol translations */
  50. extern char * nl_ether_proto2str(int, char *, size_t);
  51. extern int nl_str2ether_proto(const char *);
  52. /* IP protocol translations */
  53. extern char * nl_ip_proto2str(int, char *, size_t);
  54. extern int nl_str2ip_proto(const char *);
  55. /* Dumping helpers */
  56. extern void nl_new_line(struct nl_dump_params *);
  57. extern void nl_dump(struct nl_dump_params *, const char *, ...);
  58. extern void nl_dump_line(struct nl_dump_params *, const char *, ...);
  59. #ifdef __cplusplus
  60. }
  61. #endif
  62. #endif