VirtualBox

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

最後變更 在這個檔案從16477是 16477,由 vboxsync 提交於 16 年 前

LGPL disclaimer by filemuncher

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

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