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 # define socklen_t unix_socklen_t
83 # include <sys/types.h>
95 # undef _TIMEVAL_DEFINED
97 # define WS_DEFINE_SELECT
101 # define WS_DEFINE_SELECT
102 # include <sys/types.h>
104 #endif /* !USE_WS_PREFIX */
106 #endif /* __WINE_WINSOCKAPI_STDLIB_H */
109 # include <windows.h>
118 typedef unsigned char WS_u_char;
119 typedef unsigned short WS_u_short;
120 typedef unsigned int WS_u_int;
122 typedef unsigned long WS_u_long;
124 typedef unsigned int 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;
132 typedef unsigned long u_long;
134 typedef unsigned int u_long;
136 #define _BSDTYPES_DEFINED
140 # define WS(x) WS_##x
147 #endif /* defined(__cplusplus) */
152 #ifndef USE_WS_PREFIX
162 #define AF_OSI AF_ISO
171 #define AF_APPLETALK 16
172 #define AF_NETBIOS 17
173 #define AF_VOICEVIEW 18
174 #define AF_FIREFOX 19
175 #define AF_UNKNOWN1 20
179 #define AF_CLUSTER 24
183 #define PF_UNSPEC AF_UNSPEC
184 #define PF_UNIX AF_UNIX
185 #define PF_INET AF_INET
186 #define PF_IMPLINK AF_IMPLINK
187 #define PF_PUP AF_PUP
188 #define PF_CHAOS AF_CHAOS
190 #define PF_IPX AF_IPX
191 #define PF_ISO AF_ISO
192 #define PF_OSI AF_OSI
193 #define PF_ECMA AF_ECMA
194 #define PF_DATAKIT AF_DATAKIT
195 #define PF_CCITT AF_CCITT
196 #define PF_SNA AF_SNA
197 #define PF_DECnet AF_DECnet
198 #define PF_DLI AF_DLI
199 #define PF_LAT AF_LAT
200 #define PF_HYLINK AF_HYLINK
201 #define PF_APPLETALK AF_APPLETALK
202 #define PF_VOICEVIEW AF_VOICEVIEW
203 #define PF_FIREFOX AF_FIREFOX
204 #define PF_UNKNOWN1 AF_UNKNOWN1
205 #define PF_BAN AF_BAN
206 #define PF_MAX AF_MAX
207 #else /* USE_WS_PREFIX */
208 #define WS_AF_UNSPEC 0
211 #define WS_AF_IMPLINK 3
213 #define WS_AF_CHAOS 5
215 #define WS_AF_IPX WS_AF_NS
217 #define WS_AF_OSI AF_ISO
219 #define WS_AF_DATAKIT 9
220 #define WS_AF_CCITT 10
222 #define WS_AF_DECnet 12
225 #define WS_AF_HYLINK 15
226 #define WS_AF_APPLETALK 16
227 #define WS_AF_NETBIOS 17
228 #define WS_AF_VOICEVIEW 18
229 #define WS_AF_FIREFOX 19
230 #define WS_AF_UNKNOWN1 20
233 #define WS_AF_INET6 23
234 #define WS_AF_CLUSTER 24
235 #define WS_AF_12844 25
236 #define WS_AF_IRDA 26
238 #endif /* USE_WS_PREFIX */
243 #ifndef USE_WS_PREFIX
244 #define SOCK_STREAM 1
248 #define SOCK_SEQPACKET 5
249 #else /* USE_WS_PREFIX */
250 #define WS_SOCK_STREAM 1
251 #define WS_SOCK_DGRAM 2
252 #define WS_SOCK_RAW 3
253 #define WS_SOCK_RDM 4
254 #define WS_SOCK_SEQPACKET 5
255 #endif /* USE_WS_PREFIX */
261 #ifndef USE_WS_PREFIX
263 #define IPPROTO_ICMP 1
264 #define IPPROTO_IGMP 2
265 #define IPPROTO_GGP 3
266 #define IPPROTO_TCP 6
267 #define IPPROTO_UDP 17
268 #define IPPROTO_IDP 22
269 #define IPPROTO_IPV6 41
270 #define IPPROTO_ND 77
271 #define IPPROTO_RAW 255
272 #define IPPROTO_MAX 256
273 #else /* USE_WS_PREFIX */
274 #define WS_IPPROTO_IP 0
275 #define WS_IPPROTO_ICMP 1
276 #define WS_IPPROTO_IGMP 2
277 #define WS_IPPROTO_GGP 3
278 #define WS_IPPROTO_TCP 6
279 #define WS_IPPROTO_UDP 17
280 #define WS_IPPROTO_IDP 22
281 #define WS_IPPROTO_IPV6 41
282 #define WS_IPPROTO_ND 77
283 #define WS_IPPROTO_RAW 255
284 #define WS_IPPROTO_MAX 256
285 #endif /* USE_WS_PREFIX */
287 typedef struct WS(protoent)
292 } PROTOENT, *PPROTOENT, *LPPROTOENT;
301 char* n_name; /* official name of net */
302 char** n_aliases; /* alias list */
303 short n_addrtype; /* net address type */
304 WS(u_long) n_net; /* network # */
311 #ifndef USE_WS_PREFIX
312 #define IPPORT_ECHO 7
313 #define IPPORT_DISCARD 9
314 #define IPPORT_SYSTAT 11
315 #define IPPORT_DAYTIME 13
316 #define IPPORT_NETSTAT 15
317 #define IPPORT_FTP 21
318 #define IPPORT_TELNET 23
319 #define IPPORT_SMTP 25
320 #define IPPORT_TIMESERVER 37
321 #define IPPORT_NAMESERVER 42
322 #define IPPORT_WHOIS 43
323 #define IPPORT_MTP 57
324 #define IPPORT_TFTP 69
325 #define IPPORT_RJE 77
326 #define IPPORT_FINGER 79
327 #define IPPORT_TTYLINK 87
328 #define IPPORT_SUPDUP 95
329 #define IPPORT_EXECSERVER 512
330 #define IPPORT_LOGINSERVER 513
331 #define IPPORT_CMDSERVER 514
332 #define IPPORT_EFSSERVER 520
333 #define IPPORT_BIFFUDP 512
334 #define IPPORT_WHOSERVER 513
335 #define IPPORT_ROUTESERVER 520
336 #define IPPORT_RESERVED 1024
337 #else /* USE_WS_PREFIX */
338 #define WS_IPPORT_ECHO 7
339 #define WS_IPPORT_DISCARD 9
340 #define WS_IPPORT_SYSTAT 11
341 #define WS_IPPORT_DAYTIME 13
342 #define WS_IPPORT_NETSTAT 15
343 #define WS_IPPORT_FTP 21
344 #define WS_IPPORT_TELNET 23
345 #define WS_IPPORT_SMTP 25
346 #define WS_IPPORT_TIMESERVER 37
347 #define WS_IPPORT_NAMESERVER 42
348 #define WS_IPPORT_WHOIS 43
349 #define WS_IPPORT_MTP 57
350 #define WS_IPPORT_TFTP 69
351 #define WS_IPPORT_RJE 77
352 #define WS_IPPORT_FINGER 79
353 #define WS_IPPORT_TTYLINK 87
354 #define WS_IPPORT_SUPDUP 95
355 #define WS_IPPORT_EXECSERVER 512
356 #define WS_IPPORT_LOGINSERVER 513
357 #define WS_IPPORT_CMDSERVER 514
358 #define WS_IPPORT_EFSSERVER 520
359 #define WS_IPPORT_BIFFUDP 512
360 #define WS_IPPORT_WHOSERVER 513
361 #define WS_IPPORT_ROUTESERVER 520
362 #define WS_IPPORT_RESERVED 1024
363 #endif /* USE_WS_PREFIX */
365 typedef struct WS(servent)
367 char* s_name; /* official service name */
368 char** s_aliases; /* alias list */
370 char* s_proto; /* protocol to use */
371 short s_port; /* port # */
373 short s_port; /* port # */
374 char* s_proto; /* protocol to use */
376 } SERVENT, *PSERVENT, *LPSERVENT;
384 typedef struct WS(hostent)
386 char* h_name; /* official name of host */
387 char** h_aliases; /* alias list */
388 short h_addrtype; /* host address type */
389 short h_length; /* length of address */
390 char** h_addr_list; /* list of addresses from name server */
391 #define h_addr h_addr_list[0] /* address, for backward compat */
392 } HOSTENT, *PHOSTENT, *LPHOSTENT;
399 typedef UINT_PTR SOCKET;
402 * This is used instead of -1, since the
403 * SOCKET type is unsigned.
405 #define INVALID_SOCKET (SOCKET)(~0)
406 #define SOCKET_ERROR (-1)
408 typedef struct WS(sockaddr)
410 WS(u_short) sa_family;
412 } SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
414 typedef struct WS(linger)
416 WS(u_short) l_onoff; /* option on/off */
417 WS(u_short) l_linger; /* linger time */
418 } LINGER, *PLINGER, *LPLINGER;
424 #ifdef WS_DEFINE_SELECT
425 /* Define our own version of select and the associated types and macros */
427 # ifndef USE_WS_PREFIX
429 # define FD_SETSIZE 64
432 # ifndef WS_FD_SETSIZE
433 # define WS_FD_SETSIZE 64
437 typedef struct WS(fd_set)
439 WS(u_int) fd_count; /* how many are SET? */
440 # ifndef USE_WS_PREFIX
441 SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
443 SOCKET fd_array[WS_FD_SETSIZE];/* an array of SOCKETs */
445 } WS(fd_set), FD_SET, *PFD_SET, *LPFD_SET;
447 #ifndef _TIMEVAL_DEFINED
448 #define _TIMEVAL_DEFINED
449 typedef struct WS(timeval)
451 LONG tv_sec; /* seconds */
452 LONG tv_usec; /* and microseconds */
453 } TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
456 #define __WS_FD_CLR(fd, set, cast) do { \
458 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
460 if (((cast*)(set))->fd_array[__i] == fd) \
462 while (__i < ((cast*)(set))->fd_count-1) \
464 ((cast*)(set))->fd_array[__i] = \
465 ((cast*)(set))->fd_array[__i+1]; \
468 ((cast*)(set))->fd_count--; \
473 #define __WS_FD_SET1(fd, set, cast) do { \
474 if (((cast*)(set))->fd_count < FD_SETSIZE) \
475 ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd); \
477 /* This version checks if the filedesc is already in the list, and appends it
478 * only if it's not the case
480 #define __WS_FD_SET2(fd, set, cast) do { \
482 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
484 if (((cast*)(set))->fd_array[__i]==(fd)) \
487 if (__i == ((cast*)(set))->fd_count && ((cast*)(set))->fd_count < FD_SETSIZE) \
489 ((cast*)(set))->fd_count++; \
490 ((cast*)(set))->fd_array[__i]=(fd);\
494 #ifndef __WINE_WINSOCK2__
495 #define __WS_FD_SET(fd, set, cast) __WS_FD_SET1((fd),(set), cast)
497 #define __WS_FD_SET(fd, set, cast) __WS_FD_SET2((fd),(set), cast)
500 #ifndef USE_WS_PREFIX
501 #define FD_CLR(fd, set) __WS_FD_CLR((fd),(set), fd_set)
502 #define FD_SET(fd, set) __WS_FD_SET((fd),(set), fd_set)
503 #define FD_ZERO(set) (((fd_set*)(set))->fd_count=0)
504 #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set))
506 #define WS_FD_CLR(fd, set) __WS_FD_CLR((fd),(set), WS_fd_set)
507 #define WS_FD_SET(fd, set) __WS_FD_SET((fd),(set), WS_fd_set)
508 #define WS_FD_ZERO(set) (((WS_fd_set*)(set))->fd_count=0)
509 #define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (WS_fd_set*)(set))
512 int WINAPI __WSAFDIsSet(SOCKET,WS(fd_set)*);
514 #endif /* WS_DEFINE_SELECT */
516 /* we have to define hton/ntoh as macros to avoid conflicts with Unix headers */
517 #ifndef USE_WS_PREFIX
524 #ifdef WORDS_BIGENDIAN
526 #define htonl(l) ((u_long)(l))
527 #define htons(s) ((u_short)(s))
528 #define ntohl(l) ((u_long)(l))
529 #define ntohs(s) ((u_short)(s))
531 #else /* WORDS_BIGENDIAN */
533 static inline u_short __wine_ushort_swap(u_short s)
535 return (s >> 8) | (s << 8);
537 static inline u_long __wine_ulong_swap(u_long l)
539 return ((u_long)__wine_ushort_swap((u_short)l) << 16) | __wine_ushort_swap((u_short)(l >> 16));
541 #define htonl(l) __wine_ulong_swap(l)
542 #define htons(s) __wine_ushort_swap(s)
543 #define ntohl(l) __wine_ulong_swap(l)
544 #define ntohs(s) __wine_ushort_swap(s)
546 #endif /* WORDS_BIGENDIAN */
548 #endif /* USE_WS_PREFIX */
551 * Internet address (old style... should be updated)
554 #ifndef USE_WS_PREFIX
555 #define IN_CLASSA_NSHIFT 24
556 #define IN_CLASSA_MAX 128
557 #define IN_CLASSA_NET 0xff000000
558 #define IN_CLASSA_HOST 0x00ffffff
559 #define IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
560 #define IN_CLASSB_NSHIFT 16
561 #define IN_CLASSB_MAX 65536
562 #define IN_CLASSB_NET 0xffff0000
563 #define IN_CLASSB_HOST 0x0000ffff
564 #define IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
565 #define IN_CLASSC_NSHIFT 8
566 #define IN_CLASSC_NET 0xffffff00
567 #define IN_CLASSC_HOST 0x000000ff
568 #define IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
570 #define WS_IN_CLASSA_NSHIFT 24
571 #define WS_IN_CLASSA_MAX 128
572 #define WS_IN_CLASSA_NET 0xff000000
573 #define WS_IN_CLASSA_HOST 0x00ffffff
574 #define WS_IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
575 #define WS_IN_CLASSB_NSHIFT 16
576 #define WS_IN_CLASSB_MAX 65536
577 #define WS_IN_CLASSB_NET 0xffff0000
578 #define WS_IN_CLASSB_HOST 0x0000ffff
579 #define WS_IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
580 #define WS_IN_CLASSC_NSHIFT 8
581 #define WS_IN_CLASSC_NET 0xffffff00
582 #define WS_IN_CLASSC_HOST 0x000000ff
583 #define WS_IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
584 #endif /* USE_WS_PREFIX */
586 #ifndef USE_WS_PREFIX
587 #define INADDR_ANY ((u_long)0x00000000)
588 #define INADDR_LOOPBACK 0x7f000001
589 #define INADDR_BROADCAST ((u_long)0xffffffff)
590 #define INADDR_NONE 0xffffffff
592 #define WS_INADDR_ANY ((WS_u_long)0x00000000)
593 #define WS_INADDR_LOOPBACK 0x7f000001
594 #define WS_INADDR_BROADCAST ((WS_u_long)0xffffffff)
595 #define WS_INADDR_NONE 0xffffffff
596 #endif /* USE_WS_PREFIX */
598 typedef struct WS(in_addr)
602 WS(u_char) s_b1,s_b2,s_b3,s_b4;
605 WS(u_short) s_w1,s_w2;
609 #ifndef USE_WS_PREFIX
610 #define s_addr S_un.S_addr
611 #define s_host S_un.S_un_b.s_b2
612 #define s_net S_un.S_un_b.s_b1
613 #define s_imp S_un.S_un_w.s_w2
614 #define s_impno S_un.S_un_b.s_b4
615 #define s_lh S_un.S_un_b.s_b3
617 #define WS_s_addr S_un.S_addr
618 #define WS_s_host S_un.S_un_b.s_b2
619 #define WS_s_net S_un.S_un_b.s_b1
620 #define WS_s_imp S_un.S_un_w.s_w2
621 #define WS_s_impno S_un.S_un_b.s_b4
622 #define WS_s_lh S_un.S_un_b.s_b3
623 #endif /* USE_WS_PREFIX */
624 } IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
626 typedef struct WS(sockaddr_in)
629 WS(u_short) sin_port;
630 struct WS(in_addr) sin_addr;
632 } SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
635 * Multicast group information
638 #if !defined(__WINE_WINSOCK2__)
641 struct WS(in_addr) imr_multiaddr;
642 struct WS(in_addr) imr_interface;
649 #define WSADESCRIPTION_LEN 256
650 #define WSASYS_STATUS_LEN 128
652 typedef struct WS(WSAData)
660 char szDescription[WSADESCRIPTION_LEN+1];
661 char szSystemStatus[WSASYS_STATUS_LEN+1];
663 char szDescription[WSADESCRIPTION_LEN+1];
664 char szSystemStatus[WSASYS_STATUS_LEN+1];
669 } WSADATA, *LPWSADATA;
676 #ifndef USE_WS_PREFIX
677 #define SOL_SOCKET 0xffff
678 #define SO_DEBUG 0x0001
679 #define SO_ACCEPTCONN 0x0002
680 #define SO_REUSEADDR 0x0004
681 #define SO_EXCLUSIVEADDRUSE ((u_int)(~SO_REUSEADDR))
682 #define SO_KEEPALIVE 0x0008
683 #define SO_DONTROUTE 0x0010
684 #define SO_BROADCAST 0x0020
685 #define SO_USELOOPBACK 0x0040
686 #define SO_LINGER 0x0080
687 #define SO_OOBINLINE 0x0100
688 #define SO_DONTLINGER ((u_int)(~SO_LINGER))
689 #define SO_SNDBUF 0x1001
690 #define SO_RCVBUF 0x1002
691 #define SO_SNDLOWAT 0x1003
692 #define SO_RCVLOWAT 0x1004
693 #define SO_SNDTIMEO 0x1005
694 #define SO_RCVTIMEO 0x1006
695 #define SO_ERROR 0x1007
696 #define SO_TYPE 0x1008
699 #define IOCPARM_MASK 0x7f
700 #define IOC_VOID 0x20000000
701 #define IOC_OUT 0x40000000
702 #define IOC_IN 0x80000000
703 #define IOC_INOUT (IOC_IN|IOC_OUT)
705 #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
706 #define _IOR(x,y,t) (IOC_OUT|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
707 #define _IOW(x,y,t) (IOC_IN|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
711 #define WS_SOL_SOCKET 0xffff
712 #define WS_SO_DEBUG 0x0001
713 #define WS_SO_ACCEPTCONN 0x0002
714 #define WS_SO_REUSEADDR 0x0004
715 #define WS_SO_EXCLUSIVEADDRUSE ((WS_u_int)(~WS_SO_REUSEADDR))
716 #define WS_SO_KEEPALIVE 0x0008
717 #define WS_SO_DONTROUTE 0x0010
718 #define WS_SO_BROADCAST 0x0020
719 #define WS_SO_USELOOPBACK 0x0040
720 #define WS_SO_LINGER 0x0080
721 #define WS_SO_OOBINLINE 0x0100
722 #define WS_SO_DONTLINGER ((WS_u_int)(~WS_SO_LINGER))
723 #define WS_SO_SNDBUF 0x1001
724 #define WS_SO_RCVBUF 0x1002
725 #define WS_SO_SNDLOWAT 0x1003
726 #define WS_SO_RCVLOWAT 0x1004
727 #define WS_SO_SNDTIMEO 0x1005
728 #define WS_SO_RCVTIMEO 0x1006
729 #define WS_SO_ERROR 0x1007
730 #define WS_SO_TYPE 0x1008
732 #define WS_IOCPARM_MASK 0x7f
733 #define WS_IOC_VOID 0x20000000
734 #define WS_IOC_OUT 0x40000000
735 #define WS_IOC_IN 0x80000000
736 #define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
738 #define WS__IO(x,y) (WS_IOC_VOID|((x)<<8)|(y))
739 #define WS__IOR(x,y,t) (WS_IOC_OUT|(((LONG)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
740 #define WS__IOW(x,y,t) (WS_IOC_IN|(((LONG)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
744 /* IPPROTO_TCP options */
745 #ifndef USE_WS_PREFIX
746 #define TCP_NODELAY 1
748 #define WS_TCP_NODELAY 1
751 /* IPPROTO_IP options */
752 #ifndef __WINE_WINSOCK2__ /* WinSock2 has different values for the IP_ constants */
753 # ifndef USE_WS_PREFIX
754 # define IP_OPTIONS 1
755 # define IP_MULTICAST_IF 2
756 # define IP_MULTICAST_TTL 3
757 # define IP_MULTICAST_LOOP 4
758 # define IP_ADD_MEMBERSHIP 5
759 # define IP_DROP_MEMBERSHIP 6
762 # define IP_DONTFRAGMENT 9
764 # define WS_IP_OPTIONS 1
765 # define WS_IP_MULTICAST_IF 2
766 # define WS_IP_MULTICAST_TTL 3
767 # define WS_IP_MULTICAST_LOOP 4
768 # define WS_IP_ADD_MEMBERSHIP 5
769 # define WS_IP_DROP_MEMBERSHIP 6
772 # define WS_IP_DONTFRAGMENT 9
778 * Socket I/O flags (supported by spec 1.1)
780 #ifndef USE_WS_PREFIX
781 #define FIONREAD _IOR('f', 127, u_long)
782 #define FIONBIO _IOW('f', 126, u_long)
783 #define FIOASYNC _IOW('f', 125, u_long)
784 #define SIOCSHIWAT _IOW('s', 0, u_long)
785 #define SIOCGHIWAT _IOR('s', 1, u_long)
786 #define SIOCSLOWAT _IOW('s', 2, u_long)
787 #define SIOCGLOWAT _IOR('s', 3, u_long)
788 #define SIOCATMARK _IOR('s', 7, u_long)
790 #define WS_FIONREAD WS__IOR('f', 127, WS_u_long)
791 #define WS_FIONBIO WS__IOW('f', 126, WS_u_long)
792 #define WS_FIOASYNC WS__IOW('f', 125, WS_u_long)
793 #define WS_SIOCSHIWAT WS__IOW('s', 0, WS_u_long)
794 #define WS_SIOCGHIWAT WS__IOR('s', 1, WS_u_long)
795 #define WS_SIOCSLOWAT WS__IOW('s', 2, WS_u_long)
796 #define WS_SIOCGLOWAT WS__IOR('s', 3, WS_u_long)
797 #define WS_SIOCATMARK WS__IOR('s', 7, WS_u_long)
801 * Maximum queue length specifiable by listen.
803 #ifndef USE_WS_PREFIX
806 #define MSG_OOB 0x0001
807 #define MSG_PEEK 0x0002
808 #define MSG_DONTROUTE 0x0004
809 #define MSG_WAITALL 0x0008
810 #define MSG_INTERRUPT 0x0010
811 #define MSG_PARTIAL 0x8000
812 #define MSG_MAXIOVLEN 16
813 #else /* USE_WS_PREFIX */
814 #define WS_SOMAXCONN 5
816 #define WS_MSG_OOB 0x0001
817 #define WS_MSG_PEEK 0x0002
818 #define WS_MSG_DONTROUTE 0x0004
819 #define WS_MSG_WAITALL 0x0008
820 #define WS_MSG_INTERRUPT 0x0010
821 #define WS_MSG_PARTIAL 0x8000
822 #define WS_MSG_MAXIOVLEN 16
823 #endif /* USE_WS_PREFIX */
826 * Define constant based on rfc883, used by gethostbyxxxx() calls.
828 #ifndef USE_WS_PREFIX
829 #define MAXGETHOSTSTRUCT 1024
831 #define MAXGETHOSTSTRUCT 1024
836 * Define flags to be used with the WSAAsyncSelect() call.
838 #define FD_READ 0x00000001
839 #define FD_WRITE 0x00000002
840 #define FD_OOB 0x00000004
841 #define FD_ACCEPT 0x00000008
842 #define FD_CONNECT 0x00000010
843 #define FD_CLOSE 0x00000020
845 /* internal per-socket flags */
847 #define FD_WINE_LISTENING 0x10000000
848 #define FD_WINE_NONBLOCKING 0x20000000
849 #define FD_WINE_CONNECTED 0x40000000
850 #define FD_WINE_RAW 0x80000000
851 #define FD_WINE_INTERNAL 0xFFFF0000
855 * All Windows Sockets error constants are biased by WSABASEERR from
858 #define WSABASEERR 10000
860 * Windows Sockets definitions of regular Microsoft C error constants
862 #define WSAEINTR (WSABASEERR+4)
863 #define WSAEBADF (WSABASEERR+9)
864 #define WSAEACCES (WSABASEERR+13)
865 #define WSAEFAULT (WSABASEERR+14)
866 #define WSAEINVAL (WSABASEERR+22)
867 #define WSAEMFILE (WSABASEERR+24)
870 * Windows Sockets definitions of regular Berkeley error constants
872 #define WSAEWOULDBLOCK (WSABASEERR+35)
873 #define WSAEINPROGRESS (WSABASEERR+36)
874 #define WSAEALREADY (WSABASEERR+37)
875 #define WSAENOTSOCK (WSABASEERR+38)
876 #define WSAEDESTADDRREQ (WSABASEERR+39)
877 #define WSAEMSGSIZE (WSABASEERR+40)
878 #define WSAEPROTOTYPE (WSABASEERR+41)
879 #define WSAENOPROTOOPT (WSABASEERR+42)
880 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
881 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
882 #define WSAEOPNOTSUPP (WSABASEERR+45)
883 #define WSAEPFNOSUPPORT (WSABASEERR+46)
884 #define WSAEAFNOSUPPORT (WSABASEERR+47)
885 #define WSAEADDRINUSE (WSABASEERR+48)
886 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
887 #define WSAENETDOWN (WSABASEERR+50)
888 #define WSAENETUNREACH (WSABASEERR+51)
889 #define WSAENETRESET (WSABASEERR+52)
890 #define WSAECONNABORTED (WSABASEERR+53)
891 #define WSAECONNRESET (WSABASEERR+54)
892 #define WSAENOBUFS (WSABASEERR+55)
893 #define WSAEISCONN (WSABASEERR+56)
894 #define WSAENOTCONN (WSABASEERR+57)
895 #define WSAESHUTDOWN (WSABASEERR+58)
896 #define WSAETOOMANYREFS (WSABASEERR+59)
897 #define WSAETIMEDOUT (WSABASEERR+60)
898 #define WSAECONNREFUSED (WSABASEERR+61)
899 #define WSAELOOP (WSABASEERR+62)
900 #define WSAENAMETOOLONG (WSABASEERR+63)
901 #define WSAEHOSTDOWN (WSABASEERR+64)
902 #define WSAEHOSTUNREACH (WSABASEERR+65)
903 #define WSAENOTEMPTY (WSABASEERR+66)
904 #define WSAEPROCLIM (WSABASEERR+67)
905 #define WSAEUSERS (WSABASEERR+68)
906 #define WSAEDQUOT (WSABASEERR+69)
907 #define WSAESTALE (WSABASEERR+70)
908 #define WSAEREMOTE (WSABASEERR+71)
911 * Extended Windows Sockets error constant definitions
913 #define WSASYSNOTREADY (WSABASEERR+91)
914 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
915 #define WSANOTINITIALISED (WSABASEERR+93)
916 #define WSAEDISCON (WSABASEERR+101)
917 #define WSAENOMORE (WSABASEERR+102)
918 #define WSAECANCELLED (WSABASEERR+103)
919 #define WSAEINVALIDPROCTABLE (WSABASEERR+104)
920 #define WSAEINVALIDPROVIDER (WSABASEERR+105)
921 #define WSAEPROVIDERFAILEDINIT (WSABASEERR+106)
922 #define WSASYSCALLFAILURE (WSABASEERR+107)
923 #define WSASERVICE_NOT_FOUND (WSABASEERR+108)
924 #define WSATYPE_NOT_FOUND (WSABASEERR+109)
925 #define WSA_E_NO_MORE (WSABASEERR+110)
926 #define WSA_E_CANCELLED (WSABASEERR+111)
927 #define WSAEREFUSED (WSABASEERR+112)
930 * Error return codes from gethostbyname() and gethostbyaddr()
931 * (when using the resolver). Note that these errors are
932 * retrieved via WSAGetLastError() and must therefore follow
933 * the rules for avoiding clashes with error numbers from
934 * specific implementations or language run-time systems.
935 * For this reason the codes are based at WSABASEERR+1001.
936 * Note also that [WSA]NO_ADDRESS is defined only for
937 * compatibility purposes.
940 #ifndef USE_WS_PREFIX
941 #define h_errno WSAGetLastError()
943 #define WS_h_errno WSAGetLastError()
946 /* Authoritative Answer: Host not found */
947 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
949 /* Non-Authoritative: Host not found, or SERVERFAIL */
950 #define WSATRY_AGAIN (WSABASEERR+1002)
952 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
953 #define WSANO_RECOVERY (WSABASEERR+1003)
955 /* Valid name, no data record of requested type */
956 #define WSANO_DATA (WSABASEERR+1004)
958 /* no address, look for MX record */
959 #define WSANO_ADDRESS WSANO_DATA
961 #ifndef USE_WS_PREFIX
962 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
963 #define TRY_AGAIN WSATRY_AGAIN
964 #define NO_RECOVERY WSANO_RECOVERY
965 #define NO_DATA WSANO_DATA
966 #define NO_ADDRESS WSANO_ADDRESS
967 #endif /* USE_WS_PREFIX */
972 * Windows message parameter composition and decomposition
977 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
978 * when constructing the response to a WSAAsyncGetXByY() routine.
980 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
982 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
983 * when constructing the response to WSAAsyncSelect().
985 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
987 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
988 * to extract the buffer length from the lParam in the response
991 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
993 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
994 * to extract the error code from the lParam in the response
997 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
999 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
1000 * to extract the event code from the lParam in the response
1001 * to a WSAAsyncSelect().
1003 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
1005 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
1006 * to extract the error code from the lParam in the response
1007 * to a WSAAsyncSelect().
1009 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
1016 * Remember to keep this section in sync with the
1017 * "Winsock Function Typedefs" section in winsock2.h.
1019 #if !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES
1020 HANDLE WINAPI WSAAsyncGetHostByAddr(HWND,WS(u_int),const char*,int,int,char*,int);
1021 HANDLE WINAPI WSAAsyncGetHostByName(HWND,WS(u_int),const char*,char*,int);
1022 HANDLE WINAPI WSAAsyncGetProtoByName(HWND,WS(u_int),const char*,char*,int);
1023 HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND,WS(u_int),int,char*,int);
1024 HANDLE WINAPI WSAAsyncGetServByName(HWND,WS(u_int),const char*,const char*,char*,int);
1025 HANDLE WINAPI WSAAsyncGetServByPort(HWND,WS(u_int),int,const char*,char*,int);
1026 int WINAPI WSAAsyncSelect(SOCKET,HWND,WS(u_int),LONG);
1027 int WINAPI WSACancelAsyncRequest(HANDLE);
1028 int WINAPI WSACancelBlockingCall(void);
1029 int WINAPI WSACleanup(void);
1030 int WINAPI WSAGetLastError(void);
1031 BOOL WINAPI WSAIsBlocking(void);
1032 FARPROC WINAPI WSASetBlockingHook(FARPROC);
1033 void WINAPI WSASetLastError(int);
1034 int WINAPI WSAStartup(WORD,LPWSADATA);
1035 int WINAPI WSAUnhookBlockingHook(void);
1037 SOCKET WINAPI WS(accept)(SOCKET,struct WS(sockaddr)*,int*);
1038 int WINAPI WS(bind)(SOCKET,const struct WS(sockaddr)*,int);
1039 int WINAPI WS(closesocket)(SOCKET);
1040 int WINAPI WS(connect)(SOCKET,const struct WS(sockaddr)*,int);
1041 struct WS(hostent)* WINAPI WS(gethostbyaddr)(const char*,int,int);
1042 struct WS(hostent)* WINAPI WS(gethostbyname)(const char*);
1043 /* gethostname not defined because of conflicts with unistd.h */
1044 int WINAPI WS(getpeername)(SOCKET,struct WS(sockaddr)*,int*);
1045 struct WS(protoent)* WINAPI WS(getprotobyname)(const char*);
1046 struct WS(protoent)* WINAPI WS(getprotobynumber)(int);
1047 #ifdef WS_DEFINE_SELECT
1048 int WINAPI WS(select)(int,WS(fd_set)*,WS(fd_set)*,WS(fd_set)*,const struct WS(timeval)*);
1050 struct WS(servent)* WINAPI WS(getservbyname)(const char*,const char*);
1051 struct WS(servent)* WINAPI WS(getservbyport)(int,const char*);
1052 int WINAPI WS(getsockname)(SOCKET,struct WS(sockaddr)*,int*);
1053 int WINAPI WS(getsockopt)(SOCKET,int,int,char*,int*);
1054 WS(u_long) WINAPI WS(inet_addr)(const char*);
1055 char* WINAPI WS(inet_ntoa)(struct WS(in_addr));
1056 int WINAPI WS(ioctlsocket)(SOCKET,LONG,WS(u_long)*);
1057 int WINAPI WS(listen)(SOCKET,int);
1058 int WINAPI WS(recv)(SOCKET,char*,int,int);
1059 int WINAPI WS(recvfrom)(SOCKET,char*,int,int,struct WS(sockaddr)*,int*);
1060 int WINAPI WS(send)(SOCKET,const char*,int,int);
1061 int WINAPI WS(sendto)(SOCKET,const char*,int,int,const struct WS(sockaddr)*,int);
1062 int WINAPI WS(setsockopt)(SOCKET,int,int,const char*,int);
1063 int WINAPI WS(shutdown)(SOCKET,int);
1064 SOCKET WINAPI WS(socket)(int,int,int);
1066 #endif /* !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES */
1072 #ifndef __WINE_WINSOCK2__
1074 #undef WS_API_PROTOTYPES
1075 #undef WS_API_TYPEDEFS
1078 #endif /* _WINSOCKAPI_ */