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 */
23 #define HAVE_MINIMUM_IFREQ 1
27 #define HAS_INET6_STRUCTS 1
28 #define HAVE_SIN6_SCOPE_ID 1
29 #undef NEED_IN6ADDR_ANY
31 #define HAVE_SOCKADDR_STORAGE 1
32 #undef NEED_GETTIMEOFDAY
34 #undef USE_FIONBIO_IOCTL
35 #undef USE_SYSERROR_LIST
37 #undef SETNETGRENT_ARGS
38 #define USE_IFNAMELINKID 1
39 #define PORT_NONBLOCK O_NONBLOCK
41 #ifndef _POSIX_PATH_MAX
42 #define _POSIX_PATH_MAX 255
45 #define PATH_MAX _POSIX_PATH_MAX
49 * We need to know the IPv6 address family number even on IPv4-only systems.
50 * Note that this is NOT a protocol constant, and that if the system has its
51 * own AF_INET6, different from ours below, all of BIND's libraries and
52 * executables will need to be recompiled after the system <sys/socket.h>
53 * has had this type added. The type number below is correct on most BSD-
54 * derived systems for which AF_INET6 is defined.
61 #define PF_INET6 AF_INET6
65 /* Map to pre-RFC structure. */
66 #define in6_addr in_addr6
69 #ifndef HAS_INET6_STRUCTS
70 /* Replace with structure from later rev of O/S if known. */
75 #define IN6ADDR_ANY_INIT \
76 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
77 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
79 #define IN6ADDR_LOOPBACK_INIT \
80 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
81 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
83 /* Replace with structure from later rev of O/S if known. */
86 u_int8_t sin6_len; /* length of this struct */
87 u_int8_t sin6_family; /* AF_INET6 */
89 u_int16_t sin6_family; /* AF_INET6 */
91 u_int16_t sin6_port; /* transport layer port # */
92 u_int32_t sin6_flowinfo; /* IPv6 flow information */
93 struct in6_addr sin6_addr; /* IPv6 address */
94 u_int32_t sin6_scope_id; /* set of interfaces for a scope */
96 #endif /* HAS_INET6_STRUCTS */
98 #ifdef BROKEN_IN6ADDR_INIT_MACROS
99 #undef IN6ADDR_ANY_INIT
100 #undef IN6ADDR_LOOPBACK_INIT
104 #ifndef IN6ADDR_ANY_INIT
105 #define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}}
107 #ifndef IN6ADDR_LOOPBACK_INIT
108 #if BYTE_ORDER == BIG_ENDIAN
109 #define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}}
111 #define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}}
116 #ifndef IN6ADDR_ANY_INIT
118 #define IN6ADDR_ANY_INIT \
119 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
120 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
122 #define IN6ADDR_ANY_INIT \
123 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
124 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
128 #ifndef IN6ADDR_LOOPBACK_INIT
130 #define IN6ADDR_LOOPBACK_INIT \
131 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
132 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
134 #define IN6ADDR_LOOPBACK_INIT \
135 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
136 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
140 #ifndef HAVE_SOCKADDR_STORAGE
141 #define __SS_MAXSIZE 128
142 #define __SS_ALLIGSIZE (sizeof (long))
144 struct sockaddr_storage {
146 u_int8_t ss_len; /* address length */
147 u_int8_t ss_family; /* address family */
148 char __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof(u_int8_t)];
150 char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
152 u_int16_t ss_family; /* address family */
153 char __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)];
155 char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
161 #if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY)
162 #define in6addr_any isc_in6addr_any
163 extern const struct in6_addr in6addr_any;
167 * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and
168 * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1.
171 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2)
172 #undef IN6_ARE_ADDR_EQUAL
173 #undef IN6_IS_ADDR_UNSPECIFIED
174 #undef IN6_IS_ADDR_V4COMPAT
175 #undef IN6_IS_ADDR_V4MAPPED
179 #ifndef IN6_ARE_ADDR_EQUAL
180 #define IN6_ARE_ADDR_EQUAL(a,b) \
181 (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
184 #ifndef IN6_IS_ADDR_UNSPECIFIED
185 #define IN6_IS_ADDR_UNSPECIFIED(a) \
186 IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
189 #ifndef IN6_IS_ADDR_LOOPBACK
190 extern const struct in6_addr isc_in6addr_loopback;
191 #define IN6_IS_ADDR_LOOPBACK(a) \
192 IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback)
195 #ifndef IN6_IS_ADDR_V4MAPPED
196 #define IN6_IS_ADDR_V4MAPPED(a) \
197 ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
198 (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
199 (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
200 (a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \
201 (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
202 (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
205 #ifndef IN6_IS_ADDR_SITELOCAL
206 #define IN6_IS_ADDR_SITELOCAL(a) \
207 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
210 #ifndef IN6_IS_ADDR_LINKLOCAL
211 #define IN6_IS_ADDR_LINKLOCAL(a) \
212 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
215 #ifndef IN6_IS_ADDR_MULTICAST
216 #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
219 #ifndef __IPV6_ADDR_MC_SCOPE
220 #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
223 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
224 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
226 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
227 #define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08
230 #ifndef IN6_IS_ADDR_MC_SITELOCAL
231 #define IN6_IS_ADDR_MC_SITELOCAL(a) \
232 (IN6_IS_ADDR_MULTICAST(a) && \
233 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
236 #ifndef IN6_IS_ADDR_MC_ORGLOCAL
237 #define IN6_IS_ADDR_MC_ORGLOCAL(a) \
238 (IN6_IS_ADDR_MULTICAST(a) && \
239 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
243 #define INADDR_NONE 0xffffffff
246 #ifndef MAXHOSTNAMELEN
247 #define MAXHOSTNAMELEN 256
250 #ifndef INET6_ADDRSTRLEN
251 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
252 #define INET6_ADDRSTRLEN 46
256 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
260 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
264 int daemon(int nochdir, int noclose);
268 char * strsep(char **stringp, const char *delim);
272 #define ALIGN(p) (((uintptr_t)(p) + (sizeof(long) - 1)) & ~(sizeof(long) - 1))
275 #ifdef NEED_SETGROUPENT
276 int setgroupent(int stayopen);
279 #ifdef NEED_GETGROUPLIST
280 int getgrouplist(GETGROUPLIST_ARGS);
283 #ifdef POSIX_GETGRNAM_R
285 __posix_getgrnam_r(const char *, struct group *, char *, int, struct group **);
288 #ifdef NEED_GETGRNAM_R
290 getgrnam_r(const char *, struct group *, char *, size_t, struct group **);
293 #ifdef POSIX_GETGRGID_R
295 __posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ;
298 #ifdef NEED_GETGRGID_R
300 getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
303 #ifdef NEED_GETGRENT_R
304 GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS);
307 #ifdef NEED_SETGRENT_R
308 GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS);
311 #ifdef NEED_ENDGRENT_R
312 GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS);
315 #if defined(NEED_INNETGR_R) && defined(NGR_R_RETURN)
317 innetgr_r(const char *, const char *, const char *, const char *);
320 #ifdef NEED_SETNETGRENT_R
321 #ifdef NGR_R_ENT_ARGS
322 NGR_R_SET_RETURN setnetgrent_r(const char *netgroup, NGR_R_ENT_ARGS);
324 NGR_R_SET_RETURN setnetgrent_r(const char *netgroup);
328 #ifdef NEED_ENDNETGRENT_R
329 #ifdef NGR_R_ENT_ARGS
330 NGR_R_END_RETURN endnetgrent_r(NGR_R_ENT_ARGS);
332 NGR_R_END_RETURN endnetgrent_r(void);
336 #ifdef POSIX_GETPWNAM_R
338 __posix_getpwnam_r(const char *login, struct passwd *pwptr,
339 char *buf, size_t buflen, struct passwd **result);
342 #ifdef NEED_GETPWNAM_R
344 getpwnam_r(const char *login, struct passwd *pwptr,
345 char *buf, size_t buflen, struct passwd **result);
348 #ifdef POSIX_GETPWUID_R
350 __posix_getpwuid_r(uid_t uid, struct passwd *pwptr,
351 char *buf, int buflen, struct passwd **result);
354 #ifdef NEED_GETPWUID_R
356 getpwuid_r(uid_t uid, struct passwd *pwptr,
357 char *buf, size_t buflen, struct passwd **result);
360 #ifdef NEED_SETPWENT_R
361 #ifdef PASS_R_ENT_ARGS
362 PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS);
364 PASS_R_SET_RETURN setpwent_r(void);
369 #ifdef NEED_SETPASSENT_R
370 #ifdef PASS_R_ENT_ARGS
371 PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS);
373 PASS_R_SET_RETURN setpassent_r(int stayopen);
377 #ifdef NEED_GETPWENT_R
378 PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS);
381 #ifdef NEED_ENDPWENT_R
382 void endpwent_r(void);
385 #ifdef NEED_SETPASSENT
386 int setpassent(int stayopen);
389 #define gettimeofday isc__gettimeofday
390 #ifdef NEED_GETTIMEOFDAY
391 int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp);
393 int isc__gettimeofday(struct timeval *tp, struct timezone *tzp);
396 int getnetgrent(char **machinep, char **userp, char **domainp);
399 int getnetgrent_r(char **machinep, char **userp, char **domainp, NGR_R_ARGS);
402 #ifdef SETNETGRENT_ARGS
403 void setnetgrent(SETNETGRENT_ARGS);
405 void setnetgrent(const char *netgroup);
408 void endnetgrent(void);
411 int innetgr(INNETGR_ARGS);
413 int innetgr(const char *netgroup, const char *machine,
414 const char *user, const char *domain);
417 #ifdef NGR_R_ENT_ARGS
419 setnetgrent_r(const char *netgroup, NGR_R_ENT_ARGS);
422 setnetgrent_r(const char *netgroup);