VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/winsock.h@ 27512

Last change on this file since 27512 was 23571, checked in by vboxsync, 15 years ago

crOpenGL: update to wine 1.1.30

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette