dsound: Don't launch a separate thread for the mmdevapi enumerator.
[wine.git] / include / winsock.h
bloba938d5930c2ee859ae6499ca12604890c56d3728
1 /* WINSOCK.H--definitions to be used with the WINSOCK.DLL
3 * This header file corresponds to version 1.1 of the Windows Sockets
4 * specification.
6 * Copyright (C) the Wine project
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #ifdef __WINESRC__
24 # ifndef __WINE_WINSOCK2__
25 # error Please use Winsock2 in Wine
26 # endif
27 #endif
29 #ifndef __WINE_WINSOCKAPI_STDLIB_H
30 #define __WINE_WINSOCKAPI_STDLIB_H
33 * This section defines the items that conflict with the Unix headers.
35 #ifndef USE_WS_PREFIX
36 /* We are not using the WS_ prefix we risk getting conflicts for
37 * everything related to select.
39 # ifdef FD_CLR
40 /* Too late, the Unix version of stdlib.h was included before winsock.h.
41 * This means select and all the related stuff is already defined and we
42 * cannot override types and function prototypes.
43 * All we can do is disable all these symbols so that they are not used
44 * inadvertently.
46 # include <sys/types.h>
47 # undef FD_SETSIZE
48 # undef FD_CLR
49 # undef FD_SET
50 # undef FD_ZERO
51 # undef FD_ISSET
53 # define FD_SETSIZE Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
54 # define FD_CLR Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
55 # define FD_SET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
56 # define FD_ZERO Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
57 # define FD_ISSET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
58 # define fd_set Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
59 # define select Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
60 # elif defined(RLIM_INFINITY)
61 /* On Darwin stdlib.h includes sys/resource.h which defines timeval but not the fd_set macros */
62 # define fd_set unix_fd_set
63 # include <sys/types.h>
64 # include <time.h>
65 # include <stdlib.h>
66 # undef fd_set
67 # undef FD_SETSIZE
68 # undef FD_CLR
69 # undef FD_SET
70 # undef FD_ZERO
71 # undef FD_ISSET
72 # define select Include_winsock_h_before_sys_types_h_or_use_the_MSVCRT_library
73 # define timeval Include_winsock_h_before_sys_types_h_or_use_the_MSVCRT_library
74 # else /* FD_CLR */
75 /* stdlib.h has not been included yet so it's not too late. Include it now
76 * making sure that none of the select symbols is affected. Then we can
77 * define them with our own values.
79 # define fd_set unix_fd_set
80 # define timeval unix_timeval
81 # define select unix_select
82 # define socklen_t unix_socklen_t
83 # define u_long unix_u_long
84 # include <sys/types.h>
85 # include <time.h>
86 # include <stdlib.h>
87 # undef fd_set
88 # undef timeval
89 # undef select
90 # undef socklen_t
91 # undef u_long
92 # undef FD_SETSIZE
93 # undef FD_CLR
94 # undef FD_SET
95 # undef FD_ZERO
96 # undef FD_ISSET
97 # undef _TIMEVAL_DEFINED
99 # define WS_DEFINE_SELECT
100 # endif /* FD_CLR */
102 #else
103 # define WS_DEFINE_SELECT
104 # include <sys/types.h>
105 # include <stdlib.h>
106 #endif /* !USE_WS_PREFIX */
108 #endif /* __WINE_WINSOCKAPI_STDLIB_H */
110 #ifndef __WINESRC__
111 # include <windows.h>
112 #else
113 # include <windef.h>
114 #endif
116 #ifndef _WINSOCKAPI_
117 #define _WINSOCKAPI_
119 #include <inaddr.h>
121 #ifdef USE_WS_PREFIX
122 typedef unsigned char WS_u_char;
123 typedef unsigned short WS_u_short;
124 typedef unsigned int WS_u_int;
125 typedef ULONG WS_u_long;
126 #elif (defined(_MSC_VER) || defined(__MINGW32__) || defined(__WATCOMC__)) && !defined(_BSDTYPES_DEFINED)
127 /* MinGW doesn't define the u_xxx types */
128 typedef unsigned char u_char;
129 typedef unsigned short u_short;
130 typedef unsigned int u_int;
131 typedef ULONG u_long;
132 #define _BSDTYPES_DEFINED
133 #else
134 #define u_long ULONG /* make sure we don't use the system u_long */
135 #endif
137 #ifdef USE_WS_PREFIX
138 # define WS(x) WS_##x
139 #else
140 # define WS(x) x
141 #endif
143 #ifdef __cplusplus
144 extern "C" {
145 #endif /* defined(__cplusplus) */
148 * Address families
150 #ifndef USE_WS_PREFIX
151 #define AF_UNSPEC 0
152 #define AF_UNIX 1
153 #define AF_INET 2
154 #define AF_IMPLINK 3
155 #define AF_PUP 4
156 #define AF_CHAOS 5
157 #define AF_NS 6
158 #define AF_IPX AF_NS
159 #define AF_ISO 7
160 #define AF_OSI AF_ISO
161 #define AF_ECMA 8
162 #define AF_DATAKIT 9
163 #define AF_CCITT 10
164 #define AF_SNA 11
165 #define AF_DECnet 12
166 #define AF_DLI 13
167 #define AF_LAT 14
168 #define AF_HYLINK 15
169 #define AF_APPLETALK 16
170 #define AF_NETBIOS 17
171 #define AF_VOICEVIEW 18
172 #define AF_FIREFOX 19
173 #define AF_UNKNOWN1 20
174 #define AF_BAN 21
175 #define AF_ATM 22
176 #define AF_INET6 23
177 #define AF_CLUSTER 24
178 #define AF_12844 25
179 #define AF_IRDA 26
180 #define AF_MAX 27
181 #define PF_UNSPEC AF_UNSPEC
182 #define PF_UNIX AF_UNIX
183 #define PF_INET AF_INET
184 #define PF_IMPLINK AF_IMPLINK
185 #define PF_PUP AF_PUP
186 #define PF_CHAOS AF_CHAOS
187 #define PF_NS AF_NS
188 #define PF_IPX AF_IPX
189 #define PF_ISO AF_ISO
190 #define PF_OSI AF_OSI
191 #define PF_ECMA AF_ECMA
192 #define PF_DATAKIT AF_DATAKIT
193 #define PF_CCITT AF_CCITT
194 #define PF_SNA AF_SNA
195 #define PF_DECnet AF_DECnet
196 #define PF_DLI AF_DLI
197 #define PF_LAT AF_LAT
198 #define PF_HYLINK AF_HYLINK
199 #define PF_APPLETALK AF_APPLETALK
200 #define PF_VOICEVIEW AF_VOICEVIEW
201 #define PF_FIREFOX AF_FIREFOX
202 #define PF_UNKNOWN1 AF_UNKNOWN1
203 #define PF_BAN AF_BAN
204 #define PF_MAX AF_MAX
205 #else /* USE_WS_PREFIX */
206 #define WS_AF_UNSPEC 0
207 #define WS_AF_UNIX 1
208 #define WS_AF_INET 2
209 #define WS_AF_IMPLINK 3
210 #define WS_AF_PUP 4
211 #define WS_AF_CHAOS 5
212 #define WS_AF_NS 6
213 #define WS_AF_IPX WS_AF_NS
214 #define WS_AF_ISO 7
215 #define WS_AF_OSI AF_ISO
216 #define WS_AF_ECMA 8
217 #define WS_AF_DATAKIT 9
218 #define WS_AF_CCITT 10
219 #define WS_AF_SNA 11
220 #define WS_AF_DECnet 12
221 #define WS_AF_DLI 13
222 #define WS_AF_LAT 14
223 #define WS_AF_HYLINK 15
224 #define WS_AF_APPLETALK 16
225 #define WS_AF_NETBIOS 17
226 #define WS_AF_VOICEVIEW 18
227 #define WS_AF_FIREFOX 19
228 #define WS_AF_UNKNOWN1 20
229 #define WS_AF_BAN 21
230 #define WS_AF_ATM 22
231 #define WS_AF_INET6 23
232 #define WS_AF_CLUSTER 24
233 #define WS_AF_12844 25
234 #define WS_AF_IRDA 26
235 #define WS_AF_MAX 27
236 #endif /* USE_WS_PREFIX */
239 * Types
241 #ifndef USE_WS_PREFIX
242 #define SOCK_STREAM 1
243 #define SOCK_DGRAM 2
244 #define SOCK_RAW 3
245 #define SOCK_RDM 4
246 #define SOCK_SEQPACKET 5
247 #else /* USE_WS_PREFIX */
248 #define WS_SOCK_STREAM 1
249 #define WS_SOCK_DGRAM 2
250 #define WS_SOCK_RAW 3
251 #define WS_SOCK_RDM 4
252 #define WS_SOCK_SEQPACKET 5
253 #endif /* USE_WS_PREFIX */
257 * Protocols
259 #ifndef USE_WS_PREFIX
260 #define IPPROTO_IP 0
261 #define IPPROTO_ICMP 1
262 #define IPPROTO_IGMP 2
263 #define IPPROTO_GGP 3
264 #define IPPROTO_TCP 6
265 #define IPPROTO_UDP 17
266 #define IPPROTO_IDP 22
267 #define IPPROTO_IPV6 41
268 #define IPPROTO_ND 77
269 #define IPPROTO_RAW 255
270 #define IPPROTO_MAX 256
271 #else /* USE_WS_PREFIX */
272 #define WS_IPPROTO_IP 0
273 #define WS_IPPROTO_ICMP 1
274 #define WS_IPPROTO_IGMP 2
275 #define WS_IPPROTO_GGP 3
276 #define WS_IPPROTO_TCP 6
277 #define WS_IPPROTO_UDP 17
278 #define WS_IPPROTO_IDP 22
279 #define WS_IPPROTO_IPV6 41
280 #define WS_IPPROTO_ND 77
281 #define WS_IPPROTO_RAW 255
282 #define WS_IPPROTO_MAX 256
283 #endif /* USE_WS_PREFIX */
285 typedef struct WS(protoent)
287 char* p_name;
288 char** p_aliases;
289 short p_proto;
290 } PROTOENT, *PPROTOENT, *LPPROTOENT;
295 * Networks
297 struct WS(netent)
299 char* n_name; /* official name of net */
300 char** n_aliases; /* alias list */
301 short n_addrtype; /* net address type */
302 ULONG n_net; /* network # */
307 * Services
309 #ifndef USE_WS_PREFIX
310 #define IPPORT_ECHO 7
311 #define IPPORT_DISCARD 9
312 #define IPPORT_SYSTAT 11
313 #define IPPORT_DAYTIME 13
314 #define IPPORT_NETSTAT 15
315 #define IPPORT_FTP 21
316 #define IPPORT_TELNET 23
317 #define IPPORT_SMTP 25
318 #define IPPORT_TIMESERVER 37
319 #define IPPORT_NAMESERVER 42
320 #define IPPORT_WHOIS 43
321 #define IPPORT_MTP 57
322 #define IPPORT_TFTP 69
323 #define IPPORT_RJE 77
324 #define IPPORT_FINGER 79
325 #define IPPORT_TTYLINK 87
326 #define IPPORT_SUPDUP 95
327 #define IPPORT_EXECSERVER 512
328 #define IPPORT_LOGINSERVER 513
329 #define IPPORT_CMDSERVER 514
330 #define IPPORT_EFSSERVER 520
331 #define IPPORT_BIFFUDP 512
332 #define IPPORT_WHOSERVER 513
333 #define IPPORT_ROUTESERVER 520
334 #define IPPORT_RESERVED 1024
335 #else /* USE_WS_PREFIX */
336 #define WS_IPPORT_ECHO 7
337 #define WS_IPPORT_DISCARD 9
338 #define WS_IPPORT_SYSTAT 11
339 #define WS_IPPORT_DAYTIME 13
340 #define WS_IPPORT_NETSTAT 15
341 #define WS_IPPORT_FTP 21
342 #define WS_IPPORT_TELNET 23
343 #define WS_IPPORT_SMTP 25
344 #define WS_IPPORT_TIMESERVER 37
345 #define WS_IPPORT_NAMESERVER 42
346 #define WS_IPPORT_WHOIS 43
347 #define WS_IPPORT_MTP 57
348 #define WS_IPPORT_TFTP 69
349 #define WS_IPPORT_RJE 77
350 #define WS_IPPORT_FINGER 79
351 #define WS_IPPORT_TTYLINK 87
352 #define WS_IPPORT_SUPDUP 95
353 #define WS_IPPORT_EXECSERVER 512
354 #define WS_IPPORT_LOGINSERVER 513
355 #define WS_IPPORT_CMDSERVER 514
356 #define WS_IPPORT_EFSSERVER 520
357 #define WS_IPPORT_BIFFUDP 512
358 #define WS_IPPORT_WHOSERVER 513
359 #define WS_IPPORT_ROUTESERVER 520
360 #define WS_IPPORT_RESERVED 1024
361 #endif /* USE_WS_PREFIX */
363 typedef struct WS(servent)
365 char* s_name; /* official service name */
366 char** s_aliases; /* alias list */
367 #ifdef _WIN64
368 char* s_proto; /* protocol to use */
369 short s_port; /* port # */
370 #else
371 short s_port; /* port # */
372 char* s_proto; /* protocol to use */
373 #endif
374 } SERVENT, *PSERVENT, *LPSERVENT;
379 * Hosts
382 typedef struct WS(hostent)
384 char* h_name; /* official name of host */
385 char** h_aliases; /* alias list */
386 short h_addrtype; /* host address type */
387 short h_length; /* length of address */
388 char** h_addr_list; /* list of addresses from name server */
389 #define h_addr h_addr_list[0] /* address, for backward compat */
390 } HOSTENT, *PHOSTENT, *LPHOSTENT;
394 * Sockets
397 typedef UINT_PTR SOCKET;
400 * This is used instead of -1, since the
401 * SOCKET type is unsigned.
403 #define INVALID_SOCKET (SOCKET)(~0)
404 #define SOCKET_ERROR (-1)
406 typedef struct WS(sockaddr)
408 WS(u_short) sa_family;
409 char sa_data[14];
410 } SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
412 typedef struct WS(linger)
414 WS(u_short) l_onoff; /* option on/off */
415 WS(u_short) l_linger; /* linger time */
416 } LINGER, *PLINGER, *LPLINGER;
419 * Select
422 #ifdef WS_DEFINE_SELECT
423 /* Define our own version of select and the associated types and macros */
425 # ifndef USE_WS_PREFIX
426 # ifndef FD_SETSIZE
427 # define FD_SETSIZE 64
428 # endif
429 # else
430 # ifndef WS_FD_SETSIZE
431 # define WS_FD_SETSIZE 64
432 # endif
433 # endif
435 typedef struct WS(fd_set)
437 WS(u_int) fd_count; /* how many are SET? */
438 # ifndef USE_WS_PREFIX
439 SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
440 # else
441 SOCKET fd_array[WS_FD_SETSIZE];/* an array of SOCKETs */
442 # endif
443 } WS(fd_set), FD_SET, *PFD_SET, *LPFD_SET;
445 #ifndef _TIMEVAL_DEFINED
446 #define _TIMEVAL_DEFINED
447 typedef struct WS(timeval)
449 LONG tv_sec; /* seconds */
450 LONG tv_usec; /* and microseconds */
451 } TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
452 #endif
454 #define __WS_FD_CLR(fd, set, cast) do { \
455 unsigned int __i; \
456 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
458 if (((cast*)(set))->fd_array[__i] == fd) \
460 while (__i < ((cast*)(set))->fd_count-1) \
462 ((cast*)(set))->fd_array[__i] = \
463 ((cast*)(set))->fd_array[__i+1]; \
464 __i++; \
466 ((cast*)(set))->fd_count--; \
467 break; \
470 } while(0)
471 #define __WS_FD_SET1(fd, set, cast) do { \
472 if (((cast*)(set))->fd_count < FD_SETSIZE) \
473 ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd); \
474 } while(0)
475 /* This version checks if the filedesc is already in the list, and appends it
476 * only if it's not the case
478 #define __WS_FD_SET2(fd, set, cast) do { \
479 unsigned int __i; \
480 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
482 if (((cast*)(set))->fd_array[__i]==(fd)) \
483 break; \
485 if (__i == ((cast*)(set))->fd_count && ((cast*)(set))->fd_count < FD_SETSIZE) \
487 ((cast*)(set))->fd_count++; \
488 ((cast*)(set))->fd_array[__i]=(fd);\
490 } while(0)
492 #ifndef __WINE_WINSOCK2__
493 #define __WS_FD_SET(fd, set, cast) __WS_FD_SET1((fd),(set), cast)
494 #else
495 #define __WS_FD_SET(fd, set, cast) __WS_FD_SET2((fd),(set), cast)
496 #endif
498 #ifndef USE_WS_PREFIX
499 #define FD_CLR(fd, set) __WS_FD_CLR((fd),(set), fd_set)
500 #define FD_SET(fd, set) __WS_FD_SET((fd),(set), fd_set)
501 #define FD_ZERO(set) (((fd_set*)(set))->fd_count=0)
502 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set))
503 #else
504 #define WS_FD_CLR(fd, set) __WS_FD_CLR((fd),(set), WS_fd_set)
505 #define WS_FD_SET(fd, set) __WS_FD_SET((fd),(set), WS_fd_set)
506 #define WS_FD_ZERO(set) (((WS_fd_set*)(set))->fd_count=0)
507 #define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (WS_fd_set*)(set))
508 #endif
510 int WINAPI __WSAFDIsSet(SOCKET,WS(fd_set)*);
512 #endif /* WS_DEFINE_SELECT */
514 /* we have to define hton/ntoh as macros to avoid conflicts with Unix headers */
515 #ifndef USE_WS_PREFIX
517 #undef htonl
518 #undef htons
519 #undef ntohl
520 #undef ntohs
522 #ifdef WORDS_BIGENDIAN
524 #define htonl(l) ((ULONG)(l))
525 #define htons(s) ((u_short)(s))
526 #define ntohl(l) ((ULONG)(l))
527 #define ntohs(s) ((u_short)(s))
529 #else /* WORDS_BIGENDIAN */
531 static inline u_short __wine_ushort_swap(u_short s)
533 return (s >> 8) | (s << 8);
535 static inline ULONG __wine_ulong_swap(ULONG l)
537 return ((ULONG)__wine_ushort_swap((u_short)l) << 16) | __wine_ushort_swap((u_short)(l >> 16));
539 #define htonl(l) __wine_ulong_swap(l)
540 #define htons(s) __wine_ushort_swap(s)
541 #define ntohl(l) __wine_ulong_swap(l)
542 #define ntohs(s) __wine_ushort_swap(s)
544 #endif /* WORDS_BIGENDIAN */
546 #endif /* USE_WS_PREFIX */
549 * Internet address (old style... should be updated)
552 #ifndef USE_WS_PREFIX
553 #define IN_CLASSA_NSHIFT 24
554 #define IN_CLASSA_MAX 128
555 #define IN_CLASSA_NET 0xff000000
556 #define IN_CLASSA_HOST 0x00ffffff
557 #define IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
558 #define IN_CLASSB_NSHIFT 16
559 #define IN_CLASSB_MAX 65536
560 #define IN_CLASSB_NET 0xffff0000
561 #define IN_CLASSB_HOST 0x0000ffff
562 #define IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
563 #define IN_CLASSC_NSHIFT 8
564 #define IN_CLASSC_NET 0xffffff00
565 #define IN_CLASSC_HOST 0x000000ff
566 #define IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
567 #else
568 #define WS_IN_CLASSA_NSHIFT 24
569 #define WS_IN_CLASSA_MAX 128
570 #define WS_IN_CLASSA_NET 0xff000000
571 #define WS_IN_CLASSA_HOST 0x00ffffff
572 #define WS_IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
573 #define WS_IN_CLASSB_NSHIFT 16
574 #define WS_IN_CLASSB_MAX 65536
575 #define WS_IN_CLASSB_NET 0xffff0000
576 #define WS_IN_CLASSB_HOST 0x0000ffff
577 #define WS_IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
578 #define WS_IN_CLASSC_NSHIFT 8
579 #define WS_IN_CLASSC_NET 0xffffff00
580 #define WS_IN_CLASSC_HOST 0x000000ff
581 #define WS_IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
582 #endif /* USE_WS_PREFIX */
584 #ifndef USE_WS_PREFIX
585 #define INADDR_ANY ((ULONG)0x00000000)
586 #define INADDR_LOOPBACK 0x7f000001
587 #define INADDR_BROADCAST ((ULONG)0xffffffff)
588 #define INADDR_NONE 0xffffffff
589 #else
590 #define WS_INADDR_ANY ((ULONG)0x00000000)
591 #define WS_INADDR_LOOPBACK 0x7f000001
592 #define WS_INADDR_BROADCAST ((ULONG)0xffffffff)
593 #define WS_INADDR_NONE 0xffffffff
594 #endif /* USE_WS_PREFIX */
596 typedef struct WS(sockaddr_in)
598 short sin_family;
599 WS(u_short) sin_port;
600 struct WS(in_addr) sin_addr;
601 char sin_zero[8];
602 } SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
605 * Multicast group information
608 #if !defined(__WINE_WINSOCK2__)
609 struct WS(ip_mreq)
611 struct WS(in_addr) imr_multiaddr;
612 struct WS(in_addr) imr_interface;
614 #endif
617 * WSAStartup
619 #define WSADESCRIPTION_LEN 256
620 #define WSASYS_STATUS_LEN 128
622 typedef struct WS(WSAData)
624 WORD wVersion;
625 WORD wHighVersion;
626 #ifdef _WIN64
627 WORD iMaxSockets;
628 WORD iMaxUdpDg;
629 char *lpVendorInfo;
630 char szDescription[WSADESCRIPTION_LEN+1];
631 char szSystemStatus[WSASYS_STATUS_LEN+1];
632 #else
633 char szDescription[WSADESCRIPTION_LEN+1];
634 char szSystemStatus[WSASYS_STATUS_LEN+1];
635 WORD iMaxSockets;
636 WORD iMaxUdpDg;
637 char *lpVendorInfo;
638 #endif
639 } WSADATA, *LPWSADATA;
644 * {get,set}sockopt
646 #ifndef USE_WS_PREFIX
647 #define SOL_SOCKET 0xffff
648 #define SO_DEBUG 0x0001
649 #define SO_ACCEPTCONN 0x0002
650 #define SO_REUSEADDR 0x0004
651 #define SO_EXCLUSIVEADDRUSE ((u_int)(~SO_REUSEADDR))
652 #define SO_KEEPALIVE 0x0008
653 #define SO_DONTROUTE 0x0010
654 #define SO_BROADCAST 0x0020
655 #define SO_USELOOPBACK 0x0040
656 #define SO_LINGER 0x0080
657 #define SO_OOBINLINE 0x0100
658 #define SO_DONTLINGER ((u_int)(~SO_LINGER))
659 #define SO_SNDBUF 0x1001
660 #define SO_RCVBUF 0x1002
661 #define SO_SNDLOWAT 0x1003
662 #define SO_RCVLOWAT 0x1004
663 #define SO_SNDTIMEO 0x1005
664 #define SO_RCVTIMEO 0x1006
665 #define SO_ERROR 0x1007
666 #define SO_TYPE 0x1008
669 #define IOCPARM_MASK 0x7f
670 #define IOC_VOID 0x20000000
671 #define IOC_OUT 0x40000000
672 #define IOC_IN 0x80000000
673 #define IOC_INOUT (IOC_IN|IOC_OUT)
675 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
676 #define _IOR(x,y,t) (IOC_OUT|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
677 #define _IOW(x,y,t) (IOC_IN|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
679 #else
681 #define WS_SOL_SOCKET 0xffff
682 #define WS_SO_DEBUG 0x0001
683 #define WS_SO_ACCEPTCONN 0x0002
684 #define WS_SO_REUSEADDR 0x0004
685 #define WS_SO_EXCLUSIVEADDRUSE ((WS_u_int)(~WS_SO_REUSEADDR))
686 #define WS_SO_KEEPALIVE 0x0008
687 #define WS_SO_DONTROUTE 0x0010
688 #define WS_SO_BROADCAST 0x0020
689 #define WS_SO_USELOOPBACK 0x0040
690 #define WS_SO_LINGER 0x0080
691 #define WS_SO_OOBINLINE 0x0100
692 #define WS_SO_DONTLINGER ((WS_u_int)(~WS_SO_LINGER))
693 #define WS_SO_SNDBUF 0x1001
694 #define WS_SO_RCVBUF 0x1002
695 #define WS_SO_SNDLOWAT 0x1003
696 #define WS_SO_RCVLOWAT 0x1004
697 #define WS_SO_SNDTIMEO 0x1005
698 #define WS_SO_RCVTIMEO 0x1006
699 #define WS_SO_ERROR 0x1007
700 #define WS_SO_TYPE 0x1008
702 #define WS_IOCPARM_MASK 0x7f
703 #define WS_IOC_VOID 0x20000000
704 #define WS_IOC_OUT 0x40000000
705 #define WS_IOC_IN 0x80000000
706 #define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
708 #define WS__IO(x,y) (WS_IOC_VOID|((x)<<8)|(y))
709 #define WS__IOR(x,y,t) (WS_IOC_OUT|(((LONG)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
710 #define WS__IOW(x,y,t) (WS_IOC_IN|(((LONG)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
712 #endif
714 /* IPPROTO_TCP options */
715 #ifndef USE_WS_PREFIX
716 #define TCP_NODELAY 1
717 #else
718 #define WS_TCP_NODELAY 1
719 #endif
721 /* IPPROTO_IP options */
722 #ifndef __WINE_WINSOCK2__ /* WinSock2 has different values for the IP_ constants */
723 # ifndef USE_WS_PREFIX
724 # define IP_OPTIONS 1
725 # define IP_MULTICAST_IF 2
726 # define IP_MULTICAST_TTL 3
727 # define IP_MULTICAST_LOOP 4
728 # define IP_ADD_MEMBERSHIP 5
729 # define IP_DROP_MEMBERSHIP 6
730 # define IP_TTL 7
731 # define IP_TOS 8
732 # define IP_DONTFRAGMENT 9
733 # else
734 # define WS_IP_OPTIONS 1
735 # define WS_IP_MULTICAST_IF 2
736 # define WS_IP_MULTICAST_TTL 3
737 # define WS_IP_MULTICAST_LOOP 4
738 # define WS_IP_ADD_MEMBERSHIP 5
739 # define WS_IP_DROP_MEMBERSHIP 6
740 # define WS_IP_TTL 7
741 # define WS_IP_TOS 8
742 # define WS_IP_DONTFRAGMENT 9
743 # endif
744 #endif
748 * Socket I/O flags (supported by spec 1.1)
750 #ifndef USE_WS_PREFIX
751 #define FIONREAD _IOR('f', 127, ULONG)
752 #define FIONBIO _IOW('f', 126, ULONG)
753 #define FIOASYNC _IOW('f', 125, ULONG)
754 #define SIOCSHIWAT _IOW('s', 0, ULONG)
755 #define SIOCGHIWAT _IOR('s', 1, ULONG)
756 #define SIOCSLOWAT _IOW('s', 2, ULONG)
757 #define SIOCGLOWAT _IOR('s', 3, ULONG)
758 #define SIOCATMARK _IOR('s', 7, ULONG)
759 #else
760 #define WS_FIONREAD WS__IOR('f', 127, ULONG)
761 #define WS_FIONBIO WS__IOW('f', 126, ULONG)
762 #define WS_FIOASYNC WS__IOW('f', 125, ULONG)
763 #define WS_SIOCSHIWAT WS__IOW('s', 0, ULONG)
764 #define WS_SIOCGHIWAT WS__IOR('s', 1, ULONG)
765 #define WS_SIOCSLOWAT WS__IOW('s', 2, ULONG)
766 #define WS_SIOCGLOWAT WS__IOR('s', 3, ULONG)
767 #define WS_SIOCATMARK WS__IOR('s', 7, ULONG)
768 #endif
771 * Maximum queue length specifiable by listen.
773 #ifndef USE_WS_PREFIX
774 #define SOMAXCONN 5
776 #define MSG_OOB 0x0001
777 #define MSG_PEEK 0x0002
778 #define MSG_DONTROUTE 0x0004
779 #define MSG_WAITALL 0x0008
780 #define MSG_INTERRUPT 0x0010
781 #define MSG_PARTIAL 0x8000
782 #define MSG_MAXIOVLEN 16
783 #else /* USE_WS_PREFIX */
784 #define WS_SOMAXCONN 5
786 #define WS_MSG_OOB 0x0001
787 #define WS_MSG_PEEK 0x0002
788 #define WS_MSG_DONTROUTE 0x0004
789 #define WS_MSG_WAITALL 0x0008
790 #define WS_MSG_INTERRUPT 0x0010
791 #define WS_MSG_PARTIAL 0x8000
792 #define WS_MSG_MAXIOVLEN 16
793 #endif /* USE_WS_PREFIX */
796 * Define constant based on rfc883, used by gethostbyxxxx() calls.
798 #ifndef USE_WS_PREFIX
799 #define MAXGETHOSTSTRUCT 1024
800 #else
801 #define MAXGETHOSTSTRUCT 1024
802 #endif
806 * Define flags to be used with the WSAAsyncSelect() call.
808 #define FD_READ 0x00000001
809 #define FD_WRITE 0x00000002
810 #define FD_OOB 0x00000004
811 #define FD_ACCEPT 0x00000008
812 #define FD_CONNECT 0x00000010
813 #define FD_CLOSE 0x00000020
815 /* internal per-socket flags */
816 #ifdef __WINESRC__
817 #define FD_WINE_LISTENING 0x10000000
818 #define FD_WINE_NONBLOCKING 0x20000000
819 #define FD_WINE_CONNECTED 0x40000000
820 #define FD_WINE_RAW 0x80000000
821 #define FD_WINE_INTERNAL 0xFFFF0000
822 #endif
825 * All Windows Sockets error constants are biased by WSABASEERR from
826 * the "normal". They are also defined in winerror.h.
828 #define WSABASEERR 10000
830 * Windows Sockets definitions of regular Microsoft C error constants
832 #define WSAEINTR (WSABASEERR+4)
833 #define WSAEBADF (WSABASEERR+9)
834 #define WSAEACCES (WSABASEERR+13)
835 #define WSAEFAULT (WSABASEERR+14)
836 #define WSAEINVAL (WSABASEERR+22)
837 #define WSAEMFILE (WSABASEERR+24)
840 * Windows Sockets definitions of regular Berkeley error constants
842 #define WSAEWOULDBLOCK (WSABASEERR+35)
843 #define WSAEINPROGRESS (WSABASEERR+36)
844 #define WSAEALREADY (WSABASEERR+37)
845 #define WSAENOTSOCK (WSABASEERR+38)
846 #define WSAEDESTADDRREQ (WSABASEERR+39)
847 #define WSAEMSGSIZE (WSABASEERR+40)
848 #define WSAEPROTOTYPE (WSABASEERR+41)
849 #define WSAENOPROTOOPT (WSABASEERR+42)
850 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
851 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
852 #define WSAEOPNOTSUPP (WSABASEERR+45)
853 #define WSAEPFNOSUPPORT (WSABASEERR+46)
854 #define WSAEAFNOSUPPORT (WSABASEERR+47)
855 #define WSAEADDRINUSE (WSABASEERR+48)
856 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
857 #define WSAENETDOWN (WSABASEERR+50)
858 #define WSAENETUNREACH (WSABASEERR+51)
859 #define WSAENETRESET (WSABASEERR+52)
860 #define WSAECONNABORTED (WSABASEERR+53)
861 #define WSAECONNRESET (WSABASEERR+54)
862 #define WSAENOBUFS (WSABASEERR+55)
863 #define WSAEISCONN (WSABASEERR+56)
864 #define WSAENOTCONN (WSABASEERR+57)
865 #define WSAESHUTDOWN (WSABASEERR+58)
866 #define WSAETOOMANYREFS (WSABASEERR+59)
867 #define WSAETIMEDOUT (WSABASEERR+60)
868 #define WSAECONNREFUSED (WSABASEERR+61)
869 #define WSAELOOP (WSABASEERR+62)
870 #define WSAENAMETOOLONG (WSABASEERR+63)
871 #define WSAEHOSTDOWN (WSABASEERR+64)
872 #define WSAEHOSTUNREACH (WSABASEERR+65)
873 #define WSAENOTEMPTY (WSABASEERR+66)
874 #define WSAEPROCLIM (WSABASEERR+67)
875 #define WSAEUSERS (WSABASEERR+68)
876 #define WSAEDQUOT (WSABASEERR+69)
877 #define WSAESTALE (WSABASEERR+70)
878 #define WSAEREMOTE (WSABASEERR+71)
881 * Extended Windows Sockets error constant definitions
883 #define WSASYSNOTREADY (WSABASEERR+91)
884 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
885 #define WSANOTINITIALISED (WSABASEERR+93)
886 #define WSAEDISCON (WSABASEERR+101)
887 #define WSAENOMORE (WSABASEERR+102)
888 #define WSAECANCELLED (WSABASEERR+103)
889 #define WSAEINVALIDPROCTABLE (WSABASEERR+104)
890 #define WSAEINVALIDPROVIDER (WSABASEERR+105)
891 #define WSAEPROVIDERFAILEDINIT (WSABASEERR+106)
892 #define WSASYSCALLFAILURE (WSABASEERR+107)
893 #define WSASERVICE_NOT_FOUND (WSABASEERR+108)
894 #define WSATYPE_NOT_FOUND (WSABASEERR+109)
895 #define WSA_E_NO_MORE (WSABASEERR+110)
896 #define WSA_E_CANCELLED (WSABASEERR+111)
897 #define WSAEREFUSED (WSABASEERR+112)
900 * Error return codes from gethostbyname() and gethostbyaddr()
901 * (when using the resolver). Note that these errors are
902 * retrieved via WSAGetLastError() and must therefore follow
903 * the rules for avoiding clashes with error numbers from
904 * specific implementations or language run-time systems.
905 * For this reason the codes are based at WSABASEERR+1001.
906 * Note also that [WSA]NO_ADDRESS is defined only for
907 * compatibility purposes.
910 #ifndef USE_WS_PREFIX
911 #define h_errno WSAGetLastError()
912 #else
913 #define WS_h_errno WSAGetLastError()
914 #endif
916 /* Authoritative Answer: Host not found */
917 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
919 /* Non-Authoritative: Host not found, or SERVERFAIL */
920 #define WSATRY_AGAIN (WSABASEERR+1002)
922 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
923 #define WSANO_RECOVERY (WSABASEERR+1003)
925 /* Valid name, no data record of requested type */
926 #define WSANO_DATA (WSABASEERR+1004)
928 /* no address, look for MX record */
929 #define WSANO_ADDRESS WSANO_DATA
931 #ifndef USE_WS_PREFIX
932 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
933 #define TRY_AGAIN WSATRY_AGAIN
934 #define NO_RECOVERY WSANO_RECOVERY
935 #define NO_DATA WSANO_DATA
936 #define NO_ADDRESS WSANO_ADDRESS
937 #endif /* USE_WS_PREFIX */
942 * Windows message parameter composition and decomposition
943 * macros.
947 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
948 * when constructing the response to a WSAAsyncGetXByY() routine.
950 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
952 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
953 * when constructing the response to WSAAsyncSelect().
955 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
957 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
958 * to extract the buffer length from the lParam in the response
959 * to a WSAGetXByY().
961 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
963 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
964 * to extract the error code from the lParam in the response
965 * to a WSAGetXByY().
967 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
969 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
970 * to extract the event code from the lParam in the response
971 * to a WSAAsyncSelect().
973 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
975 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
976 * to extract the error code from the lParam in the response
977 * to a WSAAsyncSelect().
979 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
984 * Prototypes
986 * Remember to keep this section in sync with the
987 * "Winsock Function Typedefs" section in winsock2.h.
989 #if !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES
990 HANDLE WINAPI WSAAsyncGetHostByAddr(HWND,WS(u_int),const char*,int,int,char*,int);
991 HANDLE WINAPI WSAAsyncGetHostByName(HWND,WS(u_int),const char*,char*,int);
992 HANDLE WINAPI WSAAsyncGetProtoByName(HWND,WS(u_int),const char*,char*,int);
993 HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND,WS(u_int),int,char*,int);
994 HANDLE WINAPI WSAAsyncGetServByName(HWND,WS(u_int),const char*,const char*,char*,int);
995 HANDLE WINAPI WSAAsyncGetServByPort(HWND,WS(u_int),int,const char*,char*,int);
996 int WINAPI WSAAsyncSelect(SOCKET,HWND,WS(u_int),LONG);
997 int WINAPI WSACancelAsyncRequest(HANDLE);
998 int WINAPI WSACancelBlockingCall(void);
999 int WINAPI WSACleanup(void);
1000 int WINAPI WSAGetLastError(void);
1001 BOOL WINAPI WSAIsBlocking(void);
1002 FARPROC WINAPI WSASetBlockingHook(FARPROC);
1003 void WINAPI WSASetLastError(int);
1004 int WINAPI WSAStartup(WORD,LPWSADATA);
1005 int WINAPI WSAUnhookBlockingHook(void);
1007 SOCKET WINAPI WS(accept)(SOCKET,struct WS(sockaddr)*,int*);
1008 int WINAPI WS(bind)(SOCKET,const struct WS(sockaddr)*,int);
1009 int WINAPI WS(closesocket)(SOCKET);
1010 int WINAPI WS(connect)(SOCKET,const struct WS(sockaddr)*,int);
1011 struct WS(hostent)* WINAPI WS(gethostbyaddr)(const char*,int,int);
1012 struct WS(hostent)* WINAPI WS(gethostbyname)(const char*);
1013 int WINAPI WS(getpeername)(SOCKET,struct WS(sockaddr)*,int*);
1014 struct WS(protoent)* WINAPI WS(getprotobyname)(const char*);
1015 struct WS(protoent)* WINAPI WS(getprotobynumber)(int);
1016 #ifdef WS_DEFINE_SELECT
1017 int WINAPI WS(select)(int,WS(fd_set)*,WS(fd_set)*,WS(fd_set)*,const struct WS(timeval)*);
1018 #endif
1019 struct WS(servent)* WINAPI WS(getservbyname)(const char*,const char*);
1020 struct WS(servent)* WINAPI WS(getservbyport)(int,const char*);
1021 int WINAPI WS(getsockname)(SOCKET,struct WS(sockaddr)*,int*);
1022 int WINAPI WS(getsockopt)(SOCKET,int,int,char*,int*);
1023 ULONG WINAPI WS(inet_addr)(const char*);
1024 char* WINAPI WS(inet_ntoa)(struct WS(in_addr));
1025 int WINAPI WS(ioctlsocket)(SOCKET,LONG,ULONG*);
1026 int WINAPI WS(listen)(SOCKET,int);
1027 int WINAPI WS(recv)(SOCKET,char*,int,int);
1028 int WINAPI WS(recvfrom)(SOCKET,char*,int,int,struct WS(sockaddr)*,int*);
1029 int WINAPI WS(send)(SOCKET,const char*,int,int);
1030 int WINAPI WS(sendto)(SOCKET,const char*,int,int,const struct WS(sockaddr)*,int);
1031 int WINAPI WS(setsockopt)(SOCKET,int,int,const char*,int);
1032 int WINAPI WS(shutdown)(SOCKET,int);
1033 SOCKET WINAPI WS(socket)(int,int,int);
1035 #if defined(__MINGW32__) || defined (_MSC_VER)
1036 /* gethostname is not defined on Unix because of conflicts with unistd.h */
1037 int WINAPI WS(gethostname)(char*,int);
1038 #endif
1040 #endif /* !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES */
1042 #ifdef __cplusplus
1044 #endif
1046 #ifndef __WINE_WINSOCK2__
1047 #undef WS
1048 #undef WS_API_PROTOTYPES
1049 #undef WS_API_TYPEDEFS
1050 #endif
1052 #endif /* _WINSOCKAPI_ */