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