8 #include <sys/socket.h>
10 #if (!defined(BSD)) || (BSD < 199306)
11 #include <sys/bitypes.h>
13 #ifdef HAVE_INTTYPES_H
19 #define HAVE_MINIMUM_IFREQ 1
23 #define HAS_INET6_STRUCTS 1
24 #define HAVE_SIN6_SCOPE_ID 1
25 #undef NEED_IN6ADDR_ANY
27 #define HAVE_SOCKADDR_STORAGE 1
28 #undef NEED_GETTIMEOFDAY
30 #undef USE_FIONBIO_IOCTL
31 #undef USE_SYSERROR_LIST
33 #undef SETNETGRENT_ARGS
34 #define USE_IFNAMELINKID 1
35 #define PORT_NONBLOCK O_NONBLOCK
38 * We need to know the IPv6 address family number even on IPv4-only systems.
39 * Note that this is NOT a protocol constant, and that if the system has its
40 * own AF_INET6, different from ours below, all of BIND's libraries and
41 * executables will need to be recompiled after the system <sys/socket.h>
42 * has had this type added. The type number below is correct on most BSD-
43 * derived systems for which AF_INET6 is defined.
50 #define PF_INET6 AF_INET6
54 /* Map to pre-RFC structure. */
55 #define in6_addr in_addr6
58 #ifndef HAS_INET6_STRUCTS
59 /* Replace with structure from later rev of O/S if known. */
64 #define IN6ADDR_ANY_INIT \
65 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
66 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
68 #define IN6ADDR_LOOPBACK_INIT \
69 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
70 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
72 /* Replace with structure from later rev of O/S if known. */
75 u_int8_t sin6_len; /* length of this struct */
76 u_int8_t sin6_family; /* AF_INET6 */
78 u_int16_t sin6_family; /* AF_INET6 */
80 u_int16_t sin6_port; /* transport layer port # */
81 u_int32_t sin6_flowinfo; /* IPv6 flow information */
82 struct in6_addr sin6_addr; /* IPv6 address */
83 u_int32_t sin6_scope_id; /* set of interfaces for a scope */
85 #endif /* HAS_INET6_STRUCTS */
87 #ifdef BROKEN_IN6ADDR_INIT_MACROS
88 #undef IN6ADDR_ANY_INIT
89 #undef IN6ADDR_LOOPBACK_INIT
93 #ifndef IN6ADDR_ANY_INIT
94 #define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}}
96 #ifndef IN6ADDR_LOOPBACK_INIT
97 #if BYTE_ORDER == BIG_ENDIAN
98 #define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}}
100 #define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}}
105 #ifndef IN6ADDR_ANY_INIT
107 #define IN6ADDR_ANY_INIT \
108 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
109 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
111 #define IN6ADDR_ANY_INIT \
112 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
113 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
117 #ifndef IN6ADDR_LOOPBACK_INIT
119 #define IN6ADDR_LOOPBACK_INIT \
120 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
121 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
123 #define IN6ADDR_LOOPBACK_INIT \
124 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
125 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
129 #ifndef HAVE_SOCKADDR_STORAGE
130 #define __SS_MAXSIZE 128
131 #define __SS_ALLIGSIZE (sizeof (long))
133 struct sockaddr_storage {
135 u_int8_t ss_len; /* address length */
136 u_int8_t ss_family; /* address family */
137 char __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof(u_int8_t)];
139 char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
141 u_int16_t ss_family; /* address family */
142 char __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)];
144 char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
150 #if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY)
151 #define in6addr_any isc_in6addr_any
152 extern const struct in6_addr in6addr_any;
156 * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and
157 * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1.
160 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2)
161 #undef IN6_ARE_ADDR_EQUAL
162 #undef IN6_IS_ADDR_UNSPECIFIED
163 #undef IN6_IS_ADDR_V4COMPAT
164 #undef IN6_IS_ADDR_V4MAPPED
168 #ifndef IN6_ARE_ADDR_EQUAL
169 #define IN6_ARE_ADDR_EQUAL(a,b) \
170 (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
173 #ifndef IN6_IS_ADDR_UNSPECIFIED
174 #define IN6_IS_ADDR_UNSPECIFIED(a) \
175 IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
178 #ifndef IN6_IS_ADDR_LOOPBACK
179 extern const struct in6_addr isc_in6addr_loopback;
180 #define IN6_IS_ADDR_LOOPBACK(a) \
181 IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback)
184 #ifndef IN6_IS_ADDR_V4MAPPED
185 #define IN6_IS_ADDR_V4MAPPED(a) \
186 ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
187 (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
188 (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
189 (a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \
190 (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
191 (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
194 #ifndef IN6_IS_ADDR_SITELOCAL
195 #define IN6_IS_ADDR_SITELOCAL(a) \
196 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
199 #ifndef IN6_IS_ADDR_LINKLOCAL
200 #define IN6_IS_ADDR_LINKLOCAL(a) \
201 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
204 #ifndef IN6_IS_ADDR_MULTICAST
205 #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
208 #ifndef __IPV6_ADDR_MC_SCOPE
209 #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
212 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
213 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
215 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
216 #define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08
219 #ifndef IN6_IS_ADDR_MC_SITELOCAL
220 #define IN6_IS_ADDR_MC_SITELOCAL(a) \
221 (IN6_IS_ADDR_MULTICAST(a) && \
222 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
225 #ifndef IN6_IS_ADDR_MC_ORGLOCAL
226 #define IN6_IS_ADDR_MC_ORGLOCAL(a) \
227 (IN6_IS_ADDR_MULTICAST(a) && \
228 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
232 #define INADDR_NONE 0xffffffff
235 #ifndef MAXHOSTNAMELEN
236 #define MAXHOSTNAMELEN 256
239 #ifndef INET6_ADDRSTRLEN
240 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
241 #define INET6_ADDRSTRLEN 46
245 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
249 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
253 int daemon(int nochdir, int noclose);
257 char * strsep(char **stringp, const char *delim);
261 #define ALIGN(p) (((uintptr_t)(p) + (sizeof(long) - 1)) & ~(sizeof(long) - 1))
264 #ifdef NEED_SETGROUPENT
265 int setgroupent(int stayopen);
268 #ifdef NEED_GETGROUPLIST
269 int getgrouplist(GETGROUPLIST_ARGS);
272 #ifdef POSIX_GETGRNAM_R
274 __posix_getgrnam_r(const char *, struct group *, char *, int, struct group **);
277 #ifdef NEED_GETGRNAM_R
279 getgrnam_r(const char *, struct group *, char *, size_t, struct group **);
282 #ifdef POSIX_GETGRGID_R
284 __posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ;
287 #ifdef NEED_GETGRGID_R
289 getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
292 #ifdef NEED_GETGRENT_R
293 GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS);
296 #ifdef NEED_SETGRENT_R
297 GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS);
300 #ifdef NEED_ENDGRENT_R
301 GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS);
304 #if defined(NEED_INNETGR_R) && defined(NGR_R_RETURN)
306 innetgr_r(const char *, const char *, const char *, const char *);
309 #ifdef NEED_SETNETGRENT_R
310 #ifdef NGR_R_ENT_ARGS
311 NGR_R_SET_RETURN setnetgrent_r(const char *netgroup, NGR_R_ENT_ARGS);
313 NGR_R_SET_RETURN setnetgrent_r(const char *netgroup);
317 #ifdef NEED_ENDNETGRENT_R
318 #ifdef NGR_R_ENT_ARGS
319 NGR_R_END_RETURN endnetgrent_r(NGR_R_ENT_ARGS);
321 NGR_R_END_RETURN endnetgrent_r(void);
325 #ifdef POSIX_GETPWNAM_R
327 __posix_getpwnam_r(const char *login, struct passwd *pwptr,
328 char *buf, size_t buflen, struct passwd **result);
331 #ifdef NEED_GETPWNAM_R
333 getpwnam_r(const char *login, struct passwd *pwptr,
334 char *buf, size_t buflen, struct passwd **result);
337 #ifdef POSIX_GETPWUID_R
339 __posix_getpwuid_r(uid_t uid, struct passwd *pwptr,
340 char *buf, int buflen, struct passwd **result);
343 #ifdef NEED_GETPWUID_R
345 getpwuid_r(uid_t uid, struct passwd *pwptr,
346 char *buf, size_t buflen, struct passwd **result);
349 #ifdef NEED_SETPWENT_R
350 #ifdef PASS_R_ENT_ARGS
351 PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS);
353 PASS_R_SET_RETURN setpwent_r(void);
358 #ifdef NEED_SETPASSENT_R
359 #ifdef PASS_R_ENT_ARGS
360 PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS);
362 PASS_R_SET_RETURN setpassent_r(int stayopen);
366 #ifdef NEED_GETPWENT_R
367 PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS);
370 #ifdef NEED_ENDPWENT_R
371 void endpwent_r(void);
374 #ifdef NEED_SETPASSENT
375 int setpassent(int stayopen);
378 #define gettimeofday isc__gettimeofday
379 #ifdef NEED_GETTIMEOFDAY
380 int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp);
382 int isc__gettimeofday(struct timeval *tp, struct timezone *tzp);
385 int getnetgrent(char **machinep, char **userp, char **domainp);
388 int getnetgrent_r(char **machinep, char **userp, char **domainp, NGR_R_ARGS);
391 #ifdef SETNETGRENT_ARGS
392 void setnetgrent(SETNETGRENT_ARGS);
394 void setnetgrent(const char *netgroup);
397 void endnetgrent(void);
400 int innetgr(INNETGR_ARGS);
402 int innetgr(const char *netgroup, const char *machine,
403 const char *user, const char *domain);
406 #ifdef NGR_R_ENT_ARGS
408 setnetgrent_r(const char *netgroup, NGR_R_ENT_ARGS);
411 setnetgrent_r(const char *netgroup);