utils.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* vi: set sw=4 ts=4: */
  2. #ifndef UTILS_H
  3. #define UTILS_H 1
  4. #include "libnetlink.h"
  5. #include "ll_map.h"
  6. #include "rtm_map.h"
  7. PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
  8. extern family_t preferred_family;
  9. extern smallint show_stats; /* UNUSED */
  10. extern smallint show_details; /* UNUSED */
  11. extern smallint show_raw; /* UNUSED */
  12. extern smallint resolve_hosts; /* UNUSED */
  13. extern smallint oneline;
  14. extern char _SL_;
  15. #ifndef IPPROTO_ESP
  16. #define IPPROTO_ESP 50
  17. #endif
  18. #ifndef IPPROTO_AH
  19. #define IPPROTO_AH 51
  20. #endif
  21. #define SPRINT_BSIZE 64
  22. #define SPRINT_BUF(x) char x[SPRINT_BSIZE]
  23. typedef struct {
  24. uint8_t family;
  25. uint8_t bytelen;
  26. int16_t bitlen;
  27. uint32_t data[4];
  28. } inet_prefix;
  29. #define PREFIXLEN_SPECIFIED 1
  30. #define DN_MAXADDL 20
  31. #ifndef AF_DECnet
  32. #define AF_DECnet 12
  33. #endif
  34. struct dn_naddr {
  35. unsigned short a_len;
  36. unsigned char a_addr[DN_MAXADDL];
  37. };
  38. #define IPX_NODE_LEN 6
  39. struct ipx_addr {
  40. uint32_t ipx_net;
  41. uint8_t ipx_node[IPX_NODE_LEN];
  42. };
  43. char** next_arg(char **argv) FAST_FUNC;
  44. #define NEXT_ARG() do { argv = next_arg(argv); } while (0)
  45. uint32_t get_addr32(char *name) FAST_FUNC;
  46. int get_addr_1(inet_prefix *dst, char *arg, int family) FAST_FUNC;
  47. /*void get_prefix_1(inet_prefix *dst, char *arg, int family) FAST_FUNC;*/
  48. int get_addr(inet_prefix *dst, char *arg, int family) FAST_FUNC;
  49. void get_prefix(inet_prefix *dst, char *arg, int family) FAST_FUNC;
  50. unsigned get_unsigned(char *arg, const char *errmsg) FAST_FUNC;
  51. uint32_t get_u32(char *arg, const char *errmsg) FAST_FUNC;
  52. uint16_t get_u16(char *arg, const char *errmsg) FAST_FUNC;
  53. const char *rt_addr_n2a(int af, void *addr) FAST_FUNC;
  54. #ifdef RESOLVE_HOSTNAMES
  55. const char *format_host(int af, int len, void *addr) FAST_FUNC;
  56. #else
  57. #define format_host(af, len, addr) \
  58. rt_addr_n2a(af, addr)
  59. #endif
  60. void invarg_1_to_2(const char *, const char *) FAST_FUNC NORETURN;
  61. void duparg(const char *, const char *) FAST_FUNC NORETURN;
  62. void duparg2(const char *, const char *) FAST_FUNC NORETURN;
  63. int inet_addr_match(const inet_prefix *a, const inet_prefix *b, int bits) FAST_FUNC;
  64. //const char *dnet_ntop(int af, const void *addr, char *str, size_t len);
  65. //int dnet_pton(int af, const char *src, void *addr);
  66. //const char *ipx_ntop(int af, const void *addr, char *str, size_t len);
  67. //int ipx_pton(int af, const char *src, void *addr);
  68. unsigned get_hz(void) FAST_FUNC;
  69. POP_SAVED_FUNCTION_VISIBILITY
  70. #endif