8 #include <sys/socket.h>
11 #if (!defined(BSD)) || (BSD < 199306)
12 #include <sys/bitypes.h>
14 #ifdef HAVE_INTTYPES_H
17 #ifdef HAVE_SYS_SELECT_H
18 #include <sys/select.h>
19 #endif /* HAVE_SYS_SELECT_H */
27 #define HAVE_MINIMUM_IFREQ 1
32 const char *isc_strerror(int);
33 #define strerror isc_strerror
35 #define HAS_INET6_STRUCTS 1
36 #define HAVE_SIN6_SCOPE_ID 1
37 #undef NEED_IN6ADDR_ANY
39 #define HAVE_SOCKADDR_STORAGE 1
40 #undef NEED_GETTIMEOFDAY
41 #define HAVE_STRNDUP 1
42 #undef USE_FIONBIO_IOCTL
44 #undef SETNETGRENT_ARGS
45 #define USE_IFNAMELINKID 1
46 #define PORT_NONBLOCK O_NONBLOCK
48 #ifndef _POSIX_PATH_MAX
49 #define _POSIX_PATH_MAX 255
52 #define PATH_MAX _POSIX_PATH_MAX
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.
68 #define PF_INET6 AF_INET6
72 /* Map to pre-RFC structure. */
73 #define in6_addr in_addr6
76 #ifndef HAS_INET6_STRUCTS
77 /* Replace with structure from later rev of O/S if known. */
82 #define IN6ADDR_ANY_INIT \
83 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
84 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
86 #define IN6ADDR_LOOPBACK_INIT \
87 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
88 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
90 /* Replace with structure from later rev of O/S if known. */
93 u_int8_t sin6_len; /* length of this struct */
94 u_int8_t sin6_family; /* AF_INET6 */
96 u_int16_t sin6_family; /* AF_INET6 */
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 */
103 #endif /* HAS_INET6_STRUCTS */
105 #ifdef BROKEN_IN6ADDR_INIT_MACROS
106 #undef IN6ADDR_ANY_INIT
107 #undef IN6ADDR_LOOPBACK_INIT
111 #ifndef IN6ADDR_ANY_INIT
112 #define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}}
114 #ifndef IN6ADDR_LOOPBACK_INIT
115 #if BYTE_ORDER == BIG_ENDIAN
116 #define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}}
118 #define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}}
123 #ifndef IN6ADDR_ANY_INIT
125 #define IN6ADDR_ANY_INIT \
126 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
127 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
129 #define IN6ADDR_ANY_INIT \
130 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
131 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
135 #ifndef IN6ADDR_LOOPBACK_INIT
137 #define IN6ADDR_LOOPBACK_INIT \
138 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
139 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
141 #define IN6ADDR_LOOPBACK_INIT \
142 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
143 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
147 #ifndef HAVE_SOCKADDR_STORAGE
148 #define __SS_MAXSIZE 128
149 #define __SS_ALLIGSIZE (sizeof (long))
151 struct sockaddr_storage {
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)];
157 char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
159 u_int16_t ss_family; /* address family */
160 char __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)];
162 char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
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;
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.
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
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)
191 #ifndef IN6_IS_ADDR_UNSPECIFIED
192 #define IN6_IS_ADDR_UNSPECIFIED(a) \
193 IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
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)
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)
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))
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))
222 #ifndef IN6_IS_ADDR_MULTICAST
223 #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
226 #ifndef __IPV6_ADDR_MC_SCOPE
227 #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
230 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
231 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
233 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
234 #define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08
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))
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))
250 #define INADDR_NONE 0xffffffff
253 #ifndef MAXHOSTNAMELEN
254 #define MAXHOSTNAMELEN 256
257 #ifndef INET6_ADDRSTRLEN
258 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
259 #define INET6_ADDRSTRLEN 46
263 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
267 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
271 int daemon(int nochdir, int noclose);
275 char * strsep(char **stringp, const char *delim);
279 #define ALIGN(p) (((uintptr_t)(p) + (sizeof(long) - 1)) & ~(sizeof(long) - 1))
282 #ifdef NEED_SETGROUPENT
283 int setgroupent(int stayopen);
286 #ifdef NEED_GETGROUPLIST
287 int getgrouplist(GETGROUPLIST_ARGS);
290 #ifdef POSIX_GETGRNAM_R
292 __posix_getgrnam_r(const char *, struct group *, char *, int, struct group **);
295 #ifdef NEED_GETGRNAM_R
297 getgrnam_r(const char *, struct group *, char *, size_t, struct group **);
300 #ifdef POSIX_GETGRGID_R
302 __posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ;
305 #ifdef NEED_GETGRGID_R
307 getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
310 #ifdef NEED_GETGRENT_R
311 GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS);
314 #ifdef NEED_SETGRENT_R
315 GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS);
318 #ifdef NEED_ENDGRENT_R
319 GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS);
322 #if defined(NEED_INNETGR_R) && defined(NGR_R_RETURN)
324 innetgr_r(const char *, const char *, const char *, const char *);
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);
331 NGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup);
335 #ifdef NEED_ENDNETGRENT_R
336 #ifdef NGR_R_END_ARGS
337 NGR_R_END_RETURN endnetgrent_r(NGR_R_END_ARGS);
339 NGR_R_END_RETURN endnetgrent_r(void);
343 #ifdef POSIX_GETPWNAM_R
345 __posix_getpwnam_r(const char *login, struct passwd *pwptr,
346 char *buf, size_t buflen, struct passwd **result);
349 #ifdef NEED_GETPWNAM_R
351 getpwnam_r(const char *login, struct passwd *pwptr,
352 char *buf, size_t buflen, struct passwd **result);
355 #ifdef POSIX_GETPWUID_R
357 __posix_getpwuid_r(uid_t uid, struct passwd *pwptr,
358 char *buf, int buflen, struct passwd **result);
361 #ifdef NEED_GETPWUID_R
363 getpwuid_r(uid_t uid, struct passwd *pwptr,
364 char *buf, size_t buflen, struct passwd **result);
367 #ifdef NEED_SETPWENT_R
368 #ifdef PASS_R_ENT_ARGS
369 PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS);
371 PASS_R_SET_RETURN setpwent_r(void);
376 #ifdef NEED_SETPASSENT_R
377 #ifdef PASS_R_ENT_ARGS
378 PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS);
380 PASS_R_SET_RETURN setpassent_r(int stayopen);
384 #ifdef NEED_GETPWENT_R
385 PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS);
388 #ifdef NEED_ENDPWENT_R
389 void endpwent_r(void);
392 #ifdef NEED_SETPASSENT
393 int setpassent(int stayopen);
396 #define gettimeofday isc__gettimeofday
397 #ifdef NEED_GETTIMEOFDAY
398 int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp);
400 int isc__gettimeofday(struct timeval *tp, struct timezone *tzp);
403 int getnetgrent(NGR_R_CONST char **machinep, NGR_R_CONST char **userp,
404 NGR_R_CONST char **domainp);
407 int getnetgrent_r(NGR_R_CONST char **machinep, NGR_R_CONST char **userp,
408 NGR_R_CONST char **domainp, NGR_R_ARGS);
411 #ifdef SETNETGRENT_ARGS
412 void setnetgrent(SETNETGRENT_ARGS);
414 void setnetgrent(const char *netgroup);
417 void endnetgrent(void);
420 int innetgr(INNETGR_ARGS);
422 int innetgr(const char *netgroup, const char *machine,
423 const char *user, const char *domain);
426 #ifdef NGR_R_SET_ARGS
428 setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS);
431 setnetgrent_r(NGR_R_SET_CONST char *netgroup);
435 unsigned long strtoul(const char *, char **, int);
438 #ifdef NEED_SUN4PROTOS
440 #ifndef __SIZE_TYPE__
441 #define __SIZE_TYPE__ int
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 *);
462 int ungetc(int, FILE *);
463 int scanf(const char *, ...);
464 int sscanf(const char *, const char *, ... );
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 *);
472 int gettimeofday(struct timeval *, struct timezone *);
473 #define gettimeofday isc__gettimeofday
475 int gettimeofday(struct timeval *, struct timezone *);
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);
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 *);
500 #if !defined(__USE_FIXED_PROTOTYPES__) && !defined(__cplusplus) && !defined(__STRICT_ANSI__)
502 * 'gcc -ansi' changes the prototype for vsprintf().
503 * Use this prototype when 'gcc -ansi' is not in effect.
505 char *vsprintf(char *, const char *, va_list);