Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 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 | |
| 7 | #ifndef _WINSOCKAPI_ |
| 8 | #define _WINSOCKAPI_ |
| 9 | |
Bang Jun-Young | 544f711 | 2000-05-03 18:08:27 +0000 | [diff] [blame] | 10 | #include <sys/types.h> |
| 11 | |
Patrik Stridvall | 1ed4ecf | 1999-06-26 14:58:24 +0000 | [diff] [blame] | 12 | /* Solaris kludge */ |
| 13 | #undef FSHIFT |
| 14 | #undef PAGESIZE |
| 15 | #undef TRANSPARENT |
Alexandre Julliard | 7d654eb | 1996-02-25 11:36:22 +0000 | [diff] [blame] | 16 | #include <netinet/in.h> |
Patrik Stridvall | 1ed4ecf | 1999-06-26 14:58:24 +0000 | [diff] [blame] | 17 | #undef FSHIFT |
| 18 | #undef PAGESIZE |
| 19 | #undef TRANSPARENT |
| 20 | |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 21 | #include <arpa/inet.h> |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 22 | #include <sys/time.h> |
| 23 | #include <fcntl.h> |
| 24 | #include <netdb.h> |
Pavel Roskin | 94d9964 | 1998-12-26 11:52:51 +0000 | [diff] [blame] | 25 | #include <sys/socket.h> |
| 26 | |
| 27 | #ifdef HAVE_IPX_GNU |
| 28 | # include <netipx/ipx.h> |
| 29 | # define HAVE_IPX |
| 30 | #endif |
| 31 | |
| 32 | #ifdef HAVE_IPX_LINUX |
Stephen Langasek | dc16342 | 1998-11-08 15:42:40 +0000 | [diff] [blame] | 33 | # include <asm/types.h> |
| 34 | # include <linux/ipx.h> |
Pavel Roskin | 94d9964 | 1998-12-26 11:52:51 +0000 | [diff] [blame] | 35 | # define HAVE_IPX |
Stephen Langasek | dc16342 | 1998-11-08 15:42:40 +0000 | [diff] [blame] | 36 | #endif |
Pavel Roskin | 94d9964 | 1998-12-26 11:52:51 +0000 | [diff] [blame] | 37 | |
Jim Aston | 2e1cafa | 1999-03-14 16:35:05 +0000 | [diff] [blame] | 38 | #include "windef.h" |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 39 | #include "task.h" |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 40 | |
Patrik Stridvall | 14da7b1 | 1999-06-12 10:53:06 +0000 | [diff] [blame] | 41 | #ifdef __cplusplus |
| 42 | extern "C" { |
| 43 | #endif /* defined(__cplusplus) */ |
| 44 | |
Andreas Mohr | ae50941 | 2000-08-03 22:19:09 +0000 | [diff] [blame] | 45 | /* no "forced" alignment of ws_XXXXent here ! */ |
| 46 | |
| 47 | typedef struct ws_hostent |
| 48 | { |
| 49 | char *h_name; /* official name of host */ |
| 50 | char **h_aliases; /* alias list */ |
| 51 | short h_addrtype; /* host address type */ |
| 52 | short h_length; /* length of address */ |
| 53 | char **h_addr_list; /* list of addresses from name server */ |
| 54 | } _ws_hostent; |
| 55 | |
| 56 | typedef struct ws_protoent |
| 57 | { |
| 58 | char *p_name; /* official protocol name */ |
| 59 | char **p_aliases; /* alias list */ |
| 60 | short p_proto; /* protocol # */ |
| 61 | } _ws_protoent; |
| 62 | |
| 63 | typedef struct ws_servent |
| 64 | { |
| 65 | char *s_name; /* official service name */ |
| 66 | char **s_aliases; /* alias list */ |
| 67 | short s_port; /* port # */ |
| 68 | char *s_proto; /* protocol to use */ |
| 69 | } _ws_servent; |
| 70 | |
| 71 | typedef struct ws_netent |
| 72 | { |
| 73 | char *n_name; /* official name of net */ |
| 74 | char **n_aliases; /* alias list */ |
| 75 | short n_addrtype; /* net address type */ |
| 76 | u_long n_net; /* network # */ |
| 77 | } _ws_netent; |
| 78 | |
Patrik Stridvall | c7a8dde | 1999-04-25 12:36:53 +0000 | [diff] [blame] | 79 | #include "pshpack1.h" |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 80 | |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 81 | /* Win16 socket-related types */ |
| 82 | |
| 83 | typedef UINT16 SOCKET16; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 84 | typedef UINT SOCKET; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 85 | |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 86 | typedef struct sockaddr ws_sockaddr; |
| 87 | |
| 88 | typedef struct |
| 89 | { |
| 90 | UINT16 fd_count; /* how many are SET? */ |
| 91 | SOCKET16 fd_array[FD_SETSIZE]; /* an array of SOCKETs */ |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 92 | } ws_fd_set16; |
| 93 | |
| 94 | typedef struct |
| 95 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 96 | UINT fd_count; /* how many are SET? */ |
| 97 | SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */ |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 98 | } ws_fd_set32; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 99 | |
| 100 | /* ws_fd_set operations */ |
| 101 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 102 | INT16 WINAPI __WSAFDIsSet16( SOCKET16, ws_fd_set16 * ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 103 | INT WINAPI __WSAFDIsSet( SOCKET, ws_fd_set32 * ); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 104 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 105 | #define __WS_FD_CLR(fd, set, cast) do { \ |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 106 | UINT16 __i; \ |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 107 | for (__i = 0; __i < ((cast*)(set))->fd_count ; __i++) \ |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 108 | { \ |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 109 | if (((cast*)(set))->fd_array[__i] == fd) \ |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 110 | { \ |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 111 | while (__i < ((cast*)(set))->fd_count-1) \ |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 112 | { \ |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 113 | ((cast*)(set))->fd_array[__i] = \ |
| 114 | ((cast*)(set))->fd_array[__i+1]; \ |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 115 | __i++; \ |
| 116 | } \ |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 117 | ((cast*)(set))->fd_count--; \ |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 118 | break; \ |
| 119 | } \ |
| 120 | } \ |
| 121 | } while(0) |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 122 | #define WS_FD_CLR16(fd, set) __WS_FD_CLR((fd),(set), ws_fd_set16) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 123 | #define WS_FD_CLR(fd, set) __WS_FD_CLR((fd),(set), ws_fd_set32) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 124 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 125 | #define __WS_FD_SET(fd, set, cast) do { \ |
| 126 | if (((cast*)(set))->fd_count < FD_SETSIZE) \ |
| 127 | ((cast*)(set))->fd_array[((cast*)(set))->fd_count++]=(fd);\ |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 128 | } while(0) |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 129 | #define WS_FD_SET16(fd, set) __WS_FD_SET((fd),(set), ws_fd_set16) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 130 | #define WS_FD_SET(fd, set) __WS_FD_SET((fd),(set), ws_fd_set32) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 131 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 132 | #define WS_FD_ZERO16(set) (((ws_fd_set16*)(set))->fd_count=0) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 133 | #define WS_FD_ZERO(set) (((ws_fd_set32*)(set))->fd_count=0) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 134 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 135 | #define WS_FD_ISSET16(fd, set) __WSAFDIsSet16((SOCKET16)(fd), (ws_fd_set16*)(set)) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 136 | #define WS_FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (ws_fd_set32*)(set)) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 137 | |
| 138 | /* |
| 139 | * Internet address (old style... should be updated) |
| 140 | */ |
| 141 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 142 | struct ws_in_addr |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 143 | { |
| 144 | union { |
| 145 | struct { BYTE s_b1,s_b2,s_b3,s_b4; } S_un_b; |
| 146 | struct { UINT16 s_w1,s_w2; } S_un_w; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 147 | UINT S_addr; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 148 | } S_un; |
| 149 | #define ws_addr S_un.S_addr /* can be used for most tcp & ip code */ |
| 150 | #define ws_host S_un.S_un_b.s_b2 /* host on imp */ |
| 151 | #define ws_net S_un.S_un_b.s_b1 /* network */ |
| 152 | #define ws_imp S_un.S_un_w.s_w2 /* imp */ |
| 153 | #define ws_impno S_un.S_un_b.s_b4 /* imp # */ |
| 154 | #define ws_lh S_un.S_un_b.s_b3 /* logical host */ |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 155 | }; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 156 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 157 | struct ws_sockaddr_in |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 158 | { |
| 159 | INT16 sin_family; |
| 160 | UINT16 sin_port; |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 161 | struct ws_in_addr sin_addr; |
| 162 | BYTE sin_zero[8]; |
| 163 | }; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 164 | |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 165 | #define WSADESCRIPTION_LEN 256 |
| 166 | #define WSASYS_STATUS_LEN 128 |
| 167 | |
| 168 | typedef struct WSAData { |
| 169 | WORD wVersion; |
| 170 | WORD wHighVersion; |
| 171 | char szDescription[WSADESCRIPTION_LEN+1]; |
| 172 | char szSystemStatus[WSASYS_STATUS_LEN+1]; |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 173 | UINT16 iMaxSockets; |
| 174 | UINT16 iMaxUdpDg; |
| 175 | SEGPTR lpVendorInfo; |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 176 | } WSADATA, *LPWSADATA; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 177 | |
Patrik Stridvall | c7a8dde | 1999-04-25 12:36:53 +0000 | [diff] [blame] | 178 | #include "poppack.h" |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 179 | |
Andreas Mohr | ae50941 | 2000-08-03 22:19:09 +0000 | [diff] [blame] | 180 | /* ------ no Win16 structure defs (1-byte alignment) beyond this line! ------ */ |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 181 | |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 182 | /* |
| 183 | * This is used instead of -1, since the |
| 184 | * SOCKET type is unsigned. |
| 185 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 186 | #define INVALID_SOCKET16 (~0) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 187 | #define INVALID_SOCKET (~0) |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 188 | #define SOCKET_ERROR (-1) |
| 189 | |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 190 | |
| 191 | /* |
| 192 | * Types |
| 193 | */ |
| 194 | #define WS_SOCK_STREAM 1 /* stream socket */ |
| 195 | #define WS_SOCK_DGRAM 2 /* datagram socket */ |
| 196 | #define WS_SOCK_RAW 3 /* raw-protocol interface */ |
| 197 | #define WS_SOCK_RDM 4 /* reliably-delivered message */ |
| 198 | #define WS_SOCK_SEQPACKET 5 /* sequenced packet stream */ |
| 199 | |
Alexandre Julliard | 02e9008 | 1998-01-04 17:49:09 +0000 | [diff] [blame] | 200 | #define WS_SOL_SOCKET 0xffff |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 201 | #define WS_IPPROTO_TCP 6 |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 202 | |
| 203 | /* |
| 204 | * Option flags per-socket. |
| 205 | */ |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 206 | #define WS_SO_DEBUG 0x0001 /* turn on debugging info recording */ |
| 207 | #define WS_SO_ACCEPTCONN 0x0002 /* socket has had listen() */ |
| 208 | #define WS_SO_REUSEADDR 0x0004 /* allow local address reuse */ |
| 209 | #define WS_SO_KEEPALIVE 0x0008 /* keep connections alive */ |
| 210 | #define WS_SO_DONTROUTE 0x0010 /* just use interface addresses */ |
| 211 | #define WS_SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ |
| 212 | #define WS_SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ |
| 213 | #define WS_SO_LINGER 0x0080 /* linger on close if data present */ |
| 214 | #define WS_SO_OOBINLINE 0x0100 /* leave received OOB data in line */ |
| 215 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 216 | #define WS_SO_DONTLINGER (UINT)(~WS_SO_LINGER) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 217 | |
| 218 | /* |
| 219 | * Additional options. |
| 220 | */ |
| 221 | #define WS_SO_SNDBUF 0x1001 /* send buffer size */ |
| 222 | #define WS_SO_RCVBUF 0x1002 /* receive buffer size */ |
| 223 | #define WS_SO_SNDLOWAT 0x1003 /* send low-water mark */ |
| 224 | #define WS_SO_RCVLOWAT 0x1004 /* receive low-water mark */ |
| 225 | #define WS_SO_SNDTIMEO 0x1005 /* send timeout */ |
| 226 | #define WS_SO_RCVTIMEO 0x1006 /* receive timeout */ |
| 227 | #define WS_SO_ERROR 0x1007 /* get error status and clear */ |
| 228 | #define WS_SO_TYPE 0x1008 /* get socket type */ |
| 229 | |
| 230 | #define WS_IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */ |
| 231 | #define WS_IOC_VOID 0x20000000 /* no parameters */ |
| 232 | #define WS_IOC_OUT 0x40000000 /* copy out parameters */ |
| 233 | #define WS_IOC_IN 0x80000000 /* copy in parameters */ |
| 234 | #define WS_IOC_INOUT (WS_IOC_IN|WS_IOC_OUT) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 235 | #define WS_IOR(x,y,t) (WS_IOC_OUT|(((UINT)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y)) |
| 236 | #define WS_IOW(x,y,t) (WS_IOC_IN|(((UINT)sizeof(t)&WS_IOCPARM_MASK)<<16)|((x)<<8)|(y)) |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 237 | |
Marcus Meissner | 5eaf775 | 1999-03-09 17:31:42 +0000 | [diff] [blame] | 238 | /* IPPROTO_TCP options */ |
| 239 | #define WS_TCP_NODELAY 1 /* do not apply nagle algorithm */ |
| 240 | |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 241 | /* |
| 242 | * Socket I/O flags (supported by spec 1.1) |
| 243 | */ |
| 244 | |
| 245 | #define WS_FIONREAD WS_IOR('f', 127, u_long) |
| 246 | #define WS_FIONBIO WS_IOW('f', 126, u_long) |
| 247 | |
| 248 | #define WS_SIOCATMARK WS_IOR('s', 7, u_long) |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 249 | |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 250 | /* |
| 251 | * Maximum queue length specifiable by listen. |
| 252 | */ |
Alexandre Julliard | af0bae5 | 1995-10-03 17:06:08 +0000 | [diff] [blame] | 253 | #ifdef SOMAXCONN |
| 254 | #undef SOMAXCONN |
| 255 | #endif |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 256 | #define SOMAXCONN 5 |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 257 | |
Alexandre Julliard | 1d62f6b | 1994-05-04 19:15:00 +0000 | [diff] [blame] | 258 | #ifndef MSG_DONTROUTE |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 259 | #define MSG_DONTROUTE 0x4 /* send without using routing tables */ |
Alexandre Julliard | 1d62f6b | 1994-05-04 19:15:00 +0000 | [diff] [blame] | 260 | #endif |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 261 | #define MSG_MAXIOVLEN 16 |
| 262 | |
Moses DeJong | e0a3ba5 | 1999-11-23 22:29:00 +0000 | [diff] [blame] | 263 | #ifndef MSG_PARTIAL |
| 264 | #define MSG_PARTIAL 0x8000 /* partial send or recv (WSARecvEx) */ |
| 265 | #endif |
| 266 | |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 267 | /* |
| 268 | * Define constant based on rfc883, used by gethostbyxxxx() calls. |
| 269 | */ |
| 270 | #define MAXGETHOSTSTRUCT 1024 |
| 271 | |
| 272 | /* |
| 273 | * Define flags to be used with the WSAAsyncSelect() call. |
| 274 | */ |
Paul Quinn | 89b21b4 | 1999-03-14 13:47:00 +0000 | [diff] [blame] | 275 | #define FD_READ WS_FD_READ |
| 276 | #define FD_WRITE WS_FD_WRITE |
| 277 | #define FD_OOB WS_FD_OOB |
| 278 | #define FD_ACCEPT WS_FD_ACCEPT |
| 279 | #define FD_CONNECT WS_FD_CONNECT |
| 280 | #define FD_CLOSE WS_FD_CLOSE |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 281 | #define WS_FD_READ 0x0001 |
| 282 | #define WS_FD_WRITE 0x0002 |
| 283 | #define WS_FD_OOB 0x0004 |
| 284 | #define WS_FD_ACCEPT 0x0008 |
| 285 | #define WS_FD_CONNECT 0x0010 |
| 286 | #define WS_FD_CLOSE 0x0020 |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 287 | |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 288 | #define WS_FD_LISTENING 0x10000000 /* internal per-socket flags */ |
Ove Kaaven | f45608f | 1999-10-23 16:53:34 +0000 | [diff] [blame] | 289 | #define WS_FD_NONBLOCKING 0x20000000 |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 290 | #define WS_FD_CONNECTED 0x40000000 |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 291 | #define WS_FD_RAW 0x80000000 |
Ove Kaaven | f45608f | 1999-10-23 16:53:34 +0000 | [diff] [blame] | 292 | #define WS_FD_SERVEVENT 0x01000000 |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 293 | #define WS_FD_INTERNAL 0xFFFF0000 |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 294 | |
| 295 | /* |
| 296 | * All Windows Sockets error constants are biased by WSABASEERR from |
| 297 | * the "normal" |
| 298 | */ |
| 299 | #define WSABASEERR 10000 |
| 300 | /* |
| 301 | * Windows Sockets definitions of regular Microsoft C error constants |
| 302 | */ |
| 303 | #define WSAEINTR (WSABASEERR+4) |
| 304 | #define WSAEBADF (WSABASEERR+9) |
| 305 | #define WSAEACCES (WSABASEERR+13) |
| 306 | #define WSAEFAULT (WSABASEERR+14) |
| 307 | #define WSAEINVAL (WSABASEERR+22) |
| 308 | #define WSAEMFILE (WSABASEERR+24) |
| 309 | |
| 310 | /* |
| 311 | * Windows Sockets definitions of regular Berkeley error constants |
| 312 | */ |
| 313 | #define WSAEWOULDBLOCK (WSABASEERR+35) |
| 314 | #define WSAEINPROGRESS (WSABASEERR+36) |
| 315 | #define WSAEALREADY (WSABASEERR+37) |
| 316 | #define WSAENOTSOCK (WSABASEERR+38) |
| 317 | #define WSAEDESTADDRREQ (WSABASEERR+39) |
| 318 | #define WSAEMSGSIZE (WSABASEERR+40) |
| 319 | #define WSAEPROTOTYPE (WSABASEERR+41) |
| 320 | #define WSAENOPROTOOPT (WSABASEERR+42) |
| 321 | #define WSAEPROTONOSUPPORT (WSABASEERR+43) |
| 322 | #define WSAESOCKTNOSUPPORT (WSABASEERR+44) |
| 323 | #define WSAEOPNOTSUPP (WSABASEERR+45) |
| 324 | #define WSAEPFNOSUPPORT (WSABASEERR+46) |
| 325 | #define WSAEAFNOSUPPORT (WSABASEERR+47) |
| 326 | #define WSAEADDRINUSE (WSABASEERR+48) |
| 327 | #define WSAEADDRNOTAVAIL (WSABASEERR+49) |
| 328 | #define WSAENETDOWN (WSABASEERR+50) |
| 329 | #define WSAENETUNREACH (WSABASEERR+51) |
| 330 | #define WSAENETRESET (WSABASEERR+52) |
| 331 | #define WSAECONNABORTED (WSABASEERR+53) |
| 332 | #define WSAECONNRESET (WSABASEERR+54) |
| 333 | #define WSAENOBUFS (WSABASEERR+55) |
| 334 | #define WSAEISCONN (WSABASEERR+56) |
| 335 | #define WSAENOTCONN (WSABASEERR+57) |
| 336 | #define WSAESHUTDOWN (WSABASEERR+58) |
| 337 | #define WSAETOOMANYREFS (WSABASEERR+59) |
| 338 | #define WSAETIMEDOUT (WSABASEERR+60) |
| 339 | #define WSAECONNREFUSED (WSABASEERR+61) |
| 340 | #define WSAELOOP (WSABASEERR+62) |
| 341 | #define WSAENAMETOOLONG (WSABASEERR+63) |
| 342 | #define WSAEHOSTDOWN (WSABASEERR+64) |
| 343 | #define WSAEHOSTUNREACH (WSABASEERR+65) |
| 344 | #define WSAENOTEMPTY (WSABASEERR+66) |
| 345 | #define WSAEPROCLIM (WSABASEERR+67) |
| 346 | #define WSAEUSERS (WSABASEERR+68) |
| 347 | #define WSAEDQUOT (WSABASEERR+69) |
| 348 | #define WSAESTALE (WSABASEERR+70) |
| 349 | #define WSAEREMOTE (WSABASEERR+71) |
| 350 | |
| 351 | /* |
| 352 | * Extended Windows Sockets error constant definitions |
| 353 | */ |
| 354 | #define WSASYSNOTREADY (WSABASEERR+91) |
| 355 | #define WSAVERNOTSUPPORTED (WSABASEERR+92) |
| 356 | #define WSANOTINITIALISED (WSABASEERR+93) |
| 357 | |
| 358 | /* |
| 359 | * Error return codes from gethostbyname() and gethostbyaddr() |
| 360 | * (when using the resolver). Note that these errors are |
| 361 | * retrieved via WSAGetLastError() and must therefore follow |
| 362 | * the rules for avoiding clashes with error numbers from |
| 363 | * specific implementations or language run-time systems. |
| 364 | * For this reason the codes are based at WSABASEERR+1001. |
| 365 | * Note also that [WSA]NO_ADDRESS is defined only for |
| 366 | * compatibility purposes. |
| 367 | */ |
| 368 | |
Alexandre Julliard | b7258be | 1995-09-01 15:57:28 +0000 | [diff] [blame] | 369 | /* #define h_errno WSAGetLastError() */ |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 370 | |
| 371 | /* Authoritative Answer: Host not found */ |
| 372 | #define WSAHOST_NOT_FOUND (WSABASEERR+1001) |
| 373 | |
| 374 | /* Non-Authoritative: Host not found, or SERVERFAIL */ |
| 375 | #define WSATRY_AGAIN (WSABASEERR+1002) |
| 376 | |
| 377 | /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ |
| 378 | #define WSANO_RECOVERY (WSABASEERR+1003) |
| 379 | |
| 380 | /* Valid name, no data record of requested type */ |
| 381 | #define WSANO_DATA (WSABASEERR+1004) |
| 382 | |
| 383 | /* no address, look for MX record */ |
| 384 | #define WSANO_ADDRESS WSANO_DATA |
| 385 | |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 386 | /* Socket function prototypes */ |
| 387 | |
| 388 | #ifdef __cplusplus |
| 389 | extern "C" { |
| 390 | #endif |
| 391 | |
| 392 | /* Microsoft Windows Extension function prototypes */ |
| 393 | |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 394 | INT16 WINAPI WSAStartup16(UINT16 wVersionRequired, LPWSADATA lpWSAData); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 395 | INT WINAPI WSAStartup(UINT wVersionRequired, LPWSADATA lpWSAData); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 396 | void WINAPI WSASetLastError16(INT16 iError); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 397 | void WINAPI WSASetLastError(INT iError); |
| 398 | INT WINAPI WSACleanup(void); |
| 399 | INT WINAPI WSAGetLastError(void); |
| 400 | BOOL WINAPI WSAIsBlocking(void); |
| 401 | INT WINAPI WSACancelBlockingCall(void); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 402 | INT16 WINAPI WSAUnhookBlockingHook16(void); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 403 | INT WINAPI WSAUnhookBlockingHook(void); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 404 | FARPROC16 WINAPI WSASetBlockingHook16(FARPROC16 lpBlockFunc); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 405 | FARPROC WINAPI WSASetBlockingHook(FARPROC lpBlockFunc); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 406 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 407 | HANDLE16 WINAPI WSAAsyncGetServByName16(HWND16 hWnd, UINT16 wMsg, LPCSTR name, LPCSTR proto, |
| 408 | SEGPTR buf, INT16 buflen); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 409 | HANDLE WINAPI WSAAsyncGetServByName(HWND hWnd, UINT uMsg, LPCSTR name, LPCSTR proto, |
| 410 | LPSTR sbuf, INT buflen); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 411 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 412 | HANDLE16 WINAPI WSAAsyncGetServByPort16(HWND16 hWnd, UINT16 wMsg, INT16 port, |
| 413 | LPCSTR proto, SEGPTR buf, INT16 buflen); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 414 | HANDLE WINAPI WSAAsyncGetServByPort(HWND hWnd, UINT uMsg, INT port, |
| 415 | LPCSTR proto, LPSTR sbuf, INT buflen); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 416 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 417 | HANDLE16 WINAPI WSAAsyncGetProtoByName16(HWND16 hWnd, UINT16 wMsg, |
| 418 | LPCSTR name, SEGPTR buf, INT16 buflen); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 419 | HANDLE WINAPI WSAAsyncGetProtoByName(HWND hWnd, UINT uMsg, |
| 420 | LPCSTR name, LPSTR sbuf, INT buflen); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 421 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 422 | HANDLE16 WINAPI WSAAsyncGetProtoByNumber16(HWND16 hWnd, UINT16 wMsg, |
| 423 | INT16 number, SEGPTR buf, INT16 buflen); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 424 | HANDLE WINAPI WSAAsyncGetProtoByNumber(HWND hWnd, UINT uMsg, |
| 425 | INT number, LPSTR sbuf, INT buflen); |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 426 | |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 427 | HANDLE16 WINAPI WSAAsyncGetHostByName16(HWND16 hWnd, UINT16 wMsg, |
| 428 | LPCSTR name, SEGPTR buf, INT16 buflen); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 429 | HANDLE WINAPI WSAAsyncGetHostByName(HWND hWnd, UINT uMsg, |
| 430 | LPCSTR name, LPSTR sbuf, INT buflen); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 431 | |
| 432 | HANDLE16 WINAPI WSAAsyncGetHostByAddr16(HWND16 hWnd, UINT16 wMsg, LPCSTR addr, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 433 | INT16 len, INT16 type, SEGPTR buf, INT16 buflen); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 434 | HANDLE WINAPI WSAAsyncGetHostByAddr(HWND hWnd, UINT uMsg, LPCSTR addr, |
| 435 | INT len, INT type, LPSTR sbuf, INT buflen); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 436 | |
| 437 | INT16 WINAPI WSACancelAsyncRequest16(HANDLE16 hAsyncTaskHandle); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 438 | INT WINAPI WSACancelAsyncRequest(HANDLE hAsyncTaskHandle); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 439 | |
Patrik Stridvall | b8684a2 | 1999-07-31 17:32:05 +0000 | [diff] [blame] | 440 | INT16 WINAPI WSAAsyncSelect16(SOCKET16 s, HWND16 hWnd, UINT16 wMsg, LONG lEvent); |
| 441 | INT WINAPI WSAAsyncSelect(SOCKET s, HWND hWnd, UINT uMsg, LONG lEvent); |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 442 | |
Moses DeJong | e0a3ba5 | 1999-11-23 22:29:00 +0000 | [diff] [blame] | 443 | INT16 WINAPI WSARecvEx16(SOCKET16 s, char *buf, INT16 len, INT16 *flags); |
| 444 | INT WINAPI WSARecvEx(SOCKET s, char *buf, INT len, INT *flags); |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 445 | |
Stephen Langasek | dc16342 | 1998-11-08 15:42:40 +0000 | [diff] [blame] | 446 | /* |
Stephen Langasek | 12392cd | 1998-11-14 16:47:09 +0000 | [diff] [blame] | 447 | * Address families |
Stephen Langasek | dc16342 | 1998-11-08 15:42:40 +0000 | [diff] [blame] | 448 | */ |
Stephen Langasek | 12392cd | 1998-11-14 16:47:09 +0000 | [diff] [blame] | 449 | #define WS_AF_UNSPEC 0 /* unspecified */ |
| 450 | #define WS_AF_UNIX 1 /* local to host (pipes, portals) */ |
| 451 | #define WS_AF_INET 2 /* internetwork: UDP, TCP, etc. */ |
| 452 | #define WS_AF_IMPLINK 3 /* arpanet imp addresses */ |
| 453 | #define WS_AF_PUP 4 /* pup protocols: e.g. BSP */ |
| 454 | #define WS_AF_CHAOS 5 /* mit CHAOS protocols */ |
| 455 | #define WS_AF_NS 6 /* XEROX NS protocols */ |
| 456 | #define WS_AF_IPX WS_AF_NS /* IPX protocols: IPX, SPX, etc. */ |
| 457 | #define WS_AF_ISO 7 /* ISO protocols */ |
| 458 | #define WS_AF_OSI AF_ISO /* OSI is ISO */ |
| 459 | #define WS_AF_ECMA 8 /* european computer manufacturers */ |
| 460 | #define WS_AF_DATAKIT 9 /* datakit protocols */ |
| 461 | #define WS_AF_CCITT 10 /* CCITT protocols, X.25 etc */ |
| 462 | #define WS_AF_SNA 11 /* IBM SNA */ |
| 463 | #define WS_AF_DECnet 12 /* DECnet */ |
| 464 | #define WS_AF_DLI 13 /* Direct data link interface */ |
| 465 | #define WS_AF_LAT 14 /* LAT */ |
| 466 | #define WS_AF_HYLINK 15 /* NSC Hyperchannel */ |
| 467 | #define WS_AF_APPLETALK 16 /* AppleTalk */ |
| 468 | #define WS_AF_NETBIOS 17 /* NetBios-style addresses */ |
| 469 | #define WS_AF_VOICEVIEW 18 /* VoiceView */ |
| 470 | #define WS_AF_FIREFOX 19 /* Protocols from Firefox */ |
| 471 | #define WS_AF_UNKNOWN1 20 /* Somebody is using this! */ |
| 472 | #define WS_AF_BAN 21 /* Banyan */ |
| 473 | #define WS_AF_ATM 22 /* Native ATM Services */ |
| 474 | #define WS_AF_INET6 23 /* Internetwork Version 6 */ |
| 475 | #define WS_AF_CLUSTER 24 /* Microsoft Wolfpack */ |
| 476 | #define WS_AF_12844 25 /* IEEE 1284.4 WG AF */ |
| 477 | #define WS_AF_IRDA 26 /* IrDA */ |
| 478 | |
| 479 | #define WS_AF_MAX 27 |
| 480 | |
Patrik Stridvall | 896889f | 1999-05-08 12:50:36 +0000 | [diff] [blame] | 481 | #include "pshpack1.h" |
| 482 | |
Stephen Langasek | dc16342 | 1998-11-08 15:42:40 +0000 | [diff] [blame] | 483 | struct ws_sockaddr_ipx |
| 484 | { |
Patrik Stridvall | 896889f | 1999-05-08 12:50:36 +0000 | [diff] [blame] | 485 | INT16 sipx_family; |
| 486 | UINT sipx_network; |
| 487 | CHAR sipx_node[6]; |
| 488 | UINT16 sipx_port; |
Stephen Langasek | dc16342 | 1998-11-08 15:42:40 +0000 | [diff] [blame] | 489 | }; |
Stephen Langasek | dc16342 | 1998-11-08 15:42:40 +0000 | [diff] [blame] | 490 | |
Patrik Stridvall | 896889f | 1999-05-08 12:50:36 +0000 | [diff] [blame] | 491 | #include "poppack.h" |
| 492 | |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 493 | #ifdef __cplusplus |
| 494 | } |
| 495 | #endif |
| 496 | |
| 497 | /* Microsoft Windows Extended data types */ |
Alexandre Julliard | 1285c2f | 1996-05-06 16:06:24 +0000 | [diff] [blame] | 498 | typedef struct sockaddr SOCKADDR, *PSOCKADDR, *LPSOCKADDR; |
| 499 | typedef struct sockaddr_in SOCKADDR_IN, *PSOCKADDR_IN, *LPSOCKADDR_IN; |
| 500 | typedef struct linger LINGER, *PLINGER, *LPLINGER; |
| 501 | typedef struct in_addr IN_ADDR, *PIN_ADDR, *LPIN_ADDR; |
| 502 | typedef struct fd_set FD_SET, *PFD_SET, *LPFD_SET; |
| 503 | typedef struct hostent HOSTENT, *PHOSTENT, *LPHOSTENT; |
| 504 | typedef struct servent SERVENT, *PSERVENT, *LPSERVENT; |
| 505 | typedef struct protoent PROTOENT, *PPROTOENT, *LPPROTOENT; |
| 506 | typedef struct timeval TIMEVAL, *PTIMEVAL, *LPTIMEVAL; |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 507 | |
| 508 | /* |
| 509 | * Windows message parameter composition and decomposition |
| 510 | * macros. |
| 511 | * |
| 512 | * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation |
| 513 | * when constructing the response to a WSAAsyncGetXByY() routine. |
| 514 | */ |
| 515 | #define WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error) |
| 516 | /* |
| 517 | * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation |
| 518 | * when constructing the response to WSAAsyncSelect(). |
| 519 | */ |
| 520 | #define WSAMAKESELECTREPLY(event,error) MAKELONG(event,error) |
| 521 | /* |
| 522 | * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application |
| 523 | * to extract the buffer length from the lParam in the response |
| 524 | * to a WSAGetXByY(). |
| 525 | */ |
| 526 | #define WSAGETASYNCBUFLEN(lParam) LOWORD(lParam) |
| 527 | /* |
| 528 | * WSAGETASYNCERROR is intended for use by the Windows Sockets application |
| 529 | * to extract the error code from the lParam in the response |
| 530 | * to a WSAGetXByY(). |
| 531 | */ |
| 532 | #define WSAGETASYNCERROR(lParam) HIWORD(lParam) |
| 533 | /* |
| 534 | * WSAGETSELECTEVENT is intended for use by the Windows Sockets application |
| 535 | * to extract the event code from the lParam in the response |
| 536 | * to a WSAAsyncSelect(). |
| 537 | */ |
| 538 | #define WSAGETSELECTEVENT(lParam) LOWORD(lParam) |
| 539 | /* |
| 540 | * WSAGETSELECTERROR is intended for use by the Windows Sockets application |
| 541 | * to extract the error code from the lParam in the response |
| 542 | * to a WSAAsyncSelect(). |
| 543 | */ |
| 544 | #define WSAGETSELECTERROR(lParam) HIWORD(lParam) |
| 545 | |
Patrik Stridvall | 14da7b1 | 1999-06-12 10:53:06 +0000 | [diff] [blame] | 546 | #ifdef __cplusplus |
| 547 | } /* extern "C" */ |
| 548 | #endif /* defined(__cplusplus) */ |
| 549 | |
Alexandre Julliard | fb9a919 | 1994-03-01 19:48:04 +0000 | [diff] [blame] | 550 | #endif /* _WINSOCKAPI_ */ |
Alexandre Julliard | da0cfb3 | 1996-12-01 17:17:47 +0000 | [diff] [blame] | 551 | |