1 /* WINSOCK.H--definitions to be used with the WINSOCK.DLL
3 * This header file corresponds to version 1.1 of the Windows Sockets
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
24 # ifndef __WINE_WINSOCK2__
25 # error Please use Winsock2 in Wine
29 #ifndef __WINE_WINSOCKAPI_STDLIB_H
30 #define __WINE_WINSOCKAPI_STDLIB_H
33 * This section defines the items that conflict with the Unix headers.
36 /* We are not using the WS_ prefix we risk getting conflicts for
37 * everything related to select.
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
52 # define FD_SETSIZE Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
53 # define FD_CLR Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
54 # define FD_SET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
55 # define FD_ZERO Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
56 # define FD_ISSET Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
57 # define fd_set Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
58 # define select Include_winsock_h_before_stdlib_h_or_use_the_MSVCRT_library
59 # elif defined(RLIM_INFINITY)
60 /* On Darwin stdlib.h includes sys/resource.h which defines timeval but not the fd_set macros */
61 # define fd_set unix_fd_set
62 # include <sys/types.h>
71 # define select Include_winsock_h_before_sys_types_h_or_use_the_MSVCRT_library
72 # define timeval Include_winsock_h_before_sys_types_h_or_use_the_MSVCRT_library
74 /* stdlib.h has not been included yet so it's not too late. Include it now
75 * making sure that none of the select symbols is affected. Then we can
76 * define them with our own values.
78 # define fd_set unix_fd_set
79 # define timeval unix_timeval
80 # define select unix_select
81 # include <sys/types.h>
93 # define WS_DEFINE_SELECT
97 # define WS_DEFINE_SELECT
98 # include <sys/types.h>
100 #endif /* !USE_WS_PREFIX */
102 #endif /* __WINE_WINSOCKAPI_STDLIB_H */
105 # include <windows.h>
113 #if (defined(_MSC_VER) || defined(__MINGW_H)) && !defined(_BSD_TYPES_DEFINED)
114 /* MinGW doesn't define the u_xxx types */
115 typedef unsigned char u_char;
116 typedef unsigned short u_short;
117 typedef unsigned int u_int;
118 typedef unsigned long u_long;
122 # define WS(x) WS_##x
129 #endif /* defined(__cplusplus) */
131 /* proper 4-byte packing */
132 #include <pshpack4.h>
137 #ifndef USE_WS_PREFIX
147 #define AF_OSI AF_ISO
156 #define AF_APPLETALK 16
157 #define AF_NETBIOS 17
158 #define AF_VOICEVIEW 18
159 #define AF_FIREFOX 19
160 #define AF_UNKNOWN1 20
164 #define AF_CLUSTER 24
168 #define PF_UNSPEC AF_UNSPEC
169 #define PF_UNIX AF_UNIX
170 #define PF_INET AF_INET
171 #define PF_IMPLINK AF_IMPLINK
172 #define PF_PUP AF_PUP
173 #define PF_CHAOS AF_CHAOS
175 #define PF_IPX AF_IPX
176 #define PF_ISO AF_ISO
177 #define PF_OSI AF_OSI
178 #define PF_ECMA AF_ECMA
179 #define PF_DATAKIT AF_DATAKIT
180 #define PF_CCITT AF_CCITT
181 #define PF_SNA AF_SNA
182 #define PF_DECnet AF_DECnet
183 #define PF_DLI AF_DLI
184 #define PF_LAT AF_LAT
185 #define PF_HYLINK AF_HYLINK
186 #define PF_APPLETALK AF_APPLETALK
187 #define PF_VOICEVIEW AF_VOICEVIEW
188 #define PF_FIREFOX AF_FIREFOX
189 #define PF_UNKNOWN1 AF_UNKNOWN1
190 #define PF_BAN AF_BAN
191 #define PF_MAX AF_MAX
192 #else /* USE_WS_PREFIX */
193 #define WS_AF_UNSPEC 0
196 #define WS_AF_IMPLINK 3
198 #define WS_AF_CHAOS 5
200 #define WS_AF_IPX WS_AF_NS
202 #define WS_AF_OSI AF_ISO
204 #define WS_AF_DATAKIT 9
205 #define WS_AF_CCITT 10
207 #define WS_AF_DECnet 12
210 #define WS_AF_HYLINK 15
211 #define WS_AF_APPLETALK 16
212 #define WS_AF_NETBIOS 17
213 #define WS_AF_VOICEVIEW 18
214 #define WS_AF_FIREFOX 19
215 #define WS_AF_UNKNOWN1 20
218 #define WS_AF_INET6 23
219 #define WS_AF_CLUSTER 24
220 #define WS_AF_12844 25
221 #define WS_AF_IRDA 26
223 #endif /* USE_WS_PREFIX */
228 #ifndef USE_WS_PREFIX
229 #define SOCK_STREAM 1
233 #define SOCK_SEQPACKET 5
234 #else /* USE_WS_PREFIX */
235 #define WS_SOCK_STREAM 1
236 #define WS_SOCK_DGRAM 2
237 #define WS_SOCK_RAW 3
238 #define WS_SOCK_RDM 4
239 #define WS_SOCK_SEQPACKET 5
240 #endif /* USE_WS_PREFIX */
246 #ifndef USE_WS_PREFIX
248 #define IPPROTO_ICMP 1
249 #define IPPROTO_IGMP 2
250 #define IPPROTO_GGP 3
251 #define IPPROTO_TCP 6
252 #define IPPROTO_UDP 17
253 #define IPPROTO_IDP 22
254 #define IPPROTO_ND 77
255 #define IPPROTO_RAW 255
256 #define IPPROTO_MAX 256
257 #else /* USE_WS_PREFIX */
258 #define WS_IPPROTO_IP 0
259 #define WS_IPPROTO_ICMP 1
260 #define WS_IPPROTO_IGMP 2
261 #define WS_IPPROTO_GGP 3
262 #define WS_IPPROTO_TCP 6
263 #define WS_IPPROTO_UDP 17
264 #define WS_IPPROTO_IDP 22
265 #define WS_IPPROTO_ND 77
266 #define WS_IPPROTO_RAW 255
267 #define WS_IPPROTO_MAX 256
268 #endif /* USE_WS_PREFIX */
270 typedef struct WS(protoent)
275 } PROTOENT, *PPROTOENT, *LPPROTOENT;
284 char* n_name; /* official name of net */
285 char** n_aliases; /* alias list */
286 short n_addrtype; /* net address type */
287 u_long n_net; /* network # */
294 #ifndef USE_WS_PREFIX
295 #define IPPORT_ECHO 7
296 #define IPPORT_DISCARD 9
297 #define IPPORT_SYSTAT 11
298 #define IPPORT_DAYTIME 13
299 #define IPPORT_NETSTAT 15
300 #define IPPORT_FTP 21
301 #define IPPORT_TELNET 23
302 #define IPPORT_SMTP 25
303 #define IPPORT_TIMESERVER 37
304 #define IPPORT_NAMESERVER 42
305 #define IPPORT_WHOIS 43
306 #define IPPORT_MTP 57
307 #define IPPORT_TFTP 69
308 #define IPPORT_RJE 77
309 #define IPPORT_FINGER 79
310 #define IPPORT_TTYLINK 87
311 #define IPPORT_SUPDUP 95
312 #define IPPORT_EXECSERVER 512
313 #define IPPORT_LOGINSERVER 513
314 #define IPPORT_CMDSERVER 514
315 #define IPPORT_EFSSERVER 520
316 #define IPPORT_BIFFUDP 512
317 #define IPPORT_WHOSERVER 513
318 #define IPPORT_ROUTESERVER 520
319 #define IPPORT_RESERVED 1024
320 #else /* USE_WS_PREFIX */
321 #define WS_IPPORT_ECHO 7
322 #define WS_IPPORT_DISCARD 9
323 #define WS_IPPORT_SYSTAT 11
324 #define WS_IPPORT_DAYTIME 13
325 #define WS_IPPORT_NETSTAT 15
326 #define WS_IPPORT_FTP 21
327 #define WS_IPPORT_TELNET 23
328 #define WS_IPPORT_SMTP 25
329 #define WS_IPPORT_TIMESERVER 37
330 #define WS_IPPORT_NAMESERVER 42
331 #define WS_IPPORT_WHOIS 43
332 #define WS_IPPORT_MTP 57
333 #define WS_IPPORT_TFTP 69
334 #define WS_IPPORT_RJE 77
335 #define WS_IPPORT_FINGER 79
336 #define WS_IPPORT_TTYLINK 87
337 #define WS_IPPORT_SUPDUP 95
338 #define WS_IPPORT_EXECSERVER 512
339 #define WS_IPPORT_LOGINSERVER 513
340 #define WS_IPPORT_CMDSERVER 514
341 #define WS_IPPORT_EFSSERVER 520
342 #define WS_IPPORT_BIFFUDP 512
343 #define WS_IPPORT_WHOSERVER 513
344 #define WS_IPPORT_ROUTESERVER 520
345 #define WS_IPPORT_RESERVED 1024
346 #endif /* USE_WS_PREFIX */
348 typedef struct WS(servent)
350 char* s_name; /* official service name */
351 char** s_aliases; /* alias list */
352 short s_port; /* port # */
353 char* s_proto; /* protocol to use */
354 } SERVENT, *PSERVENT, *LPSERVENT;
362 typedef struct WS(hostent)
364 char* h_name; /* official name of host */
365 char** h_aliases; /* alias list */
366 short h_addrtype; /* host address type */
367 short h_length; /* length of address */
368 char** h_addr_list; /* list of addresses from name server */
369 #define h_addr h_addr_list[0] /* address, for backward compat */
370 } HOSTENT, *PHOSTENT, *LPHOSTENT;
377 typedef UINT_PTR SOCKET;
380 * This is used instead of -1, since the
381 * SOCKET type is unsigned.
383 #define INVALID_SOCKET (~0)
384 #define SOCKET_ERROR (-1)
386 typedef struct WS(sockaddr)
390 } SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
392 typedef struct WS(linger)
394 u_short l_onoff; /* option on/off */
395 u_short l_linger; /* linger time */
396 } LINGER, *PLINGER, *LPLINGER;
402 #ifdef WS_DEFINE_SELECT
403 /* Define our own version of select and the associated types and macros */
405 # ifndef USE_WS_PREFIX
407 # define FD_SETSIZE 64
410 # ifndef WS_FD_SETSIZE
411 # define WS_FD_SETSIZE 64
415 typedef struct WS(fd_set)
417 u_int fd_count; /* how many are SET? */
418 # ifndef USE_WS_PREFIX
419 SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
421 SOCKET fd_array[WS_FD_SETSIZE];/* an array of SOCKETs */
423 } WS(fd_set), FD_SET, *PFD_SET, *LPFD_SET;
425 #ifndef _TIMEVAL_DEFINED
426 #define _TIMEVAL_DEFINED
427 typedef struct WS(timeval)
429 long tv_sec; /* seconds */
430 long tv_usec; /* and microseconds */
431 } TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
434 #define __WS_FD_CLR(fd, set, cast) do { \
436 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
438 if (((cast*)(set))->fd_array[__i] == fd) \
440 while (__i < ((cast*)(set))->fd_count-1) \
442 ((cast*)(set))->fd_array[__i] = \
443 ((cast*)(set))->fd_array[__i+1]; \
446 ((cast*)(set))->fd_count--; \
451 #define __WS_FD_SET1(fd, set, cast) do { \
452 if (((cast*)(set))->fd_count < FD_SETSIZE) \
453 ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd); \
455 /* This version checks if the filedesc is already in the list, and appends it
456 * only if it's not the case
458 #define __WS_FD_SET2(fd, set, cast) do { \
460 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
462 if (((cast*)(set))->fd_array[__i]==(fd)) \
465 if (__i == ((cast*)(set))->fd_count && ((cast*)(set))->fd_count < FD_SETSIZE) \
467 ((cast*)(set))->fd_count++; \
468 ((cast*)(set))->fd_array[__i]=(fd);\
472 #ifndef __WINE_WINSOCK2__
473 #define __WS_FD_SET(fd, set, cast) __WS_FD_SET1((fd),(set), cast)
475 #define __WS_FD_SET(fd, set, cast) __WS_FD_SET2((fd),(set), cast)
478 #ifndef USE_WS_PREFIX
479 #define FD_CLR(fd, set) __WS_FD_CLR((fd),(set), fd_set)
480 #define FD_SET(fd, set) __WS_FD_SET((fd),(set), fd_set)
481 #define FD_ZERO(set) (((fd_set*)(set))->fd_count=0)
482 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set))
484 #define WS_FD_CLR(fd, set) __WS_FD_CLR((fd),(set), WS_fd_set)
485 #define WS_FD_SET(fd, set) __WS_FD_SET((fd),(set), WS_fd_set)
486 #define WS_FD_ZERO(set) ((WS_fd_set*)(set))->fd_count=0)
487 #define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (WS_fd_set*)(set))
490 int WINAPI __WSAFDIsSet(SOCKET,WS(fd_set)*);
492 #endif /* WS_DEFINE_SELECT */
494 /* we have to define hton/ntoh as macros to avoid conflicts with Unix headers */
495 #ifndef USE_WS_PREFIX
502 #ifdef WORDS_BIGENDIAN
504 #define htonl(l) ((u_long)(l))
505 #define htons(s) ((u_short)(s))
506 #define ntohl(l) ((u_long)(l))
507 #define ntohs(s) ((u_short)(s))
509 #else /* WORDS_BIGENDIAN */
511 inline static u_short __wine_ushort_swap(u_short s)
513 return (s >> 8) | (s << 8);
515 inline static u_long __wine_ulong_swap(u_long l)
517 return ((u_long)__wine_ushort_swap((u_short)l) << 16) | __wine_ushort_swap((u_short)(l >> 16));
519 #define htonl(l) __wine_ulong_swap(l)
520 #define htons(s) __wine_ushort_swap(s)
521 #define ntohl(l) __wine_ulong_swap(l)
522 #define ntohs(s) __wine_ushort_swap(s)
524 #endif /* WORDS_BIGENDIAN */
526 #endif /* USE_WS_PREFIX */
529 * Internet address (old style... should be updated)
532 #ifndef USE_WS_PREFIX
533 #define IN_CLASSA_NSHIFT 24
534 #define IN_CLASSA_MAX 128
535 #define IN_CLASSA_NET 0xff000000
536 #define IN_CLASSA_HOST 0x00ffffff
537 #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
538 #define IN_CLASSB_NSHIFT 16
539 #define IN_CLASSB_MAX 65536
540 #define IN_CLASSB_NET 0xffff0000
541 #define IN_CLASSB_HOST 0x0000ffff
542 #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
543 #define IN_CLASSC_NSHIFT 8
544 #define IN_CLASSC_NET 0xffffff00
545 #define IN_CLASSC_HOST 0x000000ff
546 #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
548 #define WS_IN_CLASSA_NSHIFT 24
549 #define WS_IN_CLASSA_MAX 128
550 #define WS_IN_CLASSA_NET 0xff000000
551 #define WS_IN_CLASSA_HOST 0x00ffffff
552 #define WS_IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
553 #define WS_IN_CLASSB_NSHIFT 16
554 #define WS_IN_CLASSB_MAX 65536
555 #define WS_IN_CLASSB_NET 0xffff0000
556 #define WS_IN_CLASSB_HOST 0x0000ffff
557 #define WS_IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
558 #define WS_IN_CLASSC_NSHIFT 8
559 #define WS_IN_CLASSC_NET 0xffffff00
560 #define WS_IN_CLASSC_HOST 0x000000ff
561 #define WS_IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
562 #endif /* USE_WS_PREFIX */
564 #ifndef USE_WS_PREFIX
565 #define INADDR_ANY (u_long)0x00000000
566 #define INADDR_LOOPBACK 0x7f000001
567 #define INADDR_BROADCAST (u_long)0xffffffff
568 #define INADDR_NONE 0xffffffff
570 #define WS_INADDR_ANY (u_long)0x00000000
571 #define WS_INADDR_LOOPBACK 0x7f000001
572 #define WS_INADDR_BROADCAST (u_long)0xffffffff
573 #define WS_INADDR_NONE 0xffffffff
574 #endif /* USE_WS_PREFIX */
576 typedef struct WS(in_addr)
580 u_char s_b1,s_b2,s_b3,s_b4;
587 #ifndef USE_WS_PREFIX
588 #define s_addr S_un.S_addr
589 #define s_host S_un.S_un_b.s_b2
590 #define s_net S_un.S_un_b.s_b1
591 #define s_imp S_un.S_un_w.s_w2
592 #define s_impno S_un.S_un_b.s_b4
593 #define s_lh S_un.S_un_b.s_b3
595 #define WS_s_addr S_un.S_addr
596 #define WS_s_host S_un.S_un_b.s_b2
597 #define WS_s_net S_un.S_un_b.s_b1
598 #define WS_s_imp S_un.S_un_w.s_w2
599 #define WS_s_impno S_un.S_un_b.s_b4
600 #define WS_s_lh S_un.S_un_b.s_b3
601 #endif /* USE_WS_PREFIX */
602 } IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
604 typedef struct WS(sockaddr_in)
608 struct WS(in_addr) sin_addr;
610 } SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
613 * Multicast group information
616 #if !defined(__WINE_WINSOCK2__)
619 struct WS(in_addr) imr_multiaddr;
620 struct WS(in_addr) imr_interface;
627 #define WSADESCRIPTION_LEN 256
628 #define WSASYS_STATUS_LEN 128
630 typedef struct WS(WSAData)
634 char szDescription[WSADESCRIPTION_LEN+1];
635 char szSystemStatus[WSASYS_STATUS_LEN+1];
639 } WSADATA, *LPWSADATA;
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_KEEPALIVE 0x0008
652 #define SO_DONTROUTE 0x0010
653 #define SO_BROADCAST 0x0020
654 #define SO_USELOOPBACK 0x0040
655 #define SO_LINGER 0x0080
656 #define SO_OOBINLINE 0x0100
657 #define SO_DONTLINGER (u_int)(~SO_LINGER)
658 #define SO_SNDBUF 0x1001
659 #define SO_RCVBUF 0x1002
660 #define SO_SNDLOWAT 0x1003
661 #define SO_RCVLOWAT 0x1004
662 #define SO_SNDTIMEO 0x1005
663 #define SO_RCVTIMEO 0x1006
664 #define SO_ERROR 0x1007
665 #define SO_TYPE 0x1008
668 #define IOCPARM_MASK 0x7f
669 #define IOC_VOID 0x20000000
670 #define IOC_OUT 0x40000000
671 #define IOC_IN 0x80000000
672 #define IOC_INOUT (IOC_IN|IOC_OUT)
674 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
675 #define _IOR(x,y,t) (IOC_OUT|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
676 #define _IOW(x,y,t) (IOC_IN|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
680 #define WS_SOL_SOCKET 0xffff
681 #define WS_SO_DEBUG 0x0001
682 #define WS_SO_ACCEPTCONN 0x0002
683 #define WS_SO_REUSEADDR 0x0004
684 #define WS_SO_KEEPALIVE 0x0008
685 #define WS_SO_DONTROUTE 0x0010
686 #define WS_SO_BROADCAST 0x0020
687 #define WS_SO_USELOOPBACK 0x0040
688 #define WS_SO_LINGER 0x0080
689 #define WS_SO_OOBINLINE 0x0100
690 #define WS_SO_DONTLINGER (u_int)(~WS_SO_LINGER)
691 #define WS_SO_SNDBUF 0x1001
692 #define WS_SO_RCVBUF 0x1002
693 #define WS_SO_SNDLOWAT 0x1003
694 #define WS_SO_RCVLOWAT 0x1004
695 #define WS_SO_SNDTIMEO 0x1005
696 #define WS_SO_RCVTIMEO 0x1006
697 #define WS_SO_ERROR 0x1007
698 #define WS_SO_TYPE 0x1008
700 #define WS_IOCPARM_MASK 0x7f
701 #define WS_IOC_VOID 0x20000000
702 #define WS_IOC_OUT 0x40000000
703 #define WS_IOC_IN 0x80000000
704 #define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
706 #define WS__IO(x,y) (WS_IOC_VOID|((x)<<8)|(y))
707 #define WS__IOR(x,y,t) (WS_IOC_OUT|(((long)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
708 #define WS__IOW(x,y,t) (WS_IOC_IN|(((long)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
712 /* IPPROTO_TCP options */
713 #ifndef USE_WS_PREFIX
714 #define TCP_NODELAY 1
716 #define WS_TCP_NODELAY 1
719 /* IPPROTO_IP options */
720 #ifndef __WINE_WINSOCK2__ /* WinSock2 has different values for the IP_ constants */
721 # ifndef USE_WS_PREFIX
722 # define IP_OPTIONS 1
723 # define IP_MULTICAST_IF 2
724 # define IP_MULTICAST_TTL 3
725 # define IP_MULTICAST_LOOP 4
726 # define IP_ADD_MEMBERSHIP 5
727 # define IP_DROP_MEMBERSHIP 6
730 # define IP_DONTFRAGMENT 9
732 # define WS_IP_OPTIONS 1
733 # define WS_IP_MULTICAST_IF 2
734 # define WS_IP_MULTICAST_TTL 3
735 # define WS_IP_MULTICAST_LOOP 4
736 # define WS_IP_ADD_MEMBERSHIP 5
737 # define WS_IP_DROP_MEMBERSHIP 6
740 # define WS_IP_DONTFRAGMENT 9
746 * Socket I/O flags (supported by spec 1.1)
748 #ifndef USE_WS_PREFIX
749 #define FIONREAD _IOR('f', 127, u_long)
750 #define FIONBIO _IOW('f', 126, u_long)
751 #define SIOCATMARK _IOR('s', 7, u_long)
753 #define WS_FIONREAD WS__IOR('f', 127, u_long)
754 #define WS_FIONBIO WS__IOW('f', 126, u_long)
755 #define WS_SIOCATMARK WS__IOR('s', 7, u_long)
759 * Maximum queue length specifiable by listen.
761 #ifndef USE_WS_PREFIX
764 #define MSG_OOB 0x0001
765 #define MSG_PEEK 0x0002
766 #define MSG_DONTROUTE 0x0004
767 #define MSG_MAXIOVLEN 0x000a
768 #define MSG_PARTIAL 0x8000
769 #else /* USE_WS_PREFIX */
770 #define WS_SOMAXCONN 5
772 #define WS_MSG_OOB 0x0001
773 #define WS_MSG_PEEK 0x0002
774 #define WS_MSG_DONTROUTE 0x0004
775 #define WS_MSG_MAXIOVLEN 0x000a
776 #define WS_MSG_PARTIAL 0x8000
777 #endif /* USE_WS_PREFIX */
780 * Define constant based on rfc883, used by gethostbyxxxx() calls.
782 #ifndef USE_WS_PREFIX
783 #define MAXGETHOSTSTRUCT 1024
785 #define MAXGETHOSTSTRUCT 1024
790 * Define flags to be used with the WSAAsyncSelect() call.
792 #define FD_READ 0x00000001
793 #define FD_WRITE 0x00000002
794 #define FD_OOB 0x00000004
795 #define FD_ACCEPT 0x00000008
796 #define FD_CONNECT 0x00000010
797 #define FD_CLOSE 0x00000020
799 /* internal per-socket flags */
801 #define FD_WINE_LISTENING 0x10000000
802 #define FD_WINE_NONBLOCKING 0x20000000
803 #define FD_WINE_CONNECTED 0x40000000
804 #define FD_WINE_RAW 0x80000000
805 #define FD_WINE_INTERNAL 0xFFFF0000
809 * All Windows Sockets error constants are biased by WSABASEERR from
812 #define WSABASEERR 10000
814 * Windows Sockets definitions of regular Microsoft C error constants
816 #define WSAEINTR (WSABASEERR+4)
817 #define WSAEBADF (WSABASEERR+9)
818 #define WSAEACCES (WSABASEERR+13)
819 #define WSAEFAULT (WSABASEERR+14)
820 #define WSAEINVAL (WSABASEERR+22)
821 #define WSAEMFILE (WSABASEERR+24)
824 * Windows Sockets definitions of regular Berkeley error constants
826 #define WSAEWOULDBLOCK (WSABASEERR+35)
827 #define WSAEINPROGRESS (WSABASEERR+36)
828 #define WSAEALREADY (WSABASEERR+37)
829 #define WSAENOTSOCK (WSABASEERR+38)
830 #define WSAEDESTADDRREQ (WSABASEERR+39)
831 #define WSAEMSGSIZE (WSABASEERR+40)
832 #define WSAEPROTOTYPE (WSABASEERR+41)
833 #define WSAENOPROTOOPT (WSABASEERR+42)
834 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
835 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
836 #define WSAEOPNOTSUPP (WSABASEERR+45)
837 #define WSAEPFNOSUPPORT (WSABASEERR+46)
838 #define WSAEAFNOSUPPORT (WSABASEERR+47)
839 #define WSAEADDRINUSE (WSABASEERR+48)
840 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
841 #define WSAENETDOWN (WSABASEERR+50)
842 #define WSAENETUNREACH (WSABASEERR+51)
843 #define WSAENETRESET (WSABASEERR+52)
844 #define WSAECONNABORTED (WSABASEERR+53)
845 #define WSAECONNRESET (WSABASEERR+54)
846 #define WSAENOBUFS (WSABASEERR+55)
847 #define WSAEISCONN (WSABASEERR+56)
848 #define WSAENOTCONN (WSABASEERR+57)
849 #define WSAESHUTDOWN (WSABASEERR+58)
850 #define WSAETOOMANYREFS (WSABASEERR+59)
851 #define WSAETIMEDOUT (WSABASEERR+60)
852 #define WSAECONNREFUSED (WSABASEERR+61)
853 #define WSAELOOP (WSABASEERR+62)
854 #define WSAENAMETOOLONG (WSABASEERR+63)
855 #define WSAEHOSTDOWN (WSABASEERR+64)
856 #define WSAEHOSTUNREACH (WSABASEERR+65)
857 #define WSAENOTEMPTY (WSABASEERR+66)
858 #define WSAEPROCLIM (WSABASEERR+67)
859 #define WSAEUSERS (WSABASEERR+68)
860 #define WSAEDQUOT (WSABASEERR+69)
861 #define WSAESTALE (WSABASEERR+70)
862 #define WSAEREMOTE (WSABASEERR+71)
863 #define WSAEDISCON (WSABASEERR+101)
866 * Extended Windows Sockets error constant definitions
868 #define WSASYSNOTREADY (WSABASEERR+91)
869 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
870 #define WSANOTINITIALISED (WSABASEERR+93)
871 #define WSAEDISCON (WSABASEERR+101)
872 #define WSAENOMORE (WSABASEERR+102)
873 #define WSAECANCELLED (WSABASEERR+103)
874 #define WSAEINVALIDPROCTABLE (WSABASEERR+104)
875 #define WSAEINVALIDPROVIDER (WSABASEERR+105)
876 #define WSAEPROVIDERFAILEDINIT (WSABASEERR+106)
877 #define WSASYSCALLFAILURE (WSABASEERR+107)
878 #define WSASERVICE_NOT_FOUND (WSABASEERR+108)
879 #define WSATYPE_NOT_FOUND (WSABASEERR+109)
880 #define WSA_E_NO_MORE (WSABASEERR+110)
881 #define WSA_E_CANCELLED (WSABASEERR+111)
882 #define WSAEREFUSED (WSABASEERR+112)
885 * Error return codes from gethostbyname() and gethostbyaddr()
886 * (when using the resolver). Note that these errors are
887 * retrieved via WSAGetLastError() and must therefore follow
888 * the rules for avoiding clashes with error numbers from
889 * specific implementations or language run-time systems.
890 * For this reason the codes are based at WSABASEERR+1001.
891 * Note also that [WSA]NO_ADDRESS is defined only for
892 * compatibility purposes.
895 #ifndef USE_WS_PREFIX
896 #define h_errno WSAGetLastError()
898 #define WS_h_errno WSAGetLastError()
901 /* Authoritative Answer: Host not found */
902 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
904 /* Non-Authoritative: Host not found, or SERVERFAIL */
905 #define WSATRY_AGAIN (WSABASEERR+1002)
907 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
908 #define WSANO_RECOVERY (WSABASEERR+1003)
910 /* Valid name, no data record of requested type */
911 #define WSANO_DATA (WSABASEERR+1004)
913 /* no address, look for MX record */
914 #define WSANO_ADDRESS WSANO_DATA
916 #ifndef USE_WS_PREFIX
917 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
918 #define TRY_AGAIN WSATRY_AGAIN
919 #define NO_RECOVERY WSANO_RECOVERY
920 #define NO_DATA WSANO_DATA
921 #define NO_ADDRESS WSANO_ADDRESS
922 #endif /* USE_WS_PREFIX */
927 * Windows message parameter composition and decomposition
932 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
933 * when constructing the response to a WSAAsyncGetXByY() routine.
935 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
937 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
938 * when constructing the response to WSAAsyncSelect().
940 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
942 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
943 * to extract the buffer length from the lParam in the response
946 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
948 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
949 * to extract the error code from the lParam in the response
952 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
954 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
955 * to extract the event code from the lParam in the response
956 * to a WSAAsyncSelect().
958 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
960 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
961 * to extract the error code from the lParam in the response
962 * to a WSAAsyncSelect().
964 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
971 * Remember to keep this section in sync with the
972 * "Winsock Function Typedefs" section in winsock2.h.
974 #if !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES
975 HANDLE WINAPI WSAAsyncGetHostByAddr(HWND,u_int,const char*,int,int,char*,int);
976 HANDLE WINAPI WSAAsyncGetHostByName(HWND,u_int,const char*,char*,int);
977 HANDLE WINAPI WSAAsyncGetProtoByName(HWND,u_int,const char*,char*,int);
978 HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND,u_int,int,char*,int);
979 HANDLE WINAPI WSAAsyncGetServByName(HWND,u_int,const char*,const char*,char*,int);
980 HANDLE WINAPI WSAAsyncGetServByPort(HWND,u_int,int,const char*,char*,int);
981 int WINAPI WSAAsyncSelect(SOCKET,HWND,u_int,long);
982 int WINAPI WSACancelAsyncRequest(HANDLE);
983 int WINAPI WSACancelBlockingCall(void);
984 int WINAPI WSACleanup(void);
985 int WINAPI WSAGetLastError(void);
986 BOOL WINAPI WSAIsBlocking(void);
987 FARPROC WINAPI WSASetBlockingHook(FARPROC);
988 void WINAPI WSASetLastError(int);
989 int WINAPI WSAStartup(WORD,LPWSADATA);
990 int WINAPI WSAUnhookBlockingHook(void);
992 SOCKET WINAPI WS(accept)(SOCKET,struct WS(sockaddr)*,int*);
993 int WINAPI WS(bind)(SOCKET,const struct WS(sockaddr)*,int);
994 int WINAPI WS(closesocket)(SOCKET);
995 int WINAPI WS(connect)(SOCKET,const struct WS(sockaddr)*,int);
996 struct WS(hostent)* WINAPI WS(gethostbyaddr)(const char*,int,int);
997 struct WS(hostent)* WINAPI WS(gethostbyname)(const char*);
998 /* gethostname not defined because of conflicts with unistd.h */
999 int WINAPI WS(getpeername)(SOCKET,struct WS(sockaddr)*,int*);
1000 struct WS(protoent)* WINAPI WS(getprotobyname)(const char*);
1001 struct WS(protoent)* WINAPI WS(getprotobynumber)(int);
1002 #ifdef WS_DEFINE_SELECT
1003 int WINAPI WS(select)(int,WS(fd_set)*,WS(fd_set)*,WS(fd_set)*,const struct WS(timeval)*);
1005 struct WS(servent)* WINAPI WS(getservbyname)(const char*,const char*);
1006 struct WS(servent)* WINAPI WS(getservbyport)(int,const char*);
1007 int WINAPI WS(getsockname)(SOCKET,struct WS(sockaddr)*,int*);
1008 int WINAPI WS(getsockopt)(SOCKET,int,int,char*,int*);
1009 unsigned long WINAPI WS(inet_addr)(const char*);
1010 char* WINAPI WS(inet_ntoa)(struct WS(in_addr));
1011 int WINAPI WS(ioctlsocket)(SOCKET,long,u_long*);
1012 int WINAPI WS(listen)(SOCKET,int);
1013 int WINAPI WS(recv)(SOCKET,char*,int,int);
1014 int WINAPI WS(recvfrom)(SOCKET,char*,int,int,struct WS(sockaddr)*,int*);
1015 int WINAPI WS(send)(SOCKET,const char*,int,int);
1016 int WINAPI WS(sendto)(SOCKET,const char*,int,int,const struct WS(sockaddr)*,int);
1017 int WINAPI WS(setsockopt)(SOCKET,int,int,const char*,int);
1018 int WINAPI WS(shutdown)(SOCKET,int);
1019 SOCKET WINAPI WS(socket)(int,int,int);
1021 #endif /* !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES */
1024 #include <poppack.h>
1030 #ifndef __WINE_WINSOCK2__
1032 #undef WS_API_PROTOTYPES
1033 #undef WS_API_TYPEDEFS
1036 #endif /* _WINSOCKAPI_ */