Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5131 | clevermous | 1 | /* WINSOCK.H--definitions to be used with the WINSOCK.DLL |
2 | * Copyright (c) 1993-1995, Microsoft Corp. All rights reserved. |
||
3 | * |
||
4 | * This header file corresponds to version 1.1 of the Windows Sockets specification. |
||
5 | * |
||
6 | * This file includes parts which are Copyright (c) 1982-1986 Regents |
||
7 | * of the University of California. All rights reserved. The |
||
8 | * Berkeley Software License Agreement specifies the terms and |
||
9 | * conditions for redistribution. |
||
10 | * |
||
11 | */ |
||
12 | |||
13 | #ifndef _WINSOCKAPI_ |
||
14 | #define _WINSOCKAPI_ |
||
15 | |||
16 | #define FAR |
||
17 | #define PASCAL |
||
18 | |||
19 | /* |
||
20 | * Basic system type definitions, taken from the BSD file sys/types.h. |
||
21 | */ |
||
22 | typedef unsigned char u_char; |
||
23 | typedef unsigned short u_short; |
||
24 | typedef unsigned int u_int; |
||
25 | typedef unsigned long u_long; |
||
26 | |||
27 | /* |
||
28 | * The new type to be used in all |
||
29 | * instances which refer to sockets. |
||
30 | */ |
||
31 | typedef u_int SOCKET; |
||
32 | |||
33 | // FIXME |
||
34 | #if 0 |
||
35 | /* |
||
36 | * Select uses arrays of SOCKETs. These macros manipulate such |
||
37 | * arrays. FD_SETSIZE may be defined by the user before including |
||
38 | * this file, but the default here should be >= 64. |
||
39 | * |
||
40 | * CAVEAT IMPLEMENTOR and USER: THESE MACROS AND TYPES MUST BE |
||
41 | * INCLUDED IN WINSOCK.H EXACTLY AS SHOWN HERE. |
||
42 | */ |
||
43 | #ifndef FD_SETSIZE |
||
44 | #define FD_SETSIZE 64 |
||
45 | #endif /* FD_SETSIZE */ |
||
46 | |||
47 | typedef struct fd_set { |
||
48 | u_int fd_count; /* how many are SET? */ |
||
49 | SOCKET fd_array[FD_SETSIZE]; /* an array of SOCKETs */ |
||
50 | } fd_set; |
||
51 | |||
52 | #ifdef __cplusplus |
||
53 | extern "C" { |
||
54 | #endif |
||
55 | |||
56 | extern int PASCAL FAR __WSAFDIsSet(SOCKET, fd_set FAR *); |
||
57 | |||
58 | #ifdef __cplusplus |
||
59 | } |
||
60 | #endif |
||
61 | |||
62 | |||
63 | #define FD_CLR(fd, set) do { \ |
||
64 | u_int __i; \ |
||
65 | for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count ; __i++) { \ |
||
66 | if (((fd_set FAR *)(set))->fd_array[__i] == fd) { \ |
||
67 | while (__i < ((fd_set FAR *)(set))->fd_count-1) { \ |
||
68 | ((fd_set FAR *)(set))->fd_array[__i] = \ |
||
69 | ((fd_set FAR *)(set))->fd_array[__i+1]; \ |
||
70 | __i++; \ |
||
71 | } \ |
||
72 | ((fd_set FAR *)(set))->fd_count--; \ |
||
73 | break; \ |
||
74 | } \ |
||
75 | } \ |
||
76 | } while(0) |
||
77 | |||
78 | #define FD_SET(fd, set) do { \ |
||
79 | if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) \ |
||
80 | ((fd_set FAR *)(set))->fd_array[((fd_set FAR *)(set))->fd_count++]=(fd);\ |
||
81 | } while(0) |
||
82 | |||
83 | #define FD_ZERO(set) (((fd_set FAR *)(set))->fd_count=0) |
||
84 | |||
85 | #define FD_ISSET(fd, set) __WSAFDIsSet((SOCKET)(fd), (fd_set FAR *)(set)) |
||
86 | |||
87 | /* |
||
88 | * Structure used in select() call, taken from the BSD file sys/time.h. |
||
89 | */ |
||
90 | struct timeval { |
||
91 | long tv_sec; /* seconds */ |
||
92 | long tv_usec; /* and microseconds */ |
||
93 | }; |
||
94 | |||
95 | /* |
||
96 | * Operations on timevals. |
||
97 | * |
||
98 | * NB: timercmp does not work for >= or <=. |
||
99 | */ |
||
100 | #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) |
||
101 | #define timercmp(tvp, uvp, cmp) \ |
||
102 | ((tvp)->tv_sec cmp (uvp)->tv_sec || \ |
||
103 | (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec) |
||
104 | #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 |
||
105 | #endif |
||
106 | |||
107 | /* |
||
108 | * Commands for ioctlsocket(), taken from the BSD file fcntl.h. |
||
109 | * |
||
110 | * |
||
111 | * Ioctl's have the command encoded in the lower word, |
||
112 | * and the size of any in or out parameters in the upper |
||
113 | * word. The high 2 bits of the upper word are used |
||
114 | * to encode the in/out status of the parameter; for now |
||
115 | * we restrict parameters to at most 128 bytes. |
||
116 | */ |
||
117 | #define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */ |
||
118 | #define IOC_VOID 0x20000000 /* no parameters */ |
||
119 | #define IOC_OUT 0x40000000 /* copy out parameters */ |
||
120 | #define IOC_IN 0x80000000 /* copy in parameters */ |
||
121 | #define IOC_INOUT (IOC_IN|IOC_OUT) |
||
122 | /* 0x20000000 distinguishes new & |
||
123 | old ioctl's */ |
||
124 | #define _IO(x,y) (IOC_VOID|((x)<<8)|(y)) |
||
125 | |||
126 | #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) |
||
127 | |||
128 | #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) |
||
129 | |||
130 | #define FIONREAD _IOR('f', 127, u_long) /* get # bytes to read */ |
||
131 | #define FIONBIO _IOW('f', 126, u_long) /* set/clear non-blocking i/o */ |
||
132 | #define FIOASYNC _IOW('f', 125, u_long) /* set/clear async i/o */ |
||
133 | |||
134 | /* Socket I/O Controls */ |
||
135 | #define SIOCSHIWAT _IOW('s', 0, u_long) /* set high watermark */ |
||
136 | #define SIOCGHIWAT _IOR('s', 1, u_long) /* get high watermark */ |
||
137 | #define SIOCSLOWAT _IOW('s', 2, u_long) /* set low watermark */ |
||
138 | #define SIOCGLOWAT _IOR('s', 3, u_long) /* get low watermark */ |
||
139 | #define SIOCATMARK _IOR('s', 7, u_long) /* at oob mark? */ |
||
140 | |||
141 | /* |
||
142 | * Structures returned by network data base library, taken from the |
||
143 | * BSD file netdb.h. All addresses are supplied in host order, and |
||
144 | * returned in network order (suitable for use in system calls). |
||
145 | */ |
||
146 | |||
147 | struct hostent { |
||
148 | char FAR * h_name; /* official name of host */ |
||
149 | char FAR * FAR * h_aliases; /* alias list */ |
||
150 | short h_addrtype; /* host address type */ |
||
151 | short h_length; /* length of address */ |
||
152 | char FAR * FAR * h_addr_list; /* list of addresses */ |
||
153 | #define h_addr h_addr_list[0] /* address, for backward compat */ |
||
154 | }; |
||
155 | |||
156 | /* |
||
157 | * It is assumed here that a network number |
||
158 | * fits in 32 bits. |
||
159 | */ |
||
160 | struct netent { |
||
161 | char FAR * n_name; /* official name of net */ |
||
162 | char FAR * FAR * n_aliases; /* alias list */ |
||
163 | short n_addrtype; /* net address type */ |
||
164 | u_long n_net; /* network # */ |
||
165 | }; |
||
166 | |||
167 | struct servent { |
||
168 | char FAR * s_name; /* official service name */ |
||
169 | char FAR * FAR * s_aliases; /* alias list */ |
||
170 | short s_port; /* port # */ |
||
171 | char FAR * s_proto; /* protocol to use */ |
||
172 | }; |
||
173 | |||
174 | struct protoent { |
||
175 | char FAR * p_name; /* official protocol name */ |
||
176 | char FAR * FAR * p_aliases; /* alias list */ |
||
177 | short p_proto; /* protocol # */ |
||
178 | }; |
||
179 | |||
180 | /* |
||
181 | * Constants and structures defined by the internet system, |
||
182 | * Per RFC 790, September 1981, taken from the BSD file netinet/in.h. |
||
183 | */ |
||
184 | |||
185 | /* |
||
186 | * Protocols |
||
187 | */ |
||
188 | #define IPPROTO_IP 0 /* dummy for IP */ |
||
189 | #define IPPROTO_ICMP 1 /* control message protocol */ |
||
190 | #define IPPROTO_GGP 2 /* gateway^2 (deprecated) */ |
||
191 | #define IPPROTO_TCP 6 /* tcp */ |
||
192 | #define IPPROTO_PUP 12 /* pup */ |
||
193 | #define IPPROTO_UDP 17 /* user datagram protocol */ |
||
194 | #define IPPROTO_IDP 22 /* xns idp */ |
||
195 | #define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */ |
||
196 | |||
197 | #define IPPROTO_RAW 255 /* raw IP packet */ |
||
198 | #define IPPROTO_MAX 256 |
||
199 | |||
200 | /* |
||
201 | * Port/socket numbers: network standard functions |
||
202 | */ |
||
203 | #define IPPORT_ECHO 7 |
||
204 | #define IPPORT_DISCARD 9 |
||
205 | #define IPPORT_SYSTAT 11 |
||
206 | #define IPPORT_DAYTIME 13 |
||
207 | #define IPPORT_NETSTAT 15 |
||
208 | #define IPPORT_FTP 21 |
||
209 | #define IPPORT_TELNET 23 |
||
210 | #define IPPORT_SMTP 25 |
||
211 | #define IPPORT_TIMESERVER 37 |
||
212 | #define IPPORT_NAMESERVER 42 |
||
213 | #define IPPORT_WHOIS 43 |
||
214 | #define IPPORT_MTP 57 |
||
215 | |||
216 | /* |
||
217 | * Port/socket numbers: host specific functions |
||
218 | */ |
||
219 | #define IPPORT_TFTP 69 |
||
220 | #define IPPORT_RJE 77 |
||
221 | #define IPPORT_FINGER 79 |
||
222 | #define IPPORT_TTYLINK 87 |
||
223 | #define IPPORT_SUPDUP 95 |
||
224 | |||
225 | /* |
||
226 | * UNIX TCP sockets |
||
227 | */ |
||
228 | #define IPPORT_EXECSERVER 512 |
||
229 | #define IPPORT_LOGINSERVER 513 |
||
230 | #define IPPORT_CMDSERVER 514 |
||
231 | #define IPPORT_EFSSERVER 520 |
||
232 | |||
233 | /* |
||
234 | * UNIX UDP sockets |
||
235 | */ |
||
236 | #define IPPORT_BIFFUDP 512 |
||
237 | #define IPPORT_WHOSERVER 513 |
||
238 | #define IPPORT_ROUTESERVER 520 |
||
239 | /* 520+1 also used */ |
||
240 | |||
241 | /* |
||
242 | * Ports < IPPORT_RESERVED are reserved for |
||
243 | * privileged processes (e.g. root). |
||
244 | */ |
||
245 | #define IPPORT_RESERVED 1024 |
||
246 | |||
247 | /* |
||
248 | * Link numbers |
||
249 | */ |
||
250 | #define IMPLINK_IP 155 |
||
251 | #define IMPLINK_LOWEXPER 156 |
||
252 | #define IMPLINK_HIGHEXPER 158 |
||
253 | |||
254 | /* |
||
255 | * Internet address (old style... should be updated) |
||
256 | */ |
||
257 | struct in_addr { |
||
258 | union { |
||
259 | struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b; |
||
260 | struct { u_short s_w1,s_w2; } S_un_w; |
||
261 | u_long S_addr; |
||
262 | } S_un; |
||
263 | #define s_addr S_un.S_addr |
||
264 | /* can be used for most tcp & ip code */ |
||
265 | #define s_host S_un.S_un_b.s_b2 |
||
266 | /* host on imp */ |
||
267 | #define s_net S_un.S_un_b.s_b1 |
||
268 | /* network */ |
||
269 | #define s_imp S_un.S_un_w.s_w2 |
||
270 | /* imp */ |
||
271 | #define s_impno S_un.S_un_b.s_b4 |
||
272 | /* imp # */ |
||
273 | #define s_lh S_un.S_un_b.s_b3 |
||
274 | /* logical host */ |
||
275 | }; |
||
276 | |||
277 | /* |
||
278 | * Definitions of bits in internet address integers. |
||
279 | * On subnets, the decomposition of addresses to host and net parts |
||
280 | * is done according to subnet mask, not the masks here. |
||
281 | */ |
||
282 | #define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0) |
||
283 | #define IN_CLASSA_NET 0xff000000 |
||
284 | #define IN_CLASSA_NSHIFT 24 |
||
285 | #define IN_CLASSA_HOST 0x00ffffff |
||
286 | #define IN_CLASSA_MAX 128 |
||
287 | |||
288 | #define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000) |
||
289 | #define IN_CLASSB_NET 0xffff0000 |
||
290 | #define IN_CLASSB_NSHIFT 16 |
||
291 | #define IN_CLASSB_HOST 0x0000ffff |
||
292 | #define IN_CLASSB_MAX 65536 |
||
293 | |||
294 | #define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000) |
||
295 | #define IN_CLASSC_NET 0xffffff00 |
||
296 | #define IN_CLASSC_NSHIFT 8 |
||
297 | #define IN_CLASSC_HOST 0x000000ff |
||
298 | |||
299 | #define INADDR_ANY (u_long)0x00000000 |
||
300 | #define INADDR_LOOPBACK 0x7f000001 |
||
301 | #define INADDR_BROADCAST (u_long)0xffffffff |
||
302 | #define INADDR_NONE 0xffffffff |
||
303 | |||
304 | /* |
||
305 | * Socket address, internet style. |
||
306 | */ |
||
307 | struct sockaddr_in { |
||
308 | short sin_family; |
||
309 | u_short sin_port; |
||
310 | struct in_addr sin_addr; |
||
311 | char sin_zero[8]; |
||
312 | }; |
||
313 | |||
314 | #define WSADESCRIPTION_LEN 256 |
||
315 | #define WSASYS_STATUS_LEN 128 |
||
316 | |||
317 | |||
318 | /* |
||
319 | * Options for use with [gs]etsockopt at the IP level. |
||
320 | */ |
||
321 | #define IP_OPTIONS 1 /* set/get IP per-packet options */ |
||
322 | #define IP_MULTICAST_IF 2 /* set/get IP multicast interface */ |
||
323 | #define IP_MULTICAST_TTL 3 /* set/get IP multicast timetolive */ |
||
324 | #define IP_MULTICAST_LOOP 4 /* set/get IP multicast loopback */ |
||
325 | #define IP_ADD_MEMBERSHIP 5 /* add an IP group membership */ |
||
326 | #define IP_DROP_MEMBERSHIP 6 /* drop an IP group membership */ |
||
327 | |||
328 | #define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */ |
||
329 | #define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ |
||
330 | #define IP_MAX_MEMBERSHIPS 20 /* per socket; must fit in one mbuf */ |
||
331 | |||
332 | /* |
||
333 | * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. |
||
334 | */ |
||
335 | struct ip_mreq { |
||
336 | struct in_addr imr_multiaddr; /* IP multicast address of group */ |
||
337 | struct in_addr imr_interface; /* local IP address of interface */ |
||
338 | }; |
||
339 | |||
340 | /* |
||
341 | * Definitions related to sockets: types, address families, options, |
||
342 | * taken from the BSD file sys/socket.h. |
||
343 | */ |
||
344 | |||
345 | /* |
||
346 | * This is used instead of -1, since the |
||
347 | * SOCKET type is unsigned. |
||
348 | */ |
||
349 | #define INVALID_SOCKET (SOCKET)(~0) |
||
350 | #define SOCKET_ERROR (-1) |
||
351 | |||
352 | /* |
||
353 | * Types |
||
354 | */ |
||
355 | #define SOCK_STREAM 1 /* stream socket */ |
||
356 | #define SOCK_DGRAM 2 /* datagram socket */ |
||
357 | #define SOCK_RAW 3 /* raw-protocol interface */ |
||
358 | #define SOCK_RDM 4 /* reliably-delivered message */ |
||
359 | #define SOCK_SEQPACKET 5 /* sequenced packet stream */ |
||
360 | |||
361 | /* |
||
362 | * Option flags per-socket. |
||
363 | */ |
||
364 | #define SO_DEBUG 0x0001 /* turn on debugging info recording */ |
||
365 | #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ |
||
366 | #define SO_REUSEADDR 0x0004 /* allow local address reuse */ |
||
367 | #define SO_KEEPALIVE 0x0008 /* keep connections alive */ |
||
368 | #define SO_DONTROUTE 0x0010 /* just use interface addresses */ |
||
369 | #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ |
||
370 | #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ |
||
371 | #define SO_LINGER 0x0080 /* linger on close if data present */ |
||
372 | #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ |
||
373 | |||
374 | #define SO_DONTLINGER (u_int)(~SO_LINGER) |
||
375 | |||
376 | /* |
||
377 | * Additional options. |
||
378 | */ |
||
379 | #define SO_SNDBUF 0x1001 /* send buffer size */ |
||
380 | #define SO_RCVBUF 0x1002 /* receive buffer size */ |
||
381 | #define SO_SNDLOWAT 0x1003 /* send low-water mark */ |
||
382 | #define SO_RCVLOWAT 0x1004 /* receive low-water mark */ |
||
383 | #define SO_SNDTIMEO 0x1005 /* send timeout */ |
||
384 | #define SO_RCVTIMEO 0x1006 /* receive timeout */ |
||
385 | #define SO_ERROR 0x1007 /* get error status and clear */ |
||
386 | #define SO_TYPE 0x1008 /* get socket type */ |
||
387 | |||
388 | /* |
||
389 | * Options for connect and disconnect data and options. Used only by |
||
390 | * non-TCP/IP transports such as DECNet, OSI TP4, etc. |
||
391 | */ |
||
392 | #define SO_CONNDATA 0x7000 |
||
393 | #define SO_CONNOPT 0x7001 |
||
394 | #define SO_DISCDATA 0x7002 |
||
395 | #define SO_DISCOPT 0x7003 |
||
396 | #define SO_CONNDATALEN 0x7004 |
||
397 | #define SO_CONNOPTLEN 0x7005 |
||
398 | #define SO_DISCDATALEN 0x7006 |
||
399 | #define SO_DISCOPTLEN 0x7007 |
||
400 | |||
401 | /* |
||
402 | * Option for opening sockets for synchronous access. |
||
403 | */ |
||
404 | #define SO_OPENTYPE 0x7008 |
||
405 | |||
406 | #define SO_SYNCHRONOUS_ALERT 0x10 |
||
407 | #define SO_SYNCHRONOUS_NONALERT 0x20 |
||
408 | |||
409 | /* |
||
410 | * Other NT-specific options. |
||
411 | */ |
||
412 | #define SO_MAXDG 0x7009 |
||
413 | #define SO_MAXPATHDG 0x700A |
||
414 | |||
415 | /* |
||
416 | * TCP options. |
||
417 | */ |
||
418 | #define TCP_NODELAY 0x0001 |
||
419 | #define TCP_BSDURGENT 0x7000 |
||
420 | |||
421 | /* |
||
422 | * Address families. |
||
423 | */ |
||
424 | #define AF_UNSPEC 0 /* unspecified */ |
||
425 | #define AF_UNIX 1 /* local to host (pipes, portals) */ |
||
426 | #define AF_INET 2 /* internetwork: UDP, TCP, etc. */ |
||
427 | #define AF_IMPLINK 3 /* arpanet imp addresses */ |
||
428 | #define AF_PUP 4 /* pup protocols: e.g. BSP */ |
||
429 | #define AF_CHAOS 5 /* mit CHAOS protocols */ |
||
430 | #define AF_IPX 6 /* IPX and SPX */ |
||
431 | #define AF_NS 6 /* XEROX NS protocols */ |
||
432 | #define AF_ISO 7 /* ISO protocols */ |
||
433 | #define AF_OSI AF_ISO /* OSI is ISO */ |
||
434 | #define AF_ECMA 8 /* european computer manufacturers */ |
||
435 | #define AF_DATAKIT 9 /* datakit protocols */ |
||
436 | #define AF_CCITT 10 /* CCITT protocols, X.25 etc */ |
||
437 | #define AF_SNA 11 /* IBM SNA */ |
||
438 | #define AF_DECnet 12 /* DECnet */ |
||
439 | #define AF_DLI 13 /* Direct data link interface */ |
||
440 | #define AF_LAT 14 /* LAT */ |
||
441 | #define AF_HYLINK 15 /* NSC Hyperchannel */ |
||
442 | #define AF_APPLETALK 16 /* AppleTalk */ |
||
443 | #define AF_NETBIOS 17 /* NetBios-style addresses */ |
||
444 | #define AF_VOICEVIEW 18 /* VoiceView */ |
||
445 | |||
446 | #define AF_MAX 19 |
||
447 | |||
448 | /* |
||
449 | * Structure used by kernel to store most |
||
450 | * addresses. |
||
451 | */ |
||
452 | struct sockaddr { |
||
453 | u_short sa_family; /* address family */ |
||
454 | char sa_data[14]; /* up to 14 bytes of direct address */ |
||
455 | }; |
||
456 | |||
457 | /* |
||
458 | * Structure used by kernel to pass protocol |
||
459 | * information in raw sockets. |
||
460 | */ |
||
461 | struct sockproto { |
||
462 | u_short sp_family; /* address family */ |
||
463 | u_short sp_protocol; /* protocol */ |
||
464 | }; |
||
465 | |||
466 | /* |
||
467 | * Protocol families, same as address families for now. |
||
468 | */ |
||
469 | #define PF_UNSPEC AF_UNSPEC |
||
470 | #define PF_UNIX AF_UNIX |
||
471 | #define PF_INET AF_INET |
||
472 | #define PF_IMPLINK AF_IMPLINK |
||
473 | #define PF_PUP AF_PUP |
||
474 | #define PF_CHAOS AF_CHAOS |
||
475 | #define PF_NS AF_NS |
||
476 | #define PF_IPX AF_IPX |
||
477 | #define PF_ISO AF_ISO |
||
478 | #define PF_OSI AF_OSI |
||
479 | #define PF_ECMA AF_ECMA |
||
480 | #define PF_DATAKIT AF_DATAKIT |
||
481 | #define PF_CCITT AF_CCITT |
||
482 | #define PF_SNA AF_SNA |
||
483 | #define PF_DECnet AF_DECnet |
||
484 | #define PF_DLI AF_DLI |
||
485 | #define PF_LAT AF_LAT |
||
486 | #define PF_HYLINK AF_HYLINK |
||
487 | #define PF_APPLETALK AF_APPLETALK |
||
488 | #define PF_VOICEVIEW AF_VOICEVIEW |
||
489 | |||
490 | #define PF_MAX AF_MAX |
||
491 | |||
492 | /* |
||
493 | * Structure used for manipulating linger option. |
||
494 | */ |
||
495 | struct linger { |
||
496 | u_short l_onoff; /* option on/off */ |
||
497 | u_short l_linger; /* linger time */ |
||
498 | }; |
||
499 | |||
500 | /* |
||
501 | * Level number for (get/set)sockopt() to apply to socket itself. |
||
502 | */ |
||
503 | #define SOL_SOCKET 0xffff /* options for socket level */ |
||
504 | |||
505 | /* |
||
506 | * Maximum queue length specifiable by listen. |
||
507 | */ |
||
508 | #define SOMAXCONN 5 |
||
509 | |||
510 | #define MSG_OOB 0x1 /* process out-of-band data */ |
||
511 | #define MSG_PEEK 0x2 /* peek at incoming message */ |
||
512 | #define MSG_DONTROUTE 0x4 /* send without using routing tables */ |
||
513 | |||
514 | #define MSG_MAXIOVLEN 16 |
||
515 | |||
516 | #define MSG_PARTIAL 0x8000 /* partial send or recv for message xport */ |
||
517 | |||
518 | /* |
||
519 | * Define constant based on rfc883, used by gethostbyxxxx() calls. |
||
520 | */ |
||
521 | #define MAXGETHOSTSTRUCT 1024 |
||
522 | |||
523 | /* |
||
524 | * Define flags to be used with the WSAAsyncSelect() call. |
||
525 | */ |
||
526 | #define FD_READ 0x01 |
||
527 | #define FD_WRITE 0x02 |
||
528 | #define FD_OOB 0x04 |
||
529 | #define FD_ACCEPT 0x08 |
||
530 | #define FD_CONNECT 0x10 |
||
531 | #define FD_CLOSE 0x20 |
||
532 | |||
533 | /* |
||
534 | * All Windows Sockets error constants are biased by WSABASEERR from |
||
535 | * the "normal" |
||
536 | */ |
||
537 | #define WSABASEERR 10000 |
||
538 | /* |
||
539 | * Windows Sockets definitions of regular Microsoft C error constants |
||
540 | */ |
||
541 | #define WSAEINTR (WSABASEERR+4) |
||
542 | #define WSAEBADF (WSABASEERR+9) |
||
543 | #define WSAEACCES (WSABASEERR+13) |
||
544 | #define WSAEFAULT (WSABASEERR+14) |
||
545 | #define WSAEINVAL (WSABASEERR+22) |
||
546 | #define WSAEMFILE (WSABASEERR+24) |
||
547 | |||
548 | /* |
||
549 | * Windows Sockets definitions of regular Berkeley error constants |
||
550 | */ |
||
551 | #define WSAEWOULDBLOCK (WSABASEERR+35) |
||
552 | #define WSAEINPROGRESS (WSABASEERR+36) |
||
553 | #define WSAEALREADY (WSABASEERR+37) |
||
554 | #define WSAENOTSOCK (WSABASEERR+38) |
||
555 | #define WSAEDESTADDRREQ (WSABASEERR+39) |
||
556 | #define WSAEMSGSIZE (WSABASEERR+40) |
||
557 | #define WSAEPROTOTYPE (WSABASEERR+41) |
||
558 | #define WSAENOPROTOOPT (WSABASEERR+42) |
||
559 | #define WSAEPROTONOSUPPORT (WSABASEERR+43) |
||
560 | #define WSAESOCKTNOSUPPORT (WSABASEERR+44) |
||
561 | #define WSAEOPNOTSUPP (WSABASEERR+45) |
||
562 | #define WSAEPFNOSUPPORT (WSABASEERR+46) |
||
563 | #define WSAEAFNOSUPPORT (WSABASEERR+47) |
||
564 | #define WSAEADDRINUSE (WSABASEERR+48) |
||
565 | #define WSAEADDRNOTAVAIL (WSABASEERR+49) |
||
566 | #define WSAENETDOWN (WSABASEERR+50) |
||
567 | #define WSAENETUNREACH (WSABASEERR+51) |
||
568 | #define WSAENETRESET (WSABASEERR+52) |
||
569 | #define WSAECONNABORTED (WSABASEERR+53) |
||
570 | #define WSAECONNRESET (WSABASEERR+54) |
||
571 | #define WSAENOBUFS (WSABASEERR+55) |
||
572 | #define WSAEISCONN (WSABASEERR+56) |
||
573 | #define WSAENOTCONN (WSABASEERR+57) |
||
574 | #define WSAESHUTDOWN (WSABASEERR+58) |
||
575 | #define WSAETOOMANYREFS (WSABASEERR+59) |
||
576 | #define WSAETIMEDOUT (WSABASEERR+60) |
||
577 | #define WSAECONNREFUSED (WSABASEERR+61) |
||
578 | #define WSAELOOP (WSABASEERR+62) |
||
579 | #define WSAENAMETOOLONG (WSABASEERR+63) |
||
580 | #define WSAEHOSTDOWN (WSABASEERR+64) |
||
581 | #define WSAEHOSTUNREACH (WSABASEERR+65) |
||
582 | #define WSAENOTEMPTY (WSABASEERR+66) |
||
583 | #define WSAEPROCLIM (WSABASEERR+67) |
||
584 | #define WSAEUSERS (WSABASEERR+68) |
||
585 | #define WSAEDQUOT (WSABASEERR+69) |
||
586 | #define WSAESTALE (WSABASEERR+70) |
||
587 | #define WSAEREMOTE (WSABASEERR+71) |
||
588 | |||
589 | #define WSAEDISCON (WSABASEERR+101) |
||
590 | |||
591 | /* |
||
592 | * Extended Windows Sockets error constant definitions |
||
593 | */ |
||
594 | #define WSASYSNOTREADY (WSABASEERR+91) |
||
595 | #define WSAVERNOTSUPPORTED (WSABASEERR+92) |
||
596 | #define WSANOTINITIALISED (WSABASEERR+93) |
||
597 | |||
598 | /* |
||
599 | * Error return codes from gethostbyname() and gethostbyaddr() |
||
600 | * (when using the resolver). Note that these errors are |
||
601 | * retrieved via WSAGetLastError() and must therefore follow |
||
602 | * the rules for avoiding clashes with error numbers from |
||
603 | * specific implementations or language run-time systems. |
||
604 | * For this reason the codes are based at WSABASEERR+1001. |
||
605 | * Note also that [WSA]NO_ADDRESS is defined only for |
||
606 | * compatibility purposes. |
||
607 | */ |
||
608 | |||
609 | #define h_errno WSAGetLastError() |
||
610 | |||
611 | /* Authoritative Answer: Host not found */ |
||
612 | #define WSAHOST_NOT_FOUND (WSABASEERR+1001) |
||
613 | #define HOST_NOT_FOUND WSAHOST_NOT_FOUND |
||
614 | |||
615 | /* Non-Authoritative: Host not found, or SERVERFAIL */ |
||
616 | #define WSATRY_AGAIN (WSABASEERR+1002) |
||
617 | #define TRY_AGAIN WSATRY_AGAIN |
||
618 | |||
619 | /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ |
||
620 | #define WSANO_RECOVERY (WSABASEERR+1003) |
||
621 | #define NO_RECOVERY WSANO_RECOVERY |
||
622 | |||
623 | /* Valid name, no data record of requested type */ |
||
624 | #define WSANO_DATA (WSABASEERR+1004) |
||
625 | #define NO_DATA WSANO_DATA |
||
626 | |||
627 | /* no address, look for MX record */ |
||
628 | #define WSANO_ADDRESS WSANO_DATA |
||
629 | #define NO_ADDRESS WSANO_ADDRESS |
||
630 | |||
631 | /* |
||
632 | * Windows Sockets errors redefined as regular Berkeley error constants. |
||
633 | * These are commented out in Windows NT to avoid conflicts with errno.h. |
||
634 | * Use the WSA constants instead. |
||
635 | */ |
||
636 | #if 0 |
||
637 | #define EWOULDBLOCK WSAEWOULDBLOCK |
||
638 | #define EINPROGRESS WSAEINPROGRESS |
||
639 | #define EALREADY WSAEALREADY |
||
640 | #define ENOTSOCK WSAENOTSOCK |
||
641 | #define EDESTADDRREQ WSAEDESTADDRREQ |
||
642 | #define EMSGSIZE WSAEMSGSIZE |
||
643 | #define EPROTOTYPE WSAEPROTOTYPE |
||
644 | #define ENOPROTOOPT WSAENOPROTOOPT |
||
645 | #define EPROTONOSUPPORT WSAEPROTONOSUPPORT |
||
646 | #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT |
||
647 | #define EOPNOTSUPP WSAEOPNOTSUPP |
||
648 | #define EPFNOSUPPORT WSAEPFNOSUPPORT |
||
649 | #define EAFNOSUPPORT WSAEAFNOSUPPORT |
||
650 | #define EADDRINUSE WSAEADDRINUSE |
||
651 | #define EADDRNOTAVAIL WSAEADDRNOTAVAIL |
||
652 | #define ENETDOWN WSAENETDOWN |
||
653 | #define ENETUNREACH WSAENETUNREACH |
||
654 | #define ENETRESET WSAENETRESET |
||
655 | #define ECONNABORTED WSAECONNABORTED |
||
656 | #define ECONNRESET WSAECONNRESET |
||
657 | #define ENOBUFS WSAENOBUFS |
||
658 | #define EISCONN WSAEISCONN |
||
659 | #define ENOTCONN WSAENOTCONN |
||
660 | #define ESHUTDOWN WSAESHUTDOWN |
||
661 | #define ETOOMANYREFS WSAETOOMANYREFS |
||
662 | #define ETIMEDOUT WSAETIMEDOUT |
||
663 | #define ECONNREFUSED WSAECONNREFUSED |
||
664 | #define ELOOP WSAELOOP |
||
665 | #define ENAMETOOLONG WSAENAMETOOLONG |
||
666 | #define EHOSTDOWN WSAEHOSTDOWN |
||
667 | #define EHOSTUNREACH WSAEHOSTUNREACH |
||
668 | #define ENOTEMPTY WSAENOTEMPTY |
||
669 | #define EPROCLIM WSAEPROCLIM |
||
670 | #define EUSERS WSAEUSERS |
||
671 | #define EDQUOT WSAEDQUOT |
||
672 | #define ESTALE WSAESTALE |
||
673 | #define EREMOTE WSAEREMOTE |
||
674 | #endif |
||
675 | |||
676 | /* Socket function prototypes */ |
||
677 | |||
678 | #ifdef __cplusplus |
||
679 | extern "C" { |
||
680 | #endif |
||
681 | |||
682 | SOCKET PASCAL FAR accept (SOCKET s, struct sockaddr FAR *addr, |
||
683 | int FAR *addrlen); |
||
684 | |||
685 | int PASCAL FAR bind (SOCKET s, const struct sockaddr FAR *addr, int namelen); |
||
686 | |||
687 | int PASCAL FAR closesocket (SOCKET s); |
||
688 | |||
689 | int PASCAL FAR connect (SOCKET s, const struct sockaddr FAR *name, int namelen); |
||
690 | |||
691 | int PASCAL FAR ioctlsocket (SOCKET s, long cmd, u_long FAR *argp); |
||
692 | |||
693 | int PASCAL FAR getpeername (SOCKET s, struct sockaddr FAR *name, |
||
694 | int FAR * namelen); |
||
695 | |||
696 | int PASCAL FAR getsockname (SOCKET s, struct sockaddr FAR *name, |
||
697 | int FAR * namelen); |
||
698 | |||
699 | int PASCAL FAR getsockopt (SOCKET s, int level, int optname, |
||
700 | char FAR * optval, int FAR *optlen); |
||
701 | |||
702 | u_long PASCAL FAR htonl (u_long hostlong); |
||
703 | |||
704 | u_short PASCAL FAR htons (u_short hostshort); |
||
705 | |||
706 | unsigned long PASCAL FAR inet_addr (const char FAR * cp); |
||
707 | |||
708 | char FAR * PASCAL FAR inet_ntoa (struct in_addr in); |
||
709 | |||
710 | int PASCAL FAR listen (SOCKET s, int backlog); |
||
711 | |||
712 | u_long PASCAL FAR ntohl (u_long netlong); |
||
713 | |||
714 | u_short PASCAL FAR ntohs (u_short netshort); |
||
715 | |||
716 | int PASCAL FAR recv (SOCKET s, char FAR * buf, int len, int flags); |
||
717 | |||
718 | int PASCAL FAR recvfrom (SOCKET s, char FAR * buf, int len, int flags, |
||
719 | struct sockaddr FAR *from, int FAR * fromlen); |
||
720 | |||
721 | #if 0 |
||
722 | int PASCAL FAR select (int nfds, fd_set FAR *readfds, fd_set FAR *writefds, |
||
723 | fd_set FAR *exceptfds, const struct timeval FAR *timeout); |
||
724 | #endif |
||
725 | |||
726 | int PASCAL FAR send (SOCKET s, const char FAR * buf, int len, int flags); |
||
727 | |||
728 | int PASCAL FAR sendto (SOCKET s, const char FAR * buf, int len, int flags, |
||
729 | const struct sockaddr FAR *to, int tolen); |
||
730 | |||
731 | int PASCAL FAR setsockopt (SOCKET s, int level, int optname, |
||
732 | const char FAR * optval, int optlen); |
||
733 | |||
734 | int PASCAL FAR shutdown (SOCKET s, int how); |
||
735 | |||
736 | SOCKET PASCAL FAR socket (int af, int type, int protocol); |
||
737 | |||
738 | /* Database function prototypes */ |
||
739 | |||
740 | struct hostent FAR * PASCAL FAR gethostbyaddr(const char FAR * addr, |
||
741 | int len, int type); |
||
742 | |||
743 | struct hostent FAR * PASCAL FAR gethostbyname(const char FAR * name); |
||
744 | |||
745 | int PASCAL FAR gethostname (char FAR * name, int namelen); |
||
746 | |||
747 | struct servent FAR * PASCAL FAR getservbyport(int port, const char FAR * proto); |
||
748 | |||
749 | struct servent FAR * PASCAL FAR getservbyname(const char FAR * name, |
||
750 | const char FAR * proto); |
||
751 | |||
752 | struct protoent FAR * PASCAL FAR getprotobynumber(int proto); |
||
753 | |||
754 | struct protoent FAR * PASCAL FAR getprotobyname(const char FAR * name); |
||
755 | |||
756 | #ifdef __cplusplus |
||
757 | } |
||
758 | #endif |
||
759 | |||
760 | /* Microsoft Windows Extended data types */ |
||
761 | typedef struct sockaddr SOCKADDR; |
||
762 | typedef struct sockaddr *PSOCKADDR; |
||
763 | typedef struct sockaddr FAR *LPSOCKADDR; |
||
764 | |||
765 | typedef struct sockaddr_in SOCKADDR_IN; |
||
766 | typedef struct sockaddr_in *PSOCKADDR_IN; |
||
767 | typedef struct sockaddr_in FAR *LPSOCKADDR_IN; |
||
768 | |||
769 | typedef struct linger LINGER; |
||
770 | typedef struct linger *PLINGER; |
||
771 | typedef struct linger FAR *LPLINGER; |
||
772 | |||
773 | typedef struct in_addr IN_ADDR; |
||
774 | typedef struct in_addr *PIN_ADDR; |
||
775 | typedef struct in_addr FAR *LPIN_ADDR; |
||
776 | |||
777 | typedef struct fd_set FD_SET; |
||
778 | typedef struct fd_set *PFD_SET; |
||
779 | typedef struct fd_set FAR *LPFD_SET; |
||
780 | |||
781 | typedef struct hostent HOSTENT; |
||
782 | typedef struct hostent *PHOSTENT; |
||
783 | typedef struct hostent FAR *LPHOSTENT; |
||
784 | |||
785 | typedef struct servent SERVENT; |
||
786 | typedef struct servent *PSERVENT; |
||
787 | typedef struct servent FAR *LPSERVENT; |
||
788 | |||
789 | typedef struct protoent PROTOENT; |
||
790 | typedef struct protoent *PPROTOENT; |
||
791 | typedef struct protoent FAR *LPPROTOENT; |
||
792 | |||
793 | typedef struct timeval TIMEVAL; |
||
794 | typedef struct timeval *PTIMEVAL; |
||
795 | typedef struct timeval FAR *LPTIMEVAL; |
||
796 | |||
797 | #endif /* _WINSOCKAPI_ */>8)|(y)) |