1 | /* $Id: wsock32.h,v 1.4 1999-08-16 20:18:40 phaller Exp $ */
|
---|
2 |
|
---|
3 | /* WSOCK32.H--definitions & conversions for Odin's wsock32.dll.
|
---|
4 | * Unused/unneeded Microsoft declarations removed.
|
---|
5 | *
|
---|
6 | * This header file corresponds to version 1.1 of the Windows Sockets specification.
|
---|
7 | *
|
---|
8 | * This file includes parts which are Copyright (c) 1982-1986 Regents
|
---|
9 | * of the University of California. All rights reserved. The
|
---|
10 | * Berkeley Software License Agreement specifies the terms and
|
---|
11 | * conditions for redistribution.
|
---|
12 | *
|
---|
13 | */
|
---|
14 |
|
---|
15 | #ifndef _WINSOCKAPI_
|
---|
16 | #define _WINSOCKAPI_
|
---|
17 |
|
---|
18 |
|
---|
19 | #ifdef MAKELONG
|
---|
20 | # undef MAKELONG
|
---|
21 | #endif
|
---|
22 |
|
---|
23 | #ifdef MAKEWORD
|
---|
24 | # undef MAKEWORD
|
---|
25 | #endif
|
---|
26 |
|
---|
27 | #ifdef LOBYTE
|
---|
28 | # undef LOBYTE
|
---|
29 | #endif
|
---|
30 |
|
---|
31 | #ifdef LOWORD
|
---|
32 | # undef LOWORD
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | #ifdef HIBYTE
|
---|
36 | # undef HIBYTE
|
---|
37 | #endif
|
---|
38 |
|
---|
39 | #ifdef HIWORD
|
---|
40 | # undef HIWORD
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | #define MAKEWORD(a, b) ((WORD)(((BYTE)(a)) | ((WORD)((BYTE)(b))) << 8))
|
---|
44 | #define MAKELONG(a, b) ((LONG)(((WORD)(a)) | ((DWORD)((WORD)(b))) << 16))
|
---|
45 | #define LOWORD(l) ((WORD)(l))
|
---|
46 | #define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xFFFF))
|
---|
47 | #define LOBYTE(w) ((BYTE)(w))
|
---|
48 | #define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF))
|
---|
49 |
|
---|
50 |
|
---|
51 |
|
---|
52 | /*
|
---|
53 | * Basic system type definitions, taken from the BSD file sys/types.h.
|
---|
54 | */
|
---|
55 |
|
---|
56 | #ifdef __WATCOM__
|
---|
57 | typedef unsigned char u_char;
|
---|
58 | typedef unsigned short u_short;
|
---|
59 | typedef unsigned int u_int;
|
---|
60 | typedef unsigned long u_long;
|
---|
61 | typedef int ( WIN32API *PROC)();
|
---|
62 | #else
|
---|
63 | typedef int (* WIN32API PROC)();
|
---|
64 | #endif
|
---|
65 |
|
---|
66 | //typedef unsigned short WORD;
|
---|
67 | //typedef unsigned long DWORD;
|
---|
68 | //typedef ULONG HANDLE, *PHANDLE, *LPHANDLE, *SPHANDLE;
|
---|
69 |
|
---|
70 | /*
|
---|
71 | * The new type to be used in all
|
---|
72 | * instances which refer to sockets.
|
---|
73 | */
|
---|
74 | typedef u_int SOCKET;
|
---|
75 |
|
---|
76 |
|
---|
77 |
|
---|
78 |
|
---|
79 | typedef struct AsyncStatus {
|
---|
80 | HWND hwnd; // owner's hwindow
|
---|
81 | u_int msg; // message to send when event occurs
|
---|
82 | ULONG event; // event that may occur
|
---|
83 | SOCKET socket; // the socket
|
---|
84 | int status; // blocking yes/no
|
---|
85 | TID threadID; // Thread ID for async
|
---|
86 | int MsgStat; // has message been sent yet?
|
---|
87 | struct AsyncStatus *Next; // pointer to next AsyncStatus in the list
|
---|
88 | struct AsyncStatus *Prev; // pointer to previous AsyncStatus in the list
|
---|
89 | } AsyncStatus;
|
---|
90 |
|
---|
91 |
|
---|
92 |
|
---|
93 |
|
---|
94 |
|
---|
95 |
|
---|
96 | /*
|
---|
97 | * Select uses arrays of SOCKETs. These macros manipulate such
|
---|
98 | * arrays. FD_SETSIZE may be defined by the user before including
|
---|
99 | * this file, but the default here should be >= 64.
|
---|
100 | *
|
---|
101 | * CAVEAT IMPLEMENTOR and USER: THESE MACROS AND TYPES MUST BE
|
---|
102 | * INCLUDED IN WINSOCK.H EXACTLY AS SHOWN HERE.
|
---|
103 | */
|
---|
104 | #ifndef FD_SETSIZE
|
---|
105 | #define FD_SETSIZE 64
|
---|
106 | #endif /* FD_SETSIZE */
|
---|
107 |
|
---|
108 | typedef struct Wfd_set {
|
---|
109 | u_int fd_count; /* how many are SET? */
|
---|
110 | SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
|
---|
111 | } Wfd_set;
|
---|
112 |
|
---|
113 |
|
---|
114 |
|
---|
115 | #ifdef __cplusplus
|
---|
116 | extern "C" {
|
---|
117 | #endif
|
---|
118 |
|
---|
119 | extern int PASCAL __WSAFDIsSet(SOCKET, Wfd_set *);
|
---|
120 |
|
---|
121 | #ifdef __cplusplus
|
---|
122 | }
|
---|
123 | #endif
|
---|
124 |
|
---|
125 | /*
|
---|
126 | #define FD_CLR(fd, set) do { \
|
---|
127 | u_int __i; \
|
---|
128 | for (__i = 0; __i < ((Wfd_set *)(set))->fd_count ; __i++) { \
|
---|
129 | if (((Wfd_set *)(set))->fd_array[__i] == fd) { \
|
---|
130 | while (__i < ((Wfd_set *)(set))->fd_count-1) { \
|
---|
131 | ((Wfd_set *)(set))->fd_array[__i] = \
|
---|
132 | ((Wfd_set *)(set))->fd_array[__i+1]; \
|
---|
133 | __i++; \
|
---|
134 | } \
|
---|
135 | ((Wfd_set *)(set))->fd_count--; \
|
---|
136 | break; \
|
---|
137 | } \
|
---|
138 | } \
|
---|
139 | } while(0)
|
---|
140 |
|
---|
141 | #define FD_SET(fd, set) do { \
|
---|
142 | if (((Wfd_set *)(set))->fd_count < FD_SETSIZE) \
|
---|
143 | ((Wfd_set *)(set))->fd_array[((Wfd_set *)(set))->fd_count++]=(fd);\
|
---|
144 | } while(0)
|
---|
145 |
|
---|
146 | #define FD_ZERO(set) (((Wfd_set *)(set))->fd_count=0)
|
---|
147 |
|
---|
148 | #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (Wfd_set *)(set))
|
---|
149 | */
|
---|
150 |
|
---|
151 | /*
|
---|
152 | * Structure used in select() call, taken from the BSD file sys/time.h.
|
---|
153 | */
|
---|
154 | struct Wtimeval {
|
---|
155 | long tv_sec; /* seconds */
|
---|
156 | long tv_usec; /* and microseconds */
|
---|
157 | };
|
---|
158 |
|
---|
159 | /*
|
---|
160 | * Operations on timevals.
|
---|
161 | *
|
---|
162 | * NB: timercmp does not work for >= or <=.
|
---|
163 | */
|
---|
164 | #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
|
---|
165 | #define Wtimercmp(tvp, uvp, cmp) \
|
---|
166 | ((tvp)->tv_sec cmp (uvp)->tv_sec || \
|
---|
167 | (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
|
---|
168 | #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
|
---|
169 |
|
---|
170 | /*
|
---|
171 | * Commands for ioctlsocket(), taken from the BSD file fcntl.h.
|
---|
172 | *
|
---|
173 | *
|
---|
174 | * Ioctl's have the command encoded in the lower word,
|
---|
175 | * and the size of any in or out parameters in the upper
|
---|
176 | * word. The high 2 bits of the upper word are used
|
---|
177 | * to encode the in/out status of the parameter; for now
|
---|
178 | * we restrict parameters to at most 128 bytes.
|
---|
179 | */
|
---|
180 | #define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
|
---|
181 | #define IOC_VOID 0x20000000 /* no parameters */
|
---|
182 | #define IOC_OUT 0x40000000 /* copy out parameters */
|
---|
183 | #define IOC_IN 0x80000000 /* copy in parameters */
|
---|
184 | #define IOC_INOUT (IOC_IN|IOC_OUT)
|
---|
185 | /* 0x20000000 distinguishes new &
|
---|
186 | old ioctl's */
|
---|
187 | #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
|
---|
188 |
|
---|
189 | #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
|
---|
190 |
|
---|
191 | #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
|
---|
192 |
|
---|
193 | #define WFIONREAD _IOR('f', 127, u_long) /* get # bytes to read */
|
---|
194 | #define WFIONBIO _IOW('f', 126, u_long) /* set/clear non-blocking i/o */
|
---|
195 | #define WFIOASYNC _IOW('f', 125, u_long) /* set/clear async i/o */
|
---|
196 |
|
---|
197 | /* Socket I/O Controls */
|
---|
198 | #define WSIOCSHIWAT _IOW('s', 0, u_long) /* set high watermark */
|
---|
199 | #define WSIOCGHIWAT _IOR('s', 1, u_long) /* get high watermark */
|
---|
200 | #define WSIOCSLOWAT _IOW('s', 2, u_long) /* set low watermark */
|
---|
201 | #define WSIOCGLOWAT _IOR('s', 3, u_long) /* get low watermark */
|
---|
202 | #define WSIOCATMARK _IOR('s', 7, u_long) /* at oob mark? */
|
---|
203 |
|
---|
204 | /*
|
---|
205 | * Structures returned by network data base library, taken from the
|
---|
206 | * BSD file netdb.h. All addresses are supplied in host order, and
|
---|
207 | * returned in network order (suitable for use in system calls).
|
---|
208 | */
|
---|
209 |
|
---|
210 | struct Whostent {
|
---|
211 | char * h_name; /* official name of host */
|
---|
212 | char * * h_aliases; /* alias list */
|
---|
213 | short h_addrtype; /* host address type */
|
---|
214 | short h_length; /* length of address */
|
---|
215 | char * * h_addr_list; /* list of addresses */
|
---|
216 | #define h_addr h_addr_list[0] /* address, for backward compat */
|
---|
217 | };
|
---|
218 |
|
---|
219 | /*
|
---|
220 | * It is assumed here that a network number
|
---|
221 | * fits in 32 bits.
|
---|
222 | */
|
---|
223 | struct Wnetent {
|
---|
224 | char * n_name; /* official name of net */
|
---|
225 | char * * n_aliases; /* alias list */
|
---|
226 | short n_addrtype; /* net address type */
|
---|
227 | u_long n_net; /* network # */
|
---|
228 | };
|
---|
229 |
|
---|
230 | struct Wservent {
|
---|
231 | char * s_name; /* official service name */
|
---|
232 | char * * s_aliases; /* alias list */
|
---|
233 | short s_port; /* port # */
|
---|
234 | char * s_proto; /* protocol to use */
|
---|
235 | };
|
---|
236 |
|
---|
237 | struct Wprotoent {
|
---|
238 | char * p_name; /* official protocol name */
|
---|
239 | char * * p_aliases; /* alias list */
|
---|
240 | short p_proto; /* protocol # */
|
---|
241 | };
|
---|
242 |
|
---|
243 | /*
|
---|
244 | * Constants and structures defined by the internet system,
|
---|
245 | * Per RFC 790, September 1981, taken from the BSD file netinet/in.h.
|
---|
246 | */
|
---|
247 |
|
---|
248 | /*
|
---|
249 | * Protocols
|
---|
250 | */
|
---|
251 | #define IPPROTO_IP 0 /* dummy for IP */
|
---|
252 | #define IPPROTO_ICMP 1 /* control message protocol */
|
---|
253 | //#define IPPROTO_GGP 2 /* gateway^2 (deprecated) */
|
---|
254 | #define IPPROTO_TCP 6 /* tcp */
|
---|
255 | #define IPPROTO_PUP 12 /* pup */
|
---|
256 | #define IPPROTO_UDP 17 /* user datagram protocol */
|
---|
257 | #define IPPROTO_IDP 22 /* xns idp */
|
---|
258 | #define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */
|
---|
259 |
|
---|
260 | #define IPPROTO_RAW 255 /* raw IP packet */
|
---|
261 | #define IPPROTO_MAX 256
|
---|
262 |
|
---|
263 | /*
|
---|
264 | * Port/socket numbers: network standard functions
|
---|
265 | */
|
---|
266 | #define IPPORT_ECHO 7
|
---|
267 | #define IPPORT_DISCARD 9
|
---|
268 | #define IPPORT_SYSTAT 11
|
---|
269 | #define IPPORT_DAYTIME 13
|
---|
270 | #define IPPORT_NETSTAT 15
|
---|
271 | #define IPPORT_FTP 21
|
---|
272 | #define IPPORT_TELNET 23
|
---|
273 | #define IPPORT_SMTP 25
|
---|
274 | #define IPPORT_TIMESERVER 37
|
---|
275 | #define IPPORT_NAMESERVER 42
|
---|
276 | #define IPPORT_WHOIS 43
|
---|
277 | #define IPPORT_MTP 57
|
---|
278 |
|
---|
279 | /*
|
---|
280 | * Port/socket numbers: host specific functions
|
---|
281 | */
|
---|
282 | #define IPPORT_TFTP 69
|
---|
283 | #define IPPORT_RJE 77
|
---|
284 | #define IPPORT_FINGER 79
|
---|
285 | #define IPPORT_TTYLINK 87
|
---|
286 | #define IPPORT_SUPDUP 95
|
---|
287 |
|
---|
288 | /*
|
---|
289 | * UNIX TCP sockets
|
---|
290 | */
|
---|
291 | #define IPPORT_EXECSERVER 512
|
---|
292 | #define IPPORT_LOGINSERVER 513
|
---|
293 | #define IPPORT_CMDSERVER 514
|
---|
294 | #define IPPORT_EFSSERVER 520
|
---|
295 |
|
---|
296 | /*
|
---|
297 | * UNIX UDP sockets
|
---|
298 | */
|
---|
299 | #define IPPORT_BIFFUDP 512
|
---|
300 | #define IPPORT_WHOSERVER 513
|
---|
301 | #define IPPORT_ROUTESERVER 520
|
---|
302 | /* 520+1 also used */
|
---|
303 |
|
---|
304 | /*
|
---|
305 | * Ports < IPPORT_RESERVED are reserved for
|
---|
306 | * privileged processes (e.g. root).
|
---|
307 | */
|
---|
308 | #define IPPORT_RESERVED 1024
|
---|
309 |
|
---|
310 | /*
|
---|
311 | * Link numbers
|
---|
312 | */
|
---|
313 | #define IMPLINK_IP 155
|
---|
314 | #define IMPLINK_LOWEXPER 156
|
---|
315 | #define IMPLINK_HIGHEXPER 158
|
---|
316 |
|
---|
317 | /*
|
---|
318 | * Internet address (old style... should be updated)
|
---|
319 | */
|
---|
320 | struct Win_addr {
|
---|
321 | union {
|
---|
322 | struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
|
---|
323 | struct { u_short s_w1,s_w2; } S_un_w;
|
---|
324 | u_long S_addr;
|
---|
325 | } S_un;
|
---|
326 | #define s_addr S_un.S_addr
|
---|
327 | /* can be used for most tcp & ip code */
|
---|
328 | #define s_host S_un.S_un_b.s_b2
|
---|
329 | /* host on imp */
|
---|
330 | #define s_net S_un.S_un_b.s_b1
|
---|
331 | /* network */
|
---|
332 | #define s_imp S_un.S_un_w.s_w2
|
---|
333 | /* imp */
|
---|
334 | #define s_impno S_un.S_un_b.s_b4
|
---|
335 | /* imp # */
|
---|
336 | #define s_lh S_un.S_un_b.s_b3
|
---|
337 | /* logical host */
|
---|
338 | };
|
---|
339 |
|
---|
340 | /*
|
---|
341 | * Definitions of bits in internet address integers.
|
---|
342 | * On subnets, the decomposition of addresses to host and net parts
|
---|
343 | * is done according to subnet mask, not the masks here.
|
---|
344 | */
|
---|
345 | #define WIN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
|
---|
346 | #define WIN_CLASSA_NET 0xff000000
|
---|
347 | #define WIN_CLASSA_NSHIFT 24
|
---|
348 | #define WIN_CLASSA_HOST 0x00ffffff
|
---|
349 | #define WIN_CLASSA_MAX 128
|
---|
350 |
|
---|
351 | #define WIN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
|
---|
352 | #define WIN_CLASSB_NET 0xffff0000
|
---|
353 | #define WIN_CLASSB_NSHIFT 16
|
---|
354 | #define WIN_CLASSB_HOST 0x0000ffff
|
---|
355 | #define WIN_CLASSB_MAX 65536
|
---|
356 |
|
---|
357 | #define WIN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
|
---|
358 | #define WIN_CLASSC_NET 0xffffff00
|
---|
359 | #define WIN_CLASSC_NSHIFT 8
|
---|
360 | #define WIN_CLASSC_HOST 0x000000ff
|
---|
361 |
|
---|
362 | #define WINADDR_ANY (u_long)0x00000000
|
---|
363 | #define WINADDR_LOOPBACK 0x7f000001
|
---|
364 | #define WINADDR_BROADCAST (u_long)0xffffffff
|
---|
365 | #define WINADDR_NONE 0xffffffff
|
---|
366 |
|
---|
367 | /*
|
---|
368 | * Socket address, internet style.
|
---|
369 | */
|
---|
370 | struct Wsockaddr_in {
|
---|
371 | short sin_family;
|
---|
372 | u_short sin_port;
|
---|
373 | struct in_addr sin_addr;
|
---|
374 | char sin_zero[8];
|
---|
375 | };
|
---|
376 |
|
---|
377 | #define WSADESCRIPTION_LEN 256
|
---|
378 | #define WSASYS_STATUS_LEN 128
|
---|
379 |
|
---|
380 | typedef struct WSAData {
|
---|
381 | WORD wVersion;
|
---|
382 | WORD wHighVersion;
|
---|
383 | char szDescription[WSADESCRIPTION_LEN+1];
|
---|
384 | char szSystemStatus[WSASYS_STATUS_LEN+1];
|
---|
385 | unsigned short iMaxSockets;
|
---|
386 | unsigned short iMaxUdpDg;
|
---|
387 | char * lpVendorInfo;
|
---|
388 | } WSADATA;
|
---|
389 |
|
---|
390 | typedef WSADATA *LPWSADATA;
|
---|
391 |
|
---|
392 | /*
|
---|
393 | * Options for use with [gs]etsockopt at the IP level.
|
---|
394 | */
|
---|
395 | #define IP_OPTIONS 1 /* set/get IP per-packet options */
|
---|
396 |
|
---|
397 | /*
|
---|
398 | * Definitions related to sockets: types, address families, options,
|
---|
399 | * taken from the BSD file sys/socket.h.
|
---|
400 | */
|
---|
401 |
|
---|
402 | /*
|
---|
403 | * This is used instead of -1, since the
|
---|
404 | * SOCKET type is unsigned.
|
---|
405 | */
|
---|
406 | #define INVALID_SOCKET (SOCKET)(~0)
|
---|
407 | #define SOCKET_ERROR (-1)
|
---|
408 |
|
---|
409 | /*
|
---|
410 | * Types
|
---|
411 | */
|
---|
412 | #define SOCK_STREAM 1 /* stream socket */
|
---|
413 | #define SOCK_DGRAM 2 /* datagram socket */
|
---|
414 | #define SOCK_RAW 3 /* raw-protocol interface */
|
---|
415 | #define SOCK_RDM 4 /* reliably-delivered message */
|
---|
416 | #define SOCK_SEQPACKET 5 /* sequenced packet stream */
|
---|
417 |
|
---|
418 | /*
|
---|
419 | * Option flags per-socket.
|
---|
420 | */
|
---|
421 | #define SO_DEBUG 0x0001 /* turn on debugging info recording */
|
---|
422 | #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
|
---|
423 | #define SO_REUSEADDR 0x0004 /* allow local address reuse */
|
---|
424 | #define SO_KEEPALIVE 0x0008 /* keep connections alive */
|
---|
425 | #define SO_DONTROUTE 0x0010 /* just use interface addresses */
|
---|
426 | #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
|
---|
427 | #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
|
---|
428 | #define SO_LINGER 0x0080 /* linger on close if data present */
|
---|
429 | #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
|
---|
430 |
|
---|
431 | #define SO_DONTLINGER (u_int)(~SO_LINGER)
|
---|
432 |
|
---|
433 | /*
|
---|
434 | * Additional options.
|
---|
435 | */
|
---|
436 | #define SO_SNDBUF 0x1001 /* send buffer size */
|
---|
437 | #define SO_RCVBUF 0x1002 /* receive buffer size */
|
---|
438 | #define SO_SNDLOWAT 0x1003 /* send low-water mark */
|
---|
439 | #define SO_RCVLOWAT 0x1004 /* receive low-water mark */
|
---|
440 | #define SO_SNDTIMEO 0x1005 /* send timeout */
|
---|
441 | #define SO_RCVTIMEO 0x1006 /* receive timeout */
|
---|
442 | #define SO_ERROR 0x1007 /* get error status and clear */
|
---|
443 | #define SO_TYPE 0x1008 /* get socket type */
|
---|
444 |
|
---|
445 |
|
---|
446 | /*
|
---|
447 | * TCP options.
|
---|
448 | */
|
---|
449 | #define TCP_NODELAY 0x0001
|
---|
450 | #define TCP_BSDURGENT 0x7000
|
---|
451 |
|
---|
452 | /*
|
---|
453 | * Address families.
|
---|
454 | */
|
---|
455 | #define AF_UNSPEC 0 /* unspecified */
|
---|
456 | #define AF_UNIX 1 /* local to host (pipes, portals) */
|
---|
457 | #define AF_INET 2 /* internetwork: UDP, TCP, etc. */
|
---|
458 | #define AF_IMPLINK 3 /* arpanet imp addresses */
|
---|
459 | #define AF_PUP 4 /* pup protocols: e.g. BSP */
|
---|
460 | #define AF_CHAOS 5 /* mit CHAOS protocols */
|
---|
461 | #define AF_IPX 6 /* IPX and SPX */
|
---|
462 | #define AF_NS 6 /* XEROX NS protocols */
|
---|
463 | #define AF_ISO 7 /* ISO protocols */
|
---|
464 | #define AF_OSI AF_ISO /* OSI is ISO */
|
---|
465 | #define AF_ECMA 8 /* european computer manufacturers */
|
---|
466 | #define AF_DATAKIT 9 /* datakit protocols */
|
---|
467 | #define AF_CCITT 10 /* CCITT protocols, X.25 etc */
|
---|
468 | #define AF_SNA 11 /* IBM SNA */
|
---|
469 | #define AF_DECnet 12 /* DECnet */
|
---|
470 | #define AF_DLI 13 /* Direct data link interface */
|
---|
471 | #define AF_LAT 14 /* LAT */
|
---|
472 | #define AF_HYLINK 15 /* NSC Hyperchannel */
|
---|
473 | #define AF_APPLETALK 16 /* AppleTalk */
|
---|
474 | //#define AF_NETBIOS 17 /* NetBios-style addresses */
|
---|
475 | #define AF_VOICEVIEW 18 /* VoiceView */
|
---|
476 |
|
---|
477 | //#define AF_MAX 19
|
---|
478 |
|
---|
479 | /*
|
---|
480 | * Structure used by kernel to store most
|
---|
481 | * addresses.
|
---|
482 | */
|
---|
483 | struct Wsockaddr {
|
---|
484 | u_short sa_family; /* address family */
|
---|
485 | char sa_data[14]; /* up to 14 bytes of direct address */
|
---|
486 | };
|
---|
487 |
|
---|
488 | /*
|
---|
489 | * Structure used by kernel to pass protocol
|
---|
490 | * information in raw sockets.
|
---|
491 | */
|
---|
492 | struct Wsockproto {
|
---|
493 | u_short sp_family; /* address family */
|
---|
494 | u_short sp_protocol; /* protocol */
|
---|
495 | };
|
---|
496 |
|
---|
497 | /*
|
---|
498 | * Protocol families, same as address families for now.
|
---|
499 | */
|
---|
500 | #define PF_UNSPEC AF_UNSPEC
|
---|
501 | #define PF_UNIX AF_UNIX
|
---|
502 | #define PF_INET AF_INET
|
---|
503 | #define PF_IMPLINK AF_IMPLINK
|
---|
504 | #define PF_PUP AF_PUP
|
---|
505 | #define PF_CHAOS AF_CHAOS
|
---|
506 | #define PF_NS AF_NS
|
---|
507 | #define PF_IPX AF_IPX
|
---|
508 | #define PF_ISO AF_ISO
|
---|
509 | #define PF_OSI AF_OSI
|
---|
510 | #define PF_ECMA AF_ECMA
|
---|
511 | #define PF_DATAKIT AF_DATAKIT
|
---|
512 | #define PF_CCITT AF_CCITT
|
---|
513 | #define PF_SNA AF_SNA
|
---|
514 | #define PF_DECnet AF_DECnet
|
---|
515 | #define PF_DLI AF_DLI
|
---|
516 | #define PF_LAT AF_LAT
|
---|
517 | #define PF_HYLINK AF_HYLINK
|
---|
518 | #define PF_APPLETALK AF_APPLETALK
|
---|
519 | #define PF_VOICEVIEW AF_VOICEVIEW
|
---|
520 |
|
---|
521 | #define PF_MAX AF_MAX
|
---|
522 |
|
---|
523 | /*
|
---|
524 | * Structure used for manipulating linger option.
|
---|
525 | */
|
---|
526 | struct Wlinger {
|
---|
527 | u_short l_onoff; /* option on/off */
|
---|
528 | u_short l_linger; /* linger time */
|
---|
529 | };
|
---|
530 |
|
---|
531 | /*
|
---|
532 | * Level number for (get/set)sockopt() to apply to socket itself.
|
---|
533 | */
|
---|
534 | #define SOL_SOCKET 0xffff /* options for socket level */
|
---|
535 |
|
---|
536 | /*
|
---|
537 | * Maximum queue length specifiable by listen.
|
---|
538 | */
|
---|
539 | #define SOMAXCONN 5
|
---|
540 |
|
---|
541 | #define MSG_OOB 0x1 /* process out-of-band data */
|
---|
542 | #define MSG_PEEK 0x2 /* peek at incoming message */
|
---|
543 | #define MSG_DONTROUTE 0x4 /* send without using routing tables */
|
---|
544 |
|
---|
545 | #define MSG_MAXIOVLEN 16
|
---|
546 |
|
---|
547 | #define MSG_PARTIAL 0x8000 /* partial send or recv for message xport */
|
---|
548 |
|
---|
549 | /*
|
---|
550 | * Define constant based on rfc883, used by gethostbyxxxx() calls.
|
---|
551 | */
|
---|
552 | #define MAXGETHOSTSTRUCT 1024
|
---|
553 |
|
---|
554 | /*
|
---|
555 | * Define flags to be used with the WSAAsyncSelect() call.
|
---|
556 | */
|
---|
557 | #define FD_READ 0x01
|
---|
558 | #define FD_WRITE 0x02
|
---|
559 | #define FD_OOB 0x04
|
---|
560 | #define FD_ACCEPT 0x08
|
---|
561 | #define FD_CONNECT 0x10
|
---|
562 | #define FD_CLOSE 0x20
|
---|
563 |
|
---|
564 | /*
|
---|
565 | * All Windows Sockets error constants are biased by WSABASEERR from
|
---|
566 | * the "normal"
|
---|
567 | */
|
---|
568 | #define WSABASEERR 10000
|
---|
569 | /*
|
---|
570 | * Windows Sockets definitions of regular Microsoft C error constants
|
---|
571 | */
|
---|
572 | #define WSAEINTR (WSABASEERR+4)
|
---|
573 | #define WSAEBADF (WSABASEERR+9)
|
---|
574 | #define WSAEACCES (WSABASEERR+13)
|
---|
575 | #define WSAEFAULT (WSABASEERR+14)
|
---|
576 | #define WSAEINVAL (WSABASEERR+22)
|
---|
577 | #define WSAEMFILE (WSABASEERR+24)
|
---|
578 |
|
---|
579 | /*
|
---|
580 | * Windows Sockets definitions of regular Berkeley error constants
|
---|
581 | */
|
---|
582 | #define WSAEWOULDBLOCK (WSABASEERR+35)
|
---|
583 | #define WSAEINPROGRESS (WSABASEERR+36)
|
---|
584 | #define WSAEALREADY (WSABASEERR+37)
|
---|
585 | #define WSAENOTSOCK (WSABASEERR+38)
|
---|
586 | #define WSAEDESTADDRREQ (WSABASEERR+39)
|
---|
587 | #define WSAEMSGSIZE (WSABASEERR+40)
|
---|
588 | #define WSAEPROTOTYPE (WSABASEERR+41)
|
---|
589 | #define WSAENOPROTOOPT (WSABASEERR+42)
|
---|
590 | #define WSAEPROTONOSUPPORT (WSABASEERR+43)
|
---|
591 | #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
|
---|
592 | #define WSAEOPNOTSUPP (WSABASEERR+45)
|
---|
593 | #define WSAEPFNOSUPPORT (WSABASEERR+46)
|
---|
594 | #define WSAEAFNOSUPPORT (WSABASEERR+47)
|
---|
595 | #define WSAEADDRINUSE (WSABASEERR+48)
|
---|
596 | #define WSAEADDRNOTAVAIL (WSABASEERR+49)
|
---|
597 | #define WSAENETDOWN (WSABASEERR+50)
|
---|
598 | #define WSAENETUNREACH (WSABASEERR+51)
|
---|
599 | #define WSAENETRESET (WSABASEERR+52)
|
---|
600 | #define WSAECONNABORTED (WSABASEERR+53)
|
---|
601 | #define WSAECONNRESET (WSABASEERR+54)
|
---|
602 | #define WSAENOBUFS (WSABASEERR+55)
|
---|
603 | #define WSAEISCONN (WSABASEERR+56)
|
---|
604 | #define WSAENOTCONN (WSABASEERR+57)
|
---|
605 | #define WSAESHUTDOWN (WSABASEERR+58)
|
---|
606 | #define WSAETOOMANYREFS (WSABASEERR+59)
|
---|
607 | #define WSAETIMEDOUT (WSABASEERR+60)
|
---|
608 | #define WSAECONNREFUSED (WSABASEERR+61)
|
---|
609 | #define WSAELOOP (WSABASEERR+62)
|
---|
610 | #define WSAENAMETOOLONG (WSABASEERR+63)
|
---|
611 | #define WSAEHOSTDOWN (WSABASEERR+64)
|
---|
612 | #define WSAEHOSTUNREACH (WSABASEERR+65)
|
---|
613 | #define WSAENOTEMPTY (WSABASEERR+66)
|
---|
614 | #define WSAEPROCLIM (WSABASEERR+67)
|
---|
615 | #define WSAEUSERS (WSABASEERR+68)
|
---|
616 | #define WSAEDQUOT (WSABASEERR+69)
|
---|
617 | #define WSAESTALE (WSABASEERR+70)
|
---|
618 | #define WSAEREMOTE (WSABASEERR+71)
|
---|
619 |
|
---|
620 | #define WSAEDISCON (WSABASEERR+101)
|
---|
621 |
|
---|
622 | /*
|
---|
623 | * Extended Windows Sockets error constant definitions
|
---|
624 | */
|
---|
625 | #define WSASYSNOTREADY (WSABASEERR+91)
|
---|
626 | #define WSAVERNOTSUPPORTED (WSABASEERR+92)
|
---|
627 | #define WSANOTINITIALISED (WSABASEERR+93)
|
---|
628 |
|
---|
629 | /*
|
---|
630 | * Error return codes from gethostbyname() and gethostbyaddr()
|
---|
631 | * (when using the resolver). Note that these errors are
|
---|
632 | * retrieved via WSAGetLastError() and must therefore follow
|
---|
633 | * the rules for avoiding clashes with error numbers from
|
---|
634 | * specific implementations or language run-time systems.
|
---|
635 | * For this reason the codes are based at WSABASEERR+1001.
|
---|
636 | * Note also that [WSA]NO_ADDRESS is defined only for
|
---|
637 | * compatibility purposes.
|
---|
638 | */
|
---|
639 |
|
---|
640 | #define Wh_errno WSAGetLastError()
|
---|
641 |
|
---|
642 | /* Authoritative Answer: Host not found */
|
---|
643 | #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
|
---|
644 | #define WHOST_NOT_FOUND WSAHOST_NOT_FOUND
|
---|
645 |
|
---|
646 | /* Non-Authoritative: Host not found, or SERVERFAIL */
|
---|
647 | #define WSATRY_AGAIN (WSABASEERR+1002)
|
---|
648 | #define WTRY_AGAIN WSATRY_AGAIN
|
---|
649 |
|
---|
650 | /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
|
---|
651 | #define WSANO_RECOVERY (WSABASEERR+1003)
|
---|
652 | #define WNO_RECOVERY WSANO_RECOVERY
|
---|
653 |
|
---|
654 | /* Valid name, no data record of requested type */
|
---|
655 | #define WSANO_DATA (WSABASEERR+1004)
|
---|
656 | #define WNO_DATA WSANO_DATA
|
---|
657 |
|
---|
658 | /* no address, look for MX record */
|
---|
659 | #define WSANO_ADDRESS WSANO_DATA
|
---|
660 | #define WNO_ADDRESS WSANO_ADDRESS
|
---|
661 |
|
---|
662 |
|
---|
663 | /* Socket function prototypes */
|
---|
664 |
|
---|
665 | #ifdef __cplusplus
|
---|
666 | extern "C" {
|
---|
667 | #endif
|
---|
668 |
|
---|
669 | SOCKET WIN32API OS2accept (SOCKET s, struct sockaddr *addr, int *addrlen);
|
---|
670 | int WIN32API OS2bind (SOCKET s, const struct sockaddr *addr, int namelen);
|
---|
671 | int WIN32API OS2closesocket (SOCKET s);
|
---|
672 | int WIN32API OS2connect (SOCKET s, const struct sockaddr *name, int namelen);
|
---|
673 | int WIN32API OS2ioctlsocket (SOCKET s, long cmd, u_long *argp);
|
---|
674 | int WIN32API OS2getpeername (SOCKET s, struct sockaddr *name, int * namelen);
|
---|
675 | int WIN32API OS2getsockname (SOCKET s, struct sockaddr *name, int * namelen);
|
---|
676 | int WIN32API OS2getsockopt (SOCKET s, int level, int optname, char * optval, int *optlen);
|
---|
677 | u_long WIN32API OS2htonl (u_long hostlong);
|
---|
678 | u_short WIN32API OS2htons (u_short hostshort);
|
---|
679 | u_long WIN32API OS2inet_addr (const char * cp);
|
---|
680 | char * WIN32API OS2inet_ntoa (struct in_addr in);
|
---|
681 | int WIN32API OS2listen (SOCKET s, int backlog);
|
---|
682 | u_long WIN32API OS2ntohl (u_long netlong);
|
---|
683 | u_short WIN32API OS2ntohs (u_short netshort);
|
---|
684 | int WIN32API OS2recv (SOCKET s, char * buf, int len, int flags);
|
---|
685 | int WIN32API OS2recvfrom (SOCKET s, char * buf, int len, int flags, struct sockaddr *from, int * fromlen);
|
---|
686 | int WIN32API OS2select (int nfds, Wfd_set *readfds, Wfd_set *writefds, Wfd_set *exceptfds, const struct Wtimeval *timeout);
|
---|
687 | int WIN32API OS2send (SOCKET s, const char * buf, int len, int flags);
|
---|
688 | int WIN32API OS2sendto (SOCKET s, const char * buf, int len, int flags, const struct sockaddr *to, int tolen);
|
---|
689 | int WIN32API OS2setsockopt (SOCKET s, int level, int optname, const char * optval, int optlen);
|
---|
690 | int WIN32API OS2shutdown (SOCKET s, int how);
|
---|
691 | SOCKET WIN32API OS2socket (int af, int type, int protocol);
|
---|
692 |
|
---|
693 | /* Database function prototypes */
|
---|
694 | struct Whostent * WIN32API OS2gethostbyaddr(const char * addr, int len, int type);
|
---|
695 | struct Whostent * WIN32API OS2gethostbyname(const char * name);
|
---|
696 | int WIN32API OS2gethostname (char * name, int namelen);
|
---|
697 | struct Wservent * WIN32API OS2getservbyport(int port, const char * proto);
|
---|
698 | struct Wservent * WIN32API OS2getservbyname(const char * name, const char * proto);
|
---|
699 | struct Wprotoent * WIN32API OS2getprotobynumber(int proto);
|
---|
700 | struct Wprotoent * WIN32API OS2getprotobyname(const char * name);
|
---|
701 |
|
---|
702 | /* Microsoft Windows Extension function prototypes */
|
---|
703 | int WIN32API OS2WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData);
|
---|
704 | int WIN32API OS2WSACleanup(void);
|
---|
705 | void WIN32API OS2WSASetLastError(int iError);
|
---|
706 | int WIN32API OS2WSAGetLastError(void);
|
---|
707 | BOOL WIN32API OS2WSAIsBlocking(void);
|
---|
708 | int WIN32API OS2WSAUnhookBlockingHook(void);
|
---|
709 | PROC WIN32API OS2WSASetBlockingHook(PROC lpBlockFunc);
|
---|
710 | int WIN32API OS2WSACancelBlockingCall(void);
|
---|
711 | HANDLE WIN32API OS2WSAAsyncGetServByName(HWND hWnd, u_int wMsg, const char * name, const char * proto, char * buf, int buflen);
|
---|
712 | HANDLE WIN32API OS2WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port, const char * proto, char * buf, int buflen);
|
---|
713 | HANDLE WIN32API OS2WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg, const char * name, char * buf, int buflen);
|
---|
714 | HANDLE WIN32API OS2WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg, int number, char * buf, int buflen);
|
---|
715 | HANDLE WIN32API OS2WSAAsyncGetHostByName(HWND hWnd, u_int wMsg, const char * name, char * buf, int buflen);
|
---|
716 | HANDLE WIN32API OS2WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg, const char * addr, int len, int type, char * buf, int buflen);
|
---|
717 | int WIN32API OS2WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
|
---|
718 | int WIN32API OS2WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, long lEvent);
|
---|
719 | int WIN32API OS2WSARecvEx (SOCKET s, char * buf, int len, int *flags);
|
---|
720 |
|
---|
721 |
|
---|
722 |
|
---|
723 | typedef struct _TRANSMIT_FILE_BUFFERS {
|
---|
724 | PVOID Head;
|
---|
725 | DWORD HeadLength;
|
---|
726 | PVOID Tail;
|
---|
727 | DWORD TailLength;
|
---|
728 | } TRANSMIT_FILE_BUFFERS, *PTRANSMIT_FILE_BUFFERS, *LPTRANSMIT_FILE_BUFFERS;
|
---|
729 |
|
---|
730 | typedef struct _OVERLAPPED {
|
---|
731 | DWORD Internal;
|
---|
732 | DWORD InternalHigh;
|
---|
733 | DWORD Offset;
|
---|
734 | DWORD OffsetHigh;
|
---|
735 | HANDLE hEvent;
|
---|
736 | } OVERLAPPED, *LPOVERLAPPED;
|
---|
737 |
|
---|
738 |
|
---|
739 | BOOL WIN32API OS2TransmitFile (SOCKET hSocket,
|
---|
740 | HANDLE hFile,
|
---|
741 | DWORD nNumberOfBytesToWrite,
|
---|
742 | DWORD nNumberOfBytesPerSend,
|
---|
743 | LPOVERLAPPED lpOverlapped,
|
---|
744 | LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
|
---|
745 | DWORD dwReserved);
|
---|
746 |
|
---|
747 | #ifdef __cplusplus
|
---|
748 | }
|
---|
749 | #endif
|
---|
750 |
|
---|
751 | typedef struct sockaddr SOCKADDR;
|
---|
752 | typedef struct sockaddr *PSOCKADDR;
|
---|
753 | typedef struct sockaddr *LPSOCKADDR;
|
---|
754 |
|
---|
755 | typedef struct sockaddr_in SOCKADDR_IN;
|
---|
756 | typedef struct sockaddr_in *PSOCKADDR_IN;
|
---|
757 | typedef struct sockaddr_in *LPSOCKADDR_IN;
|
---|
758 |
|
---|
759 | typedef struct linger LINGER;
|
---|
760 | typedef struct linger *PLINGER;
|
---|
761 | typedef struct linger *LPLINGER;
|
---|
762 |
|
---|
763 | typedef struct in_addr IN_ADDR;
|
---|
764 | typedef struct in_addr *PIN_ADDR;
|
---|
765 | typedef struct in_addr *LPIN_ADDR;
|
---|
766 |
|
---|
767 | typedef struct Wfd_set WFD_SET;
|
---|
768 | typedef struct Wfd_set *PWFD_SET;
|
---|
769 | typedef struct Wfd_set *LPWFD_SET;
|
---|
770 |
|
---|
771 | typedef struct Whostent WHOSTENT;
|
---|
772 | typedef struct Whostent *PWHOSTENT;
|
---|
773 | typedef struct Whostent *LPWHOSTENT;
|
---|
774 |
|
---|
775 | typedef struct Wservent WSERVENT;
|
---|
776 | typedef struct Wservent *PWSERVENT;
|
---|
777 | typedef struct Wservent *LPWSERVENT;
|
---|
778 |
|
---|
779 | typedef struct Wprotoent WPROTOENT;
|
---|
780 | typedef struct Wprotoent *PWPROTOENT;
|
---|
781 | typedef struct Wprotoent *LPWPROTOENT;
|
---|
782 |
|
---|
783 | typedef struct Wtimeval WTIMEVAL;
|
---|
784 | typedef struct Wtimeval *PWTIMEVAL;
|
---|
785 | typedef struct Wtimeval *LPWTIMEVAL;
|
---|
786 |
|
---|
787 | /*
|
---|
788 | * Windows message parameter composition and decomposition
|
---|
789 | * macros.
|
---|
790 | *
|
---|
791 | * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
|
---|
792 | * when constructing the response to a WSAAsyncGetXByY() routine.
|
---|
793 | */
|
---|
794 | #define OS2WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
|
---|
795 | /*
|
---|
796 | * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
|
---|
797 | * when constructing the response to WSAAsyncSelect().
|
---|
798 | */
|
---|
799 | #define OS2WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
|
---|
800 | /*
|
---|
801 | * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
|
---|
802 | * to extract the buffer length from the lParam in the response
|
---|
803 | * to a WSAGetXByY().
|
---|
804 | */
|
---|
805 | #define OS2WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
|
---|
806 | /*
|
---|
807 | * WSAGETASYNCERROR is intended for use by the Windows Sockets application
|
---|
808 | * to extract the error code from the lParam in the response
|
---|
809 | * to a WSAGetXByY().
|
---|
810 | */
|
---|
811 | #define OS2WSAGETASYNCERROR(lParam) HIWORD(lParam)
|
---|
812 | /*
|
---|
813 | * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
|
---|
814 | * to extract the event code from the lParam in the response
|
---|
815 | * to a WSAAsyncSelect().
|
---|
816 | */
|
---|
817 | #define OS2WSAGETSELECTEVENT(lParam) LOWORD(lParam)
|
---|
818 | /*
|
---|
819 | * WSAGETSELECTERROR is intended for use by the Windows Sockets application
|
---|
820 | * to extract the error code from the lParam in the response
|
---|
821 | * to a WSAAsyncSelect().
|
---|
822 | */
|
---|
823 | #define OS2WSAGETSELECTERROR(lParam) HIWORD(lParam)
|
---|
824 |
|
---|
825 | #endif /* _WINSOCKAPI_ */
|
---|
826 |
|
---|
827 |
|
---|