VirtualBox

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

Last change on this file since 19982 was 19678, checked in by vboxsync, 16 years ago

opengl: update wine to 1.1.21, add d3d9.dll to build list

  • 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_ND 77
279#define IPPROTO_RAW 255
280#define IPPROTO_MAX 256
281#else /* USE_WS_PREFIX */
282#define WS_IPPROTO_IP 0
283#define WS_IPPROTO_ICMP 1
284#define WS_IPPROTO_IGMP 2
285#define WS_IPPROTO_GGP 3
286#define WS_IPPROTO_TCP 6
287#define WS_IPPROTO_UDP 17
288#define WS_IPPROTO_IDP 22
289#define WS_IPPROTO_ND 77
290#define WS_IPPROTO_RAW 255
291#define WS_IPPROTO_MAX 256
292#endif /* USE_WS_PREFIX */
293
294typedef struct WS(protoent)
295{
296 char* p_name;
297 char** p_aliases;
298 short p_proto;
299} PROTOENT, *PPROTOENT, *LPPROTOENT;
300
301
302
303/*
304 * Networks
305 */
306struct WS(netent)
307{
308 char* n_name; /* official name of net */
309 char** n_aliases; /* alias list */
310 short n_addrtype; /* net address type */
311 WS(u_long) n_net; /* network # */
312};
313
314
315/*
316 * Services
317 */
318#ifndef USE_WS_PREFIX
319#define IPPORT_ECHO 7
320#define IPPORT_DISCARD 9
321#define IPPORT_SYSTAT 11
322#define IPPORT_DAYTIME 13
323#define IPPORT_NETSTAT 15
324#define IPPORT_FTP 21
325#define IPPORT_TELNET 23
326#define IPPORT_SMTP 25
327#define IPPORT_TIMESERVER 37
328#define IPPORT_NAMESERVER 42
329#define IPPORT_WHOIS 43
330#define IPPORT_MTP 57
331#define IPPORT_TFTP 69
332#define IPPORT_RJE 77
333#define IPPORT_FINGER 79
334#define IPPORT_TTYLINK 87
335#define IPPORT_SUPDUP 95
336#define IPPORT_EXECSERVER 512
337#define IPPORT_LOGINSERVER 513
338#define IPPORT_CMDSERVER 514
339#define IPPORT_EFSSERVER 520
340#define IPPORT_BIFFUDP 512
341#define IPPORT_WHOSERVER 513
342#define IPPORT_ROUTESERVER 520
343#define IPPORT_RESERVED 1024
344#else /* USE_WS_PREFIX */
345#define WS_IPPORT_ECHO 7
346#define WS_IPPORT_DISCARD 9
347#define WS_IPPORT_SYSTAT 11
348#define WS_IPPORT_DAYTIME 13
349#define WS_IPPORT_NETSTAT 15
350#define WS_IPPORT_FTP 21
351#define WS_IPPORT_TELNET 23
352#define WS_IPPORT_SMTP 25
353#define WS_IPPORT_TIMESERVER 37
354#define WS_IPPORT_NAMESERVER 42
355#define WS_IPPORT_WHOIS 43
356#define WS_IPPORT_MTP 57
357#define WS_IPPORT_TFTP 69
358#define WS_IPPORT_RJE 77
359#define WS_IPPORT_FINGER 79
360#define WS_IPPORT_TTYLINK 87
361#define WS_IPPORT_SUPDUP 95
362#define WS_IPPORT_EXECSERVER 512
363#define WS_IPPORT_LOGINSERVER 513
364#define WS_IPPORT_CMDSERVER 514
365#define WS_IPPORT_EFSSERVER 520
366#define WS_IPPORT_BIFFUDP 512
367#define WS_IPPORT_WHOSERVER 513
368#define WS_IPPORT_ROUTESERVER 520
369#define WS_IPPORT_RESERVED 1024
370#endif /* USE_WS_PREFIX */
371
372typedef struct WS(servent)
373{
374 char* s_name; /* official service name */
375 char** s_aliases; /* alias list */
376#ifdef _WIN64
377 char* s_proto; /* protocol to use */
378 short s_port; /* port # */
379#else
380 short s_port; /* port # */
381 char* s_proto; /* protocol to use */
382#endif
383} SERVENT, *PSERVENT, *LPSERVENT;
384
385
386
387/*
388 * Hosts
389 */
390
391typedef struct WS(hostent)
392{
393 char* h_name; /* official name of host */
394 char** h_aliases; /* alias list */
395 short h_addrtype; /* host address type */
396 short h_length; /* length of address */
397 char** h_addr_list; /* list of addresses from name server */
398#define h_addr h_addr_list[0] /* address, for backward compat */
399} HOSTENT, *PHOSTENT, *LPHOSTENT;
400
401
402/*
403 * Sockets
404 */
405
406typedef UINT_PTR SOCKET;
407
408/*
409 * This is used instead of -1, since the
410 * SOCKET type is unsigned.
411 */
412#define INVALID_SOCKET (SOCKET)(~0)
413#define SOCKET_ERROR (-1)
414
415typedef struct WS(sockaddr)
416{
417 WS(u_short) sa_family;
418 char sa_data[14];
419} SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
420
421typedef struct WS(linger)
422{
423 WS(u_short) l_onoff; /* option on/off */
424 WS(u_short) l_linger; /* linger time */
425} LINGER, *PLINGER, *LPLINGER;
426
427/*
428 * Select
429 */
430
431#ifdef WS_DEFINE_SELECT
432/* Define our own version of select and the associated types and macros */
433
434# ifndef USE_WS_PREFIX
435# ifndef FD_SETSIZE
436# define FD_SETSIZE 64
437# endif
438# else
439# ifndef WS_FD_SETSIZE
440# define WS_FD_SETSIZE 64
441# endif
442# endif
443
444typedef struct WS(fd_set)
445{
446 WS(u_int) fd_count; /* how many are SET? */
447# ifndef USE_WS_PREFIX
448 SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
449# else
450 SOCKET fd_array[WS_FD_SETSIZE];/* an array of SOCKETs */
451# endif
452} WS(fd_set), FD_SET, *PFD_SET, *LPFD_SET;
453
454#ifndef _TIMEVAL_DEFINED
455#define _TIMEVAL_DEFINED
456typedef struct WS(timeval)
457{
458 LONG tv_sec; /* seconds */
459 LONG tv_usec; /* and microseconds */
460} TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
461#endif
462
463#define __WS_FD_CLR(fd, set, cast) do { \
464 unsigned int __i; \
465 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
466 { \
467 if (((cast*)(set))->fd_array[__i] == fd) \
468 { \
469 while (__i < ((cast*)(set))->fd_count-1) \
470 { \
471 ((cast*)(set))->fd_array[__i] = \
472 ((cast*)(set))->fd_array[__i+1]; \
473 __i++; \
474 } \
475 ((cast*)(set))->fd_count--; \
476 break; \
477 } \
478 } \
479} while(0)
480#define __WS_FD_SET1(fd, set, cast) do { \
481 if (((cast*)(set))->fd_count < FD_SETSIZE) \
482 ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd); \
483} while(0)
484/* This version checks if the filedesc is already in the list, and appends it
485 * only if it's not the case
486 */
487#define __WS_FD_SET2(fd, set, cast) do { \
488 unsigned int __i; \
489 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
490 { \
491 if (((cast*)(set))->fd_array[__i]==(fd)) \
492 break; \
493 } \
494 if (__i == ((cast*)(set))->fd_count && ((cast*)(set))->fd_count < FD_SETSIZE) \
495 { \
496 ((cast*)(set))->fd_count++; \
497 ((cast*)(set))->fd_array[__i]=(fd);\
498 } \
499} while(0)
500
501#ifndef __WINE_WINSOCK2__
502#define __WS_FD_SET(fd, set, cast) __WS_FD_SET1((fd),(set), cast)
503#else
504#define __WS_FD_SET(fd, set, cast) __WS_FD_SET2((fd),(set), cast)
505#endif
506
507#ifndef USE_WS_PREFIX
508#define FD_CLR(fd, set) __WS_FD_CLR((fd),(set), fd_set)
509#define FD_SET(fd, set) __WS_FD_SET((fd),(set), fd_set)
510#define FD_ZERO(set) (((fd_set*)(set))->fd_count=0)
511#define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set))
512#else
513#define WS_FD_CLR(fd, set) __WS_FD_CLR((fd),(set), WS_fd_set)
514#define WS_FD_SET(fd, set) __WS_FD_SET((fd),(set), WS_fd_set)
515#define WS_FD_ZERO(set) (((WS_fd_set*)(set))->fd_count=0)
516#define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (WS_fd_set*)(set))
517#endif
518
519int WINAPI __WSAFDIsSet(SOCKET,WS(fd_set)*);
520
521#endif /* WS_DEFINE_SELECT */
522
523/* we have to define hton/ntoh as macros to avoid conflicts with Unix headers */
524#ifndef USE_WS_PREFIX
525
526#undef htonl
527#undef htons
528#undef ntohl
529#undef ntohs
530
531#ifdef WORDS_BIGENDIAN
532
533#define htonl(l) ((u_long)(l))
534#define htons(s) ((u_short)(s))
535#define ntohl(l) ((u_long)(l))
536#define ntohs(s) ((u_short)(s))
537
538#else /* WORDS_BIGENDIAN */
539
540static inline u_short __wine_ushort_swap(u_short s)
541{
542 return (s >> 8) | (s << 8);
543}
544static inline u_long __wine_ulong_swap(u_long l)
545{
546 return ((u_long)__wine_ushort_swap((u_short)l) << 16) | __wine_ushort_swap((u_short)(l >> 16));
547}
548#define htonl(l) __wine_ulong_swap(l)
549#define htons(s) __wine_ushort_swap(s)
550#define ntohl(l) __wine_ulong_swap(l)
551#define ntohs(s) __wine_ushort_swap(s)
552
553#endif /* WORDS_BIGENDIAN */
554
555#endif /* USE_WS_PREFIX */
556
557/*
558 * Internet address (old style... should be updated)
559 */
560
561#ifndef USE_WS_PREFIX
562#define IN_CLASSA_NSHIFT 24
563#define IN_CLASSA_MAX 128
564#define IN_CLASSA_NET 0xff000000
565#define IN_CLASSA_HOST 0x00ffffff
566#define IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
567#define IN_CLASSB_NSHIFT 16
568#define IN_CLASSB_MAX 65536
569#define IN_CLASSB_NET 0xffff0000
570#define IN_CLASSB_HOST 0x0000ffff
571#define IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
572#define IN_CLASSC_NSHIFT 8
573#define IN_CLASSC_NET 0xffffff00
574#define IN_CLASSC_HOST 0x000000ff
575#define IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
576#else
577#define WS_IN_CLASSA_NSHIFT 24
578#define WS_IN_CLASSA_MAX 128
579#define WS_IN_CLASSA_NET 0xff000000
580#define WS_IN_CLASSA_HOST 0x00ffffff
581#define WS_IN_CLASSA(i) (((LONG)(i) & 0x80000000) == 0)
582#define WS_IN_CLASSB_NSHIFT 16
583#define WS_IN_CLASSB_MAX 65536
584#define WS_IN_CLASSB_NET 0xffff0000
585#define WS_IN_CLASSB_HOST 0x0000ffff
586#define WS_IN_CLASSB(i) (((LONG)(i) & 0xc0000000) == 0x80000000)
587#define WS_IN_CLASSC_NSHIFT 8
588#define WS_IN_CLASSC_NET 0xffffff00
589#define WS_IN_CLASSC_HOST 0x000000ff
590#define WS_IN_CLASSC(i) (((LONG)(i) & 0xe0000000) == 0xc0000000)
591#endif /* USE_WS_PREFIX */
592
593#ifndef USE_WS_PREFIX
594#define INADDR_ANY ((u_long)0x00000000)
595#define INADDR_LOOPBACK 0x7f000001
596#define INADDR_BROADCAST ((u_long)0xffffffff)
597#define INADDR_NONE 0xffffffff
598#else
599#define WS_INADDR_ANY ((WS_u_long)0x00000000)
600#define WS_INADDR_LOOPBACK 0x7f000001
601#define WS_INADDR_BROADCAST ((WS_u_long)0xffffffff)
602#define WS_INADDR_NONE 0xffffffff
603#endif /* USE_WS_PREFIX */
604
605typedef struct WS(in_addr)
606{
607 union {
608 struct {
609 WS(u_char) s_b1,s_b2,s_b3,s_b4;
610 } S_un_b;
611 struct {
612 WS(u_short) s_w1,s_w2;
613 } S_un_w;
614 WS(u_long) S_addr;
615 } S_un;
616#ifndef USE_WS_PREFIX
617#define s_addr S_un.S_addr
618#define s_host S_un.S_un_b.s_b2
619#define s_net S_un.S_un_b.s_b1
620#define s_imp S_un.S_un_w.s_w2
621#define s_impno S_un.S_un_b.s_b4
622#define s_lh S_un.S_un_b.s_b3
623#else
624#define WS_s_addr S_un.S_addr
625#define WS_s_host S_un.S_un_b.s_b2
626#define WS_s_net S_un.S_un_b.s_b1
627#define WS_s_imp S_un.S_un_w.s_w2
628#define WS_s_impno S_un.S_un_b.s_b4
629#define WS_s_lh S_un.S_un_b.s_b3
630#endif /* USE_WS_PREFIX */
631} IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
632
633typedef struct WS(sockaddr_in)
634{
635 short sin_family;
636 WS(u_short) sin_port;
637 struct WS(in_addr) sin_addr;
638 char sin_zero[8];
639} SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
640
641/*
642 * Multicast group information
643 */
644
645#if !defined(__WINE_WINSOCK2__)
646struct WS(ip_mreq)
647{
648 struct WS(in_addr) imr_multiaddr;
649 struct WS(in_addr) imr_interface;
650};
651#endif
652
653/*
654 * WSAStartup
655 */
656#define WSADESCRIPTION_LEN 256
657#define WSASYS_STATUS_LEN 128
658
659typedef struct WS(WSAData)
660{
661 WORD wVersion;
662 WORD wHighVersion;
663#ifdef _WIN64
664 WORD iMaxSockets;
665 WORD iMaxUdpDg;
666 char *lpVendorInfo;
667 char szDescription[WSADESCRIPTION_LEN+1];
668 char szSystemStatus[WSASYS_STATUS_LEN+1];
669#else
670 char szDescription[WSADESCRIPTION_LEN+1];
671 char szSystemStatus[WSASYS_STATUS_LEN+1];
672 WORD iMaxSockets;
673 WORD iMaxUdpDg;
674 char *lpVendorInfo;
675#endif
676} WSADATA, *LPWSADATA;
677
678
679
680/*
681 * {get,set}sockopt
682 */
683#ifndef USE_WS_PREFIX
684#define SOL_SOCKET 0xffff
685#define SO_DEBUG 0x0001
686#define SO_ACCEPTCONN 0x0002
687#define SO_REUSEADDR 0x0004
688#define SO_EXCLUSIVEADDRUSE ((u_int)(~SO_REUSEADDR))
689#define SO_KEEPALIVE 0x0008
690#define SO_DONTROUTE 0x0010
691#define SO_BROADCAST 0x0020
692#define SO_USELOOPBACK 0x0040
693#define SO_LINGER 0x0080
694#define SO_OOBINLINE 0x0100
695#define SO_DONTLINGER ((u_int)(~SO_LINGER))
696#define SO_SNDBUF 0x1001
697#define SO_RCVBUF 0x1002
698#define SO_SNDLOWAT 0x1003
699#define SO_RCVLOWAT 0x1004
700#define SO_SNDTIMEO 0x1005
701#define SO_RCVTIMEO 0x1006
702#define SO_ERROR 0x1007
703#define SO_TYPE 0x1008
704
705
706#define IOCPARM_MASK 0x7f
707#define IOC_VOID 0x20000000
708#define IOC_OUT 0x40000000
709#define IOC_IN 0x80000000
710#define IOC_INOUT (IOC_IN|IOC_OUT)
711
712#define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
713#define _IOR(x,y,t) (IOC_OUT|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
714#define _IOW(x,y,t) (IOC_IN|(((UINT)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
715
716#else
717
718#define WS_SOL_SOCKET 0xffff
719#define WS_SO_DEBUG 0x0001
720#define WS_SO_ACCEPTCONN 0x0002
721#define WS_SO_REUSEADDR 0x0004
722#define WS_SO_EXCLUSIVEADDRUSE ((WS_u_int)(~WS_SO_REUSEADDR))
723#define WS_SO_KEEPALIVE 0x0008
724#define WS_SO_DONTROUTE 0x0010
725#define WS_SO_BROADCAST 0x0020
726#define WS_SO_USELOOPBACK 0x0040
727#define WS_SO_LINGER 0x0080
728#define WS_SO_OOBINLINE 0x0100
729#define WS_SO_DONTLINGER ((WS_u_int)(~WS_SO_LINGER))
730#define WS_SO_SNDBUF 0x1001
731#define WS_SO_RCVBUF 0x1002
732#define WS_SO_SNDLOWAT 0x1003
733#define WS_SO_RCVLOWAT 0x1004
734#define WS_SO_SNDTIMEO 0x1005
735#define WS_SO_RCVTIMEO 0x1006
736#define WS_SO_ERROR 0x1007
737#define WS_SO_TYPE 0x1008
738
739#define WS_IOCPARM_MASK 0x7f
740#define WS_IOC_VOID 0x20000000
741#define WS_IOC_OUT 0x40000000
742#define WS_IOC_IN 0x80000000
743#define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
744
745#define WS__IO(x,y) (WS_IOC_VOID|((x)<<8)|(y))
746#define WS__IOR(x,y,t) (WS_IOC_OUT|(((LONG)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
747#define WS__IOW(x,y,t) (WS_IOC_IN|(((LONG)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
748
749#endif
750
751/* IPPROTO_TCP options */
752#ifndef USE_WS_PREFIX
753#define TCP_NODELAY 1
754#else
755#define WS_TCP_NODELAY 1
756#endif
757
758/* IPPROTO_IP options */
759#ifndef __WINE_WINSOCK2__ /* WinSock2 has different values for the IP_ constants */
760# ifndef USE_WS_PREFIX
761# define IP_OPTIONS 1
762# define IP_MULTICAST_IF 2
763# define IP_MULTICAST_TTL 3
764# define IP_MULTICAST_LOOP 4
765# define IP_ADD_MEMBERSHIP 5
766# define IP_DROP_MEMBERSHIP 6
767# define IP_TTL 7
768# define IP_TOS 8
769# define IP_DONTFRAGMENT 9
770# else
771# define WS_IP_OPTIONS 1
772# define WS_IP_MULTICAST_IF 2
773# define WS_IP_MULTICAST_TTL 3
774# define WS_IP_MULTICAST_LOOP 4
775# define WS_IP_ADD_MEMBERSHIP 5
776# define WS_IP_DROP_MEMBERSHIP 6
777# define WS_IP_TTL 7
778# define WS_IP_TOS 8
779# define WS_IP_DONTFRAGMENT 9
780# endif
781#endif
782
783
784/*
785 * Socket I/O flags (supported by spec 1.1)
786 */
787#ifndef USE_WS_PREFIX
788#define FIONREAD _IOR('f', 127, u_long)
789#define FIONBIO _IOW('f', 126, u_long)
790#define FIOASYNC _IOW('f', 125, u_long)
791#define SIOCSHIWAT _IOW('s', 0, u_long)
792#define SIOCGHIWAT _IOR('s', 1, u_long)
793#define SIOCSLOWAT _IOW('s', 2, u_long)
794#define SIOCGLOWAT _IOR('s', 3, u_long)
795#define SIOCATMARK _IOR('s', 7, u_long)
796#else
797#define WS_FIONREAD WS__IOR('f', 127, WS_u_long)
798#define WS_FIONBIO WS__IOW('f', 126, WS_u_long)
799#define WS_FIOASYNC WS__IOW('f', 125, WS_u_long)
800#define WS_SIOCSHIWAT WS__IOW('s', 0, WS_u_long)
801#define WS_SIOCGHIWAT WS__IOR('s', 1, WS_u_long)
802#define WS_SIOCSLOWAT WS__IOW('s', 2, WS_u_long)
803#define WS_SIOCGLOWAT WS__IOR('s', 3, WS_u_long)
804#define WS_SIOCATMARK WS__IOR('s', 7, WS_u_long)
805#endif
806
807/*
808 * Maximum queue length specifiable by listen.
809 */
810#ifndef USE_WS_PREFIX
811#define SOMAXCONN 5
812
813#define MSG_OOB 0x0001
814#define MSG_PEEK 0x0002
815#define MSG_DONTROUTE 0x0004
816#define MSG_WAITALL 0x0008
817#define MSG_INTERRUPT 0x0010
818#define MSG_PARTIAL 0x8000
819#define MSG_MAXIOVLEN 16
820#else /* USE_WS_PREFIX */
821#define WS_SOMAXCONN 5
822
823#define WS_MSG_OOB 0x0001
824#define WS_MSG_PEEK 0x0002
825#define WS_MSG_DONTROUTE 0x0004
826#define WS_MSG_WAITALL 0x0008
827#define WS_MSG_INTERRUPT 0x0010
828#define WS_MSG_PARTIAL 0x8000
829#define WS_MSG_MAXIOVLEN 16
830#endif /* USE_WS_PREFIX */
831
832/*
833 * Define constant based on rfc883, used by gethostbyxxxx() calls.
834 */
835#ifndef USE_WS_PREFIX
836#define MAXGETHOSTSTRUCT 1024
837#else
838#define MAXGETHOSTSTRUCT 1024
839#endif
840
841
842/*
843 * Define flags to be used with the WSAAsyncSelect() call.
844 */
845#define FD_READ 0x00000001
846#define FD_WRITE 0x00000002
847#define FD_OOB 0x00000004
848#define FD_ACCEPT 0x00000008
849#define FD_CONNECT 0x00000010
850#define FD_CLOSE 0x00000020
851
852/* internal per-socket flags */
853#ifdef __WINESRC__
854#define FD_WINE_LISTENING 0x10000000
855#define FD_WINE_NONBLOCKING 0x20000000
856#define FD_WINE_CONNECTED 0x40000000
857#define FD_WINE_RAW 0x80000000
858#define FD_WINE_INTERNAL 0xFFFF0000
859#endif
860
861/*
862 * All Windows Sockets error constants are biased by WSABASEERR from
863 * the "normal"
864 */
865#define WSABASEERR 10000
866/*
867 * Windows Sockets definitions of regular Microsoft C error constants
868 */
869#define WSAEINTR (WSABASEERR+4)
870#define WSAEBADF (WSABASEERR+9)
871#define WSAEACCES (WSABASEERR+13)
872#define WSAEFAULT (WSABASEERR+14)
873#define WSAEINVAL (WSABASEERR+22)
874#define WSAEMFILE (WSABASEERR+24)
875
876/*
877 * Windows Sockets definitions of regular Berkeley error constants
878 */
879#define WSAEWOULDBLOCK (WSABASEERR+35)
880#define WSAEINPROGRESS (WSABASEERR+36)
881#define WSAEALREADY (WSABASEERR+37)
882#define WSAENOTSOCK (WSABASEERR+38)
883#define WSAEDESTADDRREQ (WSABASEERR+39)
884#define WSAEMSGSIZE (WSABASEERR+40)
885#define WSAEPROTOTYPE (WSABASEERR+41)
886#define WSAENOPROTOOPT (WSABASEERR+42)
887#define WSAEPROTONOSUPPORT (WSABASEERR+43)
888#define WSAESOCKTNOSUPPORT (WSABASEERR+44)
889#define WSAEOPNOTSUPP (WSABASEERR+45)
890#define WSAEPFNOSUPPORT (WSABASEERR+46)
891#define WSAEAFNOSUPPORT (WSABASEERR+47)
892#define WSAEADDRINUSE (WSABASEERR+48)
893#define WSAEADDRNOTAVAIL (WSABASEERR+49)
894#define WSAENETDOWN (WSABASEERR+50)
895#define WSAENETUNREACH (WSABASEERR+51)
896#define WSAENETRESET (WSABASEERR+52)
897#define WSAECONNABORTED (WSABASEERR+53)
898#define WSAECONNRESET (WSABASEERR+54)
899#define WSAENOBUFS (WSABASEERR+55)
900#define WSAEISCONN (WSABASEERR+56)
901#define WSAENOTCONN (WSABASEERR+57)
902#define WSAESHUTDOWN (WSABASEERR+58)
903#define WSAETOOMANYREFS (WSABASEERR+59)
904#define WSAETIMEDOUT (WSABASEERR+60)
905#define WSAECONNREFUSED (WSABASEERR+61)
906#define WSAELOOP (WSABASEERR+62)
907#define WSAENAMETOOLONG (WSABASEERR+63)
908#define WSAEHOSTDOWN (WSABASEERR+64)
909#define WSAEHOSTUNREACH (WSABASEERR+65)
910#define WSAENOTEMPTY (WSABASEERR+66)
911#define WSAEPROCLIM (WSABASEERR+67)
912#define WSAEUSERS (WSABASEERR+68)
913#define WSAEDQUOT (WSABASEERR+69)
914#define WSAESTALE (WSABASEERR+70)
915#define WSAEREMOTE (WSABASEERR+71)
916
917/*
918 * Extended Windows Sockets error constant definitions
919 */
920#define WSASYSNOTREADY (WSABASEERR+91)
921#define WSAVERNOTSUPPORTED (WSABASEERR+92)
922#define WSANOTINITIALISED (WSABASEERR+93)
923#define WSAEDISCON (WSABASEERR+101)
924#define WSAENOMORE (WSABASEERR+102)
925#define WSAECANCELLED (WSABASEERR+103)
926#define WSAEINVALIDPROCTABLE (WSABASEERR+104)
927#define WSAEINVALIDPROVIDER (WSABASEERR+105)
928#define WSAEPROVIDERFAILEDINIT (WSABASEERR+106)
929#define WSASYSCALLFAILURE (WSABASEERR+107)
930#define WSASERVICE_NOT_FOUND (WSABASEERR+108)
931#define WSATYPE_NOT_FOUND (WSABASEERR+109)
932#define WSA_E_NO_MORE (WSABASEERR+110)
933#define WSA_E_CANCELLED (WSABASEERR+111)
934#define WSAEREFUSED (WSABASEERR+112)
935
936/*
937 * Error return codes from gethostbyname() and gethostbyaddr()
938 * (when using the resolver). Note that these errors are
939 * retrieved via WSAGetLastError() and must therefore follow
940 * the rules for avoiding clashes with error numbers from
941 * specific implementations or language run-time systems.
942 * For this reason the codes are based at WSABASEERR+1001.
943 * Note also that [WSA]NO_ADDRESS is defined only for
944 * compatibility purposes.
945 */
946
947#ifndef USE_WS_PREFIX
948#define h_errno WSAGetLastError()
949#else
950#define WS_h_errno WSAGetLastError()
951#endif
952
953/* Authoritative Answer: Host not found */
954#define WSAHOST_NOT_FOUND (WSABASEERR+1001)
955
956/* Non-Authoritative: Host not found, or SERVERFAIL */
957#define WSATRY_AGAIN (WSABASEERR+1002)
958
959/* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
960#define WSANO_RECOVERY (WSABASEERR+1003)
961
962/* Valid name, no data record of requested type */
963#define WSANO_DATA (WSABASEERR+1004)
964
965/* no address, look for MX record */
966#define WSANO_ADDRESS WSANO_DATA
967
968#ifndef USE_WS_PREFIX
969#define HOST_NOT_FOUND WSAHOST_NOT_FOUND
970#define TRY_AGAIN WSATRY_AGAIN
971#define NO_RECOVERY WSANO_RECOVERY
972#define NO_DATA WSANO_DATA
973#define NO_ADDRESS WSANO_ADDRESS
974#endif /* USE_WS_PREFIX */
975
976
977
978/*
979 * Windows message parameter composition and decomposition
980 * macros.
981 */
982
983/*
984 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
985 * when constructing the response to a WSAAsyncGetXByY() routine.
986 */
987#define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
988/*
989 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
990 * when constructing the response to WSAAsyncSelect().
991 */
992#define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
993/*
994 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
995 * to extract the buffer length from the lParam in the response
996 * to a WSAGetXByY().
997 */
998#define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
999/*
1000 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
1001 * to extract the error code from the lParam in the response
1002 * to a WSAGetXByY().
1003 */
1004#define WSAGETASYNCERROR(lParam) HIWORD(lParam)
1005/*
1006 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
1007 * to extract the event code from the lParam in the response
1008 * to a WSAAsyncSelect().
1009 */
1010#define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
1011/*
1012 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
1013 * to extract the error code from the lParam in the response
1014 * to a WSAAsyncSelect().
1015 */
1016#define WSAGETSELECTERROR(lParam) HIWORD(lParam)
1017
1018
1019
1020/*
1021 * Prototypes
1022 *
1023 * Remember to keep this section in sync with the
1024 * "Winsock Function Typedefs" section in winsock2.h.
1025 */
1026#if !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES
1027HANDLE WINAPI WSAAsyncGetHostByAddr(HWND,WS(u_int),const char*,int,int,char*,int);
1028HANDLE WINAPI WSAAsyncGetHostByName(HWND,WS(u_int),const char*,char*,int);
1029HANDLE WINAPI WSAAsyncGetProtoByName(HWND,WS(u_int),const char*,char*,int);
1030HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND,WS(u_int),int,char*,int);
1031HANDLE WINAPI WSAAsyncGetServByName(HWND,WS(u_int),const char*,const char*,char*,int);
1032HANDLE WINAPI WSAAsyncGetServByPort(HWND,WS(u_int),int,const char*,char*,int);
1033int WINAPI WSAAsyncSelect(SOCKET,HWND,WS(u_int),LONG);
1034int WINAPI WSACancelAsyncRequest(HANDLE);
1035int WINAPI WSACancelBlockingCall(void);
1036int WINAPI WSACleanup(void);
1037int WINAPI WSAGetLastError(void);
1038BOOL WINAPI WSAIsBlocking(void);
1039FARPROC WINAPI WSASetBlockingHook(FARPROC);
1040void WINAPI WSASetLastError(int);
1041int WINAPI WSAStartup(WORD,LPWSADATA);
1042int WINAPI WSAUnhookBlockingHook(void);
1043
1044SOCKET WINAPI WS(accept)(SOCKET,struct WS(sockaddr)*,int*);
1045int WINAPI WS(bind)(SOCKET,const struct WS(sockaddr)*,int);
1046int WINAPI WS(closesocket)(SOCKET);
1047int WINAPI WS(connect)(SOCKET,const struct WS(sockaddr)*,int);
1048struct WS(hostent)* WINAPI WS(gethostbyaddr)(const char*,int,int);
1049struct WS(hostent)* WINAPI WS(gethostbyname)(const char*);
1050/* gethostname not defined because of conflicts with unistd.h */
1051int WINAPI WS(getpeername)(SOCKET,struct WS(sockaddr)*,int*);
1052struct WS(protoent)* WINAPI WS(getprotobyname)(const char*);
1053struct WS(protoent)* WINAPI WS(getprotobynumber)(int);
1054#ifdef WS_DEFINE_SELECT
1055int WINAPI WS(select)(int,WS(fd_set)*,WS(fd_set)*,WS(fd_set)*,const struct WS(timeval)*);
1056#endif
1057struct WS(servent)* WINAPI WS(getservbyname)(const char*,const char*);
1058struct WS(servent)* WINAPI WS(getservbyport)(int,const char*);
1059int WINAPI WS(getsockname)(SOCKET,struct WS(sockaddr)*,int*);
1060int WINAPI WS(getsockopt)(SOCKET,int,int,char*,int*);
1061WS(u_long) WINAPI WS(inet_addr)(const char*);
1062char* WINAPI WS(inet_ntoa)(struct WS(in_addr));
1063int WINAPI WS(ioctlsocket)(SOCKET,LONG,WS(u_long)*);
1064int WINAPI WS(listen)(SOCKET,int);
1065int WINAPI WS(recv)(SOCKET,char*,int,int);
1066int WINAPI WS(recvfrom)(SOCKET,char*,int,int,struct WS(sockaddr)*,int*);
1067int WINAPI WS(send)(SOCKET,const char*,int,int);
1068int WINAPI WS(sendto)(SOCKET,const char*,int,int,const struct WS(sockaddr)*,int);
1069int WINAPI WS(setsockopt)(SOCKET,int,int,const char*,int);
1070int WINAPI WS(shutdown)(SOCKET,int);
1071SOCKET WINAPI WS(socket)(int,int,int);
1072
1073#endif /* !defined(__WINE_WINSOCK2__) || WS_API_PROTOTYPES */
1074
1075#ifdef __cplusplus
1076}
1077#endif
1078
1079#ifndef __WINE_WINSOCK2__
1080#undef WS
1081#undef WS_API_PROTOTYPES
1082#undef WS_API_TYPEDEFS
1083#endif
1084
1085#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