xref: /reactos/sdk/include/psdk/winsock2.h (revision 34593d93)
1 #pragma once
2 
3 #if !(defined _WINSOCK2API_ || defined _WINSOCKAPI_)
4 #define _WINSOCK2API_
5 #define _WINSOCKAPI_ /* to prevent later inclusion of winsock.h */
6 
7 #define _GNU_H_WINDOWS32_SOCKETS
8 
9 #if (!defined(_WIN64) && !defined(WIN32))
10 #include <pshpack4.h>
11 #define _NEED_POPPACK
12 #endif
13 
14 #ifndef INCL_WINSOCK_API_PROTOTYPES
15 #define INCL_WINSOCK_API_PROTOTYPES 1
16 #endif
17 
18 #ifndef INCL_WINSOCK_API_TYPEDEFS
19 #define INCL_WINSOCK_API_TYPEDEFS 0
20 #endif
21 
22 #ifndef _INC_WINDOWS
23 #include <windows.h>
24 #endif
25 
26 #if !defined(MAKEWORD)
27 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
28 #endif
29 
30 #ifndef WINSOCK_VERSION
31 #define WINSOCK_VERSION MAKEWORD(2,2)
32 #endif
33 
34 #ifndef WINSOCK_API_LINKAGE
35 #ifdef DECLSPEC_IMPORT
36 #define WINSOCK_API_LINKAGE DECLSPEC_IMPORT
37 #else
38 #define WINSOCK_API_LINKAGE
39 #endif
40 #endif
41 
42 #if defined(__LP64__) || (!defined(_M_AMD64) && defined(__WINESRC__))
43 #if !defined(__ROS_LONG64__)
44 #define __ROS_LONG64__
45 #endif
46 #endif
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 /* Names common to Winsock1.1 and Winsock2 */
53 #if !defined ( _BSDTYPES_DEFINED )
54 /* also defined in gmon.h and in cygwin's sys/types */
55 typedef unsigned char u_char;
56 typedef unsigned short u_short;
57 typedef unsigned int u_int;
58 #ifndef __ROS_LONG64__
59 typedef unsigned long u_long;
60 #else
61 typedef unsigned int u_long;
62 #endif
63 #define _BSDTYPES_DEFINED
64 #endif /* ! def _BSDTYPES_DEFINED  */
65 
66 #if(_WIN32_WINNT >= 0x0501)
67 typedef unsigned __int64 u_int64;
68 #endif /* (_WIN32_WINNT >= 0x0501) */
69 
70 #include <ws2def.h>
71 
72 typedef UINT_PTR SOCKET;
73 
74 #ifndef FD_SETSIZE
75 #define FD_SETSIZE 64
76 #endif
77 
78 #ifndef _SYS_TYPES_FD_SET
79 
80 /* fd_set may be defined by the newlib <sys/types.h>
81  * if __USE_W32_SOCKETS not defined.
82  */
83 #ifdef fd_set
84 #undef fd_set
85 #endif
86 
87 typedef struct fd_set {
88   u_int fd_count;
89   SOCKET fd_array[FD_SETSIZE];
90 } fd_set;
91 
92 extern int PASCAL FAR __WSAFDIsSet(SOCKET,fd_set FAR*);
93 
94 #ifndef FD_CLR
95 #define FD_CLR(fd, set) do { \
96   u_int __i; \
97   for (__i = 0; __i < ((fd_set FAR*)(set))->fd_count ; __i++) { \
98     if (((fd_set FAR*)(set))->fd_array[__i] == fd) { \
99       while (__i < ((fd_set FAR*)(set))->fd_count-1) { \
100         ((fd_set FAR*)(set))->fd_array[__i] = \
101         ((fd_set FAR*)(set))->fd_array[__i+1]; \
102         __i++; \
103       } \
104     ((fd_set FAR*)(set))->fd_count--; \
105     break; \
106     } \
107   } \
108 } while(0)
109 #endif
110 
111 #ifndef FD_SET
112 /* this differs from the define in winsock.h and in cygwin sys/types.h */
113 #define FD_SET(fd, set) do { \
114   u_int __i; \
115   for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count; __i++) { \
116     if (((fd_set FAR *)(set))->fd_array[__i] == (fd)) { \
117       break; \
118     } \
119   } \
120   if (__i == ((fd_set FAR *)(set))->fd_count) { \
121     if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) { \
122       ((fd_set FAR *)(set))->fd_array[__i] = (fd); \
123       ((fd_set FAR *)(set))->fd_count++; \
124     } \
125   } \
126 } while(0)
127 #endif
128 
129 #ifndef FD_ZERO
130 #define FD_ZERO(set) (((fd_set FAR*)(set))->fd_count=0)
131 #endif
132 
133 #ifndef FD_ISSET
134 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set FAR*)(set))
135 #endif
136 
137 #elif !defined (USE_SYS_TYPES_FD_SET)
138 #warning "fd_set and associated macros have been defined in sys/types.  \
139     This may cause runtime problems with W32 sockets"
140 #endif /* ndef _SYS_TYPES_FD_SET */
141 
142 #if !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__))
143 
144 #ifndef _TIMEVAL_DEFINED
145 
146 /* also in sys/time.h */
147 #define _TIMEVAL_DEFINED
148 #define _STRUCT_TIMEVAL
149 struct timeval {
150   LONG tv_sec;
151   LONG tv_usec;
152 };
153 
154 #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
155 
156 #define timercmp(tvp, uvp, cmp) \
157   (((tvp)->tv_sec != (uvp)->tv_sec) ? \
158   ((tvp)->tv_sec cmp (uvp)->tv_sec) : \
159   ((tvp)->tv_usec cmp (uvp)->tv_usec))
160 
161 #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
162 
163 #endif /* _TIMEVAL_DEFINED */
164 
165 #define h_addr h_addr_list[0]
166 
167 struct hostent {
168   char *h_name;
169   char **h_aliases;
170   short h_addrtype;
171   short h_length;
172   char **h_addr_list;
173 };
174 
175 struct linger {
176   u_short l_onoff;
177   u_short l_linger;
178 };
179 
180 #define FIONBIO _IOW('f', 126, u_long)
181 
182 struct netent {
183   char * n_name;
184   char **n_aliases;
185   short n_addrtype;
186   u_long n_net;
187 };
188 
189 struct servent {
190   char FAR *s_name;
191   char FAR **s_aliases;
192 #ifdef _WIN64
193   char FAR *s_proto;
194   short s_port;
195 #else
196   short s_port;
197   char FAR *s_proto;
198 #endif
199 };
200 
201 struct protoent {
202   char *p_name;
203   char **p_aliases;
204   short p_proto;
205 };
206 
207 #define SOMAXCONN 0x7fffffff
208 
209 #define MSG_OOB 1
210 #define MSG_PEEK 2
211 #define MSG_DONTROUTE 4
212 #if(_WIN32_WINNT >= 0x0502)
213 #define MSG_WAITALL 8
214 #endif
215 
216 #define h_errno WSAGetLastError()
217 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
218 #define TRY_AGAIN WSATRY_AGAIN
219 #define NO_RECOVERY WSANO_RECOVERY
220 #define NO_DATA WSANO_DATA
221 #define NO_ADDRESS WSANO_ADDRESS
222 
223 #endif /* !(defined (__INSIDE_CYGWIN__) || defined (__INSIDE_MSYS__)) */
224 
225 #define FIONREAD _IOR('f', 127, u_long)
226 #define FIOASYNC _IOW('f', 125, u_long)
227 #define SIOCSHIWAT _IOW('s',  0, u_long)
228 #define SIOCGHIWAT _IOR('s',  1, u_long)
229 #define SIOCSLOWAT _IOW('s',  2, u_long)
230 #define SIOCGLOWAT _IOR('s',  3, u_long)
231 #define SIOCATMARK _IOR('s',  7, u_long)
232 
233 #define IMPLINK_IP 155
234 #define IMPLINK_LOWEXPER 156
235 #define IMPLINK_HIGHEXPER 158
236 
237 #define ADDR_ANY INADDR_ANY
238 
239 #define WSADESCRIPTION_LEN 256
240 #define WSASYS_STATUS_LEN 128
241 
242 #define INVALID_SOCKET (SOCKET)(~0)
243 
244 #define SOCKET_ERROR (-1)
245 
246 #define FROM_PROTOCOL_INFO (-1)
247 
248 #define SO_PROTOCOL_INFOA 0x2004
249 #define SO_PROTOCOL_INFOW 0x2005
250 #ifdef UNICODE
251 #define SO_PROTOCOL_INFO SO_PROTOCOL_INFOW
252 #else
253 #define SO_PROTOCOL_INFO SO_PROTOCOL_INFOA
254 #endif
255 #define PVD_CONFIG 0x3001
256 
257 #define PF_UNSPEC AF_UNSPEC
258 #define PF_UNIX AF_UNIX
259 #define PF_INET AF_INET
260 #define PF_IMPLINK AF_IMPLINK
261 #define PF_PUP AF_PUP
262 #define PF_CHAOS AF_CHAOS
263 #define PF_NS AF_NS
264 #define PF_IPX AF_IPX
265 #define PF_ISO AF_ISO
266 #define PF_OSI AF_OSI
267 #define PF_ECMA AF_ECMA
268 #define PF_DATAKIT AF_DATAKIT
269 #define PF_CCITT AF_CCITT
270 #define PF_SNA AF_SNA
271 #define PF_DECnet AF_DECnet
272 #define PF_DLI AF_DLI
273 #define PF_LAT AF_LAT
274 #define PF_HYLINK AF_HYLINK
275 #define PF_APPLETALK AF_APPLETALK
276 #define PF_VOICEVIEW AF_VOICEVIEW
277 #define PF_FIREFOX AF_FIREFOX
278 #define PF_UNKNOWN1 AF_UNKNOWN1
279 #define PF_BAN AF_BAN
280 #define PF_ATM AF_ATM
281 #define PF_INET6 AF_INET6
282 #if(_WIN32_WINNT >= 0x0600)
283 #define PF_BTH AF_BTH
284 #endif
285 #define PF_MAX AF_MAX
286 
287 #define MSG_PARTIAL 0x8000
288 #define MSG_INTERRUPT 0x10
289 #define MSG_MAXIOVLEN 16
290 
291 #define MAXGETHOSTSTRUCT 1024
292 
293 #define FD_READ_BIT 0
294 #define FD_READ (1 << FD_READ_BIT)
295 #define FD_WRITE_BIT 1
296 #define FD_WRITE (1 << FD_WRITE_BIT)
297 #define FD_OOB_BIT 2
298 #define FD_OOB (1 << FD_OOB_BIT)
299 #define FD_ACCEPT_BIT 3
300 #define FD_ACCEPT (1 << FD_ACCEPT_BIT)
301 #define FD_CONNECT_BIT 4
302 #define FD_CONNECT (1 << FD_CONNECT_BIT)
303 #define FD_CLOSE_BIT 5
304 #define FD_CLOSE (1 << FD_CLOSE_BIT)
305 #define FD_QOS_BIT 6
306 #define FD_QOS (1 << FD_QOS_BIT)
307 #define FD_GROUP_QOS_BIT 7
308 #define FD_GROUP_QOS (1 << FD_GROUP_QOS_BIT)
309 #define FD_ROUTING_INTERFACE_CHANGE_BIT 8
310 #define FD_ROUTING_INTERFACE_CHANGE (1 << FD_ROUTING_INTERFACE_CHANGE_BIT)
311 #define FD_ADDRESS_LIST_CHANGE_BIT 9
312 #define FD_ADDRESS_LIST_CHANGE (1 << FD_ADDRESS_LIST_CHANGE_BIT)
313 #define FD_MAX_EVENTS 10
314 #define FD_ALL_EVENTS ((1 << FD_MAX_EVENTS) - 1)
315 
316 #ifndef WSABASEERR
317 
318 #define WSABASEERR 10000
319 #define WSAEINTR (WSABASEERR+4)
320 #define WSAEBADF (WSABASEERR+9)
321 #define WSAEACCES (WSABASEERR+13)
322 #define WSAEFAULT (WSABASEERR+14)
323 #define WSAEINVAL (WSABASEERR+22)
324 #define WSAEMFILE (WSABASEERR+24)
325 #define WSAEWOULDBLOCK (WSABASEERR+35)
326 #define WSAEINPROGRESS (WSABASEERR+36)
327 #define WSAEALREADY (WSABASEERR+37)
328 #define WSAENOTSOCK (WSABASEERR+38)
329 #define WSAEDESTADDRREQ (WSABASEERR+39)
330 #define WSAEMSGSIZE (WSABASEERR+40)
331 #define WSAEPROTOTYPE (WSABASEERR+41)
332 #define WSAENOPROTOOPT (WSABASEERR+42)
333 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
334 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
335 #define WSAEOPNOTSUPP (WSABASEERR+45)
336 #define WSAEPFNOSUPPORT (WSABASEERR+46)
337 #define WSAEAFNOSUPPORT (WSABASEERR+47)
338 #define WSAEADDRINUSE (WSABASEERR+48)
339 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
340 #define WSAENETDOWN (WSABASEERR+50)
341 #define WSAENETUNREACH (WSABASEERR+51)
342 #define WSAENETRESET (WSABASEERR+52)
343 #define WSAECONNABORTED (WSABASEERR+53)
344 #define WSAECONNRESET (WSABASEERR+54)
345 #define WSAENOBUFS (WSABASEERR+55)
346 #define WSAEISCONN (WSABASEERR+56)
347 #define WSAENOTCONN (WSABASEERR+57)
348 #define WSAESHUTDOWN (WSABASEERR+58)
349 #define WSAETOOMANYREFS (WSABASEERR+59)
350 #define WSAETIMEDOUT (WSABASEERR+60)
351 #define WSAECONNREFUSED (WSABASEERR+61)
352 #define WSAELOOP (WSABASEERR+62)
353 #define WSAENAMETOOLONG (WSABASEERR+63)
354 #define WSAEHOSTDOWN (WSABASEERR+64)
355 #define WSAEHOSTUNREACH (WSABASEERR+65)
356 #define WSAENOTEMPTY (WSABASEERR+66)
357 #define WSAEPROCLIM (WSABASEERR+67)
358 #define WSAEUSERS (WSABASEERR+68)
359 #define WSAEDQUOT (WSABASEERR+69)
360 #define WSAESTALE (WSABASEERR+70)
361 #define WSAEREMOTE (WSABASEERR+71)
362 #define WSASYSNOTREADY (WSABASEERR+91)
363 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
364 #define WSANOTINITIALISED (WSABASEERR+93)
365 #define WSAEDISCON (WSABASEERR+101)
366 #define WSAENOMORE (WSABASEERR+102)
367 #define WSAECANCELLED (WSABASEERR+103)
368 #define WSAEINVALIDPROCTABLE (WSABASEERR+104)
369 #define WSAEINVALIDPROVIDER (WSABASEERR+105)
370 #define WSAEPROVIDERFAILEDINIT (WSABASEERR+106)
371 #define WSASYSCALLFAILURE (WSABASEERR+107)
372 #define WSASERVICE_NOT_FOUND (WSABASEERR+108)
373 #define WSATYPE_NOT_FOUND (WSABASEERR+109)
374 #define WSA_E_NO_MORE (WSABASEERR+110)
375 #define WSA_E_CANCELLED (WSABASEERR+111)
376 #define WSAEREFUSED (WSABASEERR+112)
377 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
378 #define WSATRY_AGAIN (WSABASEERR+1002)
379 #define WSANO_RECOVERY (WSABASEERR+1003)
380 #define WSANO_DATA (WSABASEERR+1004)
381 #define WSA_QOS_RECEIVERS (WSABASEERR + 1005)
382 #define WSA_QOS_SENDERS (WSABASEERR + 1006)
383 #define WSA_QOS_NO_SENDERS (WSABASEERR + 1007)
384 #define WSA_QOS_NO_RECEIVERS (WSABASEERR + 1008)
385 #define WSA_QOS_REQUEST_CONFIRMED (WSABASEERR + 1009)
386 #define WSA_QOS_ADMISSION_FAILURE (WSABASEERR + 1010)
387 #define WSA_QOS_POLICY_FAILURE (WSABASEERR + 1011)
388 #define WSA_QOS_BAD_STYLE (WSABASEERR + 1012)
389 #define WSA_QOS_BAD_OBJECT (WSABASEERR + 1013)
390 #define WSA_QOS_TRAFFIC_CTRL_ERROR (WSABASEERR + 1014)
391 #define WSA_QOS_GENERIC_ERROR (WSABASEERR + 1015)
392 #define WSA_QOS_ESERVICETYPE (WSABASEERR + 1016)
393 #define WSA_QOS_EFLOWSPEC (WSABASEERR + 1017)
394 #define WSA_QOS_EPROVSPECBUF (WSABASEERR + 1018)
395 #define WSA_QOS_EFILTERSTYLE (WSABASEERR + 1019)
396 #define WSA_QOS_EFILTERTYPE (WSABASEERR + 1020)
397 #define WSA_QOS_EFILTERCOUNT (WSABASEERR + 1021)
398 #define WSA_QOS_EOBJLENGTH (WSABASEERR + 1022)
399 #define WSA_QOS_EFLOWCOUNT (WSABASEERR + 1023)
400 #define WSA_QOS_EUNKOWNPSOBJ (WSABASEERR + 1024)
401 #define WSA_QOS_EPOLICYOBJ (WSABASEERR + 1025)
402 #define WSA_QOS_EFLOWDESC (WSABASEERR + 1026)
403 #define WSA_QOS_EPSFLOWSPEC (WSABASEERR + 1027)
404 #define WSA_QOS_EPSFILTERSPEC (WSABASEERR + 1028)
405 #define WSA_QOS_ESDMODEOBJ (WSABASEERR + 1029)
406 #define WSA_QOS_ESHAPERATEOBJ (WSABASEERR + 1030)
407 #define WSA_QOS_RESERVED_PETYPE (WSABASEERR + 1031)
408 
409 #endif /* !WSABASEERR */
410 
411 #define WSANO_ADDRESS WSANO_DATA
412 
413 #define CF_ACCEPT 0x0000
414 #define CF_REJECT 0x0001
415 #define CF_DEFER 0x0002
416 #define SD_RECEIVE 0x00
417 #define SD_SEND 0x01
418 #define SD_BOTH 0x02
419 
420 #define SG_UNCONSTRAINED_GROUP 0x01
421 #define SG_CONSTRAINED_GROUP 0x02
422 
423 #define MAX_PROTOCOL_CHAIN 7
424 
425 #define BASE_PROTOCOL      1
426 #define LAYERED_PROTOCOL   0
427 
428 #define WSAPROTOCOL_LEN 255
429 
430 #define PFL_MULTIPLE_PROTO_ENTRIES          0x00000001
431 #define PFL_RECOMMENDED_PROTO_ENTRY         0x00000002
432 #define PFL_HIDDEN                          0x00000004
433 #define PFL_MATCHES_PROTOCOL_ZERO           0x00000008
434 #define PFL_NETWORKDIRECT_PROVIDER          0x00000010
435 
436 #define XP1_CONNECTIONLESS                  0x00000001
437 #define XP1_GUARANTEED_DELIVERY             0x00000002
438 #define XP1_GUARANTEED_ORDER                0x00000004
439 #define XP1_MESSAGE_ORIENTED                0x00000008
440 #define XP1_PSEUDO_STREAM                   0x00000010
441 #define XP1_GRACEFUL_CLOSE                  0x00000020
442 #define XP1_EXPEDITED_DATA                  0x00000040
443 #define XP1_CONNECT_DATA                    0x00000080
444 #define XP1_DISCONNECT_DATA                 0x00000100
445 #define XP1_SUPPORT_BROADCAST               0x00000200
446 #define XP1_SUPPORT_MULTIPOINT              0x00000400
447 #define XP1_MULTIPOINT_CONTROL_PLANE        0x00000800
448 #define XP1_MULTIPOINT_DATA_PLANE           0x00001000
449 #define XP1_QOS_SUPPORTED                   0x00002000
450 #define XP1_INTERRUPT                       0x00004000
451 #define XP1_UNI_SEND                        0x00008000
452 #define XP1_UNI_RECV                        0x00010000
453 #define XP1_IFS_HANDLES                     0x00020000
454 #define XP1_PARTIAL_MESSAGE                 0x00040000
455 #define XP1_SAN_SUPPORT_SDP                 0x00080000
456 
457 #define BIGENDIAN                           0x0000
458 #define LITTLEENDIAN                        0x0001
459 
460 #define SECURITY_PROTOCOL_NONE              0x0000
461 
462 #define JL_SENDER_ONLY                      0x01
463 #define JL_RECEIVER_ONLY                    0x02
464 #define JL_BOTH                             0x04
465 
466 #define WSA_FLAG_OVERLAPPED                 0x01
467 #define WSA_FLAG_MULTIPOINT_C_ROOT          0x02
468 #define WSA_FLAG_MULTIPOINT_C_LEAF          0x04
469 #define WSA_FLAG_MULTIPOINT_D_ROOT          0x08
470 #define WSA_FLAG_MULTIPOINT_D_LEAF          0x10
471 #define WSA_FLAG_ACCESS_SYSTEM_SECURITY     0x40
472 
473 #define TH_NETDEV                           0x00000001
474 #define TH_TAPI                             0x00000002
475 
476 #define SERVICE_MULTIPLE                    0x00000001
477 
478 #define RES_UNUSED_1    0x00000001
479 #define RES_FLUSH_CACHE 0x00000002
480 #ifndef RES_SERVICE
481 #define RES_SERVICE     0x00000004
482 #endif
483 
484 #define SERVICE_TYPE_VALUE_IPXPORTA      "IpxSocket"
485 #define SERVICE_TYPE_VALUE_IPXPORTW     L"IpxSocket"
486 #define SERVICE_TYPE_VALUE_SAPIDA        "SapId"
487 #define SERVICE_TYPE_VALUE_SAPIDW       L"SapId"
488 
489 #define SERVICE_TYPE_VALUE_TCPPORTA      "TcpPort"
490 #define SERVICE_TYPE_VALUE_TCPPORTW     L"TcpPort"
491 
492 #define SERVICE_TYPE_VALUE_UDPPORTA      "UdpPort"
493 #define SERVICE_TYPE_VALUE_UDPPORTW     L"UdpPort"
494 
495 #define SERVICE_TYPE_VALUE_OBJECTIDA     "ObjectId"
496 #define SERVICE_TYPE_VALUE_OBJECTIDW    L"ObjectId"
497 
498 #ifdef UNICODE
499 #define SERVICE_TYPE_VALUE_SAPID        SERVICE_TYPE_VALUE_SAPIDW
500 #define SERVICE_TYPE_VALUE_TCPPORT      SERVICE_TYPE_VALUE_TCPPORTW
501 #define SERVICE_TYPE_VALUE_UDPPORT      SERVICE_TYPE_VALUE_UDPPORTW
502 #define SERVICE_TYPE_VALUE_OBJECTID     SERVICE_TYPE_VALUE_OBJECTIDW
503 #else
504 #define SERVICE_TYPE_VALUE_SAPID        SERVICE_TYPE_VALUE_SAPIDA
505 #define SERVICE_TYPE_VALUE_TCPPORT      SERVICE_TYPE_VALUE_TCPPORTA
506 #define SERVICE_TYPE_VALUE_UDPPORT      SERVICE_TYPE_VALUE_UDPPORTA
507 #define SERVICE_TYPE_VALUE_OBJECTID     SERVICE_TYPE_VALUE_OBJECTIDA
508 #endif
509 
510 #define LUP_DEEP                0x0001
511 #define LUP_CONTAINERS          0x0002
512 #define LUP_NOCONTAINERS        0x0004
513 #define LUP_NEAREST             0x0008
514 #define LUP_RETURN_NAME         0x0010
515 #define LUP_RETURN_TYPE         0x0020
516 #define LUP_RETURN_VERSION      0x0040
517 #define LUP_RETURN_COMMENT      0x0080
518 #define LUP_RETURN_ADDR         0x0100
519 #define LUP_RETURN_BLOB         0x0200
520 #define LUP_RETURN_ALIASES      0x0400
521 #define LUP_RETURN_QUERY_STRING 0x0800
522 #define LUP_RETURN_ALL          0x0FF0
523 #define LUP_RES_SERVICE         0x8000
524 #define LUP_FLUSHCACHE          0x1000
525 #define LUP_FLUSHPREVIOUS       0x2000
526 #define LUP_NON_AUTHORITATIVE   0x4000
527 #define LUP_SECURE              0x8000
528 #define LUP_RETURN_PREFERRED_NAMES 0x10000
529 #define LUP_ADDRCONFIG          0x00100000
530 #define LUP_DUAL_ADDR           0x00200000
531 #define LUP_FILESERVER          0x00400000
532 
533 #define RESULT_IS_ALIAS      0x0001
534 #if(_WIN32_WINNT >= 0x0501)
535 #define RESULT_IS_ADDED      0x0010
536 #define RESULT_IS_CHANGED    0x0020
537 #define RESULT_IS_DELETED    0x0040
538 #endif
539 
540 #ifndef s_addr
541 
542 #define s_addr S_un.S_addr
543 #define s_host S_un.S_un_b.s_b2
544 #define s_net S_un.S_un_b.s_b1
545 #define s_imp S_un.S_un_w.s_w2
546 #define s_impno S_un.S_un_b.s_b4
547 #define s_lh S_un.S_un_b.s_b3
548 
549 typedef struct in_addr {
550   union {
551     struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
552     struct { u_short s_w1,s_w2; } S_un_w;
553     u_long S_addr;
554   } S_un;
555 } IN_ADDR, *PIN_ADDR;
556 
557 #endif /* s_addr */
558 
559 typedef struct WSAData {
560   WORD wVersion;
561   WORD wHighVersion;
562 #ifdef _WIN64
563   unsigned short iMaxSockets;
564   unsigned short iMaxUdpDg;
565   char FAR *lpVendorInfo;
566   char szDescription[WSADESCRIPTION_LEN+1];
567   char szSystemStatus[WSASYS_STATUS_LEN+1];
568 #else
569   char szDescription[WSADESCRIPTION_LEN+1];
570   char szSystemStatus[WSASYS_STATUS_LEN+1];
571   unsigned short iMaxSockets;
572   unsigned short iMaxUdpDg;
573   char FAR *lpVendorInfo;
574 #endif
575 } WSADATA, FAR *LPWSADATA;
576 
577 struct sockproto {
578   u_short sp_family;
579   u_short sp_protocol;
580 };
581 
582 #ifdef WIN32
583 
584 #define WSAAPI FAR PASCAL
585 #define WSAEVENT HANDLE
586 #define LPWSAEVENT LPHANDLE
587 #define WSAOVERLAPPED OVERLAPPED
588 typedef struct _OVERLAPPED *LPWSAOVERLAPPED;
589 #define WSA_IO_PENDING (ERROR_IO_PENDING)
590 #define WSA_IO_INCOMPLETE (ERROR_IO_INCOMPLETE)
591 #define WSA_INVALID_HANDLE (ERROR_INVALID_HANDLE)
592 #define WSA_INVALID_PARAMETER (ERROR_INVALID_PARAMETER)
593 #define WSA_NOT_ENOUGH_MEMORY (ERROR_NOT_ENOUGH_MEMORY)
594 #define WSA_OPERATION_ABORTED (ERROR_OPERATION_ABORTED)
595 #define WSA_INVALID_EVENT ((WSAEVENT)NULL)
596 #define WSA_MAXIMUM_WAIT_EVENTS (MAXIMUM_WAIT_OBJECTS)
597 #define WSA_WAIT_FAILED ((DWORD)-1L)
598 #define WSA_WAIT_EVENT_0 (WAIT_OBJECT_0)
599 #define WSA_WAIT_IO_COMPLETION (WAIT_IO_COMPLETION)
600 #define WSA_WAIT_TIMEOUT (WAIT_TIMEOUT)
601 #define WSA_INFINITE (INFINITE)
602 
603 #else /* WIN16 */
604 
605 #define WSAAPI FAR PASCAL
606 typedef DWORD WSAEVENT, FAR * LPWSAEVENT;
607 
608 typedef struct _WSAOVERLAPPED {
609   DWORD Internal;
610   DWORD InternalHigh;
611   DWORD Offset;
612   DWORD OffsetHigh;
613   WSAEVENT hEvent;
614 } WSAOVERLAPPED, FAR * LPWSAOVERLAPPED;
615 
616 #define WSA_IO_PENDING (WSAEWOULDBLOCK)
617 #define WSA_IO_INCOMPLETE (WSAEWOULDBLOCK)
618 #define WSA_INVALID_HANDLE (WSAENOTSOCK)
619 #define WSA_INVALID_PARAMETER (WSAEINVAL)
620 #define WSA_NOT_ENOUGH_MEMORY (WSAENOBUFS)
621 #define WSA_OPERATION_ABORTED (WSAEINTR)
622 
623 #define WSA_INVALID_EVENT ((WSAEVENT)NULL)
624 #define WSA_MAXIMUM_WAIT_EVENTS (MAXIMUM_WAIT_OBJECTS)
625 #define WSA_WAIT_FAILED ((DWORD)-1L)
626 #define WSA_WAIT_EVENT_0 ((DWORD)0)
627 #define WSA_WAIT_TIMEOUT ((DWORD)0x102L)
628 #define WSA_INFINITE ((DWORD)-1L)
629 
630 #endif /* WIN32 */
631 
632 #include <qos.h>
633 
634 typedef struct _QualityOfService {
635   FLOWSPEC SendingFlowspec;
636   FLOWSPEC ReceivingFlowspec;
637   WSABUF ProviderSpecific;
638 } QOS, *LPQOS;
639 
640 typedef unsigned int GROUP;
641 
642 typedef struct _WSANETWORKEVENTS {
643   LONG lNetworkEvents;
644   int iErrorCode[FD_MAX_EVENTS];
645 } WSANETWORKEVENTS, *LPWSANETWORKEVENTS;
646 
647 #ifndef GUID_DEFINED
648 #include <guiddef.h>
649 #endif
650 
651 typedef struct _WSAPROTOCOLCHAIN {
652   int ChainLen;
653   DWORD ChainEntries[MAX_PROTOCOL_CHAIN];
654 } WSAPROTOCOLCHAIN, *LPWSAPROTOCOLCHAIN;
655 
656 typedef struct _WSAPROTOCOL_INFOA {
657   DWORD dwServiceFlags1;
658   DWORD dwServiceFlags2;
659   DWORD dwServiceFlags3;
660   DWORD dwServiceFlags4;
661   DWORD dwProviderFlags;
662   GUID ProviderId;
663   DWORD dwCatalogEntryId;
664   WSAPROTOCOLCHAIN ProtocolChain;
665   int iVersion;
666   int iAddressFamily;
667   int iMaxSockAddr;
668   int iMinSockAddr;
669   int iSocketType;
670   int iProtocol;
671   int iProtocolMaxOffset;
672   int iNetworkByteOrder;
673   int iSecurityScheme;
674   DWORD dwMessageSize;
675   DWORD dwProviderReserved;
676   CHAR szProtocol[WSAPROTOCOL_LEN+1];
677 } WSAPROTOCOL_INFOA, *LPWSAPROTOCOL_INFOA;
678 
679 typedef struct _WSAPROTOCOL_INFOW {
680   DWORD dwServiceFlags1;
681   DWORD dwServiceFlags2;
682   DWORD dwServiceFlags3;
683   DWORD dwServiceFlags4;
684   DWORD dwProviderFlags;
685   GUID ProviderId;
686   DWORD dwCatalogEntryId;
687   WSAPROTOCOLCHAIN ProtocolChain;
688   int iVersion;
689   int iAddressFamily;
690   int iMaxSockAddr;
691   int iMinSockAddr;
692   int iSocketType;
693   int iProtocol;
694   int iProtocolMaxOffset;
695   int iNetworkByteOrder;
696   int iSecurityScheme;
697   DWORD dwMessageSize;
698   DWORD dwProviderReserved;
699   WCHAR szProtocol[WSAPROTOCOL_LEN+1];
700 } WSAPROTOCOL_INFOW, * LPWSAPROTOCOL_INFOW;
701 
702 #ifdef UNICODE
703 typedef WSAPROTOCOL_INFOW WSAPROTOCOL_INFO;
704 typedef LPWSAPROTOCOL_INFOW LPWSAPROTOCOL_INFO;
705 #else
706 typedef WSAPROTOCOL_INFOA WSAPROTOCOL_INFO;
707 typedef LPWSAPROTOCOL_INFOA LPWSAPROTOCOL_INFO;
708 #endif
709 
710 typedef int
711 (CALLBACK *LPCONDITIONPROC)(
712   IN LPWSABUF lpCallerId,
713   IN LPWSABUF lpCallerData,
714   IN OUT LPQOS lpSQOS,
715   IN OUT LPQOS lpGQOS,
716   IN LPWSABUF lpCalleeId,
717   IN LPWSABUF lpCalleeData,
718   OUT GROUP FAR *g,
719   IN DWORD_PTR dwCallbackData);
720 
721 typedef void
722 (CALLBACK *LPWSAOVERLAPPED_COMPLETION_ROUTINE)(
723   IN DWORD dwError,
724   IN DWORD cbTransferred,
725   IN LPWSAOVERLAPPED lpOverlapped,
726   IN DWORD dwFlags);
727 
728 #if(_WIN32_WINNT >= 0x0501)
729 
730 #define SIO_NSP_NOTIFY_CHANGE _WSAIOW(IOC_WS2,25)
731 
732 typedef enum _WSACOMPLETIONTYPE {
733   NSP_NOTIFY_IMMEDIATELY = 0,
734   NSP_NOTIFY_HWND,
735   NSP_NOTIFY_EVENT,
736   NSP_NOTIFY_PORT,
737   NSP_NOTIFY_APC
738 } WSACOMPLETIONTYPE, * PWSACOMPLETIONTYPE, *LPWSACOMPLETIONTYPE;
739 
740 typedef struct _WSACOMPLETION {
741   WSACOMPLETIONTYPE Type;
742   union {
743     struct {
744       HWND hWnd;
745       UINT uMsg;
746       WPARAM context;
747     } WindowMessage;
748     struct {
749       LPWSAOVERLAPPED lpOverlapped;
750     } Event;
751     struct {
752       LPWSAOVERLAPPED lpOverlapped;
753       LPWSAOVERLAPPED_COMPLETION_ROUTINE lpfnCompletionProc;
754     } Apc;
755     struct {
756       LPWSAOVERLAPPED lpOverlapped;
757       HANDLE hPort;
758       ULONG_PTR Key;
759     } Port;
760   } Parameters;
761 } WSACOMPLETION, *PWSACOMPLETION, *LPWSACOMPLETION;
762 
763 #endif /* (_WIN32_WINNT >= 0x0501) */
764 
765 #ifndef __BLOB_T_DEFINED /* also in wtypes.h and nspapi.h */
766 #define __BLOB_T_DEFINED
767 /* wine is using a diff define */
768 #ifndef _tagBLOB_DEFINED
769 #define _tagBLOB_DEFINED
770 #define _BLOB_DEFINED
771 #define _LPBLOB_DEFINED
772 
773 typedef struct _BLOB {
774   ULONG cbSize;
775 #ifdef MIDL_PASS
776   [size_is(cbSize)] BYTE *pBlobData;
777 #else
778   _Field_size_bytes_(cbSize) BYTE *pBlobData ;
779 #endif
780 } BLOB,*PBLOB,*LPBLOB;
781 
782 #endif /* _tagBLOB_DEFINED */
783 
784 #endif /* __BLOB_T_DEFINED */
785 
786 typedef struct _AFPROTOCOLS {
787   INT iAddressFamily;
788   INT iProtocol;
789 } AFPROTOCOLS, *PAFPROTOCOLS, *LPAFPROTOCOLS;
790 
791 typedef enum _WSAEcomparator {
792   COMP_EQUAL = 0,
793   COMP_NOTLESS
794 } WSAECOMPARATOR, *PWSAECOMPARATOR, *LPWSAECOMPARATOR;
795 
796 typedef struct _WSAVersion {
797   DWORD dwVersion;
798   WSAECOMPARATOR ecHow;
799 } WSAVERSION, *PWSAVERSION, *LPWSAVERSION;
800 
801 typedef struct _WSAQuerySetA {
802   DWORD dwSize;
803   LPSTR lpszServiceInstanceName;
804   LPGUID lpServiceClassId;
805   LPWSAVERSION lpVersion;
806   LPSTR lpszComment;
807   DWORD dwNameSpace;
808   LPGUID lpNSProviderId;
809   LPSTR lpszContext;
810   DWORD dwNumberOfProtocols;
811   _Field_size_(dwNumberOfProtocols) LPAFPROTOCOLS lpafpProtocols;
812   LPSTR lpszQueryString;
813   DWORD dwNumberOfCsAddrs;
814   _Field_size_(dwNumberOfCsAddrs) LPCSADDR_INFO lpcsaBuffer;
815   DWORD dwOutputFlags;
816   LPBLOB lpBlob;
817 } WSAQUERYSETA, *PWSAQUERYSETA, *LPWSAQUERYSETA;
818 
819 _Struct_size_bytes_(dwSize)
820 typedef struct _WSAQuerySetW {
821   _Field_range_(>=,sizeof(struct _WSAQuerySetW)) DWORD dwSize;
822   LPWSTR lpszServiceInstanceName;
823   LPGUID lpServiceClassId;
824   LPWSAVERSION lpVersion;
825   LPWSTR lpszComment;
826   DWORD dwNameSpace;
827   LPGUID lpNSProviderId;
828   LPWSTR lpszContext;
829   DWORD dwNumberOfProtocols;
830   _Field_size_(dwNumberOfProtocols) LPAFPROTOCOLS lpafpProtocols;
831   LPWSTR lpszQueryString;
832   DWORD dwNumberOfCsAddrs;
833   _Field_size_(dwNumberOfCsAddrs) LPCSADDR_INFO lpcsaBuffer;
834   DWORD dwOutputFlags;
835   LPBLOB lpBlob;
836 } WSAQUERYSETW, *PWSAQUERYSETW, *LPWSAQUERYSETW;
837 
838 typedef struct _WSAQuerySet2A {
839   DWORD dwSize;
840   LPSTR lpszServiceInstanceName;
841   LPWSAVERSION lpVersion;
842   LPSTR lpszComment;
843   DWORD dwNameSpace;
844   LPGUID lpNSProviderId;
845   LPSTR lpszContext;
846   DWORD dwNumberOfProtocols;
847   LPAFPROTOCOLS lpafpProtocols;
848   LPSTR lpszQueryString;
849   DWORD dwNumberOfCsAddrs;
850   LPCSADDR_INFO lpcsaBuffer;
851   DWORD dwOutputFlags;
852   LPBLOB lpBlob;
853 } WSAQUERYSET2A, *PWSAQUERYSET2A, *LPWSAQUERYSET2A;
854 
855 typedef struct _WSAQuerySet2W {
856   DWORD dwSize;
857   LPWSTR lpszServiceInstanceName;
858   LPWSAVERSION lpVersion;
859   LPWSTR lpszComment;
860   DWORD dwNameSpace;
861   LPGUID lpNSProviderId;
862   LPWSTR lpszContext;
863   DWORD dwNumberOfProtocols;
864   _Field_size_(dwNumberOfProtocols) LPAFPROTOCOLS lpafpProtocols;
865   LPWSTR lpszQueryString;
866   DWORD dwNumberOfCsAddrs;
867   _Field_size_(dwNumberOfCsAddrs) LPCSADDR_INFO lpcsaBuffer;
868   DWORD dwOutputFlags;
869   LPBLOB lpBlob;
870 } WSAQUERYSET2W, *PWSAQUERYSET2W, *LPWSAQUERYSET2W;
871 
872 #ifdef UNICODE
873 typedef WSAQUERYSETW WSAQUERYSET;
874 typedef PWSAQUERYSETW PWSAQUERYSET;
875 typedef LPWSAQUERYSETW LPWSAQUERYSET;
876 typedef WSAQUERYSET2W WSAQUERYSET2;
877 typedef PWSAQUERYSET2W PWSAQUERYSET2;
878 typedef LPWSAQUERYSET2W LPWSAQUERYSET2;
879 #else
880 typedef WSAQUERYSETA WSAQUERYSET;
881 typedef PWSAQUERYSETA PWSAQUERYSET;
882 typedef LPWSAQUERYSETA LPWSAQUERYSET;
883 typedef WSAQUERYSET2A WSAQUERYSET2;
884 typedef PWSAQUERYSET2A PWSAQUERYSET2;
885 typedef LPWSAQUERYSET2A LPWSAQUERYSET2;
886 #endif /* UNICODE */
887 
888 typedef enum _WSAESETSERVICEOP {
889   RNRSERVICE_REGISTER=0,
890   RNRSERVICE_DEREGISTER,
891   RNRSERVICE_DELETE
892 } WSAESETSERVICEOP, *PWSAESETSERVICEOP, *LPWSAESETSERVICEOP;
893 
894 typedef struct _WSANSClassInfoA {
895   LPSTR lpszName;
896   DWORD dwNameSpace;
897   DWORD dwValueType;
898   DWORD dwValueSize;
899   LPVOID lpValue;
900 } WSANSCLASSINFOA, *PWSANSCLASSINFOA, *LPWSANSCLASSINFOA;
901 
902 typedef struct _WSANSClassInfoW {
903   LPWSTR lpszName;
904   DWORD dwNameSpace;
905   DWORD dwValueType;
906   DWORD dwValueSize;
907   LPVOID lpValue;
908 } WSANSCLASSINFOW, *PWSANSCLASSINFOW, *LPWSANSCLASSINFOW;
909 
910 #ifdef UNICODE
911 typedef WSANSCLASSINFOW WSANSCLASSINFO;
912 typedef PWSANSCLASSINFOW PWSANSCLASSINFO;
913 typedef LPWSANSCLASSINFOW LPWSANSCLASSINFO;
914 #else
915 typedef WSANSCLASSINFOA WSANSCLASSINFO;
916 typedef PWSANSCLASSINFOA PWSANSCLASSINFO;
917 typedef LPWSANSCLASSINFOA LPWSANSCLASSINFO;
918 #endif
919 
920 typedef struct _WSAServiceClassInfoA {
921   LPGUID lpServiceClassId;
922   LPSTR lpszServiceClassName;
923   DWORD dwCount;
924   LPWSANSCLASSINFOA lpClassInfos;
925 } WSASERVICECLASSINFOA, *PWSASERVICECLASSINFOA, *LPWSASERVICECLASSINFOA;
926 
927 typedef struct _WSAServiceClassInfoW {
928   LPGUID lpServiceClassId;
929   LPWSTR lpszServiceClassName;
930   DWORD dwCount;
931   LPWSANSCLASSINFOW lpClassInfos;
932 } WSASERVICECLASSINFOW, *PWSASERVICECLASSINFOW, *LPWSASERVICECLASSINFOW;
933 
934 #ifdef UNICODE
935 typedef WSASERVICECLASSINFOW WSASERVICECLASSINFO;
936 typedef PWSASERVICECLASSINFOW PWSASERVICECLASSINFO;
937 typedef LPWSASERVICECLASSINFOW LPWSASERVICECLASSINFO;
938 #else
939 typedef WSASERVICECLASSINFOA WSASERVICECLASSINFO;
940 typedef PWSASERVICECLASSINFOA PWSASERVICECLASSINFO;
941 typedef LPWSASERVICECLASSINFOA LPWSASERVICECLASSINFO;
942 #endif
943 
944 typedef struct _WSANAMESPACE_INFOA {
945   GUID NSProviderId;
946   DWORD dwNameSpace;
947   BOOL fActive;
948   DWORD dwVersion;
949   LPSTR lpszIdentifier;
950 } WSANAMESPACE_INFOA, *PWSANAMESPACE_INFOA, *LPWSANAMESPACE_INFOA;
951 
952 typedef struct _WSANAMESPACE_INFOW {
953   GUID NSProviderId;
954   DWORD dwNameSpace;
955   BOOL fActive;
956   DWORD dwVersion;
957   LPWSTR lpszIdentifier;
958 } WSANAMESPACE_INFOW, *PWSANAMESPACE_INFOW, *LPWSANAMESPACE_INFOW;
959 
960 typedef struct _WSANAMESPACE_INFOEXA {
961   GUID NSProviderId;
962   DWORD dwNameSpace;
963   BOOL fActive;
964   DWORD dwVersion;
965   LPSTR lpszIdentifier;
966   BLOB ProviderSpecific;
967 } WSANAMESPACE_INFOEXA, *PWSANAMESPACE_INFOEXA, *LPWSANAMESPACE_INFOEXA;
968 
969 typedef struct _WSANAMESPACE_INFOEXW {
970   GUID NSProviderId;
971   DWORD dwNameSpace;
972   BOOL fActive;
973   DWORD dwVersion;
974   LPWSTR lpszIdentifier;
975   BLOB ProviderSpecific;
976 } WSANAMESPACE_INFOEXW, *PWSANAMESPACE_INFOEXW, *LPWSANAMESPACE_INFOEXW;
977 
978 #ifdef UNICODE
979 typedef WSANAMESPACE_INFOW WSANAMESPACE_INFO;
980 typedef PWSANAMESPACE_INFOW PWSANAMESPACE_INFO;
981 typedef LPWSANAMESPACE_INFOW LPWSANAMESPACE_INFO;
982 typedef WSANAMESPACE_INFOEXW WSANAMESPACE_INFOEX;
983 typedef PWSANAMESPACE_INFOEXW PWSANAMESPACE_INFOEX;
984 typedef LPWSANAMESPACE_INFOEXW LPWSANAMESPACE_INFOEX;
985 #else
986 typedef WSANAMESPACE_INFOA WSANAMESPACE_INFO;
987 typedef PWSANAMESPACE_INFOA PWSANAMESPACE_INFO;
988 typedef LPWSANAMESPACE_INFOA LPWSANAMESPACE_INFO;
989 typedef WSANAMESPACE_INFOEXA WSANAMESPACE_INFOEX;
990 typedef PWSANAMESPACE_INFOEXA PWSANAMESPACE_INFOEX;
991 typedef LPWSANAMESPACE_INFOEXA LPWSANAMESPACE_INFOEX;
992 #endif /* UNICODE */
993 
994 #if(_WIN32_WINNT >= 0x0600)
995 
996 #define POLLRDNORM  0x0100
997 #define POLLRDBAND  0x0200
998 #define POLLIN      (POLLRDNORM | POLLRDBAND)
999 #define POLLPRI     0x0400
1000 
1001 #define POLLWRNORM  0x0010
1002 #define POLLOUT     (POLLWRNORM)
1003 #define POLLWRBAND  0x0020
1004 
1005 #define POLLERR     0x0001
1006 #define POLLHUP     0x0002
1007 #define POLLNVAL    0x0004
1008 
1009 typedef struct pollfd {
1010   SOCKET fd;
1011   SHORT events;
1012   SHORT revents;
1013 } WSAPOLLFD, *PWSAPOLLFD, FAR *LPWSAPOLLFD;
1014 
1015 #endif /* (_WIN32_WINNT >= 0x0600) */
1016 
1017 #if INCL_WINSOCK_API_TYPEDEFS
1018 
1019 _Must_inspect_result_
1020 typedef SOCKET
1021 (WSAAPI *LPFN_ACCEPT)(
1022   _In_ SOCKET s,
1023   _Out_writes_bytes_opt_(*addrlen) struct sockaddr FAR *addr,
1024   _Inout_opt_ int FAR *addrlen);
1025 
1026 typedef int
1027 (WSAAPI *LPFN_BIND)(
1028   _In_ SOCKET s,
1029   _In_reads_bytes_(namelen) const struct sockaddr FAR *name,
1030   _In_ int namelen);
1031 
1032 typedef int
1033 (WSAAPI *LPFN_CLOSESOCKET)(
1034   _In_ SOCKET s);
1035 
1036 typedef int
1037 (WSAAPI *LPFN_CONNECT)(
1038   _In_ SOCKET s,
1039   _In_reads_bytes_(namelen) const struct sockaddr FAR *name,
1040   _In_ int namelen);
1041 
1042 typedef int
1043 (WSAAPI *LPFN_IOCTLSOCKET)(
1044   _In_ SOCKET s,
1045   _In_ long cmd,
1046   _Inout_ u_long FAR *argp);
1047 
1048 typedef int
1049 (WSAAPI *LPFN_GETPEERNAME)(
1050   _In_ SOCKET s,
1051   _Out_writes_bytes_to_(*namelen,*namelen) struct sockaddr FAR *name,
1052   _Inout_ int FAR *namelen);
1053 
1054 typedef int
1055 (WSAAPI *LPFN_GETSOCKNAME)(
1056   _In_ SOCKET s,
1057   _Out_writes_bytes_to_(*namelen,*namelen) struct sockaddr FAR *name,
1058   _Inout_ int FAR *namelen);
1059 
1060 typedef int
1061 (WSAAPI *LPFN_GETSOCKOPT)(
1062   _In_ SOCKET s,
1063   _In_ int level,
1064   _In_ int optname,
1065   _Out_writes_bytes_(*optlen) char FAR *optval,
1066   _Inout_ int FAR *optlen);
1067 
1068 typedef u_long
1069 (WSAAPI *LPFN_HTONL)(
1070   _In_ u_long hostlong);
1071 
1072 typedef u_short
1073 (WSAAPI *LPFN_HTONS)(
1074   _In_ u_short hostshort);
1075 
1076 typedef unsigned long
1077 (WSAAPI *LPFN_INET_ADDR)(
1078   _In_ const char FAR *cp);
1079 
1080 typedef char FAR *
1081 (WSAAPI *LPFN_INET_NTOA)(
1082   _In_ struct in_addr in);
1083 
1084 typedef int
1085 (WSAAPI *LPFN_LISTEN)(
1086   _In_ SOCKET s,
1087   _In_ int backlog);
1088 
1089 typedef u_long
1090 (WSAAPI *LPFN_NTOHL)(
1091   _In_ u_long netlong);
1092 
1093 typedef u_short
1094 (WSAAPI *LPFN_NTOHS)(
1095   _In_ u_short netshort);
1096 
1097 typedef int
1098 (WSAAPI *LPFN_RECV)(
1099   _In_ SOCKET s,
1100   _Out_writes_bytes_to_(len, return) char FAR *buf,
1101   _In_ int len,
1102   _In_ int flags);
1103 
1104 typedef int
1105 (WSAAPI *LPFN_RECVFROM)(
1106   _In_ SOCKET s,
1107   _Out_writes_bytes_to_(len, return) char FAR *buf,
1108   _In_ int len,
1109   _In_ int flags,
1110   _Out_writes_bytes_to_opt_(*fromlen, *fromlen) struct sockaddr FAR *from,
1111   _Inout_opt_ int FAR * fromlen);
1112 
1113 typedef int
1114 (WSAAPI *LPFN_SELECT)(
1115   _In_ int nfds,
1116   _Inout_opt_ fd_set FAR *readfds,
1117   _Inout_opt_ fd_set FAR *writefds,
1118   _Inout_opt_ fd_set FAR *exceptfds,
1119   _In_opt_ const struct timeval FAR *timeout);
1120 
1121 typedef int
1122 (WSAAPI *LPFN_SEND)(
1123   _In_ SOCKET s,
1124   _In_reads_bytes_(len) const char FAR *buf,
1125   _In_ int len,
1126   _In_ int flags);
1127 
1128 typedef int
1129 (WSAAPI *LPFN_SENDTO)(
1130   _In_ SOCKET s,
1131   _In_reads_bytes_(len) const char FAR *buf,
1132   _In_ int len,
1133   _In_ int flags,
1134   _In_reads_bytes_(tolen) const struct sockaddr FAR *to,
1135   _In_ int tolen);
1136 
1137 typedef int
1138 (WSAAPI *LPFN_SETSOCKOPT)(
1139   _In_ SOCKET s,
1140   _In_ int level,
1141   _In_ int optname,
1142   _In_reads_bytes_(optlen) const char FAR *optval,
1143   _In_ int optlen);
1144 
1145 typedef int
1146 (WSAAPI *LPFN_SHUTDOWN)(
1147   _In_ SOCKET s,
1148   _In_ int how);
1149 
1150 _Must_inspect_result_
1151 typedef SOCKET
1152 (WSAAPI *LPFN_SOCKET)(
1153   _In_ int af,
1154   _In_ int type,
1155   _In_ int protocol);
1156 
1157 typedef struct hostent FAR *
1158 (WSAAPI *LPFN_GETHOSTBYADDR)(
1159   _In_reads_bytes_(len) const char FAR *addr,
1160   _In_ int len,
1161   _In_ int type);
1162 
1163 typedef struct hostent FAR *
1164 (WSAAPI *LPFN_GETHOSTBYNAME)(
1165   _In_ const char FAR *name);
1166 
1167 typedef int
1168 (WSAAPI *LPFN_GETHOSTNAME)(
1169   _Out_writes_bytes_(namelen) char FAR *name,
1170   _In_ int namelen);
1171 
1172 typedef struct servent FAR *
1173 (WSAAPI *LPFN_GETSERVBYPORT)(
1174   _In_ int port,
1175   _In_opt_z_ const char FAR *proto);
1176 
1177 typedef struct servent FAR *
1178 (WSAAPI *LPFN_GETSERVBYNAME)(
1179   _In_z_ const char FAR *name,
1180   _In_opt_z_ const char FAR *proto);
1181 
1182 typedef struct protoent FAR *
1183 (WSAAPI *LPFN_GETPROTOBYNUMBER)(
1184   _In_ int number);
1185 
1186 typedef struct protoent FAR *
1187 (WSAAPI *LPFN_GETPROTOBYNAME)(
1188   _In_z_ const char FAR *name);
1189 
1190 _Must_inspect_result_
1191 typedef int
1192 (WSAAPI *LPFN_WSASTARTUP)(
1193   _In_ WORD wVersionRequired,
1194   _Out_ LPWSADATA lpWSAData);
1195 
1196 typedef int
1197 (WSAAPI *LPFN_WSACLEANUP)(void);
1198 
1199 typedef void
1200 (WSAAPI *LPFN_WSASETLASTERROR)(
1201   _In_ int iError);
1202 
1203 typedef int
1204 (WSAAPI *LPFN_WSAGETLASTERROR)(void);
1205 
1206 typedef BOOL
1207 (WSAAPI *LPFN_WSAISBLOCKING)(void);
1208 
1209 typedef int
1210 (WSAAPI *LPFN_WSAUNHOOKBLOCKINGHOOK)(void);
1211 
1212 typedef FARPROC
1213 (WSAAPI *LPFN_WSASETBLOCKINGHOOK)(
1214   _In_ FARPROC lpBlockFunc);
1215 
1216 typedef int
1217 (WSAAPI *LPFN_WSACANCELBLOCKINGCALL)(void);
1218 
1219 typedef HANDLE
1220 (WSAAPI *LPFN_WSAASYNCGETSERVBYNAME)(
1221   _In_ HWND hWnd,
1222   _In_ u_int wMsg,
1223   _In_z_ const char FAR *name,
1224   _In_z_ const char FAR *proto,
1225   _Out_writes_bytes_(buflen) char FAR *buf,
1226   _In_ int buflen);
1227 
1228 typedef HANDLE
1229 (WSAAPI *LPFN_WSAASYNCGETSERVBYPORT)(
1230   _In_ HWND hWnd,
1231   _In_ u_int wMsg,
1232   _In_ int port,
1233   _In_ const char FAR *proto,
1234   _Out_writes_bytes_(buflen) char FAR *buf,
1235   _In_ int buflen);
1236 
1237 typedef HANDLE
1238 (WSAAPI *LPFN_WSAASYNCGETPROTOBYNAME)(
1239   _In_ HWND hWnd,
1240   _In_ u_int wMsg,
1241   _In_z_ const char FAR *name,
1242   _Out_writes_bytes_(buflen) char FAR *buf,
1243   _In_ int buflen);
1244 
1245 typedef HANDLE
1246 (WSAAPI *LPFN_WSAASYNCGETPROTOBYNUMBER)(
1247   _In_ HWND hWnd,
1248   _In_ u_int wMsg,
1249   _In_ int number,
1250   _Out_writes_bytes_(buflen) char FAR *buf,
1251   _In_ int buflen);
1252 
1253 typedef HANDLE
1254 (WSAAPI *LPFN_WSAASYNCGETHOSTBYNAME)(
1255   _In_ HWND hWnd,
1256   _In_ u_int wMsg,
1257   _In_z_ const char FAR *name,
1258   _Out_writes_bytes_(buflen) char FAR *buf,
1259   _In_ int buflen);
1260 
1261 typedef HANDLE
1262 (WSAAPI *LPFN_WSAASYNCGETHOSTBYADDR)(
1263   _In_ HWND hWnd,
1264   _In_ u_int wMsg,
1265   _In_reads_bytes_(len) const char FAR *addr,
1266   _In_ int len,
1267   _In_ int type,
1268   _Out_writes_bytes_(buflen) char FAR *buf,
1269   _In_ int buflen);
1270 
1271 typedef int
1272 (WSAAPI *LPFN_WSACANCELASYNCREQUEST)(
1273   _In_ HANDLE hAsyncTaskHandle);
1274 
1275 typedef int
1276 (WSAAPI *LPFN_WSAASYNCSELECT)(
1277   _In_ SOCKET s,
1278   _In_ HWND hWnd,
1279   _In_ u_int wMsg,
1280   _In_ long lEvent);
1281 
1282 _Must_inspect_result_
1283 typedef SOCKET
1284 (WSAAPI *LPFN_WSAACCEPT)(
1285   _In_ SOCKET s,
1286   _Out_writes_bytes_to_opt_(*addrlen,*addrlen) struct sockaddr FAR *addr,
1287   _Inout_opt_ LPINT addrlen,
1288   _In_opt_ LPCONDITIONPROC lpfnCondition,
1289   _In_opt_ DWORD_PTR dwCallbackData);
1290 
1291 typedef BOOL
1292 (WSAAPI *LPFN_WSACLOSEEVENT)(
1293   _In_ WSAEVENT hEvent);
1294 
1295 typedef int
1296 (WSAAPI *LPFN_WSACONNECT)(
1297   _In_ SOCKET s,
1298   _In_reads_bytes_(namelen) const struct sockaddr FAR *name,
1299   _In_ int namelen,
1300   _In_opt_ LPWSABUF lpCallerData,
1301   _Out_opt_ LPWSABUF lpCalleeData,
1302   _In_opt_ LPQOS lpSQOS,
1303   _In_opt_ LPQOS lpGQOS);
1304 
1305 typedef WSAEVENT
1306 (WSAAPI *LPFN_WSACREATEEVENT)(void);
1307 
1308 typedef int
1309 (WSAAPI *LPFN_WSADUPLICATESOCKETA)(
1310   _In_ SOCKET s,
1311   _In_ DWORD dwProcessId,
1312   _Out_ LPWSAPROTOCOL_INFOA lpProtocolInfo);
1313 
1314 typedef int
1315 (WSAAPI *LPFN_WSADUPLICATESOCKETW)(
1316   _In_ SOCKET s,
1317   _In_ DWORD dwProcessId,
1318   _Out_ LPWSAPROTOCOL_INFOW lpProtocolInfo);
1319 
1320 #ifdef UNICODE
1321 #define LPFN_WSADUPLICATESOCKET LPFN_WSADUPLICATESOCKETW
1322 #else
1323 #define LPFN_WSADUPLICATESOCKET LPFN_WSADUPLICATESOCKETA
1324 #endif
1325 
1326 typedef int
1327 (WSAAPI *LPFN_WSAENUMNETWORKEVENTS)(
1328   _In_ SOCKET s,
1329   _In_ WSAEVENT hEventObject,
1330   _Out_ LPWSANETWORKEVENTS lpNetworkEvents);
1331 
1332 typedef int
1333 (WSAAPI *LPFN_WSAENUMPROTOCOLSA)(
1334   _In_opt_ LPINT lpiProtocols,
1335   _Out_writes_bytes_to_opt_(*lpdwBufferLength,*lpdwBufferLength) LPWSAPROTOCOL_INFOA lpProtocolBuffer,
1336   _Inout_ LPDWORD lpdwBufferLength);
1337 
1338 typedef int
1339 (WSAAPI *LPFN_WSAENUMPROTOCOLSW)(
1340   _In_opt_ LPINT lpiProtocols,
1341   _Out_writes_bytes_to_opt_(*lpdwBufferLength,*lpdwBufferLength) LPWSAPROTOCOL_INFOW lpProtocolBuffer,
1342   _Inout_ LPDWORD lpdwBufferLength);
1343 
1344 #ifdef UNICODE
1345 #define LPFN_WSAENUMPROTOCOLS LPFN_WSAENUMPROTOCOLSW
1346 #else
1347 #define LPFN_WSAENUMPROTOCOLS LPFN_WSAENUMPROTOCOLSA
1348 #endif
1349 
1350 typedef int
1351 (WSAAPI *LPFN_WSAEVENTSELECT)(
1352   _In_ SOCKET s,
1353   _In_opt_ WSAEVENT hEventObject,
1354   _In_ long lNetworkEvents);
1355 
1356 typedef BOOL
1357 (WSAAPI *LPFN_WSAGETOVERLAPPEDRESULT)(
1358   _In_ SOCKET s,
1359   _In_ LPWSAOVERLAPPED lpOverlapped,
1360   _Out_ LPDWORD lpcbTransfer,
1361   _In_ BOOL fWait,
1362   _Out_ LPDWORD lpdwFlags);
1363 
1364 typedef BOOL
1365 (WSAAPI *LPFN_WSAGETQOSBYNAME)(
1366   IN SOCKET s,
1367   IN LPWSABUF lpQOSName,
1368   OUT LPQOS lpQOS);
1369 
1370 typedef int
1371 (WSAAPI *LPFN_WSAHTONL)(
1372   _In_ SOCKET s,
1373   _In_ u_long hostlong,
1374   _Out_ u_long FAR *lpnetlong);
1375 
1376 typedef int
1377 (WSAAPI *LPFN_WSAHTONS)(
1378   _In_ SOCKET s,
1379   _In_ u_short hostshort,
1380   _Out_ u_short FAR *lpnetshort);
1381 
1382 typedef int
1383 (WSAAPI *LPFN_WSAIOCTL)(
1384   _In_ SOCKET s,
1385   _In_ DWORD dwIoControlCode,
1386   _In_reads_bytes_opt_(cbInBuffer) LPVOID lpvInBuffer,
1387   _In_ DWORD cbInBuffer,
1388   _Out_writes_bytes_to_opt_(cbOutBuffer, *lpcbBytesReturned) LPVOID lpvOutBuffer,
1389   _In_ DWORD cbOutBuffer,
1390   _Out_ LPDWORD lpcbBytesReturned,
1391   _Inout_opt_ LPWSAOVERLAPPED lpOverlapped,
1392   _In_opt_ LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
1393 
1394 typedef SOCKET
1395 (WSAAPI *LPFN_WSAJOINLEAF)(
1396   _In_ SOCKET s,
1397   _In_reads_bytes_(namelen) const struct sockaddr FAR *name,
1398   _In_ int namelen,
1399   _In_opt_ LPWSABUF lpCallerData,
1400   _Out_opt_ LPWSABUF lpCalleeData,
1401   _In_opt_ LPQOS lpSQOS,
1402   _In_opt_ LPQOS lpGQOS,
1403   _In_ DWORD dwFlags);
1404 
1405 typedef int
1406 (WSAAPI *LPFN_WSANTOHL)(
1407   _In_ SOCKET s,
1408   _In_ u_long netlong,
1409   _Out_ u_long FAR *lphostlong);
1410 
1411 typedef int
1412 (WSAAPI *LPFN_WSANTOHS)(
1413   _In_ SOCKET s,
1414   _In_ u_short netshort,
1415   _Out_ u_short FAR *lphostshort);
1416 
1417 typedef int
1418 (WSAAPI *LPFN_WSARECV)(
1419   _In_ SOCKET s,
1420   _In_reads_(dwBufferCount) LPWSABUF lpBuffers,
1421   _In_ DWORD dwBufferCount,
1422   _Out_opt_ LPDWORD lpNumberOfBytesRecvd,
1423   _Inout_ LPDWORD lpFlags,
1424   _Inout_opt_ LPWSAOVERLAPPED lpOverlapped,
1425   _In_opt_ LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
1426 
1427 typedef int
1428 (WSAAPI *LPFN_WSARECVDISCONNECT)(
1429   _In_ SOCKET s,
1430   __out_data_source(NETWORK) LPWSABUF lpInboundDisconnectData);
1431 
1432 typedef int
1433 (WSAAPI *LPFN_WSARECVFROM)(
1434   _In_ SOCKET s,
1435   _In_reads_(dwBufferCount) LPWSABUF lpBuffers,
1436   _In_ DWORD dwBufferCount,
1437   _Out_opt_ LPDWORD lpNumberOfBytesRecvd,
1438   _Inout_ LPDWORD lpFlags,
1439   _Out_writes_bytes_to_opt_(*lpFromlen,*lpFromlen) struct sockaddr FAR *lpFrom,
1440   _Inout_opt_ LPINT lpFromlen,
1441   _Inout_opt_ LPWSAOVERLAPPED lpOverlapped,
1442   _In_opt_ LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
1443 
1444 typedef BOOL
1445 (WSAAPI *LPFN_WSARESETEVENT)(
1446   _In_ WSAEVENT hEvent);
1447 
1448 typedef int
1449 (WSAAPI *LPFN_WSASEND)(
1450   _In_ SOCKET s,
1451   _In_reads_(dwBufferCount) LPWSABUF lpBuffers,
1452   _In_ DWORD dwBufferCount,
1453   _Out_opt_ LPDWORD lpNumberOfBytesSent,
1454   _In_ DWORD dwFlags,
1455   _Inout_opt_ LPWSAOVERLAPPED lpOverlapped,
1456   _In_opt_ LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
1457 
1458 typedef int
1459 (WSAAPI *LPFN_WSASENDDISCONNECT)(
1460   _In_ SOCKET s,
1461   _In_opt_ LPWSABUF lpOutboundDisconnectData);
1462 
1463 typedef int
1464 (WSAAPI *LPFN_WSASENDTO)(
1465   _In_ SOCKET s,
1466   _In_reads_(dwBufferCount) LPWSABUF lpBuffers,
1467   _In_ DWORD dwBufferCount,
1468   _Out_opt_ LPDWORD lpNumberOfBytesSent,
1469   _In_ DWORD dwFlags,
1470   _In_reads_bytes_opt_(iTolen) const struct sockaddr FAR *lpTo,
1471   _In_ int iTolen,
1472   _Inout_opt_ LPWSAOVERLAPPED lpOverlapped,
1473   _In_opt_ LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
1474 
1475 typedef BOOL
1476 (WSAAPI *LPFN_WSASETEVENT)(
1477   _In_ WSAEVENT hEvent);
1478 
1479 _Must_inspect_result_
1480 typedef SOCKET
1481 (WSAAPI *LPFN_WSASOCKETA)(
1482   _In_ int af,
1483   _In_ int type,
1484   _In_ int protocol,
1485   _In_opt_ LPWSAPROTOCOL_INFOA lpProtocolInfo,
1486   _In_ GROUP g,
1487   _In_ DWORD dwFlags);
1488 
1489 _Must_inspect_result_
1490 typedef SOCKET
1491 (WSAAPI *LPFN_WSASOCKETW)(
1492   _In_ int af,
1493   _In_ int type,
1494   _In_ int protocol,
1495   _In_opt_ LPWSAPROTOCOL_INFOW lpProtocolInfo,
1496   _In_ GROUP g,
1497   _In_ DWORD dwFlags);
1498 
1499 #ifdef UNICODE
1500 #define LPFN_WSASOCKET LPFN_WSASOCKETW
1501 #else
1502 #define LPFN_WSASOCKET LPFN_WSASOCKETA
1503 #endif
1504 
1505 typedef DWORD
1506 (WSAAPI *LPFN_WSAWAITFORMULTIPLEEVENTS)(
1507   _In_ DWORD cEvents,
1508   _In_reads_(cEvents) const WSAEVENT FAR *lphEvents,
1509   _In_ BOOL fWaitAll,
1510   _In_ DWORD dwTimeout,
1511   _In_ BOOL fAlertable);
1512 
1513 typedef INT
1514 (WSAAPI *LPFN_WSAADDRESSTOSTRINGA)(
1515   _In_reads_bytes_(dwAddressLength) LPSOCKADDR lpsaAddress,
1516   _In_ DWORD dwAddressLength,
1517   _In_opt_ LPWSAPROTOCOL_INFOA lpProtocolInfo,
1518   _Out_writes_to_(*lpdwAddressStringLength,*lpdwAddressStringLength) LPSTR lpszAddressString,
1519   _Inout_ LPDWORD lpdwAddressStringLength);
1520 
1521 typedef INT
1522 (WSAAPI *LPFN_WSAADDRESSTOSTRINGW)(
1523   _In_reads_bytes_(dwAddressLength) LPSOCKADDR lpsaAddress,
1524   _In_ DWORD dwAddressLength,
1525   _In_opt_ LPWSAPROTOCOL_INFOW lpProtocolInfo,
1526   _Out_writes_to_(*lpdwAddressStringLength,*lpdwAddressStringLength) LPWSTR lpszAddressString,
1527   _Inout_ LPDWORD lpdwAddressStringLength);
1528 
1529 #ifdef UNICODE
1530 #define LPFN_WSAADDRESSTOSTRING LPFN_WSAADDRESSTOSTRINGW
1531 #else
1532 #define LPFN_WSAADDRESSTOSTRING LPFN_WSAADDRESSTOSTRINGA
1533 #endif
1534 
1535 typedef INT
1536 (WSAAPI *LPFN_WSASTRINGTOADDRESSA)(
1537   _In_ LPSTR AddressString,
1538   _In_ INT AddressFamily,
1539   _In_opt_ LPWSAPROTOCOL_INFOA lpProtocolInfo,
1540   _Out_writes_bytes_to_(*lpAddressLength,*lpAddressLength) LPSOCKADDR lpAddress,
1541   _Inout_ LPINT lpAddressLength);
1542 
1543 typedef INT
1544 (WSAAPI *LPFN_WSASTRINGTOADDRESSW)(
1545   _In_ LPWSTR AddressString,
1546   _In_ INT AddressFamily,
1547   _In_opt_ LPWSAPROTOCOL_INFOW lpProtocolInfo,
1548   _Out_writes_bytes_to_(*lpAddressLength,*lpAddressLength) LPSOCKADDR lpAddress,
1549   _Inout_ LPINT lpAddressLength);
1550 
1551 #ifdef UNICODE
1552 #define LPFN_WSASTRINGTOADDRESS LPFN_WSASTRINGTOADDRESSW
1553 #else
1554 #define LPFN_WSASTRINGTOADDRESS LPFN_WSASTRINGTOADDRESSA
1555 #endif
1556 
1557 typedef INT
1558 (WSAAPI *LPFN_WSALOOKUPSERVICEBEGINA)(
1559   _In_ LPWSAQUERYSETA lpqsRestrictions,
1560   _In_ DWORD dwControlFlags,
1561   _Out_ LPHANDLE lphLookup);
1562 
1563 typedef INT
1564 (WSAAPI *LPFN_WSALOOKUPSERVICEBEGINW)(
1565   _In_ LPWSAQUERYSETW lpqsRestrictions,
1566   _In_ DWORD dwControlFlags,
1567   _Out_ LPHANDLE lphLookup);
1568 
1569 #ifdef UNICODE
1570 #define LPFN_WSALOOKUPSERVICEBEGIN LPFN_WSALOOKUPSERVICEBEGINW
1571 #else
1572 #define LPFN_WSALOOKUPSERVICEBEGIN LPFN_WSALOOKUPSERVICEBEGINA
1573 #endif
1574 
1575 typedef INT
1576 (WSAAPI *LPFN_WSALOOKUPSERVICENEXTA)(
1577   _In_ HANDLE hLookup,
1578   _In_ DWORD dwControlFlags,
1579   _Inout_ LPDWORD lpdwBufferLength,
1580   _Out_writes_bytes_to_(*lpdwBufferLength,*lpdwBufferLength) LPWSAQUERYSETA lpqsResults);
1581 
1582 typedef INT
1583 (WSAAPI *LPFN_WSALOOKUPSERVICENEXTW)(
1584   _In_ HANDLE hLookup,
1585   _In_ DWORD dwControlFlags,
1586   _Inout_ LPDWORD lpdwBufferLength,
1587   _Out_writes_bytes_to_opt_(*lpdwBufferLength,*lpdwBufferLength) LPWSAQUERYSETW lpqsResults);
1588 
1589 #ifdef UNICODE
1590 #define LPFN_WSALOOKUPSERVICENEXT LPFN_WSALOOKUPSERVICENEXTW
1591 #else
1592 #define LPFN_WSALOOKUPSERVICENEXT LPFN_WSALOOKUPSERVICENEXTA
1593 #endif
1594 
1595 typedef INT
1596 (WSAAPI *LPFN_WSALOOKUPSERVICEEND)(
1597   _In_ HANDLE hLookup);
1598 
1599 typedef INT
1600 (WSAAPI *LPFN_WSAINSTALLSERVICECLASSA)(
1601   _In_ LPWSASERVICECLASSINFOA lpServiceClassInfo);
1602 
1603 typedef INT
1604 (WSAAPI *LPFN_WSAINSTALLSERVICECLASSW)(
1605   _In_ LPWSASERVICECLASSINFOW lpServiceClassInfo);
1606 
1607 #ifdef UNICODE
1608 #define LPFN_WSAINSTALLSERVICECLASS LPFN_WSAINSTALLSERVICECLASSW
1609 #else
1610 #define LPFN_WSAINSTALLSERVICECLASS LPFN_WSAINSTALLSERVICECLASSA
1611 #endif
1612 
1613 typedef INT
1614 (WSAAPI *LPFN_WSAREMOVESERVICECLASS)(
1615   _In_ LPGUID lpServiceClassId);
1616 
1617 typedef INT
1618 (WSAAPI *LPFN_WSAGETSERVICECLASSINFOA)(
1619   _In_ LPGUID lpProviderId,
1620   _In_ LPGUID lpServiceClassId,
1621   _Inout_ LPDWORD lpdwBufSize,
1622   _Out_writes_bytes_to_(*lpdwBufSize,*lpdwBufSize) LPWSASERVICECLASSINFOA lpServiceClassInfo);
1623 
1624 typedef INT
1625 (WSAAPI *LPFN_WSAGETSERVICECLASSINFOW)(
1626   _In_ LPGUID lpProviderId,
1627   _In_ LPGUID lpServiceClassId,
1628   _Inout_ LPDWORD lpdwBufSize,
1629   _Out_writes_bytes_to_(*lpdwBufSize,*lpdwBufSize) LPWSASERVICECLASSINFOW lpServiceClassInfo);
1630 
1631 #ifdef UNICODE
1632 #define LPFN_WSAGETSERVICECLASSINFO LPFN_WSAGETSERVICECLASSINFOW
1633 #else
1634 #define LPFN_WSAGETSERVICECLASSINFO LPFN_WSAGETSERVICECLASSINFOA
1635 #endif
1636 
1637 typedef INT
1638 (WSAAPI *LPFN_WSAENUMNAMESPACEPROVIDERSA)(
1639   _Inout_ LPDWORD lpdwBufferLength,
1640   _Out_writes_bytes_to_(*lpdwBufferLength,*lpdwBufferLength) LPWSANAMESPACE_INFOA lpnspBuffer);
1641 
1642 typedef INT
1643 (WSAAPI *LPFN_WSAENUMNAMESPACEPROVIDERSW)(
1644   _Inout_ LPDWORD lpdwBufferLength,
1645   _Out_writes_bytes_to_(*lpdwBufferLength,*lpdwBufferLength) LPWSANAMESPACE_INFOW lpnspBuffer);
1646 
1647 #ifdef UNICODE
1648 #define LPFN_WSAENUMNAMESPACEPROVIDERS LPFN_WSAENUMNAMESPACEPROVIDERSW
1649 #else
1650 #define LPFN_WSAENUMNAMESPACEPROVIDERS LPFN_WSAENUMNAMESPACEPROVIDERSA
1651 #endif
1652 
1653 typedef INT
1654 (WSAAPI *LPFN_WSAGETSERVICECLASSNAMEBYCLASSIDA)(
1655   _In_ LPGUID lpServiceClassId,
1656   _Out_writes_bytes_to_(*lpdwBufferLength,*lpdwBufferLength) LPSTR lpszServiceClassName,
1657   _Inout_ LPDWORD lpdwBufferLength);
1658 
1659 typedef INT
1660 (WSAAPI *LPFN_WSAGETSERVICECLASSNAMEBYCLASSIDW)(
1661   _In_ LPGUID lpServiceClassId,
1662   _Out_writes_bytes_to_(*lpdwBufferLength,*lpdwBufferLength) LPWSTR lpszServiceClassName,
1663   _Inout_ LPDWORD lpdwBufferLength);
1664 
1665 #ifdef UNICODE
1666 #define LPFN_WSAGETSERVICECLASSNAMEBYCLASSID LPFN_WSAGETSERVICECLASSNAMEBYCLASSIDW
1667 #else
1668 #define LPFN_WSAGETSERVICECLASSNAMEBYCLASSID LPFN_WSAGETSERVICECLASSNAMEBYCLASSIDA
1669 #endif
1670 
1671 typedef INT
1672 (WSAAPI *LPFN_WSASETSERVICEA)(
1673   _In_ LPWSAQUERYSETA lpqsRegInfo,
1674   _In_ WSAESETSERVICEOP essoperation,
1675   _In_ DWORD dwControlFlags);
1676 
1677 typedef INT
1678 (WSAAPI *LPFN_WSASETSERVICEW)(
1679   _In_ LPWSAQUERYSETW lpqsRegInfo,
1680   _In_ WSAESETSERVICEOP essoperation,
1681   _In_ DWORD dwControlFlags);
1682 
1683 #ifdef UNICODE
1684 #define LPFN_WSASETSERVICE LPFN_WSASETSERVICEW
1685 #else
1686 #define LPFN_WSASETSERVICE LPFN_WSASETSERVICEA
1687 #endif
1688 
1689 typedef INT
1690 (WSAAPI *LPFN_WSAPROVIDERCONFIGCHANGE)(
1691   _Inout_ LPHANDLE lpNotificationHandle,
1692   _Inout_opt_ LPWSAOVERLAPPED lpOverlapped,
1693   _In_opt_ LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
1694 
1695 #if(_WIN32_WINNT >= 0x0501)
1696 typedef INT
1697 (WSAAPI *LPFN_WSANSPIOCTL)(
1698   _In_ HANDLE hLookup,
1699   _In_ DWORD dwControlCode,
1700   _In_reads_bytes_opt_(cbInBuffer) LPVOID lpvInBuffer,
1701   _In_ DWORD cbInBuffer,
1702   _Out_writes_bytes_to_opt_(cbOutBuffer, *lpcbBytesReturned) LPVOID lpvOutBuffer,
1703   _In_ DWORD cbOutBuffer,
1704   _Out_ LPDWORD lpcbBytesReturned,
1705   _In_opt_ LPWSACOMPLETION lpCompletion);
1706 #endif /* (_WIN32_WINNT >= 0x0501) */
1707 
1708 #if (_WIN32_WINNT >= 0x0600)
1709 
1710 typedef INT
1711 (WSAAPI *LPFN_WSAENUMNAMESPACEPROVIDERSEXA)(
1712   _Inout_ LPDWORD lpdwBufferLength,
1713   _Out_writes_bytes_to_(*lpdwBufferLength,*lpdwBufferLength) LPWSANAMESPACE_INFOEXA lpnspBuffer);
1714 
1715 typedef INT
1716 (WSAAPI *LPFN_WSAENUMNAMESPACEPROVIDERSEXW)(
1717   _Inout_ LPDWORD lpdwBufferLength,
1718   _Out_writes_bytes_to_(*lpdwBufferLength,*lpdwBufferLength) LPWSANAMESPACE_INFOEXW lpnspBuffer);
1719 
1720 #ifdef UNICODE
1721 #define LPFN_WSAENUMNAMESPACEPROVIDERSEX LPFN_WSAENUMNAMESPACEPROVIDERSEXW
1722 #else
1723 #define LPFN_WSAENUMNAMESPACEPROVIDERSEX LPFN_WSAENUMNAMESPACEPROVIDERSEXA
1724 #endif
1725 
1726 #endif /* (_WIN32_WINNT >= 0x600) */
1727 
1728 #endif /* INCL_WINSOCK_API_TYPEDEFS */
1729 
1730 #if INCL_WINSOCK_API_PROTOTYPES
1731 
1732 _Must_inspect_result_
1733 WINSOCK_API_LINKAGE
1734 SOCKET
1735 WSAAPI
1736 accept(
1737   _In_ SOCKET s,
1738   _Out_writes_bytes_opt_(*addrlen) struct sockaddr FAR *addr,
1739   _Inout_opt_ int FAR *addrlen);
1740 
1741 WINSOCK_API_LINKAGE
1742 int
1743 WSAAPI
1744 bind(
1745   _In_ SOCKET s,
1746   _In_reads_bytes_(namelen) const struct sockaddr FAR *addr,
1747   _In_ int namelen);
1748 
1749 WINSOCK_API_LINKAGE
1750 int
1751 WSAAPI
1752 closesocket(
1753   _In_ SOCKET s);
1754 
1755 WINSOCK_API_LINKAGE
1756 int
1757 WSAAPI
1758 connect(
1759   _In_ SOCKET s,
1760   _In_reads_bytes_(namelen) const struct sockaddr FAR *name,
1761   _In_ int namelen);
1762 
1763 WINSOCK_API_LINKAGE
1764 int
1765 WSAAPI
1766 ioctlsocket(
1767   _In_ SOCKET s,
1768   _In_ long cmd,
1769   _Inout_ u_long FAR *argp);
1770 
1771 WINSOCK_API_LINKAGE
1772 int
1773 WSAAPI
1774 getpeername(
1775   _In_ SOCKET s,
1776   _Out_writes_bytes_to_(*namelen,*namelen) struct sockaddr FAR *name,
1777   _Inout_ int FAR *namelen);
1778 
1779 WINSOCK_API_LINKAGE
1780 int
1781 WSAAPI
1782 getsockname(
1783   _In_ SOCKET s,
1784   _Out_writes_bytes_to_(*namelen,*namelen) struct sockaddr FAR *name,
1785   _Inout_ int FAR *namelen);
1786 
1787 WINSOCK_API_LINKAGE
1788 int
1789 WSAAPI
1790 getsockopt(
1791   _In_ SOCKET s,
1792   _In_ int level,
1793   _In_ int optname,
1794   _Out_writes_bytes_(*optlen) char FAR *optval,
1795   _Inout_ int FAR *optlen);
1796 
1797 WINSOCK_API_LINKAGE
1798 u_long
1799 WSAAPI
1800 htonl(
1801   IN u_long hostlong);
1802 
1803 WINSOCK_API_LINKAGE
1804 u_short
1805 WSAAPI
1806 htons(
1807   _In_ u_short hostshort);
1808 
1809 WINSOCK_API_LINKAGE
1810 unsigned long
1811 WSAAPI
1812 inet_addr(
1813   _In_z_ const char FAR *cp);
1814 
1815 WINSOCK_API_LINKAGE
1816 char FAR *
1817 WSAAPI
1818 inet_ntoa(
1819   _In_ struct in_addr in);
1820 
1821 WINSOCK_API_LINKAGE
1822 int
1823 WSAAPI
1824 listen(
1825   _In_ SOCKET s,
1826   _In_ int backlog);
1827 
1828 WINSOCK_API_LINKAGE
1829 u_long
1830 WSAAPI
1831 ntohl(
1832   _In_ u_long netlong);
1833 
1834 WINSOCK_API_LINKAGE
1835 u_short
1836 WSAAPI
1837 ntohs(
1838   _In_ u_short netshort);
1839 
1840 WINSOCK_API_LINKAGE
1841 int
1842 WSAAPI
1843 recv(
1844   _In_ SOCKET s,
1845   _Out_writes_bytes_to_(len, return) __out_data_source(NETWORK) char FAR *buf,
1846   _In_ int len,
1847   _In_ int flags);
1848 
1849 WINSOCK_API_LINKAGE
1850 int
1851 WSAAPI
1852 recvfrom(
1853   _In_ SOCKET s,
1854   _Out_writes_bytes_to_(len, return) __out_data_source(NETWORK) char FAR *buf,
1855   _In_ int len,
1856   _In_ int flags,
1857   _Out_writes_bytes_to_opt_(*fromlen, *fromlen) struct sockaddr FAR *from,
1858   _Inout_opt_ int FAR *fromlen);
1859 
1860 WINSOCK_API_LINKAGE
1861 int
1862 WSAAPI
1863 select(
1864   _In_ int nfds,
1865   _Inout_opt_ fd_set FAR *readfds,
1866   _Inout_opt_ fd_set FAR *writefds,
1867   _Inout_opt_ fd_set FAR *exceptfds,
1868   _In_opt_ const struct timeval FAR *timeout);
1869 
1870 WINSOCK_API_LINKAGE
1871 int
1872 WSAAPI
1873 send(
1874   _In_ SOCKET s,
1875   _In_reads_bytes_(len) const char FAR *buf,
1876   _In_ int len,
1877   _In_ int flags);
1878 
1879 WINSOCK_API_LINKAGE
1880 int
1881 WSAAPI
1882 sendto(
1883   _In_ SOCKET s,
1884   _In_reads_bytes_(len) const char FAR *buf,
1885   _In_ int len,
1886   _In_ int flags,
1887   _In_reads_bytes_(tolen) const struct sockaddr FAR *to,
1888   _In_ int tolen);
1889 
1890 WINSOCK_API_LINKAGE
1891 int
1892 WSAAPI
1893 setsockopt(
1894   _In_ SOCKET s,
1895   _In_ int level,
1896   _In_ int optname,
1897   _In_reads_bytes_opt_(optlen) const char FAR *optval,
1898   _In_ int optlen);
1899 
1900 WINSOCK_API_LINKAGE
1901 int
1902 WSAAPI
1903 shutdown(
1904   _In_ SOCKET s,
1905   _In_ int how);
1906 
1907 _Must_inspect_result_
1908 WINSOCK_API_LINKAGE
1909 SOCKET
1910 WSAAPI
1911 socket(
1912   _In_ int af,
1913   _In_ int type,
1914   _In_ int protocol);
1915 
1916 WINSOCK_API_LINKAGE
1917 struct hostent FAR *
1918 WSAAPI
1919 gethostbyaddr(
1920   _In_reads_bytes_(len) const char FAR *addr,
1921   _In_ int len,
1922   _In_ int type);
1923 
1924 WINSOCK_API_LINKAGE
1925 struct hostent FAR *
1926 WSAAPI
1927 gethostbyname(
1928   _In_z_ const char FAR *name);
1929 
1930 WINSOCK_API_LINKAGE
1931 int
1932 WSAAPI
1933 gethostname(
1934   _Out_writes_bytes_(namelen) char FAR *name,
1935   _In_ int namelen);
1936 
1937 WINSOCK_API_LINKAGE
1938 struct servent FAR *
1939 WSAAPI
1940 getservbyport(
1941   _In_ int port,
1942   _In_opt_z_ const char FAR *proto);
1943 
1944 WINSOCK_API_LINKAGE
1945 struct servent FAR *
1946 WSAAPI
1947 getservbyname(
1948   _In_z_ const char FAR *name,
1949   _In_opt_z_ const char FAR *proto);
1950 
1951 WINSOCK_API_LINKAGE
1952 struct protoent FAR *
1953 WSAAPI
1954 getprotobynumber(
1955   _In_ int number);
1956 
1957 WINSOCK_API_LINKAGE
1958 struct protoent FAR *
1959 WSAAPI
1960 getprotobyname(
1961   _In_z_ const char FAR *name);
1962 
1963 _Must_inspect_result_
1964 WINSOCK_API_LINKAGE
1965 int
1966 WSAAPI
1967 WSAStartup(
1968   _In_ WORD wVersionRequired,
1969   _Out_ LPWSADATA lpWSAData);
1970 
1971 WINSOCK_API_LINKAGE
1972 int
1973 WSAAPI
1974 WSACleanup(void);
1975 
1976 WINSOCK_API_LINKAGE
1977 void
1978 WSAAPI
1979 WSASetLastError(
1980   _In_ int iError);
1981 
1982 WINSOCK_API_LINKAGE
1983 int
1984 WSAAPI
1985 WSAGetLastError(void);
1986 
1987 WINSOCK_API_LINKAGE
1988 BOOL
1989 WSAAPI
1990 WSAIsBlocking(void);
1991 
1992 WINSOCK_API_LINKAGE
1993 int
1994 WSAAPI
1995 WSAUnhookBlockingHook(void);
1996 
1997 WINSOCK_API_LINKAGE
1998 FARPROC
1999 WSAAPI
2000 WSASetBlockingHook(
2001   _In_ FARPROC lpBlockFunc);
2002 
2003 WINSOCK_API_LINKAGE
2004 int
2005 WSAAPI
2006 WSACancelBlockingCall(void);
2007 
2008 WINSOCK_API_LINKAGE
2009 HANDLE
2010 WSAAPI
2011 WSAAsyncGetServByName(
2012   _In_ HWND hWnd,
2013   _In_ u_int wMsg,
2014   _In_z_ const char FAR *name,
2015   _In_z_ const char FAR *proto,
2016   _Out_writes_bytes_(buflen) char FAR *buf,
2017   _In_ int buflen);
2018 
2019 WINSOCK_API_LINKAGE
2020 HANDLE
2021 WSAAPI
2022 WSAAsyncGetServByPort(
2023   _In_ HWND hWnd,
2024   _In_ u_int wMsg,
2025   _In_ int port,
2026   _In_ const char FAR *proto,
2027   _Out_writes_bytes_(buflen) char FAR *buf,
2028   _In_ int buflen);
2029 
2030 WINSOCK_API_LINKAGE
2031 HANDLE
2032 WSAAPI
2033 WSAAsyncGetProtoByName(
2034   _In_ HWND hWnd,
2035   _In_ u_int wMsg,
2036   _In_z_ const char FAR *name,
2037   _Out_writes_bytes_(buflen) char FAR *buf,
2038   _In_ int buflen);
2039 
2040 WINSOCK_API_LINKAGE
2041 HANDLE
2042 WSAAPI
2043 WSAAsyncGetProtoByNumber(
2044   _In_ HWND hWnd,
2045   _In_ u_int wMsg,
2046   _In_ int number,
2047   _Out_writes_bytes_(buflen) char FAR *buf,
2048   _In_ int buflen);
2049 
2050 WINSOCK_API_LINKAGE
2051 HANDLE
2052 WSAAPI
2053 WSAAsyncGetHostByName(
2054   _In_ HWND hWnd,
2055   _In_ u_int wMsg,
2056   _In_z_ const char FAR *name,
2057   _Out_writes_bytes_(buflen) char FAR *buf,
2058   _In_ int buflen);
2059 
2060 WINSOCK_API_LINKAGE
2061 HANDLE
2062 WSAAPI
2063 WSAAsyncGetHostByAddr(
2064   _In_ HWND hWnd,
2065   _In_ u_int wMsg,
2066   _In_reads_bytes_(len) const char FAR *addr,
2067   _In_ int len,
2068   _In_ int type,
2069   _Out_writes_bytes_(buflen) char FAR *buf,
2070   _In_ int buflen);
2071 
2072 WINSOCK_API_LINKAGE
2073 int
2074 WSAAPI
2075 WSACancelAsyncRequest(
2076   _In_ HANDLE hAsyncTaskHandle);
2077 
2078 WINSOCK_API_LINKAGE
2079 int
2080 WSAAPI
2081 WSAAsyncSelect(
2082   _In_ SOCKET s,
2083   _In_ HWND hWnd,
2084   _In_ u_int wMsg,
2085   _In_ long lEvent);
2086 
2087 _Must_inspect_result_
2088 WINSOCK_API_LINKAGE
2089 SOCKET
2090 WSAAPI
2091 WSAAccept(
2092   _In_ SOCKET s,
2093   _Out_writes_bytes_to_opt_(*addrlen,*addrlen) struct sockaddr FAR *addr,
2094   _Inout_opt_ LPINT addrlen,
2095   _In_opt_ LPCONDITIONPROC lpfnCondition,
2096   _In_opt_ DWORD_PTR dwCallbackData);
2097 
2098 WINSOCK_API_LINKAGE
2099 BOOL
2100 WSAAPI
2101 WSACloseEvent(
2102   _In_ WSAEVENT hEvent);
2103 
2104 WINSOCK_API_LINKAGE
2105 int
2106 WSAAPI
2107 WSAConnect(
2108   _In_ SOCKET s,
2109   _In_reads_bytes_(namelen) const struct sockaddr FAR *name,
2110   _In_ int namelen,
2111   _In_opt_ LPWSABUF lpCallerData,
2112   _Out_opt_ LPWSABUF lpCalleeData,
2113   _In_opt_ LPQOS lpSQOS,
2114   _In_opt_ LPQOS lpGQOS);
2115 
2116 #ifdef UNICODE
2117 #define WSAConnectByName WSAConnectByNameW
2118 #else
2119 #define WSAConnectByName WSAConnectByNameA
2120 #endif
2121 
2122 BOOL
2123 PASCAL
2124 WSAConnectByNameW(
2125   _In_ SOCKET s,
2126   _In_ LPWSTR nodename,
2127   _In_ LPWSTR servicename,
2128   _Inout_opt_ LPDWORD LocalAddressLength,
2129   _Out_writes_bytes_to_opt_(*LocalAddressLength,*LocalAddressLength) LPSOCKADDR LocalAddress,
2130   _Inout_opt_ LPDWORD RemoteAddressLength,
2131   _Out_writes_bytes_to_opt_(*RemoteAddressLength,*RemoteAddressLength) LPSOCKADDR RemoteAddress,
2132   _In_opt_ const struct timeval *timeout,
2133   _Reserved_ LPWSAOVERLAPPED Reserved);
2134 
2135 BOOL
2136 PASCAL
2137 WSAConnectByNameA(
2138   _In_ SOCKET s,
2139   _In_ LPCSTR nodename,
2140   _In_ LPCSTR servicename,
2141   _Inout_opt_ LPDWORD LocalAddressLength,
2142   _Out_writes_bytes_to_opt_(*LocalAddressLength,*LocalAddressLength) LPSOCKADDR LocalAddress,
2143   _Inout_opt_ LPDWORD RemoteAddressLength,
2144   _Out_writes_bytes_to_opt_(*RemoteAddressLength,*RemoteAddressLength) LPSOCKADDR RemoteAddress,
2145   _In_opt_ const struct timeval *timeout,
2146   _Reserved_ LPWSAOVERLAPPED Reserved);
2147 
2148 BOOL
2149 PASCAL
2150 WSAConnectByList(
2151   _In_ SOCKET s,
2152   _In_ PSOCKET_ADDRESS_LIST SocketAddress,
2153   _Inout_opt_ LPDWORD LocalAddressLength,
2154   _Out_writes_bytes_to_opt_(*LocalAddressLength,*LocalAddressLength) LPSOCKADDR LocalAddress,
2155   _Inout_opt_ LPDWORD RemoteAddressLength,
2156   _Out_writes_bytes_to_opt_(*RemoteAddressLength,*RemoteAddressLength) LPSOCKADDR RemoteAddress,
2157   _In_opt_ const struct timeval *timeout,
2158   _Reserved_ LPWSAOVERLAPPED Reserved);
2159 
2160 WINSOCK_API_LINKAGE
2161 WSAEVENT
2162 WSAAPI
2163 WSACreateEvent(void);
2164 
2165 WINSOCK_API_LINKAGE
2166 int
2167 WSAAPI
2168 WSADuplicateSocketA(
2169   _In_ SOCKET s,
2170   _In_ DWORD dwProcessId,
2171   _Out_ LPWSAPROTOCOL_INFOA lpProtocolInfo);
2172 
2173 WINSOCK_API_LINKAGE
2174 int
2175 WSAAPI
2176 WSADuplicateSocketW(
2177   _In_ SOCKET s,
2178   _In_ DWORD dwProcessId,
2179   _Out_ LPWSAPROTOCOL_INFOW lpProtocolInfo);
2180 
2181 #ifdef UNICODE
2182 #define WSADuplicateSocket WSADuplicateSocketW
2183 #else
2184 #define WSADuplicateSocket WSADuplicateSocketA
2185 #endif
2186 
2187 WINSOCK_API_LINKAGE
2188 int
2189 WSAAPI
2190 WSAEnumNetworkEvents(
2191   _In_ SOCKET s,
2192   _In_ WSAEVENT hEventObject,
2193   _Out_ LPWSANETWORKEVENTS lpNetworkEvents);
2194 
2195 WINSOCK_API_LINKAGE
2196 int
2197 WSAAPI
2198 WSAEnumProtocolsA(
2199   _In_opt_ LPINT lpiProtocols,
2200   _Out_writes_bytes_to_opt_(*lpdwBufferLength,*lpdwBufferLength) LPWSAPROTOCOL_INFOA lpProtocolBuffer,
2201   _Inout_ LPDWORD lpdwBufferLength);
2202 
2203 WINSOCK_API_LINKAGE
2204 int
2205 WSAAPI
2206 WSAEnumProtocolsW(
2207   _In_opt_ LPINT lpiProtocols,
2208   _Out_writes_bytes_to_opt_(*lpdwBufferLength,*lpdwBufferLength) LPWSAPROTOCOL_INFOW lpProtocolBuffer,
2209   _Inout_ LPDWORD lpdwBufferLength);
2210 
2211 #ifdef UNICODE
2212 #define WSAEnumProtocols WSAEnumProtocolsW
2213 #else
2214 #define WSAEnumProtocols WSAEnumProtocolsA
2215 #endif
2216 
2217 WINSOCK_API_LINKAGE
2218 int
2219 WSAAPI
2220 WSAEventSelect(
2221   _In_ SOCKET s,
2222   _In_opt_ WSAEVENT hEventObject,
2223   _In_ long lNetworkEvents);
2224 
2225 WINSOCK_API_LINKAGE
2226 BOOL
2227 WSAAPI
2228 WSAGetOverlappedResult(
2229   _In_ SOCKET s,
2230   _In_ LPWSAOVERLAPPED lpOverlapped,
2231   _Out_ LPDWORD lpcbTransfer,
2232   _In_ BOOL fWait,
2233   _Out_ LPDWORD lpdwFlags);
2234 
2235 WINSOCK_API_LINKAGE
2236 BOOL
2237 WSAAPI
2238 WSAGetQOSByName(
2239   _In_ SOCKET s,
2240   _In_ LPWSABUF lpQOSName,
2241   _Out_ LPQOS lpQOS);
2242 
2243 WINSOCK_API_LINKAGE
2244 int
2245 WSAAPI
2246 WSAHtonl(
2247   _In_ SOCKET s,
2248   _In_ u_long hostlong,
2249   _Out_ u_long FAR *lpnetlong);
2250 
2251 WINSOCK_API_LINKAGE
2252 int
2253 WSAAPI
2254 WSAHtons(
2255   _In_ SOCKET s,
2256   _In_ u_short hostshort,
2257   _Out_ u_short FAR *lpnetshort);
2258 
2259 WINSOCK_API_LINKAGE
2260 int
2261 WSAAPI
2262 WSAIoctl(
2263   _In_ SOCKET s,
2264   _In_ DWORD dwIoControlCode,
2265   _In_reads_bytes_opt_(cbInBuffer) LPVOID lpvInBuffer,
2266   _In_ DWORD cbInBuffer,
2267   _Out_writes_bytes_to_opt_(cbOutBuffer, *lpcbBytesReturned) LPVOID lpvOutBuffer,
2268   _In_ DWORD cbOutBuffer,
2269   _Out_ LPDWORD lpcbBytesReturned,
2270   _Inout_opt_ LPWSAOVERLAPPED lpOverlapped,
2271   _In_opt_ LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
2272 
2273 WINSOCK_API_LINKAGE
2274 SOCKET
2275 WSAAPI
2276 WSAJoinLeaf(
2277   _In_ SOCKET s,
2278   _In_reads_bytes_(namelen) const struct sockaddr FAR *name,
2279   _In_ int namelen,
2280   _In_opt_ LPWSABUF lpCallerData,
2281   _Out_opt_ LPWSABUF lpCalleeData,
2282   _In_opt_ LPQOS lpSQOS,
2283   _In_opt_ LPQOS lpGQOS,
2284   _In_ DWORD dwFlags);
2285 
2286 WINSOCK_API_LINKAGE
2287 int
2288 WSAAPI
2289 WSANtohl(
2290   _In_ SOCKET s,
2291   _In_ u_long netlong,
2292   _Out_ u_long FAR *lphostlong);
2293 
2294 WINSOCK_API_LINKAGE
2295 int
2296 WSAAPI
2297 WSANtohs(
2298   _In_ SOCKET s,
2299   _In_ u_short netshort,
2300   _Out_ u_short FAR *lphostshort);
2301 
2302 WINSOCK_API_LINKAGE
2303 int
2304 WSAAPI
2305 WSARecv(
2306   _In_ SOCKET s,
2307   _In_reads_(dwBufferCount) __out_data_source(NETWORK) LPWSABUF lpBuffers,
2308   _In_ DWORD dwBufferCount,
2309   _Out_opt_ LPDWORD lpNumberOfBytesRecvd,
2310   _Inout_ LPDWORD lpFlags,
2311   _Inout_opt_ LPWSAOVERLAPPED lpOverlapped,
2312   _In_opt_ LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
2313 
2314 WINSOCK_API_LINKAGE
2315 int
2316 WSAAPI
2317 WSARecvDisconnect(
2318   _In_ SOCKET s,
2319   _In_opt_ __out_data_source(NETWORK) LPWSABUF lpInboundDisconnectData);
2320 
2321 WINSOCK_API_LINKAGE
2322 int
2323 WSAAPI
2324 WSARecvFrom(
2325   _In_ SOCKET s,
2326   _In_reads_(dwBufferCount) __out_data_source(NETWORK) LPWSABUF lpBuffers,
2327   _In_ DWORD dwBufferCount,
2328   _Out_opt_ LPDWORD lpNumberOfBytesRecvd,
2329   _Inout_ LPDWORD lpFlags,
2330   _Out_writes_bytes_to_opt_(*lpFromlen,*lpFromlen) struct sockaddr FAR *lpFrom,
2331   _Inout_opt_ LPINT lpFromlen,
2332   _Inout_opt_ LPWSAOVERLAPPED lpOverlapped,
2333   _In_opt_ LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
2334 
2335 WINSOCK_API_LINKAGE
2336 BOOL
2337 WSAAPI
2338 WSAResetEvent(
2339   _In_ WSAEVENT hEvent);
2340 
2341 WINSOCK_API_LINKAGE
2342 int
2343 WSAAPI
2344 WSASendDisconnect(
2345   _In_ SOCKET s,
2346   _In_opt_ LPWSABUF lpOutboundDisconnectData);
2347 
2348 WINSOCK_API_LINKAGE
2349 int
2350 WSAAPI
2351 WSASend(
2352   _In_ SOCKET s,
2353   _In_reads_(dwBufferCount) LPWSABUF lpBuffers,
2354   _In_ DWORD dwBufferCount,
2355   _Out_opt_ LPDWORD lpNumberOfBytesSent,
2356   _In_ DWORD dwFlags,
2357   _Inout_opt_ LPWSAOVERLAPPED lpOverlapped,
2358   _In_opt_ LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
2359 
2360 WINSOCK_API_LINKAGE
2361 int
2362 WSAAPI
2363 WSASendTo(
2364   _In_ SOCKET s,
2365   _In_reads_(dwBufferCount) LPWSABUF lpBuffers,
2366   _In_ DWORD dwBufferCount,
2367   _Out_opt_ LPDWORD lpNumberOfBytesSent,
2368   _In_ DWORD dwFlags,
2369   _In_reads_bytes_opt_(iTolen) const struct sockaddr FAR *lpTo,
2370   _In_ int iTolen,
2371   _Inout_opt_ LPWSAOVERLAPPED lpOverlapped,
2372   _In_opt_ LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
2373 
2374 WINSOCK_API_LINKAGE
2375 BOOL
2376 WSAAPI
2377 WSASetEvent(
2378   _In_ WSAEVENT hEvent);
2379 
2380 _Must_inspect_result_
2381 WINSOCK_API_LINKAGE
2382 SOCKET
2383 WSAAPI
2384 WSASocketA(
2385   _In_ int af,
2386   _In_ int type,
2387   _In_ int protocol,
2388   _In_opt_ LPWSAPROTOCOL_INFOA lpProtocolInfo,
2389   _In_ GROUP g,
2390   _In_ DWORD dwFlags);
2391 
2392 _Must_inspect_result_
2393 WINSOCK_API_LINKAGE
2394 SOCKET
2395 WSAAPI
2396 WSASocketW(
2397   _In_ int af,
2398   _In_ int type,
2399   _In_ int protocol,
2400   _In_opt_ LPWSAPROTOCOL_INFOW lpProtocolInfo,
2401   _In_ GROUP g,
2402   _In_ DWORD dwFlags);
2403 
2404 #ifdef UNICODE
2405 #define WSASocket WSASocketW
2406 #else
2407 #define WSASocket WSASocketA
2408 #endif
2409 
2410 WINSOCK_API_LINKAGE
2411 DWORD
2412 WSAAPI
2413 WSAWaitForMultipleEvents(
2414   _In_ DWORD cEvents,
2415   _In_reads_(cEvents) const WSAEVENT FAR *lphEvents,
2416   _In_ BOOL fWaitAll,
2417   _In_ DWORD dwTimeout,
2418   _In_ BOOL fAlertable);
2419 
2420 WINSOCK_API_LINKAGE
2421 INT
2422 WSAAPI
2423 WSAAddressToStringA(
2424   _In_reads_bytes_(dwAddressLength) LPSOCKADDR lpsaAddress,
2425   _In_ DWORD dwAddressLength,
2426   _In_opt_ LPWSAPROTOCOL_INFOA lpProtocolInfo,
2427   _Out_writes_to_(*lpdwAddressStringLength,*lpdwAddressStringLength) LPSTR lpszAddressString,
2428   _Inout_ LPDWORD lpdwAddressStringLength);
2429 
2430 WINSOCK_API_LINKAGE
2431 INT
2432 WSAAPI
2433 WSAAddressToStringW(
2434   _In_reads_bytes_(dwAddressLength) LPSOCKADDR lpsaAddress,
2435   _In_ DWORD dwAddressLength,
2436   _In_opt_ LPWSAPROTOCOL_INFOW lpProtocolInfo,
2437   _Out_writes_to_(*lpdwAddressStringLength,*lpdwAddressStringLength) LPWSTR lpszAddressString,
2438   _Inout_ LPDWORD lpdwAddressStringLength);
2439 
2440 #ifdef UNICODE
2441 #define WSAAddressToString WSAAddressToStringW
2442 #else
2443 #define WSAAddressToString WSAAddressToStringA
2444 #endif
2445 
2446 WINSOCK_API_LINKAGE
2447 INT
2448 WSAAPI
2449 WSAStringToAddressA(
2450   _In_ LPSTR AddressString,
2451   _In_ INT AddressFamily,
2452   _In_opt_ LPWSAPROTOCOL_INFOA lpProtocolInfo,
2453   _Out_writes_bytes_to_(*lpAddressLength,*lpAddressLength) LPSOCKADDR lpAddress,
2454   _Inout_ LPINT lpAddressLength);
2455 
2456 WINSOCK_API_LINKAGE
2457 INT
2458 WSAAPI
2459 WSAStringToAddressW(
2460   _In_ LPWSTR AddressString,
2461   _In_ INT AddressFamily,
2462   _In_opt_ LPWSAPROTOCOL_INFOW lpProtocolInfo,
2463   _Out_writes_bytes_to_(*lpAddressLength,*lpAddressLength) LPSOCKADDR lpAddress,
2464   _Inout_ LPINT lpAddressLength);
2465 
2466 #ifdef UNICODE
2467 #define WSAStringToAddress WSAStringToAddressW
2468 #else
2469 #define WSAStringToAddress WSAStringToAddressA
2470 #endif
2471 
2472 WINSOCK_API_LINKAGE
2473 INT
2474 WSAAPI
2475 WSALookupServiceBeginA(
2476   _In_ LPWSAQUERYSETA lpqsRestrictions,
2477   _In_ DWORD dwControlFlags,
2478   _Out_ LPHANDLE lphLookup);
2479 
2480 WINSOCK_API_LINKAGE
2481 INT
2482 WSAAPI
2483 WSALookupServiceBeginW(
2484   _In_ LPWSAQUERYSETW lpqsRestrictions,
2485   _In_ DWORD dwControlFlags,
2486   _Out_ LPHANDLE lphLookup);
2487 
2488 #ifdef UNICODE
2489 #define WSALookupServiceBegin WSALookupServiceBeginW
2490 #else
2491 #define WSALookupServiceBegin WSALookupServiceBeginA
2492 #endif
2493 
2494 WINSOCK_API_LINKAGE
2495 INT
2496 WSAAPI
2497 WSALookupServiceNextA(
2498   _In_ HANDLE hLookup,
2499   _In_ DWORD dwControlFlags,
2500   _Inout_ LPDWORD lpdwBufferLength,
2501   _Out_writes_bytes_to_(*lpdwBufferLength,*lpdwBufferLength) LPWSAQUERYSETA lpqsResults);
2502 
2503 WINSOCK_API_LINKAGE
2504 INT
2505 WSAAPI
2506 WSALookupServiceNextW(
2507   _In_ HANDLE hLookup,
2508   _In_ DWORD dwControlFlags,
2509   _Inout_ LPDWORD lpdwBufferLength,
2510   _Out_writes_bytes_to_opt_(*lpdwBufferLength,*lpdwBufferLength) LPWSAQUERYSETW lpqsResults);
2511 
2512 #ifdef UNICODE
2513 #define WSALookupServiceNext WSALookupServiceNextW
2514 #else
2515 #define WSALookupServiceNext WSALookupServiceNextA
2516 #endif
2517 
2518 WINSOCK_API_LINKAGE
2519 INT
2520 WSAAPI
2521 WSALookupServiceEnd(
2522   _In_ HANDLE hLookup);
2523 
2524 WINSOCK_API_LINKAGE
2525 INT
2526 WSAAPI
2527 WSAInstallServiceClassA(
2528   _In_ LPWSASERVICECLASSINFOA lpServiceClassInfo);
2529 
2530 WINSOCK_API_LINKAGE
2531 INT
2532 WSAAPI
2533 WSAInstallServiceClassW(
2534   _In_ LPWSASERVICECLASSINFOW lpServiceClassInfo);
2535 
2536 #ifdef UNICODE
2537 #define WSAInstallServiceClass WSAInstallServiceClassW
2538 #else
2539 #define WSAInstallServiceClass WSAInstallServiceClassA
2540 #endif
2541 
2542 WINSOCK_API_LINKAGE
2543 INT
2544 WSAAPI
2545 WSARemoveServiceClass(
2546   _In_ LPGUID lpServiceClassId);
2547 
2548 WINSOCK_API_LINKAGE
2549 INT
2550 WSAAPI
2551 WSAGetServiceClassInfoA(
2552   _In_ LPGUID lpProviderId,
2553   _In_ LPGUID lpServiceClassId,
2554   _Inout_ LPDWORD lpdwBufSize,
2555   _Out_writes_bytes_to_(*lpdwBufSize,*lpdwBufSize) LPWSASERVICECLASSINFOA lpServiceClassInfo);
2556 
2557 WINSOCK_API_LINKAGE
2558 INT
2559 WSAAPI
2560 WSAGetServiceClassInfoW(
2561   _In_ LPGUID lpProviderId,
2562   _In_ LPGUID lpServiceClassId,
2563   _Inout_ LPDWORD lpdwBufSize,
2564   _Out_writes_bytes_to_(*lpdwBufSize,*lpdwBufSize) LPWSASERVICECLASSINFOW lpServiceClassInfo);
2565 
2566 #ifdef UNICODE
2567 #define WSAGetServiceClassInfo WSAGetServiceClassInfoW
2568 #else
2569 #define WSAGetServiceClassInfo WSAGetServiceClassInfoA
2570 #endif
2571 
2572 WINSOCK_API_LINKAGE
2573 INT
2574 WSAAPI
2575 WSAEnumNameSpaceProvidersA(
2576   _Inout_ LPDWORD lpdwBufferLength,
2577   _Out_writes_bytes_to_(*lpdwBufferLength,*lpdwBufferLength) LPWSANAMESPACE_INFOA lpnspBuffer);
2578 
2579 WINSOCK_API_LINKAGE
2580 INT
2581 WSAAPI
2582 WSAEnumNameSpaceProvidersW(
2583   _Inout_ LPDWORD lpdwBufferLength,
2584   _Out_writes_bytes_to_(*lpdwBufferLength,*lpdwBufferLength) LPWSANAMESPACE_INFOW lpnspBuffer);
2585 
2586 #ifdef UNICODE
2587 #define WSAEnumNameSpaceProviders WSAEnumNameSpaceProvidersW
2588 #else
2589 #define WSAEnumNameSpaceProviders WSAEnumNameSpaceProvidersA
2590 #endif
2591 
2592 _Success_(return == 0)
2593 WINSOCK_API_LINKAGE
2594 INT
2595 WSAAPI
2596 WSAGetServiceClassNameByClassIdA(
2597   _In_ LPGUID lpServiceClassId,
2598   _Out_writes_bytes_to_(*lpdwBufferLength,*lpdwBufferLength) LPSTR lpszServiceClassName,
2599   _Inout_ LPDWORD lpdwBufferLength);
2600 
2601 _Success_(return == 0)
2602 WINSOCK_API_LINKAGE
2603 INT
2604 WSAAPI
2605 WSAGetServiceClassNameByClassIdW(
2606   _In_ LPGUID lpServiceClassId,
2607   _Out_writes_bytes_to_(*lpdwBufferLength,*lpdwBufferLength) LPWSTR lpszServiceClassName,
2608   _Inout_ LPDWORD lpdwBufferLength);
2609 
2610 #ifdef UNICODE
2611 #define WSAGetServiceClassNameByClassId WSAGetServiceClassNameByClassIdW
2612 #else
2613 #define WSAGetServiceClassNameByClassId WSAGetServiceClassNameByClassIdA
2614 #endif
2615 
2616 WINSOCK_API_LINKAGE
2617 INT
2618 WSAAPI
2619 WSASetServiceA(
2620   _In_ LPWSAQUERYSETA lpqsRegInfo,
2621   _In_ WSAESETSERVICEOP essoperation,
2622   _In_ DWORD dwControlFlags);
2623 
2624 WINSOCK_API_LINKAGE
2625 INT
2626 WSAAPI
2627 WSASetServiceW(
2628   _In_ LPWSAQUERYSETW lpqsRegInfo,
2629   _In_ WSAESETSERVICEOP essoperation,
2630   _In_ DWORD dwControlFlags);
2631 
2632 #ifdef UNICODE
2633 #define WSASetService WSASetServiceW
2634 #else
2635 #define WSASetService WSASetServiceA
2636 #endif
2637 
2638 WINSOCK_API_LINKAGE
2639 INT
2640 WSAAPI
2641 WSAProviderConfigChange(
2642   _Inout_ LPHANDLE lpNotificationHandle,
2643   _Inout_opt_ LPWSAOVERLAPPED lpOverlapped,
2644   _In_opt_ LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
2645 
2646 #if(_WIN32_WINNT >= 0x0501)
2647 WINSOCK_API_LINKAGE
2648 INT
2649 WSAAPI
2650 WSANSPIoctl(
2651   _In_ HANDLE hLookup,
2652   _In_ DWORD dwControlCode,
2653   _In_reads_bytes_opt_(cbInBuffer) LPVOID lpvInBuffer,
2654   _In_ DWORD cbInBuffer,
2655   _Out_writes_bytes_to_opt_(cbOutBuffer, *lpcbBytesReturned) LPVOID lpvOutBuffer,
2656   _In_ DWORD cbOutBuffer,
2657   _Out_ LPDWORD lpcbBytesReturned,
2658   _In_opt_ LPWSACOMPLETION lpCompletion);
2659 #endif /* (_WIN32_WINNT >= 0x0501) */
2660 
2661 #if(_WIN32_WINNT >= 0x0600)
2662 
2663 WINSOCK_API_LINKAGE
2664 int
2665 WSAAPI
2666 WSASendMsg(
2667   _In_ SOCKET Handle,
2668   _In_ LPWSAMSG lpMsg,
2669   _In_ DWORD dwFlags,
2670   _Out_opt_ LPDWORD lpNumberOfBytesSent,
2671   _Inout_opt_ LPWSAOVERLAPPED lpOverlapped,
2672   _In_opt_ LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
2673 
2674 WINSOCK_API_LINKAGE
2675 INT
2676 WSAAPI
2677 WSAEnumNameSpaceProvidersExA(
2678   _Inout_ LPDWORD lpdwBufferLength,
2679   _Out_writes_bytes_to_(*lpdwBufferLength,*lpdwBufferLength) LPWSANAMESPACE_INFOEXA lpnspBuffer);
2680 
2681 WINSOCK_API_LINKAGE
2682 INT
2683 WSAAPI
2684 WSAEnumNameSpaceProvidersExW(
2685   _Inout_ LPDWORD lpdwBufferLength,
2686   _Out_writes_bytes_to_(*lpdwBufferLength,*lpdwBufferLength) LPWSANAMESPACE_INFOEXW lpnspBuffer);
2687 
2688 #ifdef UNICODE
2689 #define WSAEnumNameSpaceProvidersEx WSAEnumNameSpaceProvidersExW
2690 #else
2691 #define WSAEnumNameSpaceProvidersEx WSAEnumNameSpaceProvidersExA
2692 #endif
2693 
2694 WINSOCK_API_LINKAGE
2695 int
2696 WSAAPI
2697 WSAPoll(
2698   _Inout_ LPWSAPOLLFD fdArray,
2699   _In_ ULONG fds,
2700   _In_ INT timeout);
2701 
2702 #endif /* (_WIN32_WINNT >= 0x0600) */
2703 
2704 #endif /* INCL_WINSOCK_API_PROTOTYPES */
2705 
2706 typedef struct sockaddr_in FAR *LPSOCKADDR_IN;
2707 typedef struct linger LINGER;
2708 typedef struct linger *PLINGER;
2709 typedef struct linger FAR *LPLINGER;
2710 typedef struct fd_set FD_SET;
2711 typedef struct fd_set *PFD_SET;
2712 typedef struct fd_set FAR *LPFD_SET;
2713 typedef struct hostent HOSTENT;
2714 typedef struct hostent *PHOSTENT;
2715 typedef struct hostent FAR *LPHOSTENT;
2716 typedef struct servent SERVENT;
2717 typedef struct servent *PSERVENT;
2718 typedef struct servent FAR *LPSERVENT;
2719 typedef struct protoent PROTOENT;
2720 typedef struct protoent *PPROTOENT;
2721 typedef struct protoent FAR *LPPROTOENT;
2722 typedef struct timeval TIMEVAL;
2723 typedef struct timeval *PTIMEVAL;
2724 typedef struct timeval FAR *LPTIMEVAL;
2725 
2726 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
2727 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
2728 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
2729 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
2730 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
2731 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
2732 
2733 #ifdef __cplusplus
2734 }
2735 #endif
2736 
2737 #ifdef _NEED_POPPACK
2738 #include <poppack.h>
2739 #endif
2740 
2741 /* FIXME :
2742 #if(_WIN32_WINNT >= 0x0501)
2743 #ifdef IPV6STRICT
2744 #include <wsipv6ok.h>
2745 #endif
2746 #endif */
2747 
2748 #endif /* !(defined _WINSOCK2API_ || defined _WINSOCKAPI_) */
2749