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
46 # include <sys/types.h>
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>
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
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 # include <sys/types.h>
94 # define WS_DEFINE_SELECT
98 # define WS_DEFINE_SELECT
99 # include <sys/types.h>
101 #endif /* !USE_WS_PREFIX */
103 #endif /* __WINE_WINSOCKAPI_STDLIB_H */
106 # include <windows.h>
114 #if (defined(_MSC_VER) || defined(__MINGW_H) || defined(__WATCOMC__)) && !defined(_BSDTYPES_DEFINED)
115 /* MinGW doesn't define the u_xxx types */
116 typedef unsigned char u_char;
117 typedef unsigned short u_short;
118 typedef unsigned int u_int;
119 typedef unsigned long u_long;
120 #define _BSDTYPES_DEFINED
124 # define WS(x) WS_##x
131 #endif /* defined(__cplusplus) */
133 /* proper 4-byte packing */
134 #include <pshpack4.h>
139 #ifndef USE_WS_PREFIX
149 #define AF_OSI AF_ISO
158 #define AF_APPLETALK 16
159 #define AF_NETBIOS 17
160 #define AF_VOICEVIEW 18
161 #define AF_FIREFOX 19
162 #define AF_UNKNOWN1 20
166 #define AF_CLUSTER 24
170 #define PF_UNSPEC AF_UNSPEC
171 #define PF_UNIX AF_UNIX
172 #define PF_INET AF_INET
173 #define PF_IMPLINK AF_IMPLINK
174 #define PF_PUP AF_PUP
175 #define PF_CHAOS AF_CHAOS
177 #define PF_IPX AF_IPX
178 #define PF_ISO AF_ISO
179 #define PF_OSI AF_OSI
180 #define PF_ECMA AF_ECMA
181 #define PF_DATAKIT AF_DATAKIT
182 #define PF_CCITT AF_CCITT
183 #define PF_SNA AF_SNA
184 #define PF_DECnet AF_DECnet
185 #define PF_DLI AF_DLI
186 #define PF_LAT AF_LAT
187 #define PF_HYLINK AF_HYLINK
188 #define PF_APPLETALK AF_APPLETALK
189 #define PF_VOICEVIEW AF_VOICEVIEW
190 #define PF_FIREFOX AF_FIREFOX
191 #define PF_UNKNOWN1 AF_UNKNOWN1
192 #define PF_BAN AF_BAN
193 #define PF_MAX AF_MAX
194 #else /* USE_WS_PREFIX */
195 #define WS_AF_UNSPEC 0
198 #define WS_AF_IMPLINK 3
200 #define WS_AF_CHAOS 5
202 #define WS_AF_IPX WS_AF_NS
204 #define WS_AF_OSI AF_ISO
206 #define WS_AF_DATAKIT 9
207 #define WS_AF_CCITT 10
209 #define WS_AF_DECnet 12
212 #define WS_AF_HYLINK 15
213 #define WS_AF_APPLETALK 16
214 #define WS_AF_NETBIOS 17
215 #define WS_AF_VOICEVIEW 18
216 #define WS_AF_FIREFOX 19
217 #define WS_AF_UNKNOWN1 20
220 #define WS_AF_INET6 23
221 #define WS_AF_CLUSTER 24
222 #define WS_AF_12844 25
223 #define WS_AF_IRDA 26
225 #endif /* USE_WS_PREFIX */
230 #ifndef USE_WS_PREFIX
231 #define SOCK_STREAM 1
235 #define SOCK_SEQPACKET 5
236 #else /* USE_WS_PREFIX */
237 #define WS_SOCK_STREAM 1
238 #define WS_SOCK_DGRAM 2
239 #define WS_SOCK_RAW 3
240 #define WS_SOCK_RDM 4
241 #define WS_SOCK_SEQPACKET 5
242 #endif /* USE_WS_PREFIX */
248 #ifndef USE_WS_PREFIX
250 #define IPPROTO_ICMP 1
251 #define IPPROTO_IGMP 2
252 #define IPPROTO_GGP 3
253 #define IPPROTO_TCP 6
254 #define IPPROTO_UDP 17
255 #define IPPROTO_IDP 22
256 #define IPPROTO_ND 77
257 #define IPPROTO_RAW 255
258 #define IPPROTO_MAX 256
259 #else /* USE_WS_PREFIX */
260 #define WS_IPPROTO_IP 0
261 #define WS_IPPROTO_ICMP 1
262 #define WS_IPPROTO_IGMP 2
263 #define WS_IPPROTO_GGP 3
264 #define WS_IPPROTO_TCP 6
265 #define WS_IPPROTO_UDP 17
266 #define WS_IPPROTO_IDP 22
267 #define WS_IPPROTO_ND 77
268 #define WS_IPPROTO_RAW 255
269 #define WS_IPPROTO_MAX 256
270 #endif /* USE_WS_PREFIX */
272 typedef struct WS(protoent)
277 } PROTOENT, *PPROTOENT, *LPPROTOENT;
286 char* n_name; /* official name of net */
287 char** n_aliases; /* alias list */
288 short n_addrtype; /* net address type */
289 u_long n_net; /* network # */
296 #ifndef USE_WS_PREFIX
297 #define IPPORT_ECHO 7
298 #define IPPORT_DISCARD 9
299 #define IPPORT_SYSTAT 11
300 #define IPPORT_DAYTIME 13
301 #define IPPORT_NETSTAT 15
302 #define IPPORT_FTP 21
303 #define IPPORT_TELNET 23
304 #define IPPORT_SMTP 25
305 #define IPPORT_TIMESERVER 37
306 #define IPPORT_NAMESERVER 42
307 #define IPPORT_WHOIS 43
308 #define IPPORT_MTP 57
309 #define IPPORT_TFTP 69
310 #define IPPORT_RJE 77
311 #define IPPORT_FINGER 79
312 #define IPPORT_TTYLINK 87
313 #define IPPORT_SUPDUP 95
314 #define IPPORT_EXECSERVER 512
315 #define IPPORT_LOGINSERVER 513
316 #define IPPORT_CMDSERVER 514
317 #define IPPORT_EFSSERVER 520
318 #define IPPORT_BIFFUDP 512
319 #define IPPORT_WHOSERVER 513
320 #define IPPORT_ROUTESERVER 520
321 #define IPPORT_RESERVED 1024
322 #else /* USE_WS_PREFIX */
323 #define WS_IPPORT_ECHO 7
324 #define WS_IPPORT_DISCARD 9
325 #define WS_IPPORT_SYSTAT 11
326 #define WS_IPPORT_DAYTIME 13
327 #define WS_IPPORT_NETSTAT 15
328 #define WS_IPPORT_FTP 21
329 #define WS_IPPORT_TELNET 23
330 #define WS_IPPORT_SMTP 25
331 #define WS_IPPORT_TIMESERVER 37
332 #define WS_IPPORT_NAMESERVER 42
333 #define WS_IPPORT_WHOIS 43
334 #define WS_IPPORT_MTP 57
335 #define WS_IPPORT_TFTP 69
336 #define WS_IPPORT_RJE 77
337 #define WS_IPPORT_FINGER 79
338 #define WS_IPPORT_TTYLINK 87
339 #define WS_IPPORT_SUPDUP 95
340 #define WS_IPPORT_EXECSERVER 512
341 #define WS_IPPORT_LOGINSERVER 513
342 #define WS_IPPORT_CMDSERVER 514
343 #define WS_IPPORT_EFSSERVER 520
344 #define WS_IPPORT_BIFFUDP 512
345 #define WS_IPPORT_WHOSERVER 513
346 #define WS_IPPORT_ROUTESERVER 520
347 #define WS_IPPORT_RESERVED 1024
348 #endif /* USE_WS_PREFIX */
350 typedef struct WS(servent)
352 char* s_name; /* official service name */
353 char** s_aliases; /* alias list */
354 short s_port; /* port # */
355 char* s_proto; /* protocol to use */
356 } SERVENT, *PSERVENT, *LPSERVENT;
364 typedef struct WS(hostent)
366 char* h_name; /* official name of host */
367 char** h_aliases; /* alias list */
368 short h_addrtype; /* host address type */
369 short h_length; /* length of address */
370 char** h_addr_list; /* list of addresses from name server */
371 #define h_addr h_addr_list[0] /* address, for backward compat */
372 } HOSTENT, *PHOSTENT, *LPHOSTENT;
379 typedef UINT_PTR SOCKET;
382 * This is used instead of -1, since the
383 * SOCKET type is unsigned.
385 #define INVALID_SOCKET (~0)
386 #define SOCKET_ERROR (-1)
388 typedef struct WS(sockaddr)
392 } SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
394 typedef struct WS(linger)
396 u_short l_onoff; /* option on/off */
397 u_short l_linger; /* linger time */
398 } LINGER, *PLINGER, *LPLINGER;
404 #ifdef WS_DEFINE_SELECT
405 /* Define our own version of select and the associated types and macros */
407 # ifndef USE_WS_PREFIX
409 # define FD_SETSIZE 64
412 # ifndef WS_FD_SETSIZE
413 # define WS_FD_SETSIZE 64
417 typedef struct WS(fd_set)
419 u_int fd_count; /* how many are SET? */
420 # ifndef USE_WS_PREFIX
421 SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
423 SOCKET fd_array[WS_FD_SETSIZE];/* an array of SOCKETs */
425 } WS(fd_set), FD_SET, *PFD_SET, *LPFD_SET;
427 #ifndef _TIMEVAL_DEFINED
428 #define _TIMEVAL_DEFINED
429 typedef struct WS(timeval)
431 long tv_sec; /* seconds */
432 long tv_usec; /* and microseconds */
433 } TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
436 #define __WS_FD_CLR(fd, set, cast) do { \
438 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
440 if (((cast*)(set))->fd_array[__i] == fd) \
442 while (__i < ((cast*)(set))->fd_count-1) \
444 ((cast*)(set))->fd_array[__i] = \
445 ((cast*)(set))->fd_array[__i+1]; \
448 ((cast*)(set))->fd_count--; \
453 #define __WS_FD_SET1(fd, set, cast) do { \
454 if (((cast*)(set))->fd_count < FD_SETSIZE) \
455 ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd); \
457 /* This version checks if the filedesc is already in the list, and appends it
458 * only if it's not the case
460 #define __WS_FD_SET2(fd, set, cast) do { \
462 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
464 if (((cast*)(set))->fd_array[__i]==(fd)) \
467 if (__i == ((cast*)(set))->fd_count && ((cast*)(set))->fd_count < FD_SETSIZE) \
469 ((cast*)(set))->fd_count++; \
470 ((cast*)(set))->fd_array[__i]=(fd);\
474 #ifndef __WINE_WINSOCK2__
475 #define __WS_FD_SET(fd, set, cast) __WS_FD_SET1((fd),(set), cast)
477 #define __WS_FD_SET(fd, set, cast) __WS_FD_SET2((fd),(set), cast)
480 #ifndef USE_WS_PREFIX
481 #define FD_CLR(fd, set) __WS_FD_CLR((fd),(set), fd_set)
482 #define FD_SET(fd, set) __WS_FD_SET((fd),(set), fd_set)
483 #define FD_ZERO(set) (((fd_set*)(set))->fd_count=0)
484 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set))
486 #define WS_FD_CLR(fd, set) __WS_FD_CLR((fd),(set), WS_fd_set)
487 #define WS_FD_SET(fd, set) __WS_FD_SET((fd),(set), WS_fd_set)
488 #define WS_FD_ZERO(set) ((WS_fd_set*)(set))->fd_count=0)
489 #define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (WS_fd_set*)(set))
492 int WINAPI __WSAFDIsSet(SOCKET,WS(fd_set)*);
494 #endif /* WS_DEFINE_SELECT */
496 /* we have to define hton/ntoh as macros to avoid conflicts with Unix headers */
497 #ifndef USE_WS_PREFIX
504 #ifdef WORDS_BIGENDIAN
506 #define htonl(l) ((u_long)(l))
507 #define htons(s) ((u_short)(s))
508 #define ntohl(l) ((u_long)(l))
509 #define ntohs(s) ((u_short)(s))
511 #else /* WORDS_BIGENDIAN */
513 inline static u_short __wine_ushort_swap(u_short s)
515 return (s >> 8) | (s << 8);
517 inline static u_long __wine_ulong_swap(u_long l)
519 return ((u_long)__wine_ushort_swap((u_short)l) << 16) | __wine_ushort_swap((u_short)(l >> 16));
521 #define htonl(l) __wine_ulong_swap(l)
522 #define htons(s) __wine_ushort_swap(s)
523 #define ntohl(l) __wine_ulong_swap(l)
524 #define ntohs(s) __wine_ushort_swap(s)
526 #endif /* WORDS_BIGENDIAN */
528 #endif /* USE_WS_PREFIX */
531 * Internet address (old style... should be updated)
534 #ifndef USE_WS_PREFIX
535 #define IN_CLASSA_NSHIFT 24
536 #define IN_CLASSA_MAX 128
537 #define IN_CLASSA_NET 0xff000000
538 #define IN_CLASSA_HOST 0x00ffffff
539 #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
540 #define IN_CLASSB_NSHIFT 16
541 #define IN_CLASSB_MAX 65536
542 #define IN_CLASSB_NET 0xffff0000
543 #define IN_CLASSB_HOST 0x0000ffff
544 #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
545 #define IN_CLASSC_NSHIFT 8
546 #define IN_CLASSC_NET 0xffffff00
547 #define IN_CLASSC_HOST 0x000000ff
548 #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
550 #define WS_IN_CLASSA_NSHIFT 24
551 #define WS_IN_CLASSA_MAX 128
552 #define WS_IN_CLASSA_NET 0xff000000
553 #define WS_IN_CLASSA_HOST 0x00ffffff
554 #define WS_IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
555 #define WS_IN_CLASSB_NSHIFT 16
556 #define WS_IN_CLASSB_MAX 65536
557 #define WS_IN_CLASSB_NET 0xffff0000
558 #define WS_IN_CLASSB_HOST 0x0000ffff
559 #define WS_IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
560 #define WS_IN_CLASSC_NSHIFT 8
561 #define WS_IN_CLASSC_NET 0xffffff00
562 #define WS_IN_CLASSC_HOST 0x000000ff
563 #define WS_IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
564 #endif /* USE_WS_PREFIX */
566 #ifndef USE_WS_PREFIX
567 #define INADDR_ANY (u_long)0x00000000
568 #define INADDR_LOOPBACK 0x7f000001
569 #define INADDR_BROADCAST (u_long)0xffffffff
570 #define INADDR_NONE 0xffffffff
572 #define WS_INADDR_ANY (u_long)0x00000000
573 #define WS_INADDR_LOOPBACK 0x7f000001
574 #define WS_INADDR_BROADCAST (u_long)0xffffffff
575 #define WS_INADDR_NONE 0xffffffff
576 #endif /* USE_WS_PREFIX */
578 typedef struct WS(in_addr)
582 u_char s_b1,s_b2,s_b3,s_b4;
589 #ifndef USE_WS_PREFIX
590 #define s_addr S_un.S_addr
591 #define s_host S_un.S_un_b.s_b2
592 #define s_net S_un.S_un_b.s_b1
593 #define s_imp S_un.S_un_w.s_w2
594 #define s_impno S_un.S_un_b.s_b4
595 #define s_lh S_un.S_un_b.s_b3
597 #define WS_s_addr S_un.S_addr
598 #define WS_s_host S_un.S_un_b.s_b2
599 #define WS_s_net S_un.S_un_b.s_b1
600 #define WS_s_imp S_un.S_un_w.s_w2
601 #define WS_s_impno S_un.S_un_b.s_b4
602 #define WS_s_lh S_un.S_un_b.s_b3
603 #endif /* USE_WS_PREFIX */
604 } IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
606 typedef struct WS(sockaddr_in)
610 struct WS(in_addr) sin_addr;
612 } SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
615 * Multicast group information
618 #if !defined(__WINE_WINSOCK2__)
621 struct WS(in_addr) imr_multiaddr;
622 struct WS(in_addr) imr_interface;
629 #define WSADESCRIPTION_LEN 256
630 #define WSASYS_STATUS_LEN 128
632 typedef struct WS(WSAData)
636 char szDescription[WSADESCRIPTION_LEN+1];
637 char szSystemStatus[WSASYS_STATUS_LEN+1];
641 } WSADATA, *LPWSADATA;
648 #ifndef USE_WS_PREFIX
649 #define SOL_SOCKET 0xffff
650 #define SO_DEBUG 0x0001
651 #define SO_ACCEPTCONN 0x0002
652 #define SO_REUSEADDR 0x0004
653 #define SO_KEEPALIVE 0x0008
654 #define SO_DONTROUTE 0x0010
655 #define SO_BROADCAST 0x0020
656 #define SO_USELOOPBACK 0x0040
657 #define SO_LINGER 0x0080
658 #define SO_OOBINLINE 0x0100
659 #define SO_DONTLINGER (u_int)(~SO_LINGER)
660 #define SO_SNDBUF 0x1001
661 #define SO_RCVBUF 0x1002
662 #define SO_SNDLOWAT 0x1003
663 #define SO_RCVLOWAT 0x1004
664 #define SO_SNDTIMEO 0x1005
665 #define SO_RCVTIMEO 0x1006
666 #define SO_ERROR 0x1007
667 #define SO_TYPE 0x1008
670 #define IOCPARM_MASK 0x7f
671 #define IOC_VOID 0x20000000
672 #define IOC_OUT 0x40000000
673 #define IOC_IN 0x80000000
674 #define IOC_INOUT (IOC_IN|IOC_OUT)
676 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
677 #define _IOR(x,y,t) (IOC_OUT|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
678 #define _IOW(x,y,t) (IOC_IN|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
682 #define WS_SOL_SOCKET 0xffff
683 #define WS_SO_DEBUG 0x0001
684 #define WS_SO_ACCEPTCONN 0x0002
685 #define WS_SO_REUSEADDR 0x0004
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 (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))
714 /* IPPROTO_TCP options */
715 #ifndef USE_WS_PREFIX
716 #define TCP_NODELAY 1
718 #define WS_TCP_NODELAY 1
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
732 # define IP_DONTFRAGMENT 9
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
742 # define WS_IP_DONTFRAGMENT 9
748 * Socket I/O flags (supported by spec 1.1)
750 #ifndef USE_WS_PREFIX
751 #define FIONREAD _IOR('f', 127, u_long)
752 #define FIONBIO _IOW('f', 126, u_long)
753 #define FIOASYNC _IOW('f', 125, u_long)
754 #define SIOCSHIWAT _IOW('s', 0, u_long)
755 #define SIOCGHIWAT _IOR('s', 1, u_long)
756 #define SIOCSLOWAT _IOW('s', 2, u_long)
757 #define SIOCGLOWAT _IOR('s', 3, u_long)
758 #define SIOCATMARK _IOR('s', 7, u_long)
760 #define WS_FIONREAD WS__IOR('f', 127, u_long)
761 #define WS_FIONBIO WS__IOW('f', 126, u_long)
762 #define WS_FIOASYNC WS__IOW('f', 125, u_long)
763 #define WS_SIOCSHIWAT WS__IOW('s', 0, u_long)
764 #define WS_SIOCGHIWAT WS__IOR('s', 1, u_long)
765 #define WS_SIOCSLOWAT WS__IOW('s', 2, u_long)
766 #define WS_SIOCGLOWAT WS__IOR('s', 3, u_long)
767 #define WS_SIOCATMARK WS__IOR('s', 7, u_long)
771 * Maximum queue length specifiable by listen.
773 #ifndef USE_WS_PREFIX
776 #define MSG_OOB 0x0001
777 #define MSG_PEEK 0x0002
778 #define MSG_DONTROUTE 0x0004
779 #define MSG_MAXIOVLEN 0x000a
780 #define MSG_PARTIAL 0x8000
781 #else /* USE_WS_PREFIX */
782 #define WS_SOMAXCONN 5
784 #define WS_MSG_OOB 0x0001
785 #define WS_MSG_PEEK 0x0002
786 #define WS_MSG_DONTROUTE 0x0004
787 #define WS_MSG_MAXIOVLEN 0x000a
788 #define WS_MSG_PARTIAL 0x8000
789 #endif /* USE_WS_PREFIX */
792 * Define constant based on rfc883, used by gethostbyxxxx() calls.
794 #ifndef USE_WS_PREFIX
795 #define MAXGETHOSTSTRUCT 1024
797 #define MAXGETHOSTSTRUCT 1024
802 * Define flags to be used with the WSAAsyncSelect() call.
804 #define FD_READ 0x00000001
805 #define FD_WRITE 0x00000002
806 #define FD_OOB 0x00000004
807 #define FD_ACCEPT 0x00000008
808 #define FD_CONNECT 0x00000010
809 #define FD_CLOSE 0x00000020
811 /* internal per-socket flags */
813 #define FD_WINE_LISTENING 0x10000000
814 #define FD_WINE_NONBLOCKING 0x20000000
815 #define FD_WINE_CONNECTED 0x40000000
816 #define FD_WINE_RAW 0x80000000
817 #define FD_WINE_INTERNAL 0xFFFF0000
821 * All Windows Sockets error constants are biased by WSABASEERR from
824 #define WSABASEERR 10000
826 * Windows Sockets definitions of regular Microsoft C error constants
828 #define WSAEINTR (WSABASEERR+4)
829 #define WSAEBADF (WSABASEERR+9)
830 #define WSAEACCES (WSABASEERR+13)
831 #define WSAEFAULT (WSABASEERR+14)
832 #define WSAEINVAL (WSABASEERR+22)
833 #define WSAEMFILE (WSABASEERR+24)
836 * Windows Sockets definitions of regular Berkeley error constants
838 #define WSAEWOULDBLOCK (WSABASEERR+35)
839 #define WSAEINPROGRESS (WSABASEERR+36)
840 #define WSAEALREADY (WSABASEERR+37)
841 #define WSAENOTSOCK (WSABASEERR+38)
842 #define WSAEDESTADDRREQ (WSABASEERR+39)
843 #define WSAEMSGSIZE (WSABASEERR+40)
844 #define WSAEPROTOTYPE (WSABASEERR+41)
845 #define WSAENOPROTOOPT (WSABASEERR+42)
846 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
847 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
848 #define WSAEOPNOTSUPP (WSABASEERR+45)
849 #define WSAEPFNOSUPPORT (WSABASEERR+46)
850 #define WSAEAFNOSUPPORT (WSABASEERR+47)
851 #define WSAEADDRINUSE (WSABASEERR+48)
852 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
853 #define WSAENETDOWN (WSABASEERR+50)
854 #define WSAENETUNREACH (WSABASEERR+51)
855 #define WSAENETRESET (WSABASEERR+52)
856 #define WSAECONNABORTED (WSABASEERR+53)
857 #define WSAECONNRESET (WSABASEERR+54)
858 #define WSAENOBUFS (WSABASEERR+55)
859 #define WSAEISCONN (WSABASEERR+56)
860 #define WSAENOTCONN (WSABASEERR+57)
861 #define WSAESHUTDOWN (WSABASEERR+58)
862 #define WSAETOOMANYREFS (WSABASEERR+59)
863 #define WSAETIMEDOUT (WSABASEERR+60)
864 #define WSAECONNREFUSED (WSABASEERR+61)
865 #define WSAELOOP (WSABASEERR+62)
866 #define WSAENAMETOOLONG (WSABASEERR+63)
867 #define WSAEHOSTDOWN (WSABASEERR+64)
868 #define WSAEHOSTUNREACH (WSABASEERR+65)
869 #define WSAENOTEMPTY (WSABASEERR+66)
870 #define WSAEPROCLIM (WSABASEERR+67)
871 #define WSAEUSERS (WSABASEERR+68)
872 #define WSAEDQUOT (WSABASEERR+69)
873 #define WSAESTALE (WSABASEERR+70)
874 #define WSAEREMOTE (WSABASEERR+71)
875 #define WSAEDISCON (WSABASEERR+101)
878 * Extended Windows Sockets error constant definitions
880 #define WSASYSNOTREADY (WSABASEERR+91)
881 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
882 #define WSANOTINITIALISED (WSABASEERR+93)
883 #define WSAEDISCON (WSABASEERR+101)
884 #define WSAENOMORE (WSABASEERR+102)
885 #define WSAECANCELLED (WSABASEERR+103)
886 #define WSAEINVALIDPROCTABLE (WSABASEERR+104)
887 #define WSAEINVALIDPROVIDER (WSABASEERR+105)
888 #define WSAEPROVIDERFAILEDINIT (WSABASEERR+106)
889 #define WSASYSCALLFAILURE (WSABASEERR+107)
890 #define WSASERVICE_NOT_FOUND (WSABASEERR+108)
891 #define WSATYPE_NOT_FOUND (WSABASEERR+109)
892 #define WSA_E_NO_MORE (WSABASEERR+110)
893 #define WSA_E_CANCELLED (WSABASEERR+111)
894 #define WSAEREFUSED (WSABASEERR+112)
897 * Error return codes from gethostbyname() and gethostbyaddr()
898 * (when using the resolver). Note that these errors are
899 * retrieved via WSAGetLastError() and must therefore follow
900 * the rules for avoiding clashes with error numbers from
901 * specific implementations or language run-time systems.
902 * For this reason the codes are based at WSABASEERR+1001.
903 * Note also that [WSA]NO_ADDRESS is defined only for
904 * compatibility purposes.
907 #ifndef USE_WS_PREFIX
908 #define h_errno WSAGetLastError()
910 #define WS_h_errno WSAGetLastError()
913 /* Authoritative Answer: Host not found */
914 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
916 /* Non-Authoritative: Host not found, or SERVERFAIL */
917 #define WSATRY_AGAIN (WSABASEERR+1002)
919 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
920 #define WSANO_RECOVERY (WSABASEERR+1003)
922 /* Valid name, no data record of requested type */
923 #define WSANO_DATA (WSABASEERR+1004)
925 /* no address, look for MX record */
926 #define WSANO_ADDRESS WSANO_DATA
928 #ifndef USE_WS_PREFIX
929 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
930 #define TRY_AGAIN WSATRY_AGAIN
931 #define NO_RECOVERY WSANO_RECOVERY
932 #define NO_DATA WSANO_DATA
933 #define NO_ADDRESS WSANO_ADDRESS
934 #endif /* USE_WS_PREFIX */
939 * Windows message parameter composition and decomposition
944 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
945 * when constructing the response to a WSAAsyncGetXByY() routine.
947 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
949 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
950 * when constructing the response to WSAAsyncSelect().
952 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
954 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
955 * to extract the buffer length from the lParam in the response
958 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
960 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
961 * to extract the error code from the lParam in the response
964 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
966 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
967 * to extract the event code from the lParam in the response
968 * to a WSAAsyncSelect().
970 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
972 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
973 * to extract the error code from the lParam in the response
974 * to a WSAAsyncSelect().
976 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
983 * Remember to keep this section in sync with the
984 * "Winsock Function Typedefs" section in winsock2.h.
986 #if !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES
987 HANDLE WINAPI WSAAsyncGetHostByAddr(HWND,u_int,const char*,int,int,char*,int);
988 HANDLE WINAPI WSAAsyncGetHostByName(HWND,u_int,const char*,char*,int);
989 HANDLE WINAPI WSAAsyncGetProtoByName(HWND,u_int,const char*,char*,int);
990 HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND,u_int,int,char*,int);
991 HANDLE WINAPI WSAAsyncGetServByName(HWND,u_int,const char*,const char*,char*,int);
992 HANDLE WINAPI WSAAsyncGetServByPort(HWND,u_int,int,const char*,char*,int);
993 int WINAPI WSAAsyncSelect(SOCKET,HWND,u_int,long);
994 int WINAPI WSACancelAsyncRequest(HANDLE);
995 int WINAPI WSACancelBlockingCall(void);
996 int WINAPI WSACleanup(void);
997 int WINAPI WSAGetLastError(void);
998 BOOL WINAPI WSAIsBlocking(void);
999 FARPROC WINAPI WSASetBlockingHook(FARPROC);
1000 void WINAPI WSASetLastError(int);
1001 int WINAPI WSAStartup(WORD,LPWSADATA);
1002 int WINAPI WSAUnhookBlockingHook(void);
1004 SOCKET WINAPI WS(accept)(SOCKET,struct WS(sockaddr)*,int*);
1005 int WINAPI WS(bind)(SOCKET,const struct WS(sockaddr)*,int);
1006 int WINAPI WS(closesocket)(SOCKET);
1007 int WINAPI WS(connect)(SOCKET,const struct WS(sockaddr)*,int);
1008 struct WS(hostent)* WINAPI WS(gethostbyaddr)(const char*,int,int);
1009 struct WS(hostent)* WINAPI WS(gethostbyname)(const char*);
1010 /* gethostname not defined because of conflicts with unistd.h */
1011 int WINAPI WS(getpeername)(SOCKET,struct WS(sockaddr)*,int*);
1012 struct WS(protoent)* WINAPI WS(getprotobyname)(const char*);
1013 struct WS(protoent)* WINAPI WS(getprotobynumber)(int);
1014 #ifdef WS_DEFINE_SELECT
1015 int WINAPI WS(select)(int,WS(fd_set)*,WS(fd_set)*,WS(fd_set)*,const struct WS(timeval)*);
1017 struct WS(servent)* WINAPI WS(getservbyname)(const char*,const char*);
1018 struct WS(servent)* WINAPI WS(getservbyport)(int,const char*);
1019 int WINAPI WS(getsockname)(SOCKET,struct WS(sockaddr)*,int*);
1020 int WINAPI WS(getsockopt)(SOCKET,int,int,char*,int*);
1021 unsigned long WINAPI WS(inet_addr)(const char*);
1022 char* WINAPI WS(inet_ntoa)(struct WS(in_addr));
1023 int WINAPI WS(ioctlsocket)(SOCKET,long,u_long*);
1024 int WINAPI WS(listen)(SOCKET,int);
1025 int WINAPI WS(recv)(SOCKET,char*,int,int);
1026 int WINAPI WS(recvfrom)(SOCKET,char*,int,int,struct WS(sockaddr)*,int*);
1027 int WINAPI WS(send)(SOCKET,const char*,int,int);
1028 int WINAPI WS(sendto)(SOCKET,const char*,int,int,const struct WS(sockaddr)*,int);
1029 int WINAPI WS(setsockopt)(SOCKET,int,int,const char*,int);
1030 int WINAPI WS(shutdown)(SOCKET,int);
1031 SOCKET WINAPI WS(socket)(int,int,int);
1033 #endif /* !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES */
1036 #include <poppack.h>
1042 #ifndef __WINE_WINSOCK2__
1044 #undef WS_API_PROTOTYPES
1045 #undef WS_API_TYPEDEFS
1048 #endif /* _WINSOCKAPI_ */