configure first checks whether it is possible to compile IPX code with
[wine/multimedia.git] / include / winsock.h
blob22b73633f4390b21b57d0c5d51d9f82f4ed07ba4
1 /* WINSOCK.H--definitions to be used with the WINSOCK.DLL
3 * This header file corresponds to version 1.1 of the Windows Sockets
4 * specification.
5 */
7 #ifndef _WINSOCKAPI_
8 #define _WINSOCKAPI_
10 #include <netinet/in.h>
11 #include <arpa/inet.h>
12 #include <sys/types.h>
13 #include <sys/time.h>
14 #include <fcntl.h>
15 #include <netdb.h>
16 #include <sys/socket.h>
18 #ifdef HAVE_IPX_GNU
19 # include <netipx/ipx.h>
20 # define HAVE_IPX
21 #endif
23 #ifdef HAVE_IPX_LINUX
24 # include <asm/types.h>
25 # include <linux/ipx.h>
26 # define HAVE_IPX
27 #endif
29 #include "windows.h"
30 #include "task.h"
32 #pragma pack(1)
34 /* Win16 socket-related types */
36 typedef UINT16 SOCKET16;
37 typedef UINT32 SOCKET32;
39 typedef struct ws_hostent
41 SEGPTR h_name; /* official name of host */
42 SEGPTR h_aliases; /* alias list */
43 INT16 h_addrtype; /* host address type */
44 INT16 h_length; /* length of address */
45 SEGPTR h_addr_list; /* list of addresses from name server */
46 } _ws_hostent;
48 typedef struct ws_protoent
50 SEGPTR p_name; /* official protocol name */
51 SEGPTR p_aliases; /* alias list */
52 INT16 p_proto; /* protocol # */
53 } _ws_protoent;
55 typedef struct ws_servent
57 SEGPTR s_name; /* official service name */
58 SEGPTR s_aliases; /* alias list */
59 INT16 s_port; /* port # */
60 SEGPTR s_proto; /* protocol to use */
61 } _ws_servent;
63 typedef struct ws_netent
65 SEGPTR n_name; /* official name of net */
66 SEGPTR n_aliases; /* alias list */
67 INT16 n_addrtype; /* net address type */
68 INT32 n_net; /* network # */
69 } _ws_netent;
71 typedef struct sockaddr ws_sockaddr;
73 typedef struct
75 UINT16 fd_count; /* how many are SET? */
76 SOCKET16 fd_array[FD_SETSIZE]; /* an array of SOCKETs */
77 } ws_fd_set16;
79 typedef struct
81 UINT32 fd_count; /* how many are SET? */
82 SOCKET32 fd_array[FD_SETSIZE]; /* an array of SOCKETs */
83 } ws_fd_set32;
85 /* ws_fd_set operations */
87 INT16 WINAPI __WSAFDIsSet16( SOCKET16, ws_fd_set16 * );
88 INT32 WINAPI __WSAFDIsSet32( SOCKET32, ws_fd_set32 * );
89 #define __WSAFDIsSet WINELIB_NAME(__WSAFDIsSet);
91 #define __WS_FD_CLR(fd, set, cast) do { \
92 UINT16 __i; \
93 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
94 { \
95 if (((cast*)(set))->fd_array[__i] == fd) \
96 { \
97 while (__i < ((cast*)(set))->fd_count-1) \
98 { \
99 ((cast*)(set))->fd_array[__i] = \
100 ((cast*)(set))->fd_array[__i+1]; \
101 __i++; \
103 ((cast*)(set))->fd_count--; \
104 break; \
107 } while(0)
108 #define WS_FD_CLR16(fd, set) __WS_FD_CLR((fd),(set), ws_fd_set16)
109 #define WS_FD_CLR32(fd, set) __WS_FD_CLR((fd),(set), ws_fd_set32)
110 #define WS_FD_CLR WINELIB_NAME(WS_FD_CLR);
112 #define __WS_FD_SET(fd, set, cast) do { \
113 if (((cast*)(set))->fd_count < FD_SETSIZE) \
114 ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd);\
115 } while(0)
116 #define WS_FD_SET16(fd, set) __WS_FD_SET((fd),(set), ws_fd_set16)
117 #define WS_FD_SET32(fd, set) __WS_FD_SET((fd),(set), ws_fd_set32)
118 #define WS_FD_SET WINELIB_NAME(WS_FD_SET);
120 #define WS_FD_ZERO16(set) (((ws_fd_set16*)(set))->fd_count=0)
121 #define WS_FD_ZERO32(set) (((ws_fd_set32*)(set))->fd_count=0)
122 #define WS_FD_ZERO WINELIB_NAME(WS_FD_ZERO);
124 #define WS_FD_ISSET16(fd, set) __WSAFDIsSet16((SOCKET16)(fd), (ws_fd_set16*)(set))
125 #define WS_FD_ISSET32(fd, set) __WSAFDIsSet32((SOCKET32)(fd), (ws_fd_set32*)(set))
126 #define WS_FD_ISSET WINELIB_NAME(WS_FD_ISSET);
129 * Internet address (old style... should be updated)
132 struct ws_in_addr
134 union {
135 struct { BYTE s_b1,s_b2,s_b3,s_b4; } S_un_b;
136 struct { UINT16 s_w1,s_w2; } S_un_w;
137 UINT32 S_addr;
138 } S_un;
139 #define ws_addr S_un.S_addr /* can be used for most tcp & ip code */
140 #define ws_host S_un.S_un_b.s_b2 /* host on imp */
141 #define ws_net S_un.S_un_b.s_b1 /* network */
142 #define ws_imp S_un.S_un_w.s_w2 /* imp */
143 #define ws_impno S_un.S_un_b.s_b4 /* imp # */
144 #define ws_lh S_un.S_un_b.s_b3 /* logical host */
147 struct ws_sockaddr_in
149 INT16 sin_family;
150 UINT16 sin_port;
151 struct ws_in_addr sin_addr;
152 BYTE sin_zero[8];
155 #define WSADESCRIPTION_LEN 256
156 #define WSASYS_STATUS_LEN 128
158 typedef struct WSAData {
159 WORD wVersion;
160 WORD wHighVersion;
161 char szDescription[WSADESCRIPTION_LEN+1];
162 char szSystemStatus[WSASYS_STATUS_LEN+1];
163 UINT16 iMaxSockets;
164 UINT16 iMaxUdpDg;
165 SEGPTR lpVendorInfo;
166 } WSADATA, *LPWSADATA;
168 #pragma pack(4)
170 /* ----------------------------------- no Win16 structure defs beyond this line! */
173 * This is used instead of -1, since the
174 * SOCKET type is unsigned.
176 #define INVALID_SOCKET16 (~0)
177 #define INVALID_SOCKET32 (~0)
178 #define SOCKET_ERROR (-1)
180 DECL_WINELIB_TYPE(INVALID_SOCKET)
181 DECL_WINELIB_TYPE(SOCKET)
184 * Types
186 #define WS_SOCK_STREAM 1 /* stream socket */
187 #define WS_SOCK_DGRAM 2 /* datagram socket */
188 #define WS_SOCK_RAW 3 /* raw-protocol interface */
189 #define WS_SOCK_RDM 4 /* reliably-delivered message */
190 #define WS_SOCK_SEQPACKET 5 /* sequenced packet stream */
192 #define WS_SOL_SOCKET 0xffff
193 #define WS_IPPROTO_TCP 6
196 * Option flags per-socket.
198 #define WS_SO_DEBUG 0x0001 /* turn on debugging info recording */
199 #define WS_SO_ACCEPTCONN 0x0002 /* socket has had listen() */
200 #define WS_SO_REUSEADDR 0x0004 /* allow local address reuse */
201 #define WS_SO_KEEPALIVE 0x0008 /* keep connections alive */
202 #define WS_SO_DONTROUTE 0x0010 /* just use interface addresses */
203 #define WS_SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
204 #define WS_SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
205 #define WS_SO_LINGER 0x0080 /* linger on close if data present */
206 #define WS_SO_OOBINLINE 0x0100 /* leave received OOB data in line */
208 #define WS_SO_DONTLINGER (UINT32)(~WS_SO_LINGER)
211 * Additional options.
213 #define WS_SO_SNDBUF 0x1001 /* send buffer size */
214 #define WS_SO_RCVBUF 0x1002 /* receive buffer size */
215 #define WS_SO_SNDLOWAT 0x1003 /* send low-water mark */
216 #define WS_SO_RCVLOWAT 0x1004 /* receive low-water mark */
217 #define WS_SO_SNDTIMEO 0x1005 /* send timeout */
218 #define WS_SO_RCVTIMEO 0x1006 /* receive timeout */
219 #define WS_SO_ERROR 0x1007 /* get error status and clear */
220 #define WS_SO_TYPE 0x1008 /* get socket type */
222 #define WS_IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
223 #define WS_IOC_VOID 0x20000000 /* no parameters */
224 #define WS_IOC_OUT 0x40000000 /* copy out parameters */
225 #define WS_IOC_IN 0x80000000 /* copy in parameters */
226 #define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
227 #define WS_IOR(x,y,t) (WS_IOC_OUT|(((UINT32)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
228 #define WS_IOW(x,y,t) (WS_IOC_IN|(((UINT32)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
231 * Socket I/O flags (supported by spec 1.1)
234 #define WS_FIONREAD WS_IOR('f', 127, u_long)
235 #define WS_FIONBIO WS_IOW('f', 126, u_long)
237 #define WS_SIOCATMARK WS_IOR('s', 7, u_long)
240 * Maximum queue length specifiable by listen.
242 #ifdef SOMAXCONN
243 #undef SOMAXCONN
244 #endif
245 #define SOMAXCONN 5
247 #ifndef MSG_DONTROUTE
248 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
249 #endif
250 #define MSG_MAXIOVLEN 16
253 * Define constant based on rfc883, used by gethostbyxxxx() calls.
255 #define MAXGETHOSTSTRUCT 1024
258 * Define flags to be used with the WSAAsyncSelect() call.
260 #define WS_FD_READ 0x0001
261 #define WS_FD_WRITE 0x0002
262 #define WS_FD_OOB 0x0004
263 #define WS_FD_ACCEPT 0x0008
264 #define WS_FD_CONNECT 0x0010
265 #define WS_FD_CLOSE 0x0020
267 #define WS_FD_LISTENING 0x10000000 /* internal per-socket flags */
268 #define WS_FD_INACTIVE 0x20000000
269 #define WS_FD_CONNECTED 0x40000000
270 #define WS_FD_RAW 0x80000000
271 #define WS_FD_INTERNAL 0xFFFF0000
274 * All Windows Sockets error constants are biased by WSABASEERR from
275 * the "normal"
277 #define WSABASEERR 10000
279 * Windows Sockets definitions of regular Microsoft C error constants
281 #define WSAEINTR (WSABASEERR+4)
282 #define WSAEBADF (WSABASEERR+9)
283 #define WSAEACCES (WSABASEERR+13)
284 #define WSAEFAULT (WSABASEERR+14)
285 #define WSAEINVAL (WSABASEERR+22)
286 #define WSAEMFILE (WSABASEERR+24)
289 * Windows Sockets definitions of regular Berkeley error constants
291 #define WSAEWOULDBLOCK (WSABASEERR+35)
292 #define WSAEINPROGRESS (WSABASEERR+36)
293 #define WSAEALREADY (WSABASEERR+37)
294 #define WSAENOTSOCK (WSABASEERR+38)
295 #define WSAEDESTADDRREQ (WSABASEERR+39)
296 #define WSAEMSGSIZE (WSABASEERR+40)
297 #define WSAEPROTOTYPE (WSABASEERR+41)
298 #define WSAENOPROTOOPT (WSABASEERR+42)
299 #define WSAEPROTONOSUPPORT (WSABASEERR+43)
300 #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
301 #define WSAEOPNOTSUPP (WSABASEERR+45)
302 #define WSAEPFNOSUPPORT (WSABASEERR+46)
303 #define WSAEAFNOSUPPORT (WSABASEERR+47)
304 #define WSAEADDRINUSE (WSABASEERR+48)
305 #define WSAEADDRNOTAVAIL (WSABASEERR+49)
306 #define WSAENETDOWN (WSABASEERR+50)
307 #define WSAENETUNREACH (WSABASEERR+51)
308 #define WSAENETRESET (WSABASEERR+52)
309 #define WSAECONNABORTED (WSABASEERR+53)
310 #define WSAECONNRESET (WSABASEERR+54)
311 #define WSAENOBUFS (WSABASEERR+55)
312 #define WSAEISCONN (WSABASEERR+56)
313 #define WSAENOTCONN (WSABASEERR+57)
314 #define WSAESHUTDOWN (WSABASEERR+58)
315 #define WSAETOOMANYREFS (WSABASEERR+59)
316 #define WSAETIMEDOUT (WSABASEERR+60)
317 #define WSAECONNREFUSED (WSABASEERR+61)
318 #define WSAELOOP (WSABASEERR+62)
319 #define WSAENAMETOOLONG (WSABASEERR+63)
320 #define WSAEHOSTDOWN (WSABASEERR+64)
321 #define WSAEHOSTUNREACH (WSABASEERR+65)
322 #define WSAENOTEMPTY (WSABASEERR+66)
323 #define WSAEPROCLIM (WSABASEERR+67)
324 #define WSAEUSERS (WSABASEERR+68)
325 #define WSAEDQUOT (WSABASEERR+69)
326 #define WSAESTALE (WSABASEERR+70)
327 #define WSAEREMOTE (WSABASEERR+71)
330 * Extended Windows Sockets error constant definitions
332 #define WSASYSNOTREADY (WSABASEERR+91)
333 #define WSAVERNOTSUPPORTED (WSABASEERR+92)
334 #define WSANOTINITIALISED (WSABASEERR+93)
337 * Error return codes from gethostbyname() and gethostbyaddr()
338 * (when using the resolver). Note that these errors are
339 * retrieved via WSAGetLastError() and must therefore follow
340 * the rules for avoiding clashes with error numbers from
341 * specific implementations or language run-time systems.
342 * For this reason the codes are based at WSABASEERR+1001.
343 * Note also that [WSA]NO_ADDRESS is defined only for
344 * compatibility purposes.
347 /* #define h_errno WSAGetLastError() */
349 /* Authoritative Answer: Host not found */
350 #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
352 /* Non-Authoritative: Host not found, or SERVERFAIL */
353 #define WSATRY_AGAIN (WSABASEERR+1002)
355 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
356 #define WSANO_RECOVERY (WSABASEERR+1003)
358 /* Valid name, no data record of requested type */
359 #define WSANO_DATA (WSABASEERR+1004)
361 /* no address, look for MX record */
362 #define WSANO_ADDRESS WSANO_DATA
364 /* Socket function prototypes */
366 #ifdef __cplusplus
367 extern "C" {
368 #endif
370 /* Microsoft Windows Extension function prototypes */
372 INT16 WINAPI WSAStartup16(UINT16 wVersionRequired, LPWSADATA lpWSAData);
373 INT32 WINAPI WSAStartup32(UINT32 wVersionRequired, LPWSADATA lpWSAData);
374 #define WSAStartup WINELIB_NAME(WSAStartup);
375 void WINAPI WSASetLastError16(INT16 iError);
376 void WINAPI WSASetLastError32(INT32 iError);
377 #define WSASetLastError WINELIB_NAME(WSASetLastError);
378 INT32 WINAPI WSACleanup(void);
379 INT32 WINAPI WSAGetLastError(void);
380 BOOL32 WINAPI WSAIsBlocking(void);
381 INT32 WINAPI WSACancelBlockingCall(void);
382 INT16 WINAPI WSAUnhookBlockingHook16(void);
383 INT32 WINAPI WSAUnhookBlockingHook32(void);
384 #define WSAUnhookBlockingHook WINELIB_NAME(WSAUnhookBlockingHook)
385 FARPROC16 WINAPI WSASetBlockingHook16(FARPROC16 lpBlockFunc);
386 FARPROC32 WINAPI WSASetBlockingHook32(FARPROC32 lpBlockFunc);
387 #define WSASetBlockingHook WINELIB_NAME(WSASetBlockingHook)
389 HANDLE16 WINAPI WSAAsyncGetServByName16(HWND16 hWnd, UINT16 wMsg, LPCSTR name, LPCSTR proto,
390 SEGPTR buf, INT16 buflen);
391 HANDLE32 WINAPI WSAAsyncGetServByName32(HWND32 hWnd, UINT32 uMsg, LPCSTR name, LPCSTR proto,
392 LPSTR sbuf, INT32 buflen);
393 #define WSAAsyncGetServByName WINELIB_NAME(WSAAsyncGetServByName)
395 HANDLE16 WINAPI WSAAsyncGetServByPort16(HWND16 hWnd, UINT16 wMsg, INT16 port,
396 LPCSTR proto, SEGPTR buf, INT16 buflen);
397 HANDLE32 WINAPI WSAAsyncGetServByPort32(HWND32 hWnd, UINT32 uMsg, INT32 port,
398 LPCSTR proto, LPSTR sbuf, INT32 buflen);
399 #define WSAAsyncGetServByPort WINELIB_NAME(WSAAsyncGetServByPort)
401 HANDLE16 WINAPI WSAAsyncGetProtoByName16(HWND16 hWnd, UINT16 wMsg,
402 LPCSTR name, SEGPTR buf, INT16 buflen);
403 HANDLE32 WINAPI WSAAsyncGetProtoByName32(HWND32 hWnd, UINT32 uMsg,
404 LPCSTR name, LPSTR sbuf, INT32 buflen);
405 #define WSAAsyncGetProtoByByName WINELIB_NAME(WSAAsyncGetProtoByByName)
407 HANDLE16 WINAPI WSAAsyncGetProtoByNumber16(HWND16 hWnd, UINT16 wMsg,
408 INT16 number, SEGPTR buf, INT16 buflen);
409 HANDLE32 WINAPI WSAAsyncGetProtoByNumber32(HWND32 hWnd, UINT32 uMsg,
410 INT32 number, LPSTR sbuf, INT32 buflen);
411 #define WSAAsyncGetProtoByNumber WINELIB_NAME(WSAAsyncGetProtoByNumber)
413 HANDLE16 WINAPI WSAAsyncGetHostByName16(HWND16 hWnd, UINT16 wMsg,
414 LPCSTR name, SEGPTR buf, INT16 buflen);
415 HANDLE32 WINAPI WSAAsyncGetHostByName32(HWND32 hWnd, UINT32 uMsg,
416 LPCSTR name, LPSTR sbuf, INT32 buflen);
417 #define WSAAsyncGetHostByName WINELIB_NAME(WSAAsyncGetHostByName)
419 HANDLE16 WINAPI WSAAsyncGetHostByAddr16(HWND16 hWnd, UINT16 wMsg, LPCSTR addr,
420 INT16 len, INT16 type, SEGPTR buf, INT16 buflen);
421 HANDLE32 WINAPI WSAAsyncGetHostByAddr32(HWND32 hWnd, UINT32 uMsg, LPCSTR addr,
422 INT32 len, INT32 type, LPSTR sbuf, INT32 buflen);
423 #define WSAAsyncGetHostByAddr WINELIB_NAME(WSAAsyncGetHostByAddr)
425 INT16 WINAPI WSACancelAsyncRequest16(HANDLE16 hAsyncTaskHandle);
426 INT32 WINAPI WSACancelAsyncRequest32(HANDLE32 hAsyncTaskHandle);
427 #define WSACancelAsyncRequest WINELIB_NAME(WSACancelAsyncRequest)
429 INT16 WINAPI WSAAsyncSelect16(SOCKET16 s, HWND16 hWnd, UINT16 wMsg, UINT32 lEvent);
430 INT32 WINAPI WSAAsyncSelect32(SOCKET32 s, HWND32 hWnd, UINT32 uMsg, UINT32 lEvent);
431 #define WSAAsyncSelect WINELIB_NAME(WSAAsyncSelect)
435 * Address families
437 #define WS_AF_UNSPEC 0 /* unspecified */
438 #define WS_AF_UNIX 1 /* local to host (pipes, portals) */
439 #define WS_AF_INET 2 /* internetwork: UDP, TCP, etc. */
440 #define WS_AF_IMPLINK 3 /* arpanet imp addresses */
441 #define WS_AF_PUP 4 /* pup protocols: e.g. BSP */
442 #define WS_AF_CHAOS 5 /* mit CHAOS protocols */
443 #define WS_AF_NS 6 /* XEROX NS protocols */
444 #define WS_AF_IPX WS_AF_NS /* IPX protocols: IPX, SPX, etc. */
445 #define WS_AF_ISO 7 /* ISO protocols */
446 #define WS_AF_OSI AF_ISO /* OSI is ISO */
447 #define WS_AF_ECMA 8 /* european computer manufacturers */
448 #define WS_AF_DATAKIT 9 /* datakit protocols */
449 #define WS_AF_CCITT 10 /* CCITT protocols, X.25 etc */
450 #define WS_AF_SNA 11 /* IBM SNA */
451 #define WS_AF_DECnet 12 /* DECnet */
452 #define WS_AF_DLI 13 /* Direct data link interface */
453 #define WS_AF_LAT 14 /* LAT */
454 #define WS_AF_HYLINK 15 /* NSC Hyperchannel */
455 #define WS_AF_APPLETALK 16 /* AppleTalk */
456 #define WS_AF_NETBIOS 17 /* NetBios-style addresses */
457 #define WS_AF_VOICEVIEW 18 /* VoiceView */
458 #define WS_AF_FIREFOX 19 /* Protocols from Firefox */
459 #define WS_AF_UNKNOWN1 20 /* Somebody is using this! */
460 #define WS_AF_BAN 21 /* Banyan */
461 #define WS_AF_ATM 22 /* Native ATM Services */
462 #define WS_AF_INET6 23 /* Internetwork Version 6 */
463 #define WS_AF_CLUSTER 24 /* Microsoft Wolfpack */
464 #define WS_AF_12844 25 /* IEEE 1284.4 WG AF */
465 #define WS_AF_IRDA 26 /* IrDA */
467 #define WS_AF_MAX 27
469 struct ws_sockaddr_ipx
471 INT16 sipx_family __attribute__((packed));
472 UINT32 sipx_network __attribute__((packed));
473 CHAR sipx_node[6] __attribute__((packed));
474 UINT16 sipx_port __attribute__((packed));
477 #ifdef __cplusplus
479 #endif
481 /* Microsoft Windows Extended data types */
482 typedef struct sockaddr SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
483 typedef struct sockaddr_in SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
484 typedef struct linger LINGER, *PLINGER, *LPLINGER;
485 typedef struct in_addr IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
486 typedef struct fd_set FD_SET, *PFD_SET, *LPFD_SET;
487 typedef struct hostent HOSTENT, *PHOSTENT, *LPHOSTENT;
488 typedef struct servent SERVENT, *PSERVENT, *LPSERVENT;
489 typedef struct protoent PROTOENT, *PPROTOENT, *LPPROTOENT;
490 typedef struct timeval TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
493 * Windows message parameter composition and decomposition
494 * macros.
496 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
497 * when constructing the response to a WSAAsyncGetXByY() routine.
499 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
501 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
502 * when constructing the response to WSAAsyncSelect().
504 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
506 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
507 * to extract the buffer length from the lParam in the response
508 * to a WSAGetXByY().
510 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
512 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
513 * to extract the error code from the lParam in the response
514 * to a WSAGetXByY().
516 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
518 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
519 * to extract the event code from the lParam in the response
520 * to a WSAAsyncSelect().
522 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
524 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
525 * to extract the error code from the lParam in the response
526 * to a WSAAsyncSelect().
528 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
530 /* ----------------------------------- internal structures */
532 /* ws_... struct conversion flags */
534 #define WS_DUP_LINEAR 0x0001
535 #define WS_DUP_NATIVE 0x0000 /* not used anymore */
536 #define WS_DUP_OFFSET 0x0002 /* internal pointers are offsets */
537 #define WS_DUP_SEGPTR 0x0004 /* internal pointers are SEGPTRs */
538 /* by default, internal pointers are linear */
539 /* async DNS op flags */
541 #define AOP_IO 0x0000001 /* aop_control paramaters */
543 #define AOP_CONTROL_REMOVE 0x0000000 /* aop_control return values */
544 #define AOP_CONTROL_KEEP 0x0000001
546 typedef struct __aop
548 /* AOp header */
550 struct __aop *next, *prev;
551 int fd[2]; /* pipe */
552 int (*aop_control)(struct __aop*, int); /* SIGIO handler */
553 pid_t pid; /* child process pid */
555 /* custom data */
557 HWND32 hWnd; /* hWnd to post */
558 UINT32 uMsg; /* uMsg message to. */
560 union
562 SEGPTR seg_base;
563 LPSTR lin_base;
564 void* ptr_base;
565 } b; /* buffer to copy result to */
567 UINT32 buflen;
568 UINT32 flags; /* WSMSG_ASYNC_... */
569 } ws_async_op;
571 #define WSMSG_ASYNC_HOSTBYNAME 0x0001
572 #define WSMSG_ASYNC_HOSTBYADDR 0x0002
573 #define WSMSG_ASYNC_PROTOBYNAME 0x0010
574 #define WSMSG_ASYNC_PROTOBYNUM 0x0020
575 #define WSMSG_ASYNC_SERVBYNAME 0x0100
576 #define WSMSG_ASYNC_SERVBYPORT 0x0200
577 #define WSMSG_ASYNC_RQMASK 0x0fff
579 #define WSMSG_WIN32_AOP 0x1000
580 #define WSMSG_DEAD_AOP 0x8000
582 typedef struct __sop /* WSAAsyncSelect() control struct */
584 struct __sop *next, *prev;
586 struct __ws* pws;
587 HWND32 hWnd;
588 UINT32 uMsg;
589 } ws_select_op;
591 typedef struct __ws /* socket */
593 int fd;
594 unsigned flags;
595 ws_select_op* psop;
596 } ws_socket;
598 #define WS_MAX_SOCKETS_PER_PROCESS 16
599 #define WS_MAX_UDP_DATAGRAM 1024
601 #define WSI_BLOCKINGCALL 0x00000001 /* per-thread info flags */
602 #define WSI_BLOCKINGHOOK32 0x00000002 /* 32-bit callback */
604 typedef struct _WSINFO
606 struct _WSINFO* prev,*next;
608 unsigned flags;
609 INT32 err; /* WSAGetLastError() return value */
610 INT16 num_startup; /* reference counter */
611 INT16 num_async_rq;
612 INT16 last_free; /* entry in the socket table */
613 UINT16 buflen;
614 char* buffer; /* allocated from SEGPTR heap */
615 struct ws_hostent *he;
616 int helen;
617 struct ws_servent *se;
618 int selen;
619 struct ws_protoent *pe;
620 int pelen;
621 char* dbuffer; /* buffer for dummies (32 bytes) */
623 ws_socket sock[WS_MAX_SOCKETS_PER_PROCESS];
624 DWORD blocking_hook;
625 HTASK16 tid; /* owning task id - process might be better */
626 } WSINFO, *LPWSINFO;
628 /* function prototypes */
629 int WS_dup_he(LPWSINFO pwsi, struct hostent* p_he, int flag);
630 int WS_dup_pe(LPWSINFO pwsi, struct protoent* p_pe, int flag);
631 int WS_dup_se(LPWSINFO pwsi, struct servent* p_se, int flag);
633 void WS_do_async_gethost(LPWSINFO, unsigned);
634 void WS_do_async_getproto(LPWSINFO, unsigned);
635 void WS_do_async_getserv(LPWSINFO, unsigned);
637 /* winsock_dns.c */
638 extern HANDLE16 __WSAsyncDBQuery(LPWSINFO pwsi, HWND32 hWnd, UINT32 uMsg,
639 INT32 type, LPCSTR init, INT32 len, LPCSTR proto, void* sbuf,
640 INT32 buflen, UINT32 flag);
642 int WINSOCK_async_io(int fd, int async);
643 int WINSOCK_unblock_io(int fd, int noblock);
645 int WINSOCK_check_async_op(ws_async_op* p_aop);
646 void WINSOCK_link_async_op(ws_async_op* p_aop);
647 void WINSOCK_unlink_async_op(ws_async_op* p_aop);
648 int WINSOCK_cancel_async_op(ws_async_op* p_aop);
650 void WINSOCK_cancel_task_aops(HTASK16, void (*__memfree)(void*) );
652 BOOL32 WINSOCK_HandleIO(int* fd_max, int num_pending, fd_set pending_set[3], fd_set master_set[3] );
653 void WINSOCK_Shutdown(void);
654 UINT16 wsaErrno(void);
655 UINT16 wsaHerrno(void);
657 extern INT32 WINSOCK_DeleteTaskWSI( TDB* pTask, struct _WSINFO* );
659 #endif /* _WINSOCKAPI_ */