Added advapi32 to imported DLLs list.
[wine/wine-kai.git] / include / winsock.h
blob101d1200e9f05af3a5d3f6910797e304df16795b
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 #ifndef RC_INVOKED
11 #include <sys/types.h>
13 /* Solaris uses these macro names */
14 #undef FSHIFT
15 #undef TRANSPARENT
16 #include <netinet/in.h>
17 /* Restore the Windows values */
18 #ifdef _WINUSER_
19 #undef FSHIFT
20 #define FSHIFT 0x04
21 #endif
22 #ifdef _WINGDI_
23 #undef TRANSPARENT
24 #define TRANSPARENT 1
25 #endif
27 #include <arpa/inet.h>
28 #include <sys/time.h>
29 #include <fcntl.h>
30 #include <netdb.h>
31 #include <sys/socket.h>
32 #include <sys/ioctl.h>
33 #endif /* RC_INVOKED */
35 #include "windef.h"
37 #ifdef __cplusplus
38 extern "C" {
39 #endif /* defined(__cplusplus) */
41 /* no "forced" alignment of ws_XXXXent here ! */
43 typedef struct ws_hostent
45 char *h_name; /* official name of host */
46 char **h_aliases; /* alias list */
47 short h_addrtype; /* host address type */
48 short h_length; /* length of address */
49 char **h_addr_list; /* list of addresses from name server */
50 } _ws_hostent;
52 typedef struct ws_protoent
54 char *p_name; /* official protocol name */
55 char **p_aliases; /* alias list */
56 short p_proto; /* protocol # */
57 } _ws_protoent;
59 typedef struct ws_servent
61 char *s_name; /* official service name */
62 char **s_aliases; /* alias list */
63 short s_port; /* port # */
64 char *s_proto; /* protocol to use */
65 } _ws_servent;
67 typedef struct ws_netent
69 char *n_name; /* official name of net */
70 char **n_aliases; /* alias list */
71 short n_addrtype; /* net address type */
72 u_long n_net; /* network # */
73 } _ws_netent;
75 #include "pshpack1.h"
77 typedef UINT SOCKET;
79 typedef struct sockaddr ws_sockaddr;
81 typedef struct ws_fd_set32_struct
83 UINT fd_count; /* how many are SET? */
84 SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
85 } ws_fd_set32;
88 /* ws_fd_set operations */
90 INT WINAPI __WSAFDIsSet( SOCKET, ws_fd_set32 * );
92 #define __WS_FD_CLR(fd, set, cast) do { \
93 UINT __i; \
94 for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \
95 { \
96 if (((cast*)(set))->fd_array[__i] == fd) \
97 { \
98 while (__i < ((cast*)(set))->fd_count-1) \
99 { \
100 ((cast*)(set))->fd_array[__i] = \
101 ((cast*)(set))->fd_array[__i+1]; \
102 __i++; \
104 ((cast*)(set))->fd_count--; \
105 break; \
108 } while(0)
109 #define WS_FD_CLR(fd, set) __WS_FD_CLR((fd),(set), ws_fd_set32)
111 #define __WS_FD_SET(fd, set, cast) do { \
112 if (((cast*)(set))->fd_count < FD_SETSIZE) \
113 ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd);\
114 } while(0)
115 #define WS_FD_SET(fd, set) __WS_FD_SET((fd),(set), ws_fd_set32)
116 #define WS_FD_ZERO(set) (((ws_fd_set32*)(set))->fd_count=0)
117 #define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (ws_fd_set32*)(set))
120 * Internet address (old style... should be updated)
123 struct ws_in_addr
125 union {
126 struct { BYTE s_b1,s_b2,s_b3,s_b4; } S_un_b;
127 struct { WORD s_w1,s_w2; } S_un_w;
128 UINT S_addr;
129 } S_un;
130 #define ws_addr S_un.S_addr /* can be used for most tcp & ip code */
131 #define ws_host S_un.S_un_b.s_b2 /* host on imp */
132 #define ws_net S_un.S_un_b.s_b1 /* network */
133 #define ws_imp S_un.S_un_w.s_w2 /* imp */
134 #define ws_impno S_un.S_un_b.s_b4 /* imp # */
135 #define ws_lh S_un.S_un_b.s_b3 /* logical host */
138 struct ws_sockaddr_in
140 SHORT sin_family;
141 WORD sin_port;
142 struct ws_in_addr sin_addr;
143 BYTE sin_zero[8];
146 #define WSADESCRIPTION_LEN 256
147 #define WSASYS_STATUS_LEN 128
149 typedef struct WSAData {
150 WORD wVersion;
151 WORD wHighVersion;
152 char szDescription[WSADESCRIPTION_LEN+1];
153 char szSystemStatus[WSASYS_STATUS_LEN+1];
154 WORD iMaxSockets;
155 WORD iMaxUdpDg;
156 SEGPTR lpVendorInfo;
157 } WSADATA, *LPWSADATA;
159 #include "poppack.h"
162 * This is used instead of -1, since the
163 * SOCKET type is unsigned.
165 #define INVALID_SOCKET (~0)
166 #define SOCKET_ERROR (-1)
170 * Types
172 #define WS_SOCK_STREAM 1 /* stream socket */
173 #define WS_SOCK_DGRAM 2 /* datagram socket */
174 #define WS_SOCK_RAW 3 /* raw-protocol interface */
175 #define WS_SOCK_RDM 4 /* reliably-delivered message */
176 #define WS_SOCK_SEQPACKET 5 /* sequenced packet stream */
178 #define WS_SOL_SOCKET 0xffff
179 #define WS_IPPROTO_TCP 6
182 * Option flags per-socket.
184 #define WS_SO_DEBUG 0x0001 /* turn on debugging info recording */
185 #define WS_SO_ACCEPTCONN 0x0002 /* socket has had listen() */
186 #define WS_SO_REUSEADDR 0x0004 /* allow local address reuse */
187 #define WS_SO_KEEPALIVE 0x0008 /* keep connections alive */
188 #define WS_SO_DONTROUTE 0x0010 /* just use interface addresses */
189 #define WS_SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
190 #define WS_SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
191 #define WS_SO_LINGER 0x0080 /* linger on close if data present */
192 #define WS_SO_OOBINLINE 0x0100 /* leave received OOB data in line */
194 #define WS_SO_DONTLINGER (UINT)(~WS_SO_LINGER)
197 * Additional options.
199 #define WS_SO_SNDBUF 0x1001 /* send buffer size */
200 #define WS_SO_RCVBUF 0x1002 /* receive buffer size */
201 #define WS_SO_SNDLOWAT 0x1003 /* send low-water mark */
202 #define WS_SO_RCVLOWAT 0x1004 /* receive low-water mark */
203 #define WS_SO_SNDTIMEO 0x1005 /* send timeout */
204 #define WS_SO_RCVTIMEO 0x1006 /* receive timeout */
205 #define WS_SO_ERROR 0x1007 /* get error status and clear */
206 #define WS_SO_TYPE 0x1008 /* get socket type */
208 #define WS_IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
209 #define WS_IOC_VOID 0x20000000 /* no parameters */
210 #define WS_IOC_OUT 0x40000000 /* copy out parameters */
211 #define WS_IOC_IN 0x80000000 /* copy in parameters */
212 #define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT)
213 #define WS_IOR(x,y,t) (WS_IOC_OUT|(((UINT)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
214 #define WS_IOW(x,y,t) (WS_IOC_IN|(((UINT)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y))
216 /* IPPROTO_TCP options */
217 #define WS_TCP_NODELAY 1 /* do not apply nagle algorithm */
220 * Socket I/O flags (supported by spec 1.1)
223 #define WS_FIONREAD WS_IOR('f', 127, u_long)
224 #define WS_FIONBIO WS_IOW('f', 126, u_long)
226 #define WS_SIOCATMARK WS_IOR('s', 7, u_long)
229 * Maximum queue length specifiable by listen.
231 #ifdef SOMAXCONN
232 #undef SOMAXCONN
233 #endif
234 #define SOMAXCONN 5
236 #ifndef MSG_DONTROUTE
237 #define MSG_DONTROUTE 0x4 /* send without using routing tables */
238 #endif
239 #define MSG_MAXIOVLEN 16
241 #ifndef MSG_PARTIAL
242 #define MSG_PARTIAL 0x8000 /* partial send or recv (WSARecvEx) */
243 #endif
246 * Define constant based on rfc883, used by gethostbyxxxx() calls.
248 #define MAXGETHOSTSTRUCT 1024
251 * Define flags to be used with the WSAAsyncSelect() call.
253 #define FD_READ WS_FD_READ
254 #define FD_WRITE WS_FD_WRITE
255 #define FD_OOB WS_FD_OOB
256 #define FD_ACCEPT WS_FD_ACCEPT
257 #define FD_CONNECT WS_FD_CONNECT
258 #define FD_CLOSE WS_FD_CLOSE
259 #define WS_FD_READ 0x0001
260 #define WS_FD_WRITE 0x0002
261 #define WS_FD_OOB 0x0004
262 #define WS_FD_ACCEPT 0x0008
263 #define WS_FD_CONNECT 0x0010
264 #define WS_FD_CLOSE 0x0020
266 #define WS_FD_LISTENING 0x10000000 /* internal per-socket flags */
267 #define WS_FD_NONBLOCKING 0x20000000
268 #define WS_FD_CONNECTED 0x40000000
269 #define WS_FD_RAW 0x80000000
270 #define WS_FD_SERVEVENT 0x01000000
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 INT WINAPI WSAStartup(UINT wVersionRequired, LPWSADATA lpWSAData);
373 void WINAPI WSASetLastError(INT iError);
374 INT WINAPI WSACleanup(void);
375 INT WINAPI WSAGetLastError(void);
376 BOOL WINAPI WSAIsBlocking(void);
377 INT WINAPI WSACancelBlockingCall(void);
378 INT WINAPI WSAUnhookBlockingHook(void);
379 FARPROC WINAPI WSASetBlockingHook(FARPROC lpBlockFunc);
380 HANDLE WINAPI WSAAsyncGetServByName(HWND hWnd, UINT uMsg, LPCSTR name, LPCSTR proto,
381 LPSTR sbuf, INT buflen);
382 HANDLE WINAPI WSAAsyncGetServByPort(HWND hWnd, UINT uMsg, INT port,
383 LPCSTR proto, LPSTR sbuf, INT buflen);
384 HANDLE WINAPI WSAAsyncGetProtoByName(HWND hWnd, UINT uMsg,
385 LPCSTR name, LPSTR sbuf, INT buflen);
386 HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND hWnd, UINT uMsg,
387 INT number, LPSTR sbuf, INT buflen);
388 HANDLE WINAPI WSAAsyncGetHostByName(HWND hWnd, UINT uMsg,
389 LPCSTR name, LPSTR sbuf, INT buflen);
390 HANDLE WINAPI WSAAsyncGetHostByAddr(HWND hWnd, UINT uMsg, LPCSTR addr,
391 INT len, INT type, LPSTR sbuf, INT buflen);
392 INT WINAPI WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
393 INT WINAPI WSAAsyncSelect(SOCKET s, HWND hWnd, UINT uMsg, LONG lEvent);
394 INT WINAPI WSARecvEx(SOCKET s, char *buf, INT len, INT *flags);
397 * Address families
399 #define WS_AF_UNSPEC 0 /* unspecified */
400 #define WS_AF_UNIX 1 /* local to host (pipes, portals) */
401 #define WS_AF_INET 2 /* internetwork: UDP, TCP, etc. */
402 #define WS_AF_IMPLINK 3 /* arpanet imp addresses */
403 #define WS_AF_PUP 4 /* pup protocols: e.g. BSP */
404 #define WS_AF_CHAOS 5 /* mit CHAOS protocols */
405 #define WS_AF_NS 6 /* XEROX NS protocols */
406 #define WS_AF_IPX WS_AF_NS /* IPX protocols: IPX, SPX, etc. */
407 #define WS_AF_ISO 7 /* ISO protocols */
408 #define WS_AF_OSI AF_ISO /* OSI is ISO */
409 #define WS_AF_ECMA 8 /* european computer manufacturers */
410 #define WS_AF_DATAKIT 9 /* datakit protocols */
411 #define WS_AF_CCITT 10 /* CCITT protocols, X.25 etc */
412 #define WS_AF_SNA 11 /* IBM SNA */
413 #define WS_AF_DECnet 12 /* DECnet */
414 #define WS_AF_DLI 13 /* Direct data link interface */
415 #define WS_AF_LAT 14 /* LAT */
416 #define WS_AF_HYLINK 15 /* NSC Hyperchannel */
417 #define WS_AF_APPLETALK 16 /* AppleTalk */
418 #define WS_AF_NETBIOS 17 /* NetBios-style addresses */
419 #define WS_AF_VOICEVIEW 18 /* VoiceView */
420 #define WS_AF_FIREFOX 19 /* Protocols from Firefox */
421 #define WS_AF_UNKNOWN1 20 /* Somebody is using this! */
422 #define WS_AF_BAN 21 /* Banyan */
423 #define WS_AF_ATM 22 /* Native ATM Services */
424 #define WS_AF_INET6 23 /* Internetwork Version 6 */
425 #define WS_AF_CLUSTER 24 /* Microsoft Wolfpack */
426 #define WS_AF_12844 25 /* IEEE 1284.4 WG AF */
427 #define WS_AF_IRDA 26 /* IrDA */
429 #define WS_AF_MAX 27
431 #include "pshpack1.h"
433 struct ws_sockaddr_ipx
435 SHORT sipx_family;
436 UINT sipx_network;
437 CHAR sipx_node[6];
438 WORD sipx_port;
441 #include "poppack.h"
443 #ifdef __cplusplus
445 #endif
447 /* Microsoft Windows Extended data types */
448 typedef struct sockaddr SOCKADDR, *PSOCKADDR, *LPSOCKADDR;
449 typedef struct sockaddr_in SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN;
450 typedef struct linger LINGER, *PLINGER, *LPLINGER;
451 typedef struct in_addr IN_ADDR, *PIN_ADDR, *LPIN_ADDR;
452 typedef struct ws_fd_set32_struct FD_SET, *PFD_SET, *LPFD_SET;
453 typedef struct hostent HOSTENT, *PHOSTENT, *LPHOSTENT;
454 typedef struct servent SERVENT, *PSERVENT, *LPSERVENT;
455 typedef struct protoent PROTOENT, *PPROTOENT, *LPPROTOENT;
456 typedef struct timeval TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
459 * Windows message parameter composition and decomposition
460 * macros.
462 * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
463 * when constructing the response to a WSAAsyncGetXByY() routine.
465 #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
467 * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
468 * when constructing the response to WSAAsyncSelect().
470 #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
472 * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
473 * to extract the buffer length from the lParam in the response
474 * to a WSAGetXByY().
476 #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
478 * WSAGETASYNCERROR is intended for use by the Windows Sockets application
479 * to extract the error code from the lParam in the response
480 * to a WSAGetXByY().
482 #define WSAGETASYNCERROR(lParam) HIWORD(lParam)
484 * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
485 * to extract the event code from the lParam in the response
486 * to a WSAAsyncSelect().
488 #define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
490 * WSAGETSELECTERROR is intended for use by the Windows Sockets application
491 * to extract the error code from the lParam in the response
492 * to a WSAAsyncSelect().
494 #define WSAGETSELECTERROR(lParam) HIWORD(lParam)
496 #ifdef __cplusplus
497 } /* extern "C" */
498 #endif /* defined(__cplusplus) */
500 #endif /* _WINSOCKAPI_ */