1 /**
2  * This file has no copyright assigned and is placed in the Public Domain.
3  * This file is part of the mingw-w64 runtime package.
4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5  */
6 #ifndef _WS2TCPIP_H_
7 #define _WS2TCPIP_H_
8 
9 #include <_mingw_unicode.h>
10 
11 #ifdef __LP64__
12 #pragma push_macro("u_long")
13 #undef u_long
14 #define u_long __ms_u_long
15 #endif
16 
17 #include <winsock2.h>
18 #include <ws2ipdef.h>
19 #include <psdk_inc/_ip_mreq1.h>
20 #include <winapifamily.h>
21 
22 struct ip_mreq_source {
23   struct in_addr imr_multiaddr;
24   struct in_addr imr_sourceaddr;
25   struct in_addr imr_interface;
26 };
27 
28 struct ip_msfilter {
29   struct in_addr imsf_multiaddr;
30   struct in_addr imsf_interface;
31   u_long imsf_fmode;
32   u_long imsf_numsrc;
33   struct in_addr imsf_slist[1];
34 };
35 
36 #define IP_MSFILTER_SIZE(numsrc) (sizeof(struct ip_msfilter)-sizeof(struct in_addr) + (numsrc)*sizeof(struct in_addr))
37 
38 #define SIO_GET_INTERFACE_LIST _IOR('t',127,u_long)
39 
40 #define SIO_GET_INTERFACE_LIST_EX _IOR('t',126,u_long)
41 #define SIO_SET_MULTICAST_FILTER _IOW('t',125,u_long)
42 #define SIO_GET_MULTICAST_FILTER _IOW('t',124 | IOC_IN,u_long)
43 
44 #define IP_OPTIONS 1
45 #define IP_HDRINCL 2
46 #define IP_TOS 3
47 #define IP_TTL 4
48 #define IP_MULTICAST_IF 9
49 #define IP_MULTICAST_TTL 10
50 #define IP_MULTICAST_LOOP 11
51 #define IP_ADD_MEMBERSHIP 12
52 #define IP_DROP_MEMBERSHIP 13
53 #define IP_DONTFRAGMENT 14
54 #define IP_ADD_SOURCE_MEMBERSHIP 15
55 #define IP_DROP_SOURCE_MEMBERSHIP 16
56 #define IP_BLOCK_SOURCE 17
57 #define IP_UNBLOCK_SOURCE 18
58 #define IP_PKTINFO 19
59 #define IP_RECEIVE_BROADCAST 22
60 
61 #define PROTECTION_LEVEL_UNRESTRICTED 10
62 #define PROTECTION_LEVEL_DEFAULT 20
63 #define PROTECTION_LEVEL_RESTRICTED 30
64 
65 #define UDP_NOCHECKSUM 1
66 #define UDP_CHECKSUM_COVERAGE 20
67 
68 #define TCP_EXPEDITED_1122 0x0002
69 
70 
71 #include <ws2ipdef.h>
72 
73 
74 #define SS_PORT(ssp) (((struct sockaddr_in*)(ssp))->sin_port)
75 
76 #define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
77 #define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
78 
79 #ifdef __cplusplus
80 extern "C" {
81 #endif
82 
83   extern const struct in6_addr in6addr_any;
84   extern const struct in6_addr in6addr_loopback;
85 
86 int IN6_IS_ADDR_UNSPECIFIED(const struct in6_addr *);
87 int IN6_IS_ADDR_LOOPBACK(const struct in6_addr *);
88 int IN6_IS_ADDR_MULTICAST(const struct in6_addr *);
89 int IN6_IS_ADDR_LINKLOCAL(const struct in6_addr *);
90 int IN6_IS_ADDR_SITELOCAL(const struct in6_addr *);
91 int IN6_IS_ADDR_V4MAPPED(const struct in6_addr *);
92 int IN6_IS_ADDR_V4COMPAT(const struct in6_addr *);
93 int IN6_IS_ADDR_MC_NODELOCAL(const struct in6_addr *);
94 int IN6_IS_ADDR_MC_LINKLOCAL(const struct in6_addr *);
95 int IN6_IS_ADDR_MC_SITELOCAL(const struct in6_addr *);
96 int IN6_IS_ADDR_MC_ORGLOCAL(const struct in6_addr *);
97 int IN6_IS_ADDR_MC_GLOBAL(const struct in6_addr *);
98 int IN6ADDR_ISANY(const struct sockaddr_in6 *);
99 int IN6ADDR_ISLOOPBACK(const struct sockaddr_in6 *);
100 void IN6_SET_ADDR_UNSPECIFIED(struct in6_addr *);
101 void IN6_SET_ADDR_LOOPBACK(struct in6_addr *);
102 void IN6ADDR_SETANY(struct sockaddr_in6 *);
103 void IN6ADDR_SETLOOPBACK(struct sockaddr_in6 *);
104 
IN6_IS_ADDR_UNSPECIFIED(const struct in6_addr * a)105 WS2TCPIP_INLINE int IN6_IS_ADDR_UNSPECIFIED(const struct in6_addr *a) { return ((a->s6_words[0]==0) && (a->s6_words[1]==0) && (a->s6_words[2]==0) && (a->s6_words[3]==0) && (a->s6_words[4]==0) && (a->s6_words[5]==0) && (a->s6_words[6]==0) && (a->s6_words[7]==0)); }
IN6_IS_ADDR_LOOPBACK(const struct in6_addr * a)106 WS2TCPIP_INLINE int IN6_IS_ADDR_LOOPBACK(const struct in6_addr *a) { return ((a->s6_words[0]==0) && (a->s6_words[1]==0) && (a->s6_words[2]==0) && (a->s6_words[3]==0) && (a->s6_words[4]==0) && (a->s6_words[5]==0) && (a->s6_words[6]==0) && (a->s6_words[7]==0x0100)); }
IN6_IS_ADDR_MULTICAST(const struct in6_addr * a)107 WS2TCPIP_INLINE int IN6_IS_ADDR_MULTICAST(const struct in6_addr *a) { return (a->s6_bytes[0]==0xff); }
IN6_IS_ADDR_LINKLOCAL(const struct in6_addr * a)108 WS2TCPIP_INLINE int IN6_IS_ADDR_LINKLOCAL(const struct in6_addr *a) { return ((a->s6_bytes[0]==0xfe) && ((a->s6_bytes[1] & 0xc0)==0x80)); }
IN6_IS_ADDR_SITELOCAL(const struct in6_addr * a)109 WS2TCPIP_INLINE int IN6_IS_ADDR_SITELOCAL(const struct in6_addr *a) { return ((a->s6_bytes[0]==0xfe) && ((a->s6_bytes[1] & 0xc0)==0xc0)); }
IN6_IS_ADDR_V4MAPPED(const struct in6_addr * a)110 WS2TCPIP_INLINE int IN6_IS_ADDR_V4MAPPED(const struct in6_addr *a) { return ((a->s6_words[0]==0) && (a->s6_words[1]==0) && (a->s6_words[2]==0) && (a->s6_words[3]==0) && (a->s6_words[4]==0) && (a->s6_words[5]==0xffff)); }
IN6_IS_ADDR_V4COMPAT(const struct in6_addr * a)111 WS2TCPIP_INLINE int IN6_IS_ADDR_V4COMPAT(const struct in6_addr *a) { return ((a->s6_words[0]==0) && (a->s6_words[1]==0) && (a->s6_words[2]==0) && (a->s6_words[3]==0) && (a->s6_words[4]==0) && (a->s6_words[5]==0) && !((a->s6_words[6]==0) && (a->s6_addr[14]==0) && ((a->s6_addr[15]==0) || (a->s6_addr[15]==1)))); }
IN6_IS_ADDR_MC_NODELOCAL(const struct in6_addr * a)112 WS2TCPIP_INLINE int IN6_IS_ADDR_MC_NODELOCAL(const struct in6_addr *a) { return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_bytes[1] & 0xf)==1); }
IN6_IS_ADDR_MC_LINKLOCAL(const struct in6_addr * a)113 WS2TCPIP_INLINE int IN6_IS_ADDR_MC_LINKLOCAL(const struct in6_addr *a) { return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_bytes[1] & 0xf)==2); }
IN6_IS_ADDR_MC_SITELOCAL(const struct in6_addr * a)114 WS2TCPIP_INLINE int IN6_IS_ADDR_MC_SITELOCAL(const struct in6_addr *a) { return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_bytes[1] & 0xf)==5); }
IN6_IS_ADDR_MC_ORGLOCAL(const struct in6_addr * a)115 WS2TCPIP_INLINE int IN6_IS_ADDR_MC_ORGLOCAL(const struct in6_addr *a) { return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_bytes[1] & 0xf)==8); }
IN6_IS_ADDR_MC_GLOBAL(const struct in6_addr * a)116 WS2TCPIP_INLINE int IN6_IS_ADDR_MC_GLOBAL(const struct in6_addr *a) { return IN6_IS_ADDR_MULTICAST(a) && ((a->s6_bytes[1] & 0xf)==0xe); }
IN6ADDR_ISANY(const struct sockaddr_in6 * a)117 WS2TCPIP_INLINE int IN6ADDR_ISANY(const struct sockaddr_in6 *a) { return ((a->sin6_family==AF_INET6) && IN6_IS_ADDR_UNSPECIFIED(&a->sin6_addr)); }
IN6ADDR_ISLOOPBACK(const struct sockaddr_in6 * a)118 WS2TCPIP_INLINE int IN6ADDR_ISLOOPBACK(const struct sockaddr_in6 *a) { return ((a->sin6_family==AF_INET6) && IN6_IS_ADDR_LOOPBACK(&a->sin6_addr)); }
IN6_SET_ADDR_UNSPECIFIED(struct in6_addr * a)119 WS2TCPIP_INLINE void IN6_SET_ADDR_UNSPECIFIED(struct in6_addr *a) { memset(a->s6_bytes,0,sizeof(struct in6_addr)); }
IN6_SET_ADDR_LOOPBACK(struct in6_addr * a)120 WS2TCPIP_INLINE void IN6_SET_ADDR_LOOPBACK(struct in6_addr *a) {
121   memset(a->s6_bytes,0,sizeof(struct in6_addr));
122   a->s6_bytes[15] = 1;
123 }
IN6ADDR_SETANY(struct sockaddr_in6 * a)124 WS2TCPIP_INLINE void IN6ADDR_SETANY(struct sockaddr_in6 *a) {
125   a->sin6_family = AF_INET6;
126   a->sin6_port = 0;
127   a->sin6_flowinfo = 0;
128   IN6_SET_ADDR_UNSPECIFIED(&a->sin6_addr);
129   a->sin6_scope_id = 0;
130 }
IN6ADDR_SETLOOPBACK(struct sockaddr_in6 * a)131 WS2TCPIP_INLINE void IN6ADDR_SETLOOPBACK(struct sockaddr_in6 *a) {
132   a->sin6_family = AF_INET6;
133   a->sin6_port = 0;
134   a->sin6_flowinfo = 0;
135   IN6_SET_ADDR_LOOPBACK(&a->sin6_addr);
136   a->sin6_scope_id = 0;
137 }
138 
139 /* Those declarations are mandatory for Open Group Base spec */
140 #define IN6_IS_ADDR_UNSPECIFIED IN6_IS_ADDR_UNSPECIFIED
141 #define IN6_IS_ADDR_LOOPBACK IN6_IS_ADDR_LOOPBACK
142 #define IN6_IS_ADDR_MULTICAST IN6_IS_ADDR_MULTICAST
143 #define IN6_IS_ADDR_LINKLOCAL IN6_IS_ADDR_LINKLOCAL
144 #define IN6_IS_ADDR_SITELOCAL IN6_IS_ADDR_SITELOCAL
145 #define IN6_IS_ADDR_V4MAPPED IN6_IS_ADDR_V4MAPPED
146 #define IN6_IS_ADDR_V4COMPAT IN6_IS_ADDR_V4COMPAT
147 #define IN6_IS_ADDR_MC_NODELOCAL IN6_IS_ADDR_MC_NODELOCAL
148 #define IN6_IS_ADDR_MC_LINKLOCAL IN6_IS_ADDR_MC_LINKLOCAL
149 #define IN6_IS_ADDR_MC_SITELOCAL IN6_IS_ADDR_MC_SITELOCAL
150 #define IN6_IS_ADDR_MC_ORGLOCAL IN6_IS_ADDR_MC_ORGLOCAL
151 #define IN6_IS_ADDR_MC_GLOBAL IN6_IS_ADDR_MC_GLOBAL
152 
153 #ifdef __cplusplus
154 }
155 #endif
156 
157 typedef struct _INTERFACE_INFO_EX {
158   u_long iiFlags;
159   SOCKET_ADDRESS iiAddress;
160   SOCKET_ADDRESS iiBroadcastAddress;
161   SOCKET_ADDRESS iiNetmask;
162 } INTERFACE_INFO_EX,*LPINTERFACE_INFO_EX;
163 
164 #define IFF_UP 0x00000001
165 #define IFF_BROADCAST 0x00000002
166 #define IFF_LOOPBACK 0x00000004
167 #define IFF_POINTTOPOINT 0x00000008
168 #define IFF_MULTICAST 0x00000010
169 
170 typedef struct in_pktinfo {
171   IN_ADDR ipi_addr;
172   UINT ipi_ifindex;
173 } IN_PKTINFO;
174 
175 C_ASSERT(sizeof(IN_PKTINFO)==8);
176 
177 typedef struct in6_pktinfo {
178   IN6_ADDR ipi6_addr;
179   UINT ipi6_ifindex;
180 } IN6_PKTINFO;
181 
182 C_ASSERT(sizeof(IN6_PKTINFO)==20);
183 
184 #define EAI_AGAIN WSATRY_AGAIN
185 #define EAI_BADFLAGS WSAEINVAL
186 #define EAI_FAIL WSANO_RECOVERY
187 #define EAI_FAMILY WSAEAFNOSUPPORT
188 #define EAI_MEMORY WSA_NOT_ENOUGH_MEMORY
189 
190 #define EAI_NONAME WSAHOST_NOT_FOUND
191 #define EAI_SERVICE WSATYPE_NOT_FOUND
192 #define EAI_SOCKTYPE WSAESOCKTNOSUPPORT
193 
194 #define EAI_NODATA 11004 /* WSANO_DATA */
195 
196 typedef struct addrinfo {
197   int ai_flags;
198   int ai_family;
199   int ai_socktype;
200   int ai_protocol;
201   size_t ai_addrlen;
202   char *ai_canonname;
203   struct sockaddr *ai_addr;
204   struct addrinfo *ai_next;
205 } ADDRINFOA,*PADDRINFOA;
206 
207 typedef struct addrinfoW {
208   int ai_flags;
209   int ai_family;
210   int ai_socktype;
211   int ai_protocol;
212   size_t ai_addrlen;
213   PWSTR ai_canonname;
214   struct sockaddr *ai_addr;
215   struct addrinfoW *ai_next;
216 } ADDRINFOW,*PADDRINFOW;
217 
218 typedef __MINGW_NAME_AW(ADDRINFO) ADDRINFOT,*PADDRINFOT;
219 
220 typedef ADDRINFOA ADDRINFO,*LPADDRINFO;
221 
222 #define AI_PASSIVE                  0x00000001
223 #define AI_CANONNAME                0x00000002
224 #define AI_NUMERICHOST              0x00000004
225 #if (_WIN32_WINNT >= 0x0600)
226 #define AI_NUMERICSERV              0x00000008
227 #define AI_ALL                      0x00000100
228 #define AI_ADDRCONFIG               0x00000400
229 #define AI_V4MAPPED                 0x00000800
230 #define AI_NON_AUTHORITATIVE        0x00004000
231 #define AI_SECURE                   0x00008000
232 #define AI_RETURN_PREFERRED_NAMES   0x00010000
233 #endif
234 #if (_WIN32_WINNT >= 0x0601)
235 #define AI_FQDN                     0x00020000
236 #define AI_FILESERVER               0x00040000
237 #endif
238 #if (_WIN32_WINNT >= 0x0602)
239 #define AI_DISABLE_IDN_ENCODING     0x00080000
240 #endif
241 
242 #ifdef __cplusplus
243 extern "C" {
244 #endif
245 
246 #define GetAddrInfo __MINGW_NAME_AW(GetAddrInfo)
247 
248   WINSOCK_API_LINKAGE int WSAAPI getaddrinfo(const char *nodename,const char *servname,const struct addrinfo *hints,struct addrinfo **res);
249   WINSOCK_API_LINKAGE int WSAAPI GetAddrInfoW(PCWSTR pNodeName,PCWSTR pServiceName,const ADDRINFOW *pHints,PADDRINFOW *ppResult);
250 
251 #define GetAddrInfoA getaddrinfo
252 
253 #if INCL_WINSOCK_API_TYPEDEFS
254   typedef int (WSAAPI *LPFN_GETADDRINFO)(const char *nodename,const char *servname,const struct addrinfo *hints,struct addrinfo **res);
255   typedef int (WSAAPI *LPFN_GETADDRINFOW)(PCWSTR pNodeName,PCWSTR pServiceName,const ADDRINFOW *pHints,PADDRINFOW *ppResult);
256 
257 #define LPFN_GETADDRINFOA LPFN_GETADDRINFO
258 
259 #define LPFN_GETADDRINFOT __MINGW_NAME_AW(LPFN_GETADDRINFO)
260 #endif
261 
262 #define FreeAddrInfo __MINGW_NAME_AW(FreeAddrInfo)
263 
264   WINSOCK_API_LINKAGE void WSAAPI freeaddrinfo(LPADDRINFO pAddrInfo);
265   WINSOCK_API_LINKAGE void WSAAPI FreeAddrInfoW(PADDRINFOW pAddrInfo);
266 
267 #define FreeAddrInfoA freeaddrinfo
268 
269 #if INCL_WINSOCK_API_TYPEDEFS
270   typedef void (WSAAPI *LPFN_FREEADDRINFO)(struct addrinfo *ai);
271   typedef void (WSAAPI *LPFN_FREEADDRINFOW)(PADDRINFOW pAddrInfo);
272 
273 #define LPFN_FREEADDRINFOA LPFN_FREEADDRINFO
274 
275 #define LPFN_FREEADDRINFOT __MINGW_NAME_AW(LPFN_FREEADDRINFO)
276 #endif
277 
278   typedef int socklen_t;
279 
280 #define GetNameInfo __MINGW_NAME_AW(GetNameInfo)
281 
282   WINSOCK_API_LINKAGE int WSAAPI getnameinfo(const struct sockaddr *sa,socklen_t salen,char *host,DWORD hostlen,char *serv,DWORD servlen,int flags);
283   WINSOCK_API_LINKAGE INT WSAAPI GetNameInfoW(const SOCKADDR *pSockaddr,socklen_t SockaddrLength,PWCHAR pNodeBuffer,DWORD NodeBufferSize,PWCHAR pServiceBuffer,DWORD ServiceBufferSize,INT Flags);
284 
285 #define GetNameInfoA getnameinfo
286 
287 #if INCL_WINSOCK_API_TYPEDEFS
288   typedef int (WSAAPI *LPFN_GETNAMEINFO)(const struct sockaddr *sa,socklen_t salen,char *host,DWORD hostlen,char *serv,DWORD servlen,int flags);
289   typedef INT (WSAAPI *LPFN_GETNAMEINFOW)(const SOCKADDR *pSockaddr,socklen_t SockaddrLength,PWCHAR pNodeBuffer,DWORD NodeBufferSize,PWCHAR pServiceBuffer,DWORD ServiceBufferSize,INT Flags);
290 
291 #define LPFN_GETNAMEINFOA LPFN_GETNAMEINFO
292 
293 #define LPFN_GETNAMEINFOT __MINGW_NAME_AW(LPFN_GETNAMEINFO)
294 #endif
295 
296 #define gai_strerror __MINGW_NAME_AW(gai_strerror)
297 
298 #define GAI_STRERROR_BUFFER_SIZE 1024
299 
300 char *gai_strerrorA (int);
301 WCHAR *gai_strerrorW(int);
302 
303 #define NI_MAXHOST 1025
304 #define NI_MAXSERV 32
305 
306 #define INET_ADDRSTRLEN 22
307 #define INET6_ADDRSTRLEN 65
308 
309 #define NI_NOFQDN 0x01
310 #define NI_NUMERICHOST 0x02
311 #define NI_NAMEREQD 0x04
312 #define NI_NUMERICSERV 0x08
313 #define NI_DGRAM 0x10
314 
315 #include <mstcpip.h>
316 
317 #if (_WIN32_WINNT >= 0x0600)
318 #define addrinfoEx __MINGW_NAME_AW(addrinfoEx)
319 #define PADDRINFOEX __MINGW_NAME_AW(PADDRINFOEX)
320 #define GetAddrInfoEx __MINGW_NAME_AW(GetAddrInfoEx)
321 #define SetAddrInfoEx __MINGW_NAME_AW(SetAddrInfoEx)
322 #define FreeAddrInfoEx __MINGW_NAME_AW(FreeAddrInfoEx)
323 
324   typedef struct addrinfoExA {
325     int                ai_flags;
326     int                ai_family;
327     int                ai_socktype;
328     int                ai_protocol;
329     size_t             ai_addrlen;
330     LPCSTR             ai_canonname;
331     struct sockaddr    *ai_addr;
332     void               *ai_blob;
333     size_t             ai_bloblen;
334     LPGUID             ai_provider;
335     struct addrinfoexA *ai_next;
336   } ADDRINFOEXA, *PADDRINFOEXA;
337 
338   typedef struct addrinfoExW {
339     int                ai_flags;
340     int                ai_family;
341     int                ai_socktype;
342     int                ai_protocol;
343     size_t             ai_addrlen;
344     LPCWSTR            ai_canonname;
345     struct sockaddr    *ai_addr;
346     void               *ai_blob;
347     size_t             ai_bloblen;
348     LPGUID             ai_provider;
349     struct addrinfoexW *ai_next;
350   } ADDRINFOEXW, *PADDRINFOEXW;
351 
352 typedef PVOID LPLOOKUPSERVICE_COMPLETION_ROUTINE; /*reserved*/
353 
354 WINSOCK_API_LINKAGE int WSAAPI GetAddrInfoExA(PCSTR pName, PCSTR pServiceName, DWORD dwNameSpace,
355 					      LPGUID lpNspId,const ADDRINFOEXA *pHints,PADDRINFOEXA *ppResult,
356 					      PTIMEVAL timeout,LPOVERLAPPED lpOverlapped,
357 					      LPLOOKUPSERVICE_COMPLETION_ROUTINE lpCompletionRoutine,
358 					      LPHANDLE lpNameHandle);
359 WINSOCK_API_LINKAGE int WSAAPI GetAddrInfoExW(PCWSTR pName,PCWSTR pServiceName,DWORD dwNameSpace,
360 					      LPGUID lpNspId,const ADDRINFOEXW *pHints,PADDRINFOEXW *ppResult,
361 					      PTIMEVAL timeout,LPOVERLAPPED lpOverlapped,
362 					      LPLOOKUPSERVICE_COMPLETION_ROUTINE lpCompletionRoutine,
363 					      LPHANDLE lpNameHandle);
364 
365 WINSOCK_API_LINKAGE int WSAAPI SetAddrInfoExA(PCSTR pName, PCSTR pServiceName, SOCKET_ADDRESS *pAddresses,
366 					      DWORD dwAddressCount,LPBLOB lpBlob,DWORD dwFlags,DWORD dwNameSpace,
367 					      LPGUID lpNspId,PTIMEVAL timeout,LPOVERLAPPED lpOverlapped,
368 					      LPLOOKUPSERVICE_COMPLETION_ROUTINE lpCompletionRoutine,
369 					      LPHANDLE lpNameHandle);
370 WINSOCK_API_LINKAGE int WSAAPI SetAddrInfoExW(PCWSTR pName,PCWSTR pServiceName,SOCKET_ADDRESS *pAddresses,
371 					      DWORD dwAddressCount,LPBLOB lpBlob,DWORD dwFlags,DWORD dwNameSpace,
372 					      LPGUID lpNspId,PTIMEVAL timeout,LPOVERLAPPED lpOverlapped,
373 					      LPLOOKUPSERVICE_COMPLETION_ROUTINE lpCompletionRoutine,
374 					      LPHANDLE lpNameHandle);
375 
376 WINSOCK_API_LINKAGE void WSAAPI FreeAddrInfoExA(PADDRINFOEXA pAddrInfo);
377 WINSOCK_API_LINKAGE void WSAAPI FreeAddrInfoExW(PADDRINFOEXW pAddrInfo);
378 
379 #if INCL_WINSOCK_API_TYPEDEFS
380 #define LPFN_GETADDRINFOEX __MINGW_NAME_AW(LPFN_GETADDRINFOEX)
381   typedef int (WSAAPI *LPFN_GETADDRINFOEXA)(PCSTR pName, PCSTR pServiceName, DWORD dwNameSpace,
382 					    LPGUID lpNspId,const ADDRINFOEXA *pHints,PADDRINFOEXA *ppResult,
383 					    PTIMEVAL timeout,LPOVERLAPPED lpOverlapped,
384 					    LPLOOKUPSERVICE_COMPLETION_ROUTINE lpCompletionRoutine,
385 					    LPHANDLE lpNameHandle);
386   typedef int (WSAAPI *LPFN_GETADDRINFOEXW)(PCWSTR pName,PCWSTR pServiceName,DWORD dwNameSpace,
387 					    LPGUID lpNspId,const ADDRINFOEXW *pHints,PADDRINFOEXW *ppResult,
388 					    PTIMEVAL timeout,LPOVERLAPPED lpOverlapped,
389 					    LPLOOKUPSERVICE_COMPLETION_ROUTINE lpCompletionRoutine,
390 					    LPHANDLE lpNameHandle);
391 
392 #define LPFN_SETADDRINFOEX __MINGW_NAME_AW(LPFN_SETADDRINFOEX)
393   typedef int (WSAAPI *LPFN_SETADDRINFOEXA)(PCSTR pName, PCSTR pServiceName, SOCKET_ADDRESS *pAddresses,
394 					    DWORD dwAddressCount,LPBLOB lpBlob,DWORD dwFlags,DWORD dwNameSpace,
395 					    LPGUID lpNspId,PTIMEVAL timeout,LPOVERLAPPED lpOverlapped,
396 					    LPLOOKUPSERVICE_COMPLETION_ROUTINE lpCompletionRoutine,
397 					    LPHANDLE lpNameHandle);
398   typedef int (WSAAPI *LPFN_SETADDRINFOEXW)(PCWSTR pName,PCWSTR pServiceName,SOCKET_ADDRESS *pAddresses,
399 					    DWORD dwAddressCount,LPBLOB lpBlob,DWORD dwFlags,DWORD dwNameSpace,
400 					    LPGUID lpNspId,PTIMEVAL timeout,LPOVERLAPPED lpOverlapped,
401 					    LPLOOKUPSERVICE_COMPLETION_ROUTINE lpCompletionRoutine,
402 					    LPHANDLE lpNameHandle);
403 
404 #define LPFN_FREEADDRINFOEX __MINGW_NAME_AW(LPFN_FREEADDRINFOEX)
405   typedef void (WSAAPI *LPFN_FREEADDRINFOEXA)(PADDRINFOEXA pAddrInfo);
406   typedef void (WSAAPI *LPFN_FREEADDRINFOEXW)(PADDRINFOEXW pAddrInfo);
407 #endif /* INCL_WINSOCK_API_TYPEDEFS */
408 
409 
410 WINSOCK_API_LINKAGE int WSAAPI WSAImpersonateSocketPeer(
411   SOCKET Socket,
412   const struct sockaddr *PeerAddress,
413   ULONG peerAddressLen
414 );
415 
416 WINSOCK_API_LINKAGE int WSAAPI WSAQuerySocketSecurity(
417   SOCKET Socket,
418   const SOCKET_SECURITY_QUERY_TEMPLATE *SecurityQueryTemplate,
419   ULONG SecurityQueryTemplateLen,
420   SOCKET_SECURITY_QUERY_INFO *SecurityQueryInfo,
421   ULONG *SecurityQueryInfoLen,
422   LPWSAOVERLAPPED Overlapped,
423   LPWSAOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine
424 );
425 
426 WINSOCK_API_LINKAGE int WSAAPI WSARevertImpersonation(void);
427 
428 WINSOCK_API_LINKAGE int WSAAPI WSASetSocketPeerTargetName(
429   SOCKET Socket,
430   const SOCKET_PEER_TARGET_NAME *PeerTargetName,
431   ULONG PeerTargetNameLen,
432   LPWSAOVERLAPPED Overlapped,
433   LPWSAOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine
434 );
435 
436 WINSOCK_API_LINKAGE int WSAAPI WSASetSocketSecurity(
437   SOCKET Socket,
438   const SOCKET_SECURITY_SETTINGS *SecuritySettings,
439   ULONG SecuritySettingsLen,
440   LPWSAOVERLAPPED Overlapped,
441   LPWSAOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine
442 );
443 
444 #define InetNtopA inet_ntop
445 
446 WINSOCK_API_LINKAGE LPCWSTR WSAAPI InetNtopW(INT Family, PVOID pAddr, LPWSTR pStringBuf, size_t StringBufSIze);
447 WINSOCK_API_LINKAGE LPCSTR WSAAPI InetNtopA(INT Family, PVOID pAddr, LPSTR pStringBuf, size_t StringBufSize);
448 
449 #define InetNtop __MINGW_NAME_AW(InetNtop)
450 
451 #define InetPtonA inet_pton
452 
453 WINSOCK_API_LINKAGE INT WSAAPI InetPtonW(INT Family, LPCWSTR pStringBuf, PVOID pAddr);
454 WINSOCK_API_LINKAGE INT WSAAPI InetPtonA(INT Family, LPCSTR pStringBuf, PVOID pAddr);
455 
456 #define InetPton __MINGW_NAME_AW(InetPton)
457 
458 #endif /*(_WIN32_WINNT >= 0x0600)*/
459 
460 #ifdef __cplusplus
461 }
462 #endif
463 
464 #ifdef __LP64__
465 #pragma pop_macro("u_long")
466 #endif
467 
468 #endif /* _WS2TCPIP_H_ */
469