utils.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. extern void incomplete_command(void) NORETURN;
  24. #define NEXT_ARG() do { if (!*++argv) incomplete_command(); } while (0)
  25. typedef struct {
  26. uint8_t family;
  27. uint8_t bytelen;
  28. int16_t bitlen;
  29. uint32_t data[4];
  30. } inet_prefix;
  31. #define PREFIXLEN_SPECIFIED 1
  32. #define DN_MAXADDL 20
  33. #ifndef AF_DECnet
  34. #define AF_DECnet 12
  35. #endif
  36. struct dn_naddr {
  37. unsigned short a_len;
  38. unsigned char a_addr[DN_MAXADDL];
  39. };
  40. #define IPX_NODE_LEN 6
  41. struct ipx_addr {
  42. uint32_t ipx_net;
  43. uint8_t ipx_node[IPX_NODE_LEN];
  44. };
  45. extern uint32_t get_addr32(char *name);
  46. extern int get_addr_1(inet_prefix *dst, char *arg, int family);
  47. /*extern int get_prefix_1(inet_prefix *dst, char *arg, int family);*/
  48. extern int get_addr(inet_prefix *dst, char *arg, int family);
  49. extern int get_prefix(inet_prefix *dst, char *arg, int family);
  50. extern unsigned get_unsigned(char *arg, const char *errmsg);
  51. extern uint32_t get_u32(char *arg, const char *errmsg);
  52. extern uint16_t get_u16(char *arg, const char *errmsg);
  53. extern const char *rt_addr_n2a(int af, void *addr, char *buf, int buflen);
  54. #ifdef RESOLVE_HOSTNAMES
  55. extern const char *format_host(int af, int len, void *addr, char *buf, int buflen);
  56. #else
  57. #define format_host(af, len, addr, buf, buflen) \
  58. rt_addr_n2a(af, addr, buf, buflen)
  59. #endif
  60. void invarg(const char *, const char *) NORETURN;
  61. void duparg(const char *, const char *) NORETURN;
  62. void duparg2(const char *, const char *) NORETURN;
  63. int inet_addr_match(inet_prefix *a, inet_prefix *b, int bits);
  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. POP_SAVED_FUNCTION_VISIBILITY
  69. #endif