1 | /* $Id: wsock32.h,v 1.1 1999-12-07 20:19:59 achimha 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 | * Select uses arrays of SOCKETs. These macros manipulate such
|
---|
80 | * arrays. FD_SETSIZE may be defined by the user before including
|
---|
81 | * this file, but the default here should be >= 64.
|
---|
82 | *
|
---|
83 | * CAVEAT IMPLEMENTOR and USER: THESE MACROS AND TYPES MUST BE
|
---|
84 | * INCLUDED IN WINSOCK.H EXACTLY AS SHOWN HERE.
|
---|
85 | */
|
---|
86 | #ifndef FD_SETSIZE
|
---|
87 | #define FD_SETSIZE 64
|
---|
88 | #endif /* FD_SETSIZE */
|
---|
89 |
|
---|
90 | typedef struct Wfd_set {
|
---|
91 | u_int fd_count; /* how many are SET? */
|
---|
92 | SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */
|
---|
93 | } Wfd_set;
|
---|
94 |
|
---|
95 |
|
---|
96 |
|
---|
97 | #ifdef __cplusplus
|
---|
98 | extern "C" {
|
---|
99 | #endif
|
---|
100 |
|
---|
101 | extern int PASCAL __WSAFDIsSet(SOCKET, Wfd_set *);
|
---|
102 |
|
---|
103 | #ifdef __cplusplus
|
---|
104 | }
|
---|
105 | #endif
|
---|
106 |
|
---|
107 | /*
|
---|
108 | #define FD_CLR(fd, set) do { \
|
---|
109 | u_int __i; \
|
---|
110 | for (__i = 0; __i < ((Wfd_set *)(set))->fd_count ; __i++) { \
|
---|
111 | if (((Wfd_set *)(set))->fd_array[__i] == fd) { \
|
---|
112 | while (__i < ((Wfd_set *)(set))->fd_count-1) { \
|
---|
113 | ((Wfd_set *)(set))->fd_array[__i] = \
|
---|
114 | ((Wfd_set *)(set))->fd_array[__i+1]; \
|
---|
115 | __i++; \
|
---|
116 | } \
|
---|
117 | ((Wfd_set *)(set))->fd_count--; \
|
---|
118 | break; \
|
---|
119 | } \
|
---|
120 | } \
|
---|
121 | } while(0)
|
---|
122 |
|
---|
123 | #define FD_SET(fd, set) do { \
|
---|
124 | if (((Wfd_set *)(set))->fd_count < FD_SETSIZE) \
|
---|
125 | ((Wfd_set *)(set))->fd_array[((Wfd_set *)(set))->fd_count++]=(fd);\
|
---|
126 | } while(0)
|
---|
127 |
|
---|
128 | #define FD_ZERO(set) (((Wfd_set *)(set))->fd_count=0)
|
---|
129 |
|
---|
130 | #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (Wfd_set *)(set))
|
---|
131 | */
|
---|
132 |
|
---|
133 | /*
|
---|
134 | * Structure used in select() call, taken from the BSD file sys/time.h.
|
---|
135 | */
|
---|
136 | struct Wtimeval {
|
---|
137 | long tv_sec; /* seconds */
|
---|
138 | long tv_usec; /* and microseconds */
|
---|
139 | };
|
---|
140 |
|
---|
141 | /*
|
---|
142 | * Operations on timevals.
|
---|
143 | *
|
---|
144 | * NB: timercmp does not work for >= or <=.
|
---|
145 | */
|
---|
146 | #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
|
---|
147 | #define Wtimercmp(tvp, uvp, cmp) \
|
---|
148 | ((tvp)->tv_sec cmp (uvp)->tv_sec || \
|
---|
149 | (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
|
---|
150 | #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
|
---|
151 |
|
---|
152 | /*
|
---|
153 | * Commands for ioctlsocket(), taken from the BSD file fcntl.h.
|
---|
154 | *
|
---|
155 | *
|
---|
156 | * Ioctl's have the command encoded in the lower word,
|
---|
157 | * and the size of any in or out parameters in the upper
|
---|
158 | * word. The high 2 bits of the upper word are used
|
---|
159 | * to encode the in/out status of the parameter; for now
|
---|
160 | * we restrict parameters to at most 128 bytes.
|
---|
161 | */
|
---|
162 | #define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
|
---|
163 | #define IOC_VOID 0x20000000 /* no parameters */
|
---|
164 | #define IOC_OUT 0x40000000 /* copy out parameters */
|
---|
165 | #define IOC_IN 0x80000000 /* copy in parameters */
|
---|
166 | #define IOC_INOUT (IOC_IN|IOC_OUT)
|
---|
167 | /* 0x20000000 distinguishes new &
|
---|
168 | old ioctl's */
|
---|
169 | #define _IO(x,y) (IOC_VOID|((x)<<8)|(y))
|
---|
170 |
|
---|
171 | #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
|
---|
172 |
|
---|
173 | #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y))
|
---|
174 |
|
---|
175 | #define WFIONREAD _IOR('f', 127, u_long) /* get # bytes to read */
|
---|
176 | #define WFIONBIO _IOW('f', 126, u_long) /* set/clear non-blocking i/o */
|
---|
177 | #define WFIOASYNC _IOW('f', 125, u_long) /* set/clear async i/o */
|
---|
178 |
|
---|
179 | /* Socket I/O Controls */
|
---|
180 | #define WSIOCSHIWAT _IOW('s', 0, u_long) /* set high watermark */
|
---|
181 | #define WSIOCGHIWAT _IOR('s', 1, u_long) /* get high watermark */
|
---|
182 | #define WSIOCSLOWAT _IOW('s', 2, u_long) /* set low watermark */
|
---|
183 | #define WSIOCGLOWAT _IOR('s', 3, u_long) /* get low watermark */
|
---|
184 | #define WSIOCATMARK _IOR('s', 7, u_long) /* at oob mark? */
|
---|
185 |
|
---|
186 | /*
|
---|
187 | * Constants and structures defined by the internet system,
|
---|
188 | * Per RFC 790, September 1981, taken from the BSD file netinet/in.h.
|
---|
189 | */
|
---|
190 |
|
---|
191 | /*
|
---|
192 | * Protocols
|
---|
193 | */
|
---|
194 | #define IPPROTO_IP 0 /* dummy for IP */
|
---|
195 | #define IPPROTO_ICMP 1 /* control message protocol */
|
---|
196 | //#define IPPROTO_GGP 2 /* gateway^2 (deprecated) */
|
---|
197 | #define IPPROTO_TCP 6 /* tcp */
|
---|
198 | #define IPPROTO_PUP 12 /* pup */
|
---|
199 | #define IPPROTO_UDP 17 /* user datagram protocol */
|
---|
200 | #define IPPROTO_IDP 22 /* xns idp */
|
---|
201 | #define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */
|
---|
202 |
|
---|
203 | #define IPPROTO_RAW 255 /* raw IP packet */
|
---|
204 | #define IPPROTO_MAX 256
|
---|
205 |
|
---|
206 | /*
|
---|
207 | * Port/socket numbers: network standard functions
|
---|
208 | */
|
---|
209 | #define IPPORT_ECHO 7
|
---|
210 | #define IPPORT_DISCARD 9
|
---|
211 | #define IPPORT_SYSTAT 11
|
---|
212 | #define IPPORT_DAYTIME 13
|
---|
213 | #define IPPORT_NETSTAT 15
|
---|
214 | #define IPPORT_FTP 21
|
---|
215 | #define IPPORT_TELNET 23
|
---|
216 | #define IPPORT_SMTP 25
|
---|
217 | #define IPPORT_TIMESERVER 37
|
---|
218 | #define IPPORT_NAMESERVER 42
|
---|
219 | #define IPPORT_WHOIS 43
|
---|
220 | #define IPPORT_MTP 57
|
---|
221 |
|
---|
222 | /*
|
---|
223 | * Port/socket numbers: host specific functions
|
---|
224 | */
|
---|
225 | #define IPPORT_TFTP 69
|
---|
226 | #define IPPORT_RJE 77
|
---|
227 | #define IPPORT_FINGER 79
|
---|
228 | #define IPPORT_TTYLINK 87
|
---|
229 | #define IPPORT_SUPDUP 95
|
---|
230 |
|
---|
231 | /*
|
---|
232 | * UNIX TCP sockets
|
---|
233 | */
|
---|
234 | #define IPPORT_EXECSERVER 512
|
---|
235 | #define IPPORT_LOGINSERVER 513
|
---|
236 | #define IPPORT_CMDSERVER 514
|
---|
237 | #define IPPORT_EFSSERVER 520
|
---|
238 |
|
---|
239 | /*
|
---|
240 | * UNIX UDP sockets
|
---|
241 | */
|
---|
242 | #define IPPORT_BIFFUDP 512
|
---|
243 | #define IPPORT_WHOSERVER 513
|
---|
244 | #define IPPORT_ROUTESERVER 520
|
---|
245 | /* 520+1 also used */
|
---|
246 |
|
---|
247 | /*
|
---|
248 | * Ports < IPPORT_RESERVED are reserved for
|
---|
249 | * privileged processes (e.g. root).
|
---|
250 | */
|
---|
251 | #define IPPORT_RESERVED 1024
|
---|
252 |
|
---|
253 | /*
|
---|
254 | * Link numbers
|
---|
255 | */
|
---|
256 | #define IMPLINK_IP 155
|
---|
257 | #define IMPLINK_LOWEXPER 156
|
---|
258 | #define IMPLINK_HIGHEXPER 158
|
---|
259 |
|
---|
260 | /*
|
---|
261 | * Internet address (old style... should be updated)
|
---|
262 | */
|
---|
263 | struct Win_addr {
|
---|
264 | union {
|
---|
265 | struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
|
---|
266 | struct { u_short s_w1,s_w2; } S_un_w;
|
---|
267 | u_long S_addr;
|
---|
268 | } S_un;
|
---|
269 | #define s_addr S_un.S_addr
|
---|
270 | /* can be used for most tcp & ip code */
|
---|
271 | #define s_host S_un.S_un_b.s_b2
|
---|
272 | /* host on imp */
|
---|
273 | #define s_net S_un.S_un_b.s_b1
|
---|
274 | /* network */
|
---|
275 | #define s_imp S_un.S_un_w.s_w2
|
---|
276 | /* imp */
|
---|
277 | #define s_impno S_un.S_un_b.s_b4
|
---|
278 | /* imp # */
|
---|
279 | #define s_lh S_un.S_un_b.s_b3
|
---|
280 | /* logical host */
|
---|
281 | };
|
---|
282 |
|
---|
283 | /*
|
---|
284 | * Definitions of bits in internet address integers.
|
---|
285 | * On subnets, the decomposition of addresses to host and net parts
|
---|
286 | * is done according to subnet mask, not the masks here.
|
---|
287 | */
|
---|
288 | #define WIN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
|
---|
289 | #define WIN_CLASSA_NET 0xff000000
|
---|
290 | #define WIN_CLASSA_NSHIFT 24
|
---|
291 | #define WIN_CLASSA_HOST 0x00ffffff
|
---|
292 | #define WIN_CLASSA_MAX 128
|
---|
293 |
|
---|
294 | #define WIN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
|
---|
295 | #define WIN_CLASSB_NET 0xffff0000
|
---|
296 | #define WIN_CLASSB_NSHIFT 16
|
---|
297 | #define WIN_CLASSB_HOST 0x0000ffff
|
---|
298 | #define WIN_CLASSB_MAX 65536
|
---|
299 |
|
---|
300 | #define WIN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
|
---|
301 | #define WIN_CLASSC_NET 0xffffff00
|
---|
302 | #define WIN_CLASSC_NSHIFT 8
|
---|
303 | #define WIN_CLASSC_HOST 0x000000ff
|
---|
304 |
|
---|
305 | #define WINADDR_ANY (u_long)0x00000000
|
---|
306 | #define WINADDR_LOOPBACK 0x7f000001
|
---|
307 | #define WINADDR_BROADCAST (u_long)0xffffffff
|
---|
308 | #define WINADDR_NONE 0xffffffff
|
---|
309 |
|
---|
310 | /*
|
---|
311 | * Socket address, internet style.
|
---|
312 | */
|
---|
313 | struct Wsockaddr_in {
|
---|
314 | short sin_family;
|
---|
315 | u_short sin_port;
|
---|
316 | struct in_addr sin_addr;
|
---|
317 | char sin_zero[8];
|
---|
318 | };
|
---|
319 |
|
---|
320 | #define WSADESCRIPTION_LEN 256
|
---|
321 | #define WSASYS_STATUS_LEN 128
|
---|
322 |
|
---|
323 | typedef struct WSAData {
|
---|
324 | WORD wVersion;
|
---|
325 | WORD wHighVersion;
|
---|
326 | char szDescription[WSADESCRIPTION_LEN+1];
|
---|
327 | char szSystemStatus[WSASYS_STATUS_LEN+1];
|
---|
328 | unsigned short iMaxSockets;
|
---|
329 | unsigned short iMaxUdpDg;
|
---|
330 | char * lpVendorInfo;
|
---|
331 | } WSADATA;
|
---|
332 |
|
---|
333 | typedef WSADATA *LPWSADATA;
|
---|
334 |
|
---|
335 | /*
|
---|
336 | * Options for use with [gs]etsockopt at the IP level.
|
---|
337 | */
|
---|
338 | #define IP_OPTIONS 1 /* set/get IP per-packet options */
|
---|
339 |
|
---|
340 | /*
|
---|
341 | * Definitions related to sockets: types, address families, options,
|
---|
342 | * taken from the BSD file sys/socket.h.
|
---|
343 | */
|
---|
344 |
|
---|
345 |
|
---|
346 | /*
|
---|
347 | * Types
|
---|
348 | */
|
---|
349 | #define SOCK_STREAM 1 /* stream socket */
|
---|
350 | #define SOCK_DGRAM 2 /* datagram socket */
|
---|
351 | #define SOCK_RAW 3 /* raw-protocol interface */
|
---|
352 | #define SOCK_RDM 4 /* reliably-delivered message */
|
---|
353 | #define SOCK_SEQPACKET 5 /* sequenced packet stream */
|
---|
354 |
|
---|
355 | /*
|
---|
356 | * Option flags per-socket.
|
---|
357 | */
|
---|
358 | #define SO_DEBUG 0x0001 /* turn on debugging info recording */
|
---|
359 | #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
|
---|
360 | #define SO_REUSEADDR 0x0004 /* allow local address reuse */
|
---|
361 | #define SO_KEEPALIVE 0x0008 /* keep connections alive */
|
---|
362 | #define SO_DONTROUTE 0x0010 /* just use interface addresses */
|
---|
363 | #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
|
---|
364 | #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
|
---|
365 | #define SO_LINGER 0x0080 /* linger on close if data present */
|
---|
366 | #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
|
---|
367 |
|
---|
368 | #define SO_DONTLINGER (u_int)(~SO_LINGER)
|
---|
369 |
|
---|
370 | /*
|
---|
371 | * Additional options.
|
---|
372 | */
|
---|
373 | #define SO_SNDBUF 0x1001 /* send buffer size */
|
---|
374 | #define SO_RCVBUF 0x1002 /* receive buffer size */
|
---|
375 | #define SO_SNDLOWAT 0x1003 /* send low-water mark */
|
---|
376 | #define SO_RCVLOWAT 0x1004 /* receive low-water mark */
|
---|
377 | #define SO_SNDTIMEO 0x1005 /* send timeout */
|
---|
378 | #define SO_RCVTIMEO 0x1006 /* receive timeout */
|
---|
379 | #define SO_ERROR 0x1007 /* get error status and clear */
|
---|
380 | #define SO_TYPE 0x1008 /* get socket type */
|
---|
381 |
|
---|
382 |
|
---|
383 | /*
|
---|
384 | * TCP options.
|
---|
385 | */
|
---|
386 | #define TCP_NODELAY 0x0001
|
---|
387 | #define TCP_BSDURGENT 0x7000
|
---|
388 |
|
---|
389 | /*
|
---|
390 | * Address families.
|
---|
391 | */
|
---|
392 | #define AF_UNSPEC 0 /* unspecified */
|
---|
393 | #define AF_UNIX 1 /* local to host (pipes, portals) */
|
---|
394 | #define AF_INET 2 /* internetwork: UDP, TCP, etc. */
|
---|
395 | #define AF_IMPLINK 3 /* arpanet imp addresses */
|
---|
396 | #define AF_PUP 4 /* pup protocols: e.g. BSP */
|
---|
397 | #define AF_CHAOS 5 /* mit CHAOS protocols */
|
---|
398 | #define AF_IPX 6 /* IPX and SPX */
|
---|
399 | #define AF_NS 6 /* XEROX NS protocols */
|
---|
400 | #define AF_ISO 7 /* ISO protocols */
|
---|
401 | #define AF_OSI AF_ISO /* OSI is ISO */
|
---|
402 | #define AF_ECMA 8 /* european computer manufacturers */
|
---|
403 | #define AF_DATAKIT 9 /* datakit protocols */
|
---|
404 | #define AF_CCITT 10 /* CCITT protocols, X.25 etc */
|
---|
405 | #define AF_SNA 11 /* IBM SNA */
|
---|
406 | #define AF_DECnet 12 /* DECnet */
|
---|
407 | #define AF_DLI 13 /* Direct data link interface */
|
---|
408 | #define AF_LAT 14 /* LAT */
|
---|
409 | #define AF_HYLINK 15 /* NSC Hyperchannel */
|
---|
410 | #define AF_APPLETALK 16 /* AppleTalk */
|
---|
411 | //#define AF_NETBIOS 17 /* NetBios-style addresses */
|
---|
412 | #define AF_VOICEVIEW 18 /* VoiceView */
|
---|
413 |
|
---|
414 | //#define AF_MAX 19
|
---|
415 |
|
---|
416 | /*
|
---|
417 | * Structure used by kernel to store most
|
---|
418 | * addresses.
|
---|
419 | */
|
---|
420 | struct Wsockaddr {
|
---|
421 | u_short sa_family; /* address family */
|
---|
422 | char sa_data[14]; /* up to 14 bytes of direct address */
|
---|
423 | };
|
---|
424 |
|
---|
425 | /*
|
---|
426 | * Structure used by kernel to pass protocol
|
---|
427 | * information in raw sockets.
|
---|
428 | */
|
---|
429 | struct Wsockproto {
|
---|
430 | u_short sp_family; /* address family */
|
---|
431 | u_short sp_protocol; /* protocol */
|
---|
432 | };
|
---|
433 |
|
---|
434 | /*
|
---|
435 | * Protocol families, same as address families for now.
|
---|
436 | */
|
---|
437 | #define PF_UNSPEC AF_UNSPEC
|
---|
438 | #define PF_UNIX AF_UNIX
|
---|
439 | #define PF_INET AF_INET
|
---|
440 | #define PF_IMPLINK AF_IMPLINK
|
---|
441 | #define PF_PUP AF_PUP
|
---|
442 | #define PF_CHAOS AF_CHAOS
|
---|
443 | #define PF_NS AF_NS
|
---|
444 | #define PF_IPX AF_IPX
|
---|
445 | #define PF_ISO AF_ISO
|
---|
446 | #define PF_OSI AF_OSI
|
---|
447 | #define PF_ECMA AF_ECMA
|
---|
448 | #define PF_DATAKIT AF_DATAKIT
|
---|
449 | #define PF_CCITT AF_CCITT
|
---|
450 | #define PF_SNA AF_SNA
|
---|
451 | #define PF_DECnet AF_DECnet
|
---|
452 | #define PF_DLI AF_DLI
|
---|
453 | #define PF_LAT AF_LAT
|
---|
454 | #define PF_HYLINK AF_HYLINK
|
---|
455 | #define PF_APPLETALK AF_APPLETALK
|
---|
456 | #define PF_VOICEVIEW AF_VOICEVIEW
|
---|
457 |
|
---|
458 | #define PF_MAX AF_MAX
|
---|
459 |
|
---|
460 | /*
|
---|
461 | * Structure used for manipulating linger option.
|
---|
462 | */
|
---|
463 | struct Wlinger {
|
---|
464 | u_short l_onoff; /* option on/off */
|
---|
465 | u_short l_linger; /* linger time */
|
---|
466 | };
|
---|
467 |
|
---|
468 | /*
|
---|
469 | * Level number for (get/set)sockopt() to apply to socket itself.
|
---|
470 | */
|
---|
471 | #define SOL_SOCKET 0xffff /* options for socket level */
|
---|
472 |
|
---|
473 | /*
|
---|
474 | * Maximum queue length specifiable by listen.
|
---|
475 | */
|
---|
476 | #define SOMAXCONN 5
|
---|
477 |
|
---|
478 | #define MSG_OOB 0x1 /* process out-of-band data */
|
---|
479 | #define MSG_PEEK 0x2 /* peek at incoming message */
|
---|
480 | #define MSG_DONTROUTE 0x4 /* send without using routing tables */
|
---|
481 |
|
---|
482 | #define MSG_MAXIOVLEN 16
|
---|
483 |
|
---|
484 | #define MSG_PARTIAL 0x8000 /* partial send or recv for message xport */
|
---|
485 |
|
---|
486 | /*
|
---|
487 | * Define constant based on rfc883, used by gethostbyxxxx() calls.
|
---|
488 | */
|
---|
489 | #define MAXGETHOSTSTRUCT 1024
|
---|
490 |
|
---|
491 | /*
|
---|
492 | * Define flags to be used with the WSAAsyncSelect() call.
|
---|
493 | */
|
---|
494 | #define FD_READ 0x01
|
---|
495 | #define FD_WRITE 0x02
|
---|
496 | #define FD_OOB 0x04
|
---|
497 | #define FD_ACCEPT 0x08
|
---|
498 | #define FD_CONNECT 0x10
|
---|
499 | #define FD_CLOSE 0x20
|
---|
500 |
|
---|
501 |
|
---|
502 | /* Socket function prototypes */
|
---|
503 |
|
---|
504 | #ifdef __cplusplus
|
---|
505 | extern "C" {
|
---|
506 | #endif
|
---|
507 |
|
---|
508 | SOCKET WIN32API OS2accept (SOCKET s, struct sockaddr *addr, int *addrlen);
|
---|
509 | int WIN32API OS2bind (SOCKET s, const struct sockaddr *addr, int namelen);
|
---|
510 | int WIN32API OS2closesocket (SOCKET s);
|
---|
511 | int WIN32API OS2connect (SOCKET s, const struct sockaddr *name, int namelen);
|
---|
512 | int WIN32API OS2ioctlsocket (SOCKET s, long cmd, u_long *argp);
|
---|
513 | int WIN32API OS2getpeername (SOCKET s, struct sockaddr *name, int * namelen);
|
---|
514 | int WIN32API OS2getsockname (SOCKET s, struct sockaddr *name, int * namelen);
|
---|
515 | int WIN32API OS2getsockopt (SOCKET s, int level, int optname, char * optval, int *optlen);
|
---|
516 | u_long WIN32API OS2htonl (u_long hostlong);
|
---|
517 | u_short WIN32API OS2htons (u_short hostshort);
|
---|
518 | u_long WIN32API OS2inet_addr (const char * cp);
|
---|
519 | char * WIN32API OS2inet_ntoa (struct in_addr in);
|
---|
520 | int WIN32API OS2listen (SOCKET s, int backlog);
|
---|
521 | u_long WIN32API OS2ntohl (u_long netlong);
|
---|
522 | u_short WIN32API OS2ntohs (u_short netshort);
|
---|
523 | int WIN32API OS2recv (SOCKET s, char * buf, int len, int flags);
|
---|
524 | int WIN32API OS2recvfrom (SOCKET s, char * buf, int len, int flags, struct sockaddr *from, int * fromlen);
|
---|
525 | int WIN32API OS2select (int nfds, Wfd_set *readfds, Wfd_set *writefds, Wfd_set *exceptfds, const struct Wtimeval *timeout);
|
---|
526 | int WIN32API OS2send (SOCKET s, const char * buf, int len, int flags);
|
---|
527 | int WIN32API OS2sendto (SOCKET s, const char * buf, int len, int flags, const struct sockaddr *to, int tolen);
|
---|
528 | int WIN32API OS2setsockopt (SOCKET s, int level, int optname, const char * optval, int optlen);
|
---|
529 | int WIN32API OS2shutdown (SOCKET s, int how);
|
---|
530 | SOCKET WIN32API OS2socket (int af, int type, int protocol);
|
---|
531 |
|
---|
532 | /* Database function prototypes */
|
---|
533 | struct Whostent * WIN32API OS2gethostbyaddr(const char * addr, int len, int type);
|
---|
534 | struct Whostent * WIN32API OS2gethostbyname(const char * name);
|
---|
535 | int WIN32API OS2gethostname (char * name, int namelen);
|
---|
536 | struct Wservent * WIN32API OS2getservbyport(int port, const char * proto);
|
---|
537 | struct Wservent * WIN32API OS2getservbyname(const char * name, const char * proto);
|
---|
538 | struct Wprotoent * WIN32API OS2getprotobynumber(int proto);
|
---|
539 | struct Wprotoent * WIN32API OS2getprotobyname(const char * name);
|
---|
540 |
|
---|
541 | /* Microsoft Windows Extension function prototypes */
|
---|
542 | int WIN32API OS2WSAStartup(WORD wVersionRequired, LPWSADATA lpWSAData);
|
---|
543 | int WIN32API OS2WSACleanup(void);
|
---|
544 | BOOL WIN32API OS2WSAIsBlocking(void);
|
---|
545 | int WIN32API OS2WSAUnhookBlockingHook(void);
|
---|
546 | PROC WIN32API OS2WSASetBlockingHook(PROC lpBlockFunc);
|
---|
547 | int WIN32API OS2WSACancelBlockingCall(void);
|
---|
548 | HANDLE WIN32API OS2WSAAsyncGetServByName(HWND hWnd, u_int wMsg, const char * name, const char * proto, char * buf, int buflen);
|
---|
549 | HANDLE WIN32API OS2WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, int port, const char * proto, char * buf, int buflen);
|
---|
550 | HANDLE WIN32API OS2WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg, const char * name, char * buf, int buflen);
|
---|
551 | HANDLE WIN32API OS2WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg, int number, char * buf, int buflen);
|
---|
552 | HANDLE WIN32API OS2WSAAsyncGetHostByName(HWND hWnd, u_int wMsg, const char * name, char * buf, int buflen);
|
---|
553 | HANDLE WIN32API OS2WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg, const char * addr, int len, int type, char * buf, int buflen);
|
---|
554 | int WIN32API OS2WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
|
---|
555 | int WIN32API OS2WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, long lEvent);
|
---|
556 | int WIN32API OS2WSARecvEx (SOCKET s, char * buf, int len, int *flags);
|
---|
557 |
|
---|
558 |
|
---|
559 | typedef struct _TRANSMIT_FILE_BUFFERS {
|
---|
560 | PVOID Head;
|
---|
561 | DWORD HeadLength;
|
---|
562 | PVOID Tail;
|
---|
563 | DWORD TailLength;
|
---|
564 | } TRANSMIT_FILE_BUFFERS, *PTRANSMIT_FILE_BUFFERS, *LPTRANSMIT_FILE_BUFFERS;
|
---|
565 |
|
---|
566 | typedef struct _OVERLAPPED {
|
---|
567 | DWORD Internal;
|
---|
568 | DWORD InternalHigh;
|
---|
569 | DWORD Offset;
|
---|
570 | DWORD OffsetHigh;
|
---|
571 | HANDLE hEvent;
|
---|
572 | } OVERLAPPED, *LPOVERLAPPED;
|
---|
573 |
|
---|
574 |
|
---|
575 | BOOL WIN32API OS2TransmitFile (SOCKET hSocket,
|
---|
576 | HANDLE hFile,
|
---|
577 | DWORD nNumberOfBytesToWrite,
|
---|
578 | DWORD nNumberOfBytesPerSend,
|
---|
579 | LPOVERLAPPED lpOverlapped,
|
---|
580 | LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
|
---|
581 | DWORD dwReserved);
|
---|
582 |
|
---|
583 | #ifdef __cplusplus
|
---|
584 | }
|
---|
585 | #endif
|
---|
586 |
|
---|
587 | typedef struct sockaddr SOCKADDR;
|
---|
588 | typedef struct sockaddr *PSOCKADDR;
|
---|
589 | typedef struct sockaddr *LPSOCKADDR;
|
---|
590 |
|
---|
591 | typedef struct sockaddr_in SOCKADDR_IN;
|
---|
592 | typedef struct sockaddr_in *PSOCKADDR_IN;
|
---|
593 | typedef struct sockaddr_in *LPSOCKADDR_IN;
|
---|
594 |
|
---|
595 | typedef struct linger LINGER;
|
---|
596 | typedef struct linger *PLINGER;
|
---|
597 | typedef struct linger *LPLINGER;
|
---|
598 |
|
---|
599 | typedef struct in_addr IN_ADDR;
|
---|
600 | typedef struct in_addr *PIN_ADDR;
|
---|
601 | typedef struct in_addr *LPIN_ADDR;
|
---|
602 |
|
---|
603 | typedef struct Wfd_set WFD_SET;
|
---|
604 | typedef struct Wfd_set *PWFD_SET;
|
---|
605 | typedef struct Wfd_set *LPWFD_SET;
|
---|
606 |
|
---|
607 | typedef struct Whostent WHOSTENT;
|
---|
608 | typedef struct Whostent *PWHOSTENT;
|
---|
609 | typedef struct Whostent *LPWHOSTENT;
|
---|
610 |
|
---|
611 | typedef struct Wservent WSERVENT;
|
---|
612 | typedef struct Wservent *PWSERVENT;
|
---|
613 | typedef struct Wservent *LPWSERVENT;
|
---|
614 |
|
---|
615 | typedef struct Wprotoent WPROTOENT;
|
---|
616 | typedef struct Wprotoent *PWPROTOENT;
|
---|
617 | typedef struct Wprotoent *LPWPROTOENT;
|
---|
618 |
|
---|
619 | typedef struct Wtimeval WTIMEVAL;
|
---|
620 | typedef struct Wtimeval *PWTIMEVAL;
|
---|
621 | typedef struct Wtimeval *LPWTIMEVAL;
|
---|
622 |
|
---|
623 | /*
|
---|
624 | * Windows message parameter composition and decomposition
|
---|
625 | * macros.
|
---|
626 | *
|
---|
627 | * WSAMAKEASYNCREPLY is intended for use by the Windows Sockets implementation
|
---|
628 | * when constructing the response to a WSAAsyncGetXByY() routine.
|
---|
629 | */
|
---|
630 | #define OS2WSAMAKEASYNCREPLY(buflen,error) MAKELONG(buflen,error)
|
---|
631 | /*
|
---|
632 | * WSAMAKESELECTREPLY is intended for use by the Windows Sockets implementation
|
---|
633 | * when constructing the response to WSAAsyncSelect().
|
---|
634 | */
|
---|
635 | #define OS2WSAMAKESELECTREPLY(event,error) MAKELONG(event,error)
|
---|
636 | /*
|
---|
637 | * WSAGETASYNCBUFLEN is intended for use by the Windows Sockets application
|
---|
638 | * to extract the buffer length from the lParam in the response
|
---|
639 | * to a WSAGetXByY().
|
---|
640 | */
|
---|
641 | #define OS2WSAGETASYNCBUFLEN(lParam) LOWORD(lParam)
|
---|
642 | /*
|
---|
643 | * WSAGETASYNCERROR is intended for use by the Windows Sockets application
|
---|
644 | * to extract the error code from the lParam in the response
|
---|
645 | * to a WSAGetXByY().
|
---|
646 | */
|
---|
647 | #define OS2WSAGETASYNCERROR(lParam) HIWORD(lParam)
|
---|
648 | /*
|
---|
649 | * WSAGETSELECTEVENT is intended for use by the Windows Sockets application
|
---|
650 | * to extract the event code from the lParam in the response
|
---|
651 | * to a WSAAsyncSelect().
|
---|
652 | */
|
---|
653 | #define OS2WSAGETSELECTEVENT(lParam) LOWORD(lParam)
|
---|
654 | /*
|
---|
655 | * WSAGETSELECTERROR is intended for use by the Windows Sockets application
|
---|
656 | * to extract the error code from the lParam in the response
|
---|
657 | * to a WSAAsyncSelect().
|
---|
658 | */
|
---|
659 | #define OS2WSAGETSELECTERROR(lParam) HIWORD(lParam)
|
---|
660 |
|
---|
661 | #endif /* _WINSOCKAPI_ */
|
---|
662 |
|
---|
663 |
|
---|