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