bind - Removed version tag from contrib directory and updated README.DRAGONFLY.
[dragonfly.git] / contrib / bind / lib / bind / port_after.h.in
1 /*
2  * Copyright (C) 2004-2008  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 2001-2003  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* $Id: port_after.h.in,v 1.53.128.7 2008/02/28 05:46:12 marka Exp $ */
19
20 #ifndef port_after_h
21 #define port_after_h
22
23 #include <stdio.h>
24 #include <sys/types.h>
25 #include <sys/socket.h>
26 #include <sys/param.h>
27 #include <sys/time.h>
28 #if (!defined(BSD)) || (BSD < 199306)
29 #include <sys/bitypes.h>
30 #endif
31 #ifdef HAVE_INTTYPES_H
32 #include <inttypes.h>
33 #endif
34 #ifdef HAVE_SYS_SELECT_H
35 #include <sys/select.h>
36 #endif /* HAVE_SYS_SELECT_H */
37
38 #ifdef REENABLE_SEND
39 #undef send
40 #endif
41
42 @NEED_PSELECT@
43 @HAVE_SA_LEN@
44 @HAVE_MINIMUM_IFREQ@
45 @NEED_DAEMON@
46 @NEED_STRSEP@
47 @NEED_STRERROR@
48 #ifdef NEED_STRERROR
49 const char *isc_strerror(int);
50 #define strerror isc_strerror
51 #endif
52 @HAS_INET6_STRUCTS@
53 @HAVE_SIN6_SCOPE_ID@
54 @NEED_IN6ADDR_ANY@
55 @HAS_IN_ADDR6@
56 @HAVE_SOCKADDR_STORAGE@
57 @NEED_GETTIMEOFDAY@
58 @HAVE_STRNDUP@
59 @USE_FIONBIO_IOCTL@
60 @INNETGR_ARGS@
61 @SETNETGRENT_ARGS@
62 @USE_IFNAMELINKID@
63 @PORT_NONBLOCK@
64
65 #ifndef _POSIX_PATH_MAX
66 #define _POSIX_PATH_MAX 255
67 #endif
68 #ifndef PATH_MAX
69 #define PATH_MAX _POSIX_PATH_MAX
70 #endif
71
72 /*
73  * We need to know the IPv6 address family number even on IPv4-only systems.
74  * Note that this is NOT a protocol constant, and that if the system has its
75  * own AF_INET6, different from ours below, all of BIND's libraries and
76  * executables will need to be recompiled after the system <sys/socket.h>
77  * has had this type added.  The type number below is correct on most BSD-
78  * derived systems for which AF_INET6 is defined.
79  */
80 #ifndef AF_INET6
81 #define AF_INET6        24
82 #endif
83
84 #ifndef PF_INET6
85 #define PF_INET6        AF_INET6
86 #endif
87
88 #ifdef HAS_IN_ADDR6
89 /* Map to pre-RFC structure. */
90 #define in6_addr in_addr6
91 #endif
92
93 #ifndef HAS_INET6_STRUCTS
94 /* Replace with structure from later rev of O/S if known. */
95 struct in6_addr {
96         u_int8_t        s6_addr[16];
97 };
98
99 #define IN6ADDR_ANY_INIT \
100         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
101            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
102
103 #define IN6ADDR_LOOPBACK_INIT \
104         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
105            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
106
107 /* Replace with structure from later rev of O/S if known. */
108 struct sockaddr_in6 {
109 #ifdef  HAVE_SA_LEN
110         u_int8_t        sin6_len;       /* length of this struct */
111         u_int8_t        sin6_family;    /* AF_INET6 */
112 #else
113         u_int16_t       sin6_family;    /* AF_INET6 */
114 #endif
115         u_int16_t       sin6_port;      /* transport layer port # */
116         u_int32_t       sin6_flowinfo;  /* IPv6 flow information */
117         struct in6_addr sin6_addr;      /* IPv6 address */
118         u_int32_t       sin6_scope_id;  /* set of interfaces for a scope */
119 };
120 #endif  /* HAS_INET6_STRUCTS */
121
122 #ifdef BROKEN_IN6ADDR_INIT_MACROS
123 #undef IN6ADDR_ANY_INIT
124 #undef IN6ADDR_LOOPBACK_INIT
125 #endif
126
127 #ifdef _AIX
128 #ifndef IN6ADDR_ANY_INIT
129 #define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}}
130 #endif
131 #ifndef IN6ADDR_LOOPBACK_INIT
132 #if BYTE_ORDER == BIG_ENDIAN
133 #define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}}
134 #else
135 #define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}}
136 #endif
137 #endif
138 #endif
139
140 #ifndef IN6ADDR_ANY_INIT
141 #ifdef s6_addr
142 #define IN6ADDR_ANY_INIT \
143         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
144             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
145 #else
146 #define IN6ADDR_ANY_INIT \
147         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
148            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
149 #endif
150
151 #endif
152 #ifndef IN6ADDR_LOOPBACK_INIT
153 #ifdef s6_addr
154 #define IN6ADDR_LOOPBACK_INIT \
155         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
156             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
157 #else
158 #define IN6ADDR_LOOPBACK_INIT \
159         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
160            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
161 #endif
162 #endif
163
164 #ifndef HAVE_SOCKADDR_STORAGE
165 #define __SS_MAXSIZE 128
166 #define __SS_ALLIGSIZE (sizeof (long))
167
168 struct sockaddr_storage {
169 #ifdef  HAVE_SA_LEN
170         u_int8_t        ss_len;       /* address length */
171         u_int8_t        ss_family;    /* address family */
172         char            __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof(u_int8_t)];
173         long            __ss_align;
174         char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
175 #else
176         u_int16_t       ss_family;    /* address family */
177         char            __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)];
178         long            __ss_align;
179         char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
180 #endif
181 };
182 #endif
183
184
185 #if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY)
186 #define in6addr_any isc_in6addr_any
187 extern const struct in6_addr in6addr_any;
188 #endif
189
190 /*
191  * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and
192  * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1.
193  */
194 #ifdef __GLIBC__
195 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2)
196 #undef IN6_ARE_ADDR_EQUAL
197 #undef IN6_IS_ADDR_UNSPECIFIED
198 #undef IN6_IS_ADDR_V4COMPAT
199 #undef IN6_IS_ADDR_V4MAPPED
200 #endif
201 #endif
202
203 #ifndef IN6_ARE_ADDR_EQUAL
204 #define IN6_ARE_ADDR_EQUAL(a,b) \
205    (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
206 #endif
207
208 #ifndef IN6_IS_ADDR_UNSPECIFIED
209 #define IN6_IS_ADDR_UNSPECIFIED(a)      \
210         IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
211 #endif
212
213 #ifndef IN6_IS_ADDR_LOOPBACK
214 extern const struct in6_addr isc_in6addr_loopback;
215 #define IN6_IS_ADDR_LOOPBACK(a) \
216         IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback)
217 #endif
218
219 #ifndef IN6_IS_ADDR_V4MAPPED
220 #define IN6_IS_ADDR_V4MAPPED(a) \
221         ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
222         (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
223         (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
224         (a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \
225         (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
226         (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
227 #endif
228
229 #ifndef IN6_IS_ADDR_SITELOCAL
230 #define IN6_IS_ADDR_SITELOCAL(a)        \
231         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
232 #endif
233
234 #ifndef IN6_IS_ADDR_LINKLOCAL
235 #define IN6_IS_ADDR_LINKLOCAL(a)        \
236         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
237 #endif
238
239 #ifndef IN6_IS_ADDR_MULTICAST
240 #define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
241 #endif
242
243 #ifndef __IPV6_ADDR_MC_SCOPE
244 #define __IPV6_ADDR_MC_SCOPE(a)         ((a)->s6_addr[1] & 0x0f)
245 #endif
246
247 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
248 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
249 #endif
250 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
251 #define __IPV6_ADDR_SCOPE_ORGLOCAL  0x08
252 #endif
253
254 #ifndef IN6_IS_ADDR_MC_SITELOCAL
255 #define IN6_IS_ADDR_MC_SITELOCAL(a)     \
256         (IN6_IS_ADDR_MULTICAST(a) &&    \
257          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
258 #endif
259
260 #ifndef IN6_IS_ADDR_MC_ORGLOCAL
261 #define IN6_IS_ADDR_MC_ORGLOCAL(a)      \
262         (IN6_IS_ADDR_MULTICAST(a) &&    \
263          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
264 #endif
265
266 #ifndef INADDR_NONE
267 #define INADDR_NONE 0xffffffff
268 #endif
269
270 #ifndef MAXHOSTNAMELEN
271 #define MAXHOSTNAMELEN 256
272 #endif
273
274 #ifndef INET6_ADDRSTRLEN
275 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
276 #define INET6_ADDRSTRLEN 46
277 #endif
278
279 #ifndef MIN
280 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
281 #endif
282
283 #ifndef MAX
284 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
285 #endif
286
287 #ifdef NEED_DAEMON
288 int daemon(int nochdir, int noclose);
289 #endif
290
291 #ifdef NEED_STRSEP
292 char * strsep(char **stringp, const char *delim);
293 #endif
294
295 #ifndef ALIGN
296 #define ALIGN(p) (((uintptr_t)(p) + (sizeof(long) - 1)) & ~(sizeof(long) - 1))
297 #endif
298
299 #ifdef NEED_SETGROUPENT
300 int setgroupent(int stayopen);
301 #endif
302
303 #ifdef NEED_GETGROUPLIST
304 int getgrouplist(GETGROUPLIST_ARGS);
305 #endif
306
307 #ifdef POSIX_GETGRNAM_R
308 int
309 __posix_getgrnam_r(const char *, struct group *, char *, int, struct group **);
310 #endif
311
312 #ifdef NEED_GETGRNAM_R
313 int
314 getgrnam_r(const char *,  struct group *, char *, size_t, struct group **);
315 #endif
316
317 #ifdef POSIX_GETGRGID_R
318 int
319 __posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ;
320 #endif
321
322 #ifdef NEED_GETGRGID_R
323 int
324 getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
325 #endif
326
327 #ifdef NEED_GETGRENT_R
328 GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS);
329 #endif
330
331 #ifdef NEED_SETGRENT_R
332 GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS);
333 #endif
334
335 #ifdef NEED_ENDGRENT_R
336 GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS);
337 #endif
338
339 #if defined(NEED_INNETGR_R) && defined(NGR_R_RETURN)
340 NGR_R_RETURN
341 innetgr_r(const char *, const char *, const char *, const char *);
342 #endif
343
344 #ifdef NEED_SETNETGRENT_R
345 #ifdef NGR_R_SET_ARGS
346 NGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS);
347 #else
348 NGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup);
349 #endif
350 #endif
351
352 #ifdef NEED_ENDNETGRENT_R
353 #ifdef NGR_R_END_ARGS
354 NGR_R_END_RETURN endnetgrent_r(NGR_R_END_ARGS);
355 #else
356 NGR_R_END_RETURN endnetgrent_r(void);
357 #endif
358 #endif
359
360 #ifdef POSIX_GETPWNAM_R
361 int
362 __posix_getpwnam_r(const char *login,  struct passwd *pwptr,
363                 char *buf, size_t buflen, struct passwd **result);
364 #endif
365
366 #ifdef NEED_GETPWNAM_R
367 int
368 getpwnam_r(const char *login,  struct passwd *pwptr,
369                 char *buf, size_t buflen, struct passwd **result);
370 #endif
371
372 #ifdef POSIX_GETPWUID_R
373 int
374 __posix_getpwuid_r(uid_t uid, struct passwd *pwptr,
375                 char *buf, int buflen, struct passwd **result);
376 #endif
377
378 #ifdef NEED_GETPWUID_R
379 int
380 getpwuid_r(uid_t uid, struct passwd *pwptr,
381                 char *buf, size_t buflen, struct passwd **result);
382 #endif
383
384 #ifdef NEED_SETPWENT_R
385 #ifdef PASS_R_ENT_ARGS
386 PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS);
387 #else
388 PASS_R_SET_RETURN setpwent_r(void);
389 #endif
390
391 #endif
392
393 #ifdef NEED_SETPASSENT_R
394 #ifdef PASS_R_ENT_ARGS
395 PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS);
396 #else
397 PASS_R_SET_RETURN setpassent_r(int stayopen);
398 #endif
399 #endif
400
401 #ifdef NEED_GETPWENT_R
402 PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS);
403 #endif
404
405 #ifdef NEED_ENDPWENT_R
406 void endpwent_r(void);
407 #endif
408
409 #ifdef NEED_SETPASSENT
410 int setpassent(int stayopen);
411 #endif
412
413 #define gettimeofday isc__gettimeofday
414 #ifdef NEED_GETTIMEOFDAY
415 int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp);
416 #else
417 int isc__gettimeofday(struct timeval *tp, struct timezone *tzp);
418 #endif
419
420 int getnetgrent(NGR_R_CONST char **machinep, NGR_R_CONST char **userp,
421                 NGR_R_CONST char **domainp);
422
423 #ifdef NGR_R_ARGS
424 int getnetgrent_r(NGR_R_CONST char **machinep, NGR_R_CONST char **userp,
425                   NGR_R_CONST char **domainp, NGR_R_ARGS);
426 #endif
427
428 #ifdef SETNETGRENT_ARGS
429 void setnetgrent(SETNETGRENT_ARGS);
430 #else
431 void setnetgrent(const char *netgroup);
432 #endif
433
434 void endnetgrent(void);
435
436 #ifdef INNETGR_ARGS
437 int innetgr(INNETGR_ARGS);
438 #else
439 int innetgr(const char *netgroup, const char *machine,
440             const char *user, const char *domain);
441 #endif
442
443 #ifdef NGR_R_SET_ARGS
444 NGR_R_SET_RETURN
445 setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS);
446 #else
447 NGR_R_SET_RETURN
448 setnetgrent_r(NGR_R_SET_CONST char *netgroup);
449 #endif
450
451 #ifdef NEED_STRTOUL
452 unsigned long strtoul(const char *, char **, int);
453 #endif
454
455 #ifdef NEED_SUN4PROTOS
456 #include <stdarg.h>
457 #ifndef __SIZE_TYPE__
458 #define __SIZE_TYPE__ int
459 #endif
460 struct sockaddr;
461 struct iovec;
462 struct timeval;
463 struct timezone;
464 int fprintf(FILE *, const char *, ...);
465 int getsockname(int, struct sockaddr *, int *);
466 int getpeername(int, struct sockaddr *, int *);
467 int socket(int, int, int);
468 int connect(int, const struct sockaddr *, int);
469 int writev(int, struct iovec *, int);
470 int readv(int, struct iovec *, int);
471 int send(int, const char *, int, int);
472 void bzero(char *, int);
473 int recvfrom(int, char *, int, int, struct sockaddr *, int *);
474 int syslog(int, const char *, ... );
475 int printf(const char *, ...);
476 __SIZE_TYPE__ fread(void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *);
477 __SIZE_TYPE__ fwrite(const void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *);
478 int fclose(FILE *);
479 int ungetc(int, FILE *);
480 int scanf(const char *, ...);
481 int sscanf(const char *, const char *, ... );
482 int tolower(int);
483 int toupper(int);
484 int strcasecmp(const char *, const char *);
485 int strncasecmp(const char *, const char *, int);
486 int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
487 #ifdef gettimeofday
488 #undef gettimeofday
489 int gettimeofday(struct timeval *, struct timezone *);
490 #define gettimeofday isc__gettimeofday
491 #else
492 int gettimeofday(struct timeval *, struct timezone *);
493 #endif
494 long strtol(const char*, char **, int);
495 int fseek(FILE *, long, int);
496 int setsockopt(int, int, int, const char *, int);
497 int bind(int, const struct sockaddr *, int);
498 void bcopy(char *, char *, int);
499 int fputc(char, FILE *);
500 int listen(int, int);
501 int accept(int, struct sockaddr *, int *);
502 int getsockopt(int, int, int, char *, int *);
503 int vfprintf(FILE *, const char *, va_list);
504 int fflush(FILE *);
505 int fgetc(FILE *);
506 int fputs(const char *, FILE *);
507 int fchown(int, int, int);
508 void setbuf(FILE *, char *);
509 int gethostname(char *, int);
510 int rename(const char *, const char *);
511 time_t time(time_t *);
512 int fscanf(FILE *, const char *, ...);
513 int sscanf(const char *, const char *, ...);
514 int ioctl(int, int, caddr_t);
515 void perror(const char *);
516
517 #if !defined(__USE_FIXED_PROTOTYPES__) && !defined(__cplusplus) && !defined(__STRICT_ANSI__)
518 /*
519  * 'gcc -ansi' changes the prototype for vsprintf().
520  * Use this prototype when 'gcc -ansi' is not in effect.
521  */
522 char *vsprintf(char *, const char *, va_list);
523 #endif
524 #endif
525
526 #endif