6 #include <sys/socket.h>
8 #if (!defined(BSD)) || (BSD < 199306)
9 #include <sys/bitypes.h>
22 @HAVE_SOCKADDR_STORAGE@
31 /* XXX sunos and cygwin needs O_NDELAY */
32 #define PORT_NONBLOCK O_NONBLOCK
35 * We need to know the IPv6 address family number even on IPv4-only systems.
36 * Note that this is NOT a protocol constant, and that if the system has its
37 * own AF_INET6, different from ours below, all of BIND's libraries and
38 * executables will need to be recompiled after the system <sys/socket.h>
39 * has had this type added. The type number below is correct on most BSD-
40 * derived systems for which AF_INET6 is defined.
47 #define PF_INET6 AF_INET6
51 /* Map to pre-RFC structure. */
52 #define in6_addr in_addr6
55 #ifndef HAS_INET6_STRUCTS
56 /* Replace with structure from later rev of O/S if known. */
61 #define IN6ADDR_ANY_INIT \
62 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
63 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
65 #define IN6ADDR_LOOPBACK_INIT \
66 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
67 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
69 /* Replace with structure from later rev of O/S if known. */
72 u_int8_t sin6_len; /* length of this struct */
73 u_int8_t sin6_family; /* AF_INET6 */
75 u_int16_t sin6_family; /* AF_INET6 */
77 u_int16_t sin6_port; /* transport layer port # */
78 u_int32_t sin6_flowinfo; /* IPv6 flow information */
79 struct in6_addr sin6_addr; /* IPv6 address */
80 u_int32_t sin6_scope_id; /* set of interfaces for a scope */
82 #endif /* HAS_INET6_STRUCTS */
84 #ifdef BROKEN_IN6ADDR_INIT_MACROS
85 #undef IN6ADDR_ANY_INIT
86 #undef IN6ADDR_LOOPBACK_INIT
90 #ifndef IN6ADDR_ANY_INIT
91 #define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}}
93 #ifndef IN6ADDR_LOOPBACK_INIT
94 #if BYTE_ORDER == BIG_ENDIAN
95 #define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}}
97 #define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}}
102 #ifndef IN6ADDR_ANY_INIT
104 #define IN6ADDR_ANY_INIT \
105 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
108 #define IN6ADDR_ANY_INIT \
109 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
110 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
114 #ifndef IN6ADDR_LOOPBACK_INIT
116 #define IN6ADDR_LOOPBACK_INIT \
117 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
118 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
120 #define IN6ADDR_LOOPBACK_INIT \
121 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
122 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
126 #ifndef HAVE_SOCKADDR_STORAGE
127 #define __SS_MAXSIZE 128
128 #define __SS_ALLIGSIZE (sizeof (long))
130 struct sockaddr_storage {
132 u_int8_t ss_len; /* address length */
133 u_int8_t ss_family; /* address family */
134 char __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof(u_int8_t)];
136 char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
138 u_int16_t ss_family; /* address family */
139 char __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)];
141 char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
147 #if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY)
148 #define in6addr_any isc_in6addr_any
149 extern const struct in6_addr in6addr_any;
153 * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and
154 * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1.
157 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2)
158 #undef IN6_ARE_ADDR_EQUAL
159 #undef IN6_IS_ADDR_UNSPECIFIED
160 #undef IN6_IS_ADDR_V4COMPAT
161 #undef IN6_IS_ADDR_V4MAPPED
165 #ifndef IN6_ARE_ADDR_EQUAL
166 #define IN6_ARE_ADDR_EQUAL(a,b) \
167 (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
170 #ifndef IN6_IS_ADDR_UNSPECIFIED
171 #define IN6_IS_ADDR_UNSPECIFIED(a) \
172 IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
175 #ifndef IN6_IS_ADDR_LOOPBACK
176 extern const struct in6_addr isc_in6addr_loopback;
177 #define IN6_IS_ADDR_LOOPBACK(a) \
178 IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback)
181 #ifndef IN6_IS_ADDR_V4MAPPED
182 #define IN6_IS_ADDR_V4MAPPED(a) \
183 ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
184 (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
185 (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
186 (a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \
187 (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
188 (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
191 #ifndef IN6_IS_ADDR_SITELOCAL
192 #define IN6_IS_ADDR_SITELOCAL(a) \
193 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
196 #ifndef IN6_IS_ADDR_LINKLOCAL
197 #define IN6_IS_ADDR_LINKLOCAL(a) \
198 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
201 #ifndef IN6_IS_ADDR_MULTICAST
202 #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
205 #ifndef __IPV6_ADDR_MC_SCOPE
206 #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
209 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
210 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
212 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
213 #define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08
216 #ifndef IN6_IS_ADDR_MC_SITELOCAL
217 #define IN6_IS_ADDR_MC_SITELOCAL(a) \
218 (IN6_IS_ADDR_MULTICAST(a) && \
219 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
222 #ifndef IN6_IS_ADDR_MC_ORGLOCAL
223 #define IN6_IS_ADDR_MC_ORGLOCAL(a) \
224 (IN6_IS_ADDR_MULTICAST(a) && \
225 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
229 #define INADDR_NONE 0xffffffff
232 #ifndef MAXHOSTNAMELEN
233 #define MAXHOSTNAMELEN 256
236 #ifndef INET6_ADDRSTRLEN
237 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
238 #define INET6_ADDRSTRLEN 46
242 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
246 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
250 int daemon(int nochdir, int noclose);
254 char * strsep(char **stringp, const char *delim);
258 #define ALIGN(p) (((unsigned int)(p) + (sizeof(int) - 1)) & ~(sizeof(int) - 1))
261 #ifdef NEED_SETGROUPENT
262 int setgroupent(int stayopen);
265 #ifdef NEED_GETGROUPLIST
266 int getgrouplist(GETGROUPLIST_ARGS);
269 #ifdef POSIX_GETGRNAM_R
271 __posix_getgrnam_r(const char *, struct group *, char *, int, struct group **);
274 #ifdef NEED_GETGRNAM_R
276 getgrnam_r(const char *, struct group *, char *, size_t, struct group **);
279 #ifdef POSIX_GETGRGID_R
281 __posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ;
284 #ifdef NEED_GETGRGID_R
286 getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
289 #ifdef NEED_GETGRENT_R
290 GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS);
293 #ifdef NEED_SETGRENT_R
294 GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS);
297 #ifdef NEED_ENDGRENT_R
298 GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS);
301 #ifdef NEED_INNETGR_R
303 innetgr_r(const char *, const char *, const char *, const char *);
306 #ifdef NEED_SETNETGRENT_R
307 #ifdef NGR_R_ENT_ARGS
308 NGR_R_SET_RETURN setnetgrent_r(const char *netgroup, NGR_R_ENT_ARGS);
310 NGR_R_SET_RETURN setnetgrent_r(const char *netgroup);
314 #ifdef NEED_ENDNETGRENT_R
315 #ifdef NGR_R_ENT_ARGS
316 NGR_R_END_RETURN endnetgrent_r(NGR_R_ENT_ARGS);
318 NGR_R_END_RETURN endnetgrent_r(void);
322 #ifdef POSIX_GETPWNAM_R
324 __posix_getpwnam_r(const char *login, struct passwd *pwptr,
325 char *buf, size_t buflen, struct passwd **result);
328 #ifdef NEED_GETPWNAM_R
330 getpwnam_r(const char *login, struct passwd *pwptr,
331 char *buf, size_t buflen, struct passwd **result);
334 #ifdef POSIX_GETPWUID_R
336 __posix_getpwuid_r(uid_t uid, struct passwd *pwptr,
337 char *buf, int buflen, struct passwd **result);
340 #ifdef NEED_GETPWUID_R
342 getpwuid_r(uid_t uid, struct passwd *pwptr,
343 char *buf, size_t buflen, struct passwd **result);
346 #ifdef NEED_SETPWENT_R
347 #ifdef PASS_R_ENT_ARGS
348 PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS);
350 PASS_R_SET_RETURN setpwent_r(void);
355 #ifdef NEED_SETPASSENT_R
356 #ifdef PASS_R_ENT_ARGS
357 PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS);
359 PASS_R_SET_RETURN setpassent_r(int stayopen);
363 #ifdef NEED_GETPWENT_R
364 PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS);
367 #ifdef NEED_ENDPWENT_R
368 void endpwent_r(void);
371 #ifdef NEED_SETPASSENT
372 int setpassent(int stayopen);
375 #define gettimeofday isc__gettimeofday
376 #ifdef NEED_GETTIMEOFDAY
377 int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp);
379 int isc__gettimeofday(struct timeval *tp, struct timezone *tzp);
382 int getnetgrent(char **machinep, char **userp, char **domainp);
384 int getnetgrent_r(char **machinep, char **userp, char **domainp, NGR_R_ARGS);
386 #ifdef SETNETGRENT_ARGS
387 void setnetgrent(SETNETGRENT_ARGS);
389 void setnetgrent(const char *netgroup);
392 void endnetgrent(void);
395 int innetgr(INNETGR_ARGS);
397 int innetgr(const char *netgroup, const char *machine,
398 const char *user, const char *domain);
401 #ifdef NGR_R_ENT_ARGS
403 setnetgrent_r(const char *netgroup, NGR_R_ENT_ARGS);
406 setnetgrent_r(const char *netgroup);