Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2001 Francois Gouget |
| 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; either |
| 7 | * version 2.1 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Lesser General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser General Public |
| 15 | * License along with this library; if not, write to the Free Software |
Jonathan Ernst | 360a3f9 | 2006-05-18 14:49:52 +0200 | [diff] [blame] | 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 17 | */ |
| 18 | |
Francois Gouget | 2720231 | 2001-11-14 21:26:23 +0000 | [diff] [blame] | 19 | #ifndef __WS2TCPIP__ |
| 20 | #define __WS2TCPIP__ |
| 21 | |
Rob Shearman | 1cef5dc | 2008-01-02 22:53:58 +0000 | [diff] [blame] | 22 | #include <winsock2.h> |
| 23 | /* FIXME: #include <ws2ipdef.h> */ |
| 24 | #include <limits.h> |
| 25 | |
Francois Gouget | 2720231 | 2001-11-14 21:26:23 +0000 | [diff] [blame] | 26 | #ifdef USE_WS_PREFIX |
| 27 | #define WS(x) WS_##x |
| 28 | #else |
| 29 | #define WS(x) x |
| 30 | #endif |
| 31 | |
| 32 | /* FIXME: This gets defined by some Unix (Linux) header and messes things */ |
| 33 | #undef s6_addr |
| 34 | |
Vijay Kiran Kamuju | 6779289 | 2005-09-21 09:41:22 +0000 | [diff] [blame] | 35 | /* for addrinfo calls */ |
| 36 | typedef struct WS(addrinfo) |
| 37 | { |
| 38 | int ai_flags; |
| 39 | int ai_family; |
| 40 | int ai_socktype; |
| 41 | int ai_protocol; |
| 42 | size_t ai_addrlen; |
| 43 | char * ai_canonname; |
| 44 | struct WS(sockaddr)* ai_addr; |
| 45 | struct WS(addrinfo)* ai_next; |
| 46 | } ADDRINFOA, *PADDRINFOA; |
| 47 | |
| 48 | typedef struct WS(addrinfoW) |
| 49 | { |
| 50 | int ai_flags; |
| 51 | int ai_family; |
| 52 | int ai_socktype; |
| 53 | int ai_protocol; |
| 54 | size_t ai_addrlen; |
| 55 | PWSTR ai_canonname; |
| 56 | struct WS(sockaddr)* ai_addr; |
| 57 | struct WS(addrinfoW)* ai_next; |
| 58 | } ADDRINFOW, *PADDRINFOW; |
| 59 | |
Robert Shearman | 264503d | 2006-07-13 13:06:30 +0100 | [diff] [blame] | 60 | typedef int WS(socklen_t); |
| 61 | |
Francois Gouget | 482df92 | 2005-11-23 19:43:50 +0100 | [diff] [blame] | 62 | typedef ADDRINFOA ADDRINFO, *LPADDRINFO; |
Vijay Kiran Kamuju | 6779289 | 2005-09-21 09:41:22 +0000 | [diff] [blame] | 63 | |
Francois Gouget | ff915d4 | 2004-03-31 19:58:46 +0000 | [diff] [blame] | 64 | /* |
| 65 | * Multicast group information |
| 66 | */ |
| 67 | |
| 68 | struct WS(ip_mreq) |
| 69 | { |
| 70 | struct WS(in_addr) imr_multiaddr; |
| 71 | struct WS(in_addr) imr_interface; |
| 72 | }; |
| 73 | |
| 74 | struct WS(ip_mreq_source) { |
| 75 | struct WS(in_addr) imr_multiaddr; |
| 76 | struct WS(in_addr) imr_sourceaddr; |
| 77 | struct WS(in_addr) imr_interface; |
| 78 | }; |
| 79 | |
| 80 | struct WS(ip_msfilter) { |
| 81 | struct WS(in_addr) imsf_multiaddr; |
| 82 | struct WS(in_addr) imsf_interface; |
Rob Shearman | d82e36f | 2008-10-01 11:20:09 +0100 | [diff] [blame] | 83 | WS(u_long) imsf_fmode; |
| 84 | WS(u_long) imsf_numsrc; |
Francois Gouget | ff915d4 | 2004-03-31 19:58:46 +0000 | [diff] [blame] | 85 | struct WS(in_addr) imsf_slist[1]; |
| 86 | }; |
| 87 | |
Francois Gouget | 2720231 | 2001-11-14 21:26:23 +0000 | [diff] [blame] | 88 | typedef struct WS(in_addr6) |
| 89 | { |
Rob Shearman | d82e36f | 2008-10-01 11:20:09 +0100 | [diff] [blame] | 90 | WS(u_char) s6_addr[16]; /* IPv6 address */ |
Francois Gouget | 2720231 | 2001-11-14 21:26:23 +0000 | [diff] [blame] | 91 | } IN6_ADDR, *PIN6_ADDR, *LPIN6_ADDR; |
| 92 | |
| 93 | typedef struct WS(sockaddr_in6) |
| 94 | { |
| 95 | short sin6_family; /* AF_INET6 */ |
Rob Shearman | d82e36f | 2008-10-01 11:20:09 +0100 | [diff] [blame] | 96 | WS(u_short) sin6_port; /* Transport level port number */ |
| 97 | WS(u_long) sin6_flowinfo; /* IPv6 flow information */ |
Francois Gouget | 2720231 | 2001-11-14 21:26:23 +0000 | [diff] [blame] | 98 | struct WS(in_addr6) sin6_addr; /* IPv6 address */ |
Rob Shearman | d82e36f | 2008-10-01 11:20:09 +0100 | [diff] [blame] | 99 | WS(u_long) sin6_scope_id; /* IPv6 scope id */ |
Francois Gouget | 2720231 | 2001-11-14 21:26:23 +0000 | [diff] [blame] | 100 | } SOCKADDR_IN6,*PSOCKADDR_IN6, *LPSOCKADDR_IN6; |
| 101 | |
Marcus Meissner | aa730cc | 2005-11-16 11:21:57 +0000 | [diff] [blame] | 102 | typedef struct WS(sockaddr_in6_old) |
| 103 | { |
| 104 | short sin6_family; /* AF_INET6 */ |
Rob Shearman | d82e36f | 2008-10-01 11:20:09 +0100 | [diff] [blame] | 105 | WS(u_short) sin6_port; /* Transport level port number */ |
| 106 | WS(u_long) sin6_flowinfo; /* IPv6 flow information */ |
Marcus Meissner | aa730cc | 2005-11-16 11:21:57 +0000 | [diff] [blame] | 107 | struct WS(in_addr6) sin6_addr; /* IPv6 address */ |
| 108 | } SOCKADDR_IN6_OLD,*PSOCKADDR_IN6_OLD, *LPSOCKADDR_IN6_OLD; |
| 109 | |
Francois Gouget | 2720231 | 2001-11-14 21:26:23 +0000 | [diff] [blame] | 110 | typedef union sockaddr_gen |
| 111 | { |
| 112 | struct WS(sockaddr) Address; |
| 113 | struct WS(sockaddr_in) AddressIn; |
Marcus Meissner | aa730cc | 2005-11-16 11:21:57 +0000 | [diff] [blame] | 114 | struct WS(sockaddr_in6_old) AddressIn6; |
Francois Gouget | 2720231 | 2001-11-14 21:26:23 +0000 | [diff] [blame] | 115 | } WS(sockaddr_gen); |
| 116 | |
| 117 | /* Structure to keep interface specific information */ |
| 118 | typedef struct _INTERFACE_INFO |
| 119 | { |
Rob Shearman | d82e36f | 2008-10-01 11:20:09 +0100 | [diff] [blame] | 120 | WS(u_long) iiFlags; /* Interface flags */ |
Francois Gouget | 2720231 | 2001-11-14 21:26:23 +0000 | [diff] [blame] | 121 | WS(sockaddr_gen) iiAddress; /* Interface address */ |
| 122 | WS(sockaddr_gen) iiBroadcastAddress; /* Broadcast address */ |
| 123 | WS(sockaddr_gen) iiNetmask; /* Network mask */ |
| 124 | } INTERFACE_INFO, * LPINTERFACE_INFO; |
| 125 | |
| 126 | /* Possible flags for the iiFlags - bitmask */ |
| 127 | #ifndef USE_WS_PREFIX |
| 128 | #define IFF_UP 0x00000001 /* Interface is up */ |
| 129 | #define IFF_BROADCAST 0x00000002 /* Broadcast is supported */ |
| 130 | #define IFF_LOOPBACK 0x00000004 /* this is loopback interface */ |
| 131 | #define IFF_POINTTOPOINT 0x00000008 /* this is point-to-point interface */ |
| 132 | #define IFF_MULTICAST 0x00000010 /* multicast is supported */ |
| 133 | #else |
| 134 | #define WS_IFF_UP 0x00000001 /* Interface is up */ |
| 135 | #define WS_IFF_BROADCAST 0x00000002 /* Broadcast is supported */ |
| 136 | #define WS_IFF_LOOPBACK 0x00000004 /* this is loopback interface */ |
| 137 | #define WS_IFF_POINTTOPOINT 0x00000008 /* this is point-to-point interface */ |
| 138 | #define WS_IFF_MULTICAST 0x00000010 /* multicast is supported */ |
| 139 | #endif /* USE_WS_PREFIX */ |
| 140 | |
Mike Hearn | ceb86a9 | 2003-04-04 22:04:47 +0000 | [diff] [blame] | 141 | #ifndef USE_WS_PREFIX |
Francois Gouget | 482df92 | 2005-11-23 19:43:50 +0100 | [diff] [blame] | 142 | #define IP_OPTIONS 1 |
| 143 | #define IP_HDRINCL 2 |
| 144 | #define IP_TOS 3 |
| 145 | #define IP_TTL 4 |
| 146 | #define IP_MULTICAST_IF 9 |
| 147 | #define IP_MULTICAST_TTL 10 |
| 148 | #define IP_MULTICAST_LOOP 11 |
| 149 | #define IP_ADD_MEMBERSHIP 12 |
| 150 | #define IP_DROP_MEMBERSHIP 13 |
| 151 | #define IP_DONTFRAGMENT 14 |
| 152 | #define IP_ADD_SOURCE_MEMBERSHIP 15 |
| 153 | #define IP_DROP_SOURCE_MEMBERSHIP 16 |
| 154 | #define IP_BLOCK_SOURCE 17 |
| 155 | #define IP_UNBLOCK_SOURCE 18 |
| 156 | #define IP_PKTINFO 19 |
| 157 | #define IP_RECEIVE_BROADCAST 22 |
Mike Hearn | ceb86a9 | 2003-04-04 22:04:47 +0000 | [diff] [blame] | 158 | #else |
Francois Gouget | 482df92 | 2005-11-23 19:43:50 +0100 | [diff] [blame] | 159 | #define WS_IP_OPTIONS 1 |
| 160 | #define WS_IP_HDRINCL 2 |
| 161 | #define WS_IP_TOS 3 |
| 162 | #define WS_IP_TTL 4 |
| 163 | #define WS_IP_MULTICAST_IF 9 |
| 164 | #define WS_IP_MULTICAST_TTL 10 |
| 165 | #define WS_IP_MULTICAST_LOOP 11 |
| 166 | #define WS_IP_ADD_MEMBERSHIP 12 |
| 167 | #define WS_IP_DROP_MEMBERSHIP 13 |
| 168 | #define WS_IP_DONTFRAGMENT 14 |
| 169 | #define WS_IP_ADD_SOURCE_MEMBERSHIP 15 |
| 170 | #define WS_IP_DROP_SOURCE_MEMBERSHIP 16 |
| 171 | #define WS_IP_BLOCK_SOURCE 17 |
| 172 | #define WS_IP_UNBLOCK_SOURCE 18 |
| 173 | #define WS_IP_PKTINFO 19 |
| 174 | #define WS_IP_RECEIVE_BROADCAST 22 |
Mike Hearn | ceb86a9 | 2003-04-04 22:04:47 +0000 | [diff] [blame] | 175 | #endif /* USE_WS_PREFIX */ |
| 176 | |
Marcus Meissner | 7a6fdea | 2005-11-17 12:58:35 +0000 | [diff] [blame] | 177 | /* Possible Windows flags for getaddrinfo() */ |
| 178 | #ifndef USE_WS_PREFIX |
| 179 | # define AI_PASSIVE 0x0001 |
| 180 | # define AI_CANONNAME 0x0002 |
| 181 | # define AI_NUMERICHOST 0x0004 |
| 182 | /* getaddrinfo error codes */ |
| 183 | # define EAI_AGAIN WSATRY_AGAIN |
| 184 | # define EAI_BADFLAGS WSAEINVAL |
| 185 | # define EAI_FAIL WSANO_RECOVERY |
| 186 | # define EAI_FAMILY WSAEAFNOSUPPORT |
| 187 | # define EAI_MEMORY WSA_NOT_ENOUGH_MEMORY |
Marcus Meissner | 8e20374 | 2005-12-12 11:55:33 +0100 | [diff] [blame] | 188 | # define EAI_NODATA EAI_NONAME |
Marcus Meissner | 7a6fdea | 2005-11-17 12:58:35 +0000 | [diff] [blame] | 189 | # define EAI_NONAME WSAHOST_NOT_FOUND |
| 190 | # define EAI_SERVICE WSATYPE_NOT_FOUND |
| 191 | # define EAI_SOCKTYPE WSAESOCKTNOSUPPORT |
| 192 | #else |
| 193 | # define WS_AI_PASSIVE 0x0001 |
| 194 | # define WS_AI_CANONNAME 0x0002 |
| 195 | # define WS_AI_NUMERICHOST 0x0004 |
| 196 | /* getaddrinfo error codes */ |
| 197 | # define WS_EAI_AGAIN WSATRY_AGAIN |
| 198 | # define WS_EAI_BADFLAGS WSAEINVAL |
| 199 | # define WS_EAI_FAIL WSANO_RECOVERY |
| 200 | # define WS_EAI_FAMILY WSAEAFNOSUPPORT |
| 201 | # define WS_EAI_MEMORY WSA_NOT_ENOUGH_MEMORY |
Marcus Meissner | 8e20374 | 2005-12-12 11:55:33 +0100 | [diff] [blame] | 202 | # define WS_EAI_NODATA WS_EAI_NONAME |
Marcus Meissner | 7a6fdea | 2005-11-17 12:58:35 +0000 | [diff] [blame] | 203 | # define WS_EAI_NONAME WSAHOST_NOT_FOUND |
| 204 | # define WS_EAI_SERVICE WSATYPE_NOT_FOUND |
| 205 | # define WS_EAI_SOCKTYPE WSAESOCKTNOSUPPORT |
| 206 | #endif |
| 207 | |
Robert Shearman | 264503d | 2006-07-13 13:06:30 +0100 | [diff] [blame] | 208 | /* Possible Windows flags for getnameinfo() */ |
| 209 | #ifndef USE_WS_PREFIX |
| 210 | # define NI_NOFQDN 0x01 |
| 211 | # define NI_NUMERICHOST 0x02 |
| 212 | # define NI_NAMEREQD 0x04 |
| 213 | # define NI_NUMERICSERV 0x08 |
| 214 | # define NI_DGRAM 0x10 |
| 215 | #else |
| 216 | # define WS_NI_NOFQDN 0x01 |
| 217 | # define WS_NI_NUMERICHOST 0x02 |
| 218 | # define WS_NI_NAMEREQD 0x04 |
| 219 | # define WS_NI_NUMERICSERV 0x08 |
| 220 | # define WS_NI_DGRAM 0x10 |
| 221 | #endif |
| 222 | |
Francois Gouget | 482df92 | 2005-11-23 19:43:50 +0100 | [diff] [blame] | 223 | |
| 224 | #ifdef __cplusplus |
| 225 | extern "C" { |
| 226 | #endif |
| 227 | |
| 228 | void WINAPI WS(freeaddrinfo)(LPADDRINFO); |
| 229 | #define FreeAddrInfoA WS(freeaddrinfo) |
| 230 | void WINAPI FreeAddrInfoW(PADDRINFOW); |
| 231 | #define FreeAddrInfo WINELIB_NAME_AW(FreeAddrInfo) |
| 232 | int WINAPI WS(getaddrinfo)(const char*,const char*,const struct WS(addrinfo)*,struct WS(addrinfo)**); |
| 233 | #define GetAddrInfoA WS(getaddrinfo) |
| 234 | int WINAPI GetAddrInfoW(PCWSTR,PCWSTR,const ADDRINFOW*,PADDRINFOW*); |
| 235 | #define GetAddrInfo WINELIB_NAME_AW(GetAddrInfo) |
Robert Shearman | 264503d | 2006-07-13 13:06:30 +0100 | [diff] [blame] | 236 | int WINAPI WS(getnameinfo)(const SOCKADDR*,WS(socklen_t),PCHAR,DWORD,PCHAR,DWORD,INT); |
Francois Gouget | 482df92 | 2005-11-23 19:43:50 +0100 | [diff] [blame] | 237 | #define GetNameInfoA WS(getnameinfo) |
Robert Shearman | 264503d | 2006-07-13 13:06:30 +0100 | [diff] [blame] | 238 | INT WINAPI GetNameInfoW(const SOCKADDR*,WS(socklen_t),PWCHAR,DWORD,PWCHAR,DWORD,INT); |
Francois Gouget | 482df92 | 2005-11-23 19:43:50 +0100 | [diff] [blame] | 239 | #define GetNameInfo WINELIB_NAME_AW(GetNameInfo) |
Francois Gouget | b092b90 | 2008-12-08 09:28:02 +0100 | [diff] [blame] | 240 | PCSTR WINAPI WS(inet_ntop)(INT,PVOID,PSTR,size_t); |
| 241 | #define InetNtopA WS(inet_ntop) |
| 242 | PCWSTR WINAPI InetNtopW(INT,PVOID,PWSTR,size_t); |
| 243 | #define InetNtop WINELIB_NAME_AW(InetNtop) |
| 244 | int WINAPI WS(inet_pton)(INT,PCSTR,PVOID); |
| 245 | #define InetPtonA WS(inet_pton) |
| 246 | int WINAPI InetPtonW(INT,PCWSTR,PVOID); |
| 247 | #define InetPton WINELIB_NAME_AW(InetPton) |
Francois Gouget | 482df92 | 2005-11-23 19:43:50 +0100 | [diff] [blame] | 248 | |
| 249 | /* |
| 250 | * Ws2tcpip Function Typedefs |
| 251 | * |
| 252 | * Remember to keep this section in sync with the |
| 253 | * prototypes above. |
| 254 | */ |
| 255 | #if INCL_WINSOCK_API_TYPEDEFS |
| 256 | |
| 257 | typedef void (WINAPI *LPFN_FREEADDRINFO)(LPADDRINFO); |
| 258 | #define LPFN_FREEADDRINFOA LPFN_FREEADDRINFO |
| 259 | typedef void (WINAPI *LPFN_FREEADDRINFOW)(PADDRINFOW); |
| 260 | #define LPFN_FREEADDRINFOT WINELIB_NAME_AW(LPFN_FREEADDRINFO) |
| 261 | typedef int (WINAPI *LPFN_GETADDRINFO)(const char*,const char*,const struct WS(addrinfo)*,struct WS(addrinfo)**); |
| 262 | #define LPFN_GETADDRINFOA LPFN_GETADDRINFO |
| 263 | typedef int (WINAPI *LPFN_GETADDRINFOW)(PCWSTR,PCWSTR,const ADDRINFOW*,PADDRINFOW*); |
| 264 | #define LPFN_GETADDRINFOT WINELIB_NAME_AW(LPFN_GETADDRINFO) |
| 265 | typedef int (WINAPI *LPFN_GETNAMEINFO)(const struct sockaddr*,socklen_t,char*,DWORD,char*,DWORD,int); |
| 266 | #define LPFN_GETNAMEINFOA LPFN_GETNAMEINFO |
| 267 | typedef int (WINAPI *LPFN_GETNAMEINFOW)(const SOCKADDR*,socklen_t,PWCHAR,DWORD,PWCHAR,DWORD,INT); |
| 268 | #define LPFN_GETNAMEINFOT WINELIB_NAME_AW(LPFN_GETNAMEINFO) |
| 269 | |
| 270 | #endif |
| 271 | |
| 272 | #ifdef __cplusplus |
| 273 | } |
| 274 | #endif |
Marcus Meissner | 7a6fdea | 2005-11-17 12:58:35 +0000 | [diff] [blame] | 275 | |
Francois Gouget | 2720231 | 2001-11-14 21:26:23 +0000 | [diff] [blame] | 276 | #endif /* __WS2TCPIP__ */ |