ipstack.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #ifndef __IPSTACK_H__
  2. #define __IPSTACK_H__ 1
  3. #ifdef OLD_IP_STACK
  4. # ifndef EAI_FAMILY
  5. # define EAI_FAMILY (-1)
  6. # define EAI_FAIL (-2)
  7. # define EAI_SYSTEM (-3)
  8. # define EAI_MEMORY (-4)
  9. # endif
  10. # ifndef NI_NUMERICHOST
  11. # define NI_NUMERICHOST (1 << 0)
  12. # define NI_MAXHOST 1025
  13. # define NI_MAXSERV 32
  14. # define NI_NUMERICSERV 2
  15. # endif
  16. # ifndef AI_PASSIVE
  17. # define AI_PASSIVE (1 << 0)
  18. # endif
  19. # ifndef HAVE_STRUCT_ADDRINFO
  20. struct addrinfo {
  21. int ai_flags;
  22. int ai_family;
  23. int ai_socktype;
  24. int ai_protocol;
  25. int ai_addrlen;
  26. struct sockaddr *ai_addr;
  27. char *ai_canonname;
  28. struct addrinfo *ai_next;
  29. };
  30. # endif
  31. # if !defined(HAVE_GETADDRINFO) && !defined(HAVE_GETNAMEINFO)
  32. # define sockaddr_storage sockaddr_in
  33. # define ss_family sin_family
  34. # ifdef HAVE_SIN_LEN
  35. # define ss_len sin_len
  36. # define HAVE_SS_LEN 1
  37. # endif
  38. # define sockaddr_in6 sockaddr_in
  39. # define sin6_port sin_port
  40. # define sin6_addr sin_addr
  41. # define in6_addr in_addr
  42. # define s6_addr s_addr
  43. # endif
  44. # ifndef AF_INET6
  45. # define AF_INET6 AF_UNSPEC
  46. # define PF_INET6 AF_INET6
  47. # endif
  48. # ifndef IN6ADDR_ANY_INIT
  49. # define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
  50. # endif
  51. # ifndef IN6ADDR_LOOPBACK_INIT
  52. # define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
  53. # endif
  54. # ifndef INET6_ADDRSTRLEN
  55. # define INET6_ADDRSTRLEN 46
  56. # endif
  57. # ifndef IN6_IS_ADDR_UNSPECIFIED
  58. # define IN6_IS_ADDR_UNSPECIFIED(a) 0
  59. # endif
  60. # ifndef IN6_IS_ADDR_LOOPBACK
  61. # define IN6_IS_ADDR_LOOPBACK(a) 0
  62. # endif
  63. # ifndef IN6_IS_ADDR_MULTICAST
  64. # define IN6_IS_ADDR_MULTICAST(a) 0
  65. # endif
  66. # ifndef IN6_IS_ADDR_LINKLOCAL
  67. # define IN6_IS_ADDR_LINKLOCAL(a) 0
  68. # endif
  69. # ifndef IN6_IS_ADDR_SITELOCAL
  70. # define IN6_IS_ADDR_SITELOCAL(a) 0
  71. # endif
  72. # ifndef IN6_IS_ADDR_V4MAPPED
  73. # define IN6_IS_ADDR_V4MAPPED(a) 0
  74. # endif
  75. # ifndef IN6_IS_ADDR_V4COMPAT
  76. # define IN6_IS_ADDR_V4COMPAT(a) 0
  77. # endif
  78. # ifndef IN6_ARE_ADDR_EQUAL
  79. # define IN6_ARE_ADDR_EQUAL(a,b) 0
  80. # endif
  81. # if !defined(HAVE_INET_NTOP) && !defined(inet_ntop)
  82. # define inet_ntop(AF, SRC, DST) inet_aton(SRC, (struct in_addr *) (DST))
  83. # endif
  84. # if !defined(HAVE_INET_PTON) && !defined(inet_pton)
  85. int inet_pton(int af, const char *src, void *dst);
  86. # endif
  87. # ifndef HAVE_GETNAMEINFO
  88. int getnameinfo(const struct sockaddr *sa_, socklen_t salen,
  89. char *host, size_t hostlen,
  90. char *serv, size_t servlen, int flags);
  91. # endif
  92. # ifndef HAVE_GETADDRINFO
  93. int getaddrinfo(const char *node, const char *service,
  94. const struct addrinfo *hints, struct addrinfo **res);
  95. void freeaddrinfo(struct addrinfo *res);
  96. # endif
  97. #endif
  98. in_port_t *
  99. storage_port(struct sockaddr_storage * const ss);
  100. const in_port_t *
  101. storage_port_const(const struct sockaddr_storage * const ss);
  102. in_port_t *
  103. storage_port6(struct sockaddr_storage * const ss);
  104. const in_port_t *
  105. storage_port6_const(const struct sockaddr_storage * const ss);
  106. struct in_addr *
  107. storage_sin_addr(struct sockaddr_storage * const ss);
  108. const struct in_addr *
  109. storage_sin_addr_const(const struct sockaddr_storage * const ss);
  110. struct in6_addr *
  111. storage_sin_addr6(struct sockaddr_storage * const ss);
  112. const struct in6_addr *
  113. storage_sin_addr6_const(const struct sockaddr_storage * const ss);
  114. #endif