6 #include <sys/socket.h>
9 #if (!defined(BSD)) || (BSD < 199306)
10 #include <sys/bitypes.h>
12 #ifdef HAVE_INTTYPES_H
15 #ifdef HAVE_SYS_SELECT_H
16 #include <sys/select.h>
17 #endif /* HAVE_SYS_SELECT_H */
30 const char *isc_strerror(int);
31 #define strerror isc_strerror
37 @HAVE_SOCKADDR_STORAGE@
46 #ifndef _POSIX_PATH_MAX
47 #define _POSIX_PATH_MAX 255
50 #define PATH_MAX _POSIX_PATH_MAX
54 * We need to know the IPv6 address family number even on IPv4-only systems.
55 * Note that this is NOT a protocol constant, and that if the system has its
56 * own AF_INET6, different from ours below, all of BIND's libraries and
57 * executables will need to be recompiled after the system <sys/socket.h>
58 * has had this type added. The type number below is correct on most BSD-
59 * derived systems for which AF_INET6 is defined.
66 #define PF_INET6 AF_INET6
70 /* Map to pre-RFC structure. */
71 #define in6_addr in_addr6
74 #ifndef HAS_INET6_STRUCTS
75 /* Replace with structure from later rev of O/S if known. */
80 #define IN6ADDR_ANY_INIT \
81 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
82 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
84 #define IN6ADDR_LOOPBACK_INIT \
85 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
86 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
88 /* Replace with structure from later rev of O/S if known. */
91 u_int8_t sin6_len; /* length of this struct */
92 u_int8_t sin6_family; /* AF_INET6 */
94 u_int16_t sin6_family; /* AF_INET6 */
96 u_int16_t sin6_port; /* transport layer port # */
97 u_int32_t sin6_flowinfo; /* IPv6 flow information */
98 struct in6_addr sin6_addr; /* IPv6 address */
99 u_int32_t sin6_scope_id; /* set of interfaces for a scope */
101 #endif /* HAS_INET6_STRUCTS */
103 #ifdef BROKEN_IN6ADDR_INIT_MACROS
104 #undef IN6ADDR_ANY_INIT
105 #undef IN6ADDR_LOOPBACK_INIT
109 #ifndef IN6ADDR_ANY_INIT
110 #define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}}
112 #ifndef IN6ADDR_LOOPBACK_INIT
113 #if BYTE_ORDER == BIG_ENDIAN
114 #define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}}
116 #define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}}
121 #ifndef IN6ADDR_ANY_INIT
123 #define IN6ADDR_ANY_INIT \
124 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
125 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
127 #define IN6ADDR_ANY_INIT \
128 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
129 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
133 #ifndef IN6ADDR_LOOPBACK_INIT
135 #define IN6ADDR_LOOPBACK_INIT \
136 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
137 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
139 #define IN6ADDR_LOOPBACK_INIT \
140 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
141 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
145 #ifndef HAVE_SOCKADDR_STORAGE
146 #define __SS_MAXSIZE 128
147 #define __SS_ALLIGSIZE (sizeof (long))
149 struct sockaddr_storage {
151 u_int8_t ss_len; /* address length */
152 u_int8_t ss_family; /* address family */
153 char __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof(u_int8_t)];
155 char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
157 u_int16_t ss_family; /* address family */
158 char __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)];
160 char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
166 #if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY)
167 #define in6addr_any isc_in6addr_any
168 extern const struct in6_addr in6addr_any;
172 * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and
173 * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1.
176 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2)
177 #undef IN6_ARE_ADDR_EQUAL
178 #undef IN6_IS_ADDR_UNSPECIFIED
179 #undef IN6_IS_ADDR_V4COMPAT
180 #undef IN6_IS_ADDR_V4MAPPED
184 #ifndef IN6_ARE_ADDR_EQUAL
185 #define IN6_ARE_ADDR_EQUAL(a,b) \
186 (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
189 #ifndef IN6_IS_ADDR_UNSPECIFIED
190 #define IN6_IS_ADDR_UNSPECIFIED(a) \
191 IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
194 #ifndef IN6_IS_ADDR_LOOPBACK
195 extern const struct in6_addr isc_in6addr_loopback;
196 #define IN6_IS_ADDR_LOOPBACK(a) \
197 IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback)
200 #ifndef IN6_IS_ADDR_V4MAPPED
201 #define IN6_IS_ADDR_V4MAPPED(a) \
202 ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
203 (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
204 (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
205 (a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \
206 (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
207 (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
210 #ifndef IN6_IS_ADDR_SITELOCAL
211 #define IN6_IS_ADDR_SITELOCAL(a) \
212 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
215 #ifndef IN6_IS_ADDR_LINKLOCAL
216 #define IN6_IS_ADDR_LINKLOCAL(a) \
217 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
220 #ifndef IN6_IS_ADDR_MULTICAST
221 #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
224 #ifndef __IPV6_ADDR_MC_SCOPE
225 #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
228 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
229 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
231 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
232 #define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08
235 #ifndef IN6_IS_ADDR_MC_SITELOCAL
236 #define IN6_IS_ADDR_MC_SITELOCAL(a) \
237 (IN6_IS_ADDR_MULTICAST(a) && \
238 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
241 #ifndef IN6_IS_ADDR_MC_ORGLOCAL
242 #define IN6_IS_ADDR_MC_ORGLOCAL(a) \
243 (IN6_IS_ADDR_MULTICAST(a) && \
244 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
248 #define INADDR_NONE 0xffffffff
251 #ifndef MAXHOSTNAMELEN
252 #define MAXHOSTNAMELEN 256
255 #ifndef INET6_ADDRSTRLEN
256 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
257 #define INET6_ADDRSTRLEN 46
261 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
265 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
269 int daemon(int nochdir, int noclose);
273 char * strsep(char **stringp, const char *delim);
277 #define ALIGN(p) (((uintptr_t)(p) + (sizeof(long) - 1)) & ~(sizeof(long) - 1))
280 #ifdef NEED_SETGROUPENT
281 int setgroupent(int stayopen);
284 #ifdef NEED_GETGROUPLIST
285 int getgrouplist(GETGROUPLIST_ARGS);
288 #ifdef POSIX_GETGRNAM_R
290 __posix_getgrnam_r(const char *, struct group *, char *, int, struct group **);
293 #ifdef NEED_GETGRNAM_R
295 getgrnam_r(const char *, struct group *, char *, size_t, struct group **);
298 #ifdef POSIX_GETGRGID_R
300 __posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ;
303 #ifdef NEED_GETGRGID_R
305 getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
308 #ifdef NEED_GETGRENT_R
309 GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS);
312 #ifdef NEED_SETGRENT_R
313 GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS);
316 #ifdef NEED_ENDGRENT_R
317 GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS);
320 #if defined(NEED_INNETGR_R) && defined(NGR_R_RETURN)
322 innetgr_r(const char *, const char *, const char *, const char *);
325 #ifdef NEED_SETNETGRENT_R
326 #ifdef NGR_R_SET_ARGS
327 NGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS);
329 NGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup);
333 #ifdef NEED_ENDNETGRENT_R
334 #ifdef NGR_R_END_ARGS
335 NGR_R_END_RETURN endnetgrent_r(NGR_R_END_ARGS);
337 NGR_R_END_RETURN endnetgrent_r(void);
341 #ifdef POSIX_GETPWNAM_R
343 __posix_getpwnam_r(const char *login, struct passwd *pwptr,
344 char *buf, size_t buflen, struct passwd **result);
347 #ifdef NEED_GETPWNAM_R
349 getpwnam_r(const char *login, struct passwd *pwptr,
350 char *buf, size_t buflen, struct passwd **result);
353 #ifdef POSIX_GETPWUID_R
355 __posix_getpwuid_r(uid_t uid, struct passwd *pwptr,
356 char *buf, int buflen, struct passwd **result);
359 #ifdef NEED_GETPWUID_R
361 getpwuid_r(uid_t uid, struct passwd *pwptr,
362 char *buf, size_t buflen, struct passwd **result);
365 #ifdef NEED_SETPWENT_R
366 #ifdef PASS_R_ENT_ARGS
367 PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS);
369 PASS_R_SET_RETURN setpwent_r(void);
374 #ifdef NEED_SETPASSENT_R
375 #ifdef PASS_R_ENT_ARGS
376 PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS);
378 PASS_R_SET_RETURN setpassent_r(int stayopen);
382 #ifdef NEED_GETPWENT_R
383 PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS);
386 #ifdef NEED_ENDPWENT_R
387 void endpwent_r(void);
390 #ifdef NEED_SETPASSENT
391 int setpassent(int stayopen);
394 #define gettimeofday isc__gettimeofday
395 #ifdef NEED_GETTIMEOFDAY
396 int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp);
398 int isc__gettimeofday(struct timeval *tp, struct timezone *tzp);
401 int getnetgrent(NGR_R_CONST char **machinep, NGR_R_CONST char **userp,
402 NGR_R_CONST char **domainp);
405 int getnetgrent_r(NGR_R_CONST char **machinep, NGR_R_CONST char **userp,
406 NGR_R_CONST char **domainp, NGR_R_ARGS);
409 #ifdef SETNETGRENT_ARGS
410 void setnetgrent(SETNETGRENT_ARGS);
412 void setnetgrent(const char *netgroup);
415 void endnetgrent(void);
418 int innetgr(INNETGR_ARGS);
420 int innetgr(const char *netgroup, const char *machine,
421 const char *user, const char *domain);
424 #ifdef NGR_R_SET_ARGS
426 setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS);
429 setnetgrent_r(NGR_R_SET_CONST char *netgroup);
433 unsigned long strtoul(const char *, char **, int);
436 #ifdef NEED_SUN4PROTOS
438 #ifndef __SIZE_TYPE__
439 #define __SIZE_TYPE__ int
445 int fprintf(FILE *, const char *, ...);
446 int getsockname(int, struct sockaddr *, int *);
447 int getpeername(int, struct sockaddr *, int *);
448 int socket(int, int, int);
449 int connect(int, const struct sockaddr *, int);
450 int writev(int, struct iovec *, int);
451 int readv(int, struct iovec *, int);
452 int send(int, const char *, int, int);
453 void bzero(char *, int);
454 int recvfrom(int, char *, int, int, struct sockaddr *, int *);
455 int syslog(int, const char *, ... );
456 int printf(const char *, ...);
457 __SIZE_TYPE__ fread(void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *);
458 __SIZE_TYPE__ fwrite(const void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *);
460 int ungetc(int, FILE *);
461 int scanf(const char *, ...);
462 int sscanf(const char *, const char *, ... );
465 int strcasecmp(const char *, const char *);
466 int strncasecmp(const char *, const char *, int);
467 int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
470 int gettimeofday(struct timeval *, struct timezone *);
471 #define gettimeofday isc__gettimeofday
473 int gettimeofday(struct timeval *, struct timezone *);
475 long strtol(const char*, char **, int);
476 int fseek(FILE *, long, int);
477 int setsockopt(int, int, int, const char *, int);
478 int bind(int, const struct sockaddr *, int);
479 void bcopy(char *, char *, int);
480 int fputc(char, FILE *);
481 int listen(int, int);
482 int accept(int, struct sockaddr *, int *);
483 int getsockopt(int, int, int, char *, int *);
484 int vfprintf(FILE *, const char *, va_list);
487 int fputs(const char *, FILE *);
488 int fchown(int, int, int);
489 void setbuf(FILE *, char *);
490 int gethostname(char *, int);
491 int rename(const char *, const char *);
492 time_t time(time_t *);
493 int fscanf(FILE *, const char *, ...);
494 int sscanf(const char *, const char *, ...);
495 int ioctl(int, int, caddr_t);
496 void perror(const char *);
498 #if !defined(__USE_FIXED_PROTOTYPES__) && !defined(__cplusplus) && !defined(__STRICT_ANSI__)
500 * 'gcc -ansi' changes the prototype for vsprintf().
501 * Use this prototype when 'gcc -ansi' is not in effect.
503 char *vsprintf(char *, const char *, va_list);