9 #if !defined(_WINSOCK2API_) && defined(_WINSOCKAPI_)
10 #error Include only winsock2.h, not both winsock.h and ws2def.h in the same module.
13 #if (_WIN32_WINNT >= 0x0600)
16 #define WS2DEF_INLINE __inline
18 #define WS2DEF_INLINE extern inline
21 #endif/* (_WIN32_WINNT >= 0x0600) */
25 typedef USHORT ADDRESS_FAMILY
;
45 #define AF_APPLETALK 16
47 #define AF_VOICEVIEW 18
49 #define AF_UNKNOWN1 20
58 #if (_WIN32_WINNT < 0x0501)
64 #define AF_TCNPROCESS 29
65 #define AF_TCNMESSAGE 30
68 #if(_WIN32_WINNT < 0x0600)
75 #if (_WIN32_WINNT < 0x0601)
80 #endif /* (_WIN32_WINNT < 0x0601) */
82 #endif /* (_WIN32_WINNT < 0x0600) */
84 #endif /* (_WIN32_WINNT < 0x0501) */
90 #define SOCK_SEQPACKET 5
92 #define SOL_SOCKET 0xffff
94 #define SO_DEBUG 0x0001
95 #define SO_ACCEPTCONN 0x0002
96 #define SO_REUSEADDR 0x0004
97 #define SO_KEEPALIVE 0x0008
98 #define SO_DONTROUTE 0x0010
99 #define SO_BROADCAST 0x0020
100 #define SO_USELOOPBACK 0x0040
101 #define SO_LINGER 0x0080
102 #define SO_OOBINLINE 0x0100
104 #define SO_DONTLINGER (int)(~SO_LINGER)
105 #define SO_EXCLUSIVEADDRUSE ((int)(~SO_REUSEADDR))
107 #define SO_SNDBUF 0x1001
108 #define SO_RCVBUF 0x1002
109 #define SO_SNDLOWAT 0x1003
110 #define SO_RCVLOWAT 0x1004
111 #define SO_SNDTIMEO 0x1005
112 #define SO_RCVTIMEO 0x1006
113 #define SO_ERROR 0x1007
114 #define SO_TYPE 0x1008
115 #define SO_BSP_STATE 0x1009
117 #define SO_GROUP_ID 0x2001
118 #define SO_GROUP_PRIORITY 0x2002
119 #define SO_MAX_MSG_SIZE 0x2003
121 #define SO_CONDITIONAL_ACCEPT 0x3002
122 #define SO_PAUSE_ACCEPT 0x3003
123 #define SO_COMPARTMENT_ID 0x3004
124 #if (_WIN32_WINNT >= 0x0600)
125 #define SO_RANDOMIZE_PORT 0x3005
126 #define SO_PORT_SCALABILITY 0x3006
127 #endif /* (_WIN32_WINNT >= 0x0600) */
129 #define WSK_SO_BASE 0x4000
131 #define TCP_NODELAY 0x0001
133 #define _SS_MAXSIZE 128
134 #define _SS_ALIGNSIZE (sizeof(__int64))
136 #if (_WIN32_WINNT >= 0x0600)
138 #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(USHORT))
139 #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof(USHORT) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
143 #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof (short))
144 #define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (short) + _SS_PAD1SIZE + _SS_ALIGNSIZE))
146 #endif /* (_WIN32_WINNT >= 0x0600) */
148 #define IOC_UNIX 0x00000000
149 #define IOC_WS2 0x08000000
150 #define IOC_PROTOCOL 0x10000000
151 #define IOC_VENDOR 0x18000000
153 #if (_WIN32_WINNT >= 0x0600)
154 #define IOC_WSK (IOC_WS2|0x07000000)
157 #define _WSAIO(x,y) (IOC_VOID|(x)|(y))
158 #define _WSAIOR(x,y) (IOC_OUT|(x)|(y))
159 #define _WSAIOW(x,y) (IOC_IN|(x)|(y))
160 #define _WSAIORW(x,y) (IOC_INOUT|(x)|(y))
162 #define SIO_ASSOCIATE_HANDLE _WSAIOW(IOC_WS2,1)
163 #define SIO_ENABLE_CIRCULAR_QUEUEING _WSAIO(IOC_WS2,2)
164 #define SIO_FIND_ROUTE _WSAIOR(IOC_WS2,3)
165 #define SIO_FLUSH _WSAIO(IOC_WS2,4)
166 #define SIO_GET_BROADCAST_ADDRESS _WSAIOR(IOC_WS2,5)
167 #define SIO_GET_EXTENSION_FUNCTION_POINTER _WSAIORW(IOC_WS2,6)
168 #define SIO_GET_QOS _WSAIORW(IOC_WS2,7)
169 #define SIO_GET_GROUP_QOS _WSAIORW(IOC_WS2,8)
170 #define SIO_MULTIPOINT_LOOPBACK _WSAIOW(IOC_WS2,9)
171 #define SIO_MULTICAST_SCOPE _WSAIOW(IOC_WS2,10)
172 #define SIO_SET_QOS _WSAIOW(IOC_WS2,11)
173 #define SIO_SET_GROUP_QOS _WSAIOW(IOC_WS2,12)
174 #define SIO_TRANSLATE_HANDLE _WSAIORW(IOC_WS2,13)
175 #define SIO_ROUTING_INTERFACE_QUERY _WSAIORW(IOC_WS2,20)
176 #define SIO_ROUTING_INTERFACE_CHANGE _WSAIOW(IOC_WS2,21)
177 #define SIO_ADDRESS_LIST_QUERY _WSAIOR(IOC_WS2,22)
178 #define SIO_ADDRESS_LIST_CHANGE _WSAIO(IOC_WS2,23)
179 #define SIO_QUERY_TARGET_PNP_HANDLE _WSAIOR(IOC_WS2,24)
181 #if(_WIN32_WINNT >= 0x0501)
182 #define SIO_ADDRESS_LIST_SORT _WSAIORW(IOC_WS2,25)
185 #if (_WIN32_WINNT >= 0x0600)
186 #define SIO_RESERVED_1 _WSAIOW(IOC_WS2,26)
187 #define SIO_RESERVED_2 _WSAIOW(IOC_WS2,33)
192 #define IPPORT_TCPMUX 1
193 #define IPPORT_ECHO 7
194 #define IPPORT_DISCARD 9
195 #define IPPORT_SYSTAT 11
196 #define IPPORT_DAYTIME 13
197 #define IPPORT_NETSTAT 15
198 #define IPPORT_QOTD 17
199 #define IPPORT_MSP 18
200 #define IPPORT_CHARGEN 19
201 #define IPPORT_FTP_DATA 20
202 #define IPPORT_FTP 21
203 #define IPPORT_TELNET 23
204 #define IPPORT_SMTP 25
205 #define IPPORT_TIMESERVER 37
206 #define IPPORT_NAMESERVER 42
207 #define IPPORT_WHOIS 43
208 #define IPPORT_MTP 57
210 #define IPPORT_TFTP 69
211 #define IPPORT_RJE 77
212 #define IPPORT_FINGER 79
213 #define IPPORT_TTYLINK 87
214 #define IPPORT_SUPDUP 95
216 #define IPPORT_POP3 110
217 #define IPPORT_NTP 123
218 #define IPPORT_EPMAP 135
219 #define IPPORT_NETBIOS_NS 137
220 #define IPPORT_NETBIOS_DGM 138
221 #define IPPORT_NETBIOS_SSN 139
222 #define IPPORT_IMAP 143
223 #define IPPORT_SNMP 161
224 #define IPPORT_SNMP_TRAP 162
225 #define IPPORT_IMAP3 220
226 #define IPPORT_LDAP 389
227 #define IPPORT_HTTPS 443
228 #define IPPORT_MICROSOFT_DS 445
229 #define IPPORT_EXECSERVER 512
230 #define IPPORT_LOGINSERVER 513
231 #define IPPORT_CMDSERVER 514
232 #define IPPORT_EFSSERVER 520
234 #define IPPORT_BIFFUDP 512
235 #define IPPORT_WHOSERVER 513
236 #define IPPORT_ROUTESERVER 520
237 #define IPPORT_RESERVED 1024
239 #if (_WIN32_WINNT >= 0x0600)
241 #define IPPORT_REGISTERED_MIN IPPORT_RESERVED
242 #define IPPORT_REGISTERED_MAX 0xbfff
243 #define IPPORT_DYNAMIC_MIN 0xc000
244 #define IPPORT_DYNAMIC_MAX 0xffff
246 #endif /* (_WIN32_WINNT >= 0x0600) */
248 #define IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
249 #define IN_CLASSA_NET 0xff000000
250 #define IN_CLASSA_NSHIFT 24
251 #define IN_CLASSA_HOST 0x00ffffff
252 #define IN_CLASSA_MAX 128
254 #define IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
255 #define IN_CLASSB_NET 0xffff0000
256 #define IN_CLASSB_NSHIFT 16
257 #define IN_CLASSB_HOST 0x0000ffff
258 #define IN_CLASSB_MAX 65536
260 #define IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
261 #define IN_CLASSC_NET 0xffffff00
262 #define IN_CLASSC_NSHIFT 8
263 #define IN_CLASSC_HOST 0x000000ff
265 #define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
266 #define IN_CLASSD_NET 0xf0000000
267 #define IN_CLASSD_NSHIFT 28
268 #define IN_CLASSD_HOST 0x0fffffff
269 #define IN_MULTICAST(i) IN_CLASSD(i)
271 #define INADDR_ANY (ULONG)0x00000000
272 #define INADDR_LOOPBACK 0x7f000001
273 #define INADDR_BROADCAST (ULONG)0xffffffff
274 #define INADDR_NONE 0xffffffff
276 #define SCOPEID_UNSPECIFIED_INIT {0}
278 #define IOCPARM_MASK 0x7f
279 #define IOC_VOID 0x20000000
280 #define IOC_OUT 0x40000000
281 #define IOC_IN 0x80000000
282 #define IOC_INOUT (IOC_IN|IOC_OUT)
284 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
285 #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
286 #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
288 #define MSG_TRUNC 0x0100
289 #define MSG_CTRUNC 0x0200
290 #define MSG_BCAST 0x0400
291 #define MSG_MCAST 0x0800
293 #define AI_PASSIVE 0x00000001
294 #define AI_CANONNAME 0x00000002
295 #define AI_NUMERICHOST 0x00000004
296 #define AI_NUMERICSERV 0x00000008
298 #define AI_ALL 0x00000100
299 #define AI_ADDRCONFIG 0x00000400
300 #define AI_V4MAPPED 0x00000800
302 #define AI_NON_AUTHORITATIVE 0x00004000
303 #define AI_SECURE 0x00008000
304 #define AI_RETURN_PREFERRED_NAMES 0x00010000
306 #define AI_FQDN 0x00020000
307 #define AI_FILESERVER 0x00040000
313 #define NS_PEER_BROWSE 3
317 #define NS_TCPIP_LOCAL 10
318 #define NS_TCPIP_HOSTS 11
323 #if(_WIN32_WINNT >= 0x0501)
327 #if(_WIN32_WINNT >= 0x0600)
337 #if(_WIN32_WINNT >= 0x0600)
339 #define NS_PNRPNAME 38
340 #define NS_PNRPCLOUD 39
345 #define NS_NISPLUS 42
351 #define NI_NOFQDN 0x01
352 #define NI_NUMERICHOST 0x02
353 #define NI_NAMEREQD 0x04
354 #define NI_NUMERICSERV 0x08
355 #define NI_DGRAM 0x10
357 #define NI_MAXHOST 1025
358 #define NI_MAXSERV 32
360 typedef struct sockaddr
{
361 #if (_WIN32_WINNT < 0x0600)
364 ADDRESS_FAMILY sa_family
;
367 } SOCKADDR
, *PSOCKADDR
, FAR
*LPSOCKADDR
;
369 #ifndef __CSADDR_DEFINED__
370 #define __CSADDR_DEFINED__
372 typedef struct _SOCKET_ADDRESS
{
373 LPSOCKADDR lpSockaddr
;
375 } SOCKET_ADDRESS
, *PSOCKET_ADDRESS
, *LPSOCKET_ADDRESS
;
377 typedef struct _SOCKET_ADDRESS_LIST
{
379 SOCKET_ADDRESS Address
[1];
380 } SOCKET_ADDRESS_LIST
, *PSOCKET_ADDRESS_LIST
, FAR
*LPSOCKET_ADDRESS_LIST
;
382 #if (_WIN32_WINNT >= 0x0600)
383 #define SIZEOF_SOCKET_ADDRESS_LIST(AddressCount) \
384 (FIELD_OFFSET(SOCKET_ADDRESS_LIST, Address) + \
385 AddressCount * sizeof(SOCKET_ADDRESS))
388 typedef struct _CSADDR_INFO
{
389 SOCKET_ADDRESS LocalAddr
;
390 SOCKET_ADDRESS RemoteAddr
;
393 } CSADDR_INFO
, *PCSADDR_INFO
, FAR
*LPCSADDR_INFO
;
395 #endif /* __CSADDR_DEFINED__ */
397 typedef struct sockaddr_storage
{
398 ADDRESS_FAMILY ss_family
;
399 CHAR __ss_pad1
[_SS_PAD1SIZE
];
401 CHAR __ss_pad2
[_SS_PAD2SIZE
];
402 } SOCKADDR_STORAGE_LH
, *PSOCKADDR_STORAGE_LH
, FAR
*LPSOCKADDR_STORAGE_LH
;
404 typedef struct sockaddr_storage_xp
{
406 CHAR __ss_pad1
[_SS_PAD1SIZE
];
408 CHAR __ss_pad2
[_SS_PAD2SIZE
];
409 } SOCKADDR_STORAGE_XP
, *PSOCKADDR_STORAGE_XP
, FAR
*LPSOCKADDR_STORAGE_XP
;
411 #if (_WIN32_WINNT >= 0x0600)
413 typedef SOCKADDR_STORAGE_LH SOCKADDR_STORAGE
;
414 typedef SOCKADDR_STORAGE
*PSOCKADDR_STORAGE
, FAR
*LPSOCKADDR_STORAGE
;
416 #elif (_WIN32_WINNT >= 0x0501)
418 typedef SOCKADDR_STORAGE_XP SOCKADDR_STORAGE
;
419 typedef SOCKADDR_STORAGE
*PSOCKADDR_STORAGE
, FAR
*LPSOCKADDR_STORAGE
;
421 #endif /* (_WIN32_WINNT >= 0x0600) */
424 #if (_WIN32_WINNT >= 0x0501)
430 #if (_WIN32_WINNT >= 0x0501)
433 #if (_WIN32_WINNT >= 0x0600)
437 #if (_WIN32_WINNT >= 0x0600)
445 #if (_WIN32_WINNT >= 0x0600)
448 #if (_WIN32_WINNT >= 0x0501)
450 IPPROTO_ROUTING
= 43,
451 IPPROTO_FRAGMENT
= 44,
456 IPPROTO_DSTOPTS
= 60,
457 #endif /* (_WIN32_WINNT >= 0x0501) */
459 #if(_WIN32_WINNT >= 0x0501)
460 IPPROTO_ICLFXBM
= 78,
462 #if (_WIN32_WINNT >= 0x0600)
467 #endif /* (_WIN32_WINNT >= 0x0600) */
470 IPPROTO_RESERVED_RAW
= 257,
471 IPPROTO_RESERVED_IPSEC
= 258,
472 IPPROTO_RESERVED_IPSECOFFLOAD
= 259,
473 IPPROTO_RESERVED_MAX
= 260
477 ScopeLevelInterface
= 1,
479 ScopeLevelSubnet
= 3,
482 ScopeLevelOrganization
= 8,
483 ScopeLevelGlobal
= 14,
495 } SCOPE_ID
, *PSCOPE_ID
;
497 typedef struct sockaddr_in
{
498 #if(_WIN32_WINNT < 0x0600)
501 ADDRESS_FAMILY sin_family
;
506 } SOCKADDR_IN
, *PSOCKADDR_IN
;
508 #if(_WIN32_WINNT >= 0x0601)
509 typedef struct sockaddr_dl
{
510 ADDRESS_FAMILY sdl_family
;
513 } SOCKADDR_DL
, *PSOCKADDR_DL
;
516 typedef struct _WSABUF
{
519 } WSABUF
, FAR
* LPWSABUF
;
521 typedef struct _WSAMSG
{
525 #if (_WIN32_WINNT >= 0x0600)
531 #if (_WIN32_WINNT >= 0x0600)
536 } WSAMSG
, *PWSAMSG
, *FAR LPWSAMSG
;
538 #if (_WIN32_WINNT >= 0x0600)
539 #define _WSACMSGHDR cmsghdr
542 typedef struct _WSACMSGHDR
{
546 } WSACMSGHDR
, *PWSACMSGHDR
, FAR
*LPWSACMSGHDR
;
548 #if (_WIN32_WINNT >= 0x0600)
549 typedef WSACMSGHDR CMSGHDR
, *PCMSGHDR
;
552 #define WSA_CMSGHDR_ALIGN(length) (((length) + TYPE_ALIGNMENT(WSACMSGHDR)-1) & \
553 (~(TYPE_ALIGNMENT(WSACMSGHDR)-1)))
555 #define WSA_CMSGDATA_ALIGN(length) (((length) + MAX_NATURAL_ALIGNMENT-1) & \
556 (~(MAX_NATURAL_ALIGNMENT-1)))
558 #if(_WIN32_WINNT >= 0x0600)
559 #define CMSGHDR_ALIGN WSA_CMSGHDR_ALIGN
560 #define CMSGDATA_ALIGN WSA_CMSGDATA_ALIGN
566 * Returns a pointer to the first ancillary data object,
567 * or a null pointer if there is no ancillary data in the
568 * control buffer of the WSAMSG structure.
571 * WSA_CMSG_FIRSTHDR (
575 #define WSA_CMSG_FIRSTHDR(msg) (((msg)->Control.len >= sizeof(WSACMSGHDR)) \
576 ? (LPWSACMSGHDR)(msg)->Control.buf \
577 : (LPWSACMSGHDR)NULL)
579 #if(_WIN32_WINNT >= 0x0600)
580 #define CMSG_FIRSTHDR WSA_CMSG_FIRSTHDR
586 * Returns a pointer to the next ancillary data object,
587 * or a null if there are no more data objects.
595 #define WSA_CMSG_NXTHDR(msg, cmsg) \
597 ? WSA_CMSG_FIRSTHDR(msg) \
598 : ( ( ((PUCHAR)(cmsg) + \
599 WSA_CMSGHDR_ALIGN((cmsg)->cmsg_len) + \
600 sizeof(WSACMSGHDR) ) > \
601 (PUCHAR)((msg)->Control.buf) + \
602 (msg)->Control.len ) \
603 ? (LPWSACMSGHDR)NULL \
604 : (LPWSACMSGHDR)((PUCHAR)(cmsg) + \
605 WSA_CMSGHDR_ALIGN((cmsg)->cmsg_len)) ) )
607 #if(_WIN32_WINNT >= 0x0600)
608 #define CMSG_NXTHDR WSA_CMSG_NXTHDR
614 * Returns a pointer to the first byte of data (what is referred
615 * to as the cmsg_data member though it is not defined in
618 * Note that RFC 2292 defines this as CMSG_DATA, but that name
619 * is already used by wincrypt.h, and so Windows has used WSA_CMSG_DATA.
626 #define WSA_CMSG_DATA(cmsg) ((PUCHAR)(cmsg) + WSA_CMSGDATA_ALIGN(sizeof(WSACMSGHDR)))
631 * Returns total size of an ancillary data object given
632 * the amount of data. Used to allocate the correct amount
640 #define WSA_CMSG_SPACE(length) (WSA_CMSGDATA_ALIGN(sizeof(WSACMSGHDR) + WSA_CMSGHDR_ALIGN(length)))
642 #if(_WIN32_WINNT >= 0x0600)
643 #define CMSG_SPACE WSA_CMSG_SPACE
649 * Returns the value to store in cmsg_len given the amount of data.
656 #define WSA_CMSG_LEN(length) (WSA_CMSGDATA_ALIGN(sizeof(WSACMSGHDR)) + length)
658 #if(_WIN32_WINNT >= 0x0600)
659 #define CMSG_LEN WSA_CMSG_LEN
662 typedef struct addrinfo
{
669 struct sockaddr
*ai_addr
;
670 struct addrinfo
*ai_next
;
671 } ADDRINFOA
, *PADDRINFOA
;
673 typedef struct addrinfoW
{
680 struct sockaddr
*ai_addr
;
681 struct addrinfoW
*ai_next
;
682 } ADDRINFOW
, *PADDRINFOW
;
684 #if (_WIN32_WINNT >= 0x0600)
686 typedef struct addrinfoexA
{
693 struct sockaddr
*ai_addr
;
697 struct addrinfoexA
*ai_next
;
698 } ADDRINFOEXA
, *PADDRINFOEXA
, *LPADDRINFOEXA
;
700 typedef struct addrinfoexW
{
707 struct sockaddr
*ai_addr
;
711 struct addrinfoexW
*ai_next
;
712 } ADDRINFOEXW
, *PADDRINFOEXW
, *LPADDRINFOEXW
;
714 #endif /* (_WIN32_WINNT >= 0x0600) */