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
89 #ifndef IN6ADDR_ANY_INIT
91 #define IN6ADDR_ANY_INIT \
92 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
93 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
95 #define IN6ADDR_ANY_INIT \
96 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
97 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
101 #ifndef IN6ADDR_LOOPBACK_INIT
103 #define IN6ADDR_LOOPBACK_INIT \
104 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
105 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
107 #define IN6ADDR_LOOPBACK_INIT \
108 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
109 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
113 #ifndef HAVE_SOCKADDR_STORAGE
114 #define __SS_MAXSIZE 128
115 #define __SS_ALLIGSIZE (sizeof (long))
117 struct sockaddr_storage
{
119 u_int8_t ss_len
; /* address length */
120 u_int8_t ss_family
; /* address family */
121 char __ss_pad1
[__SS_ALLIGSIZE
- 2 * sizeof(u_int8_t
)];
123 char __ss_pad2
[__SS_MAXSIZE
- 2 * __SS_ALLIGSIZE
];
125 u_int16_t ss_family
; /* address family */
126 char __ss_pad1
[__SS_ALLIGSIZE
- sizeof(u_int16_t
)];
128 char __ss_pad2
[__SS_MAXSIZE
- 2 * __SS_ALLIGSIZE
];
134 #if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY)
135 #define in6addr_any isc_in6addr_any
136 extern const struct in6_addr in6addr_any
;
140 * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and
141 * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1.
144 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2)
145 #undef IN6_ARE_ADDR_EQUAL
146 #undef IN6_IS_ADDR_UNSPECIFIED
147 #undef IN6_IS_ADDR_V4COMPAT
148 #undef IN6_IS_ADDR_V4MAPPED
152 #ifndef IN6_ARE_ADDR_EQUAL
153 #define IN6_ARE_ADDR_EQUAL(a,b) \
154 (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
157 #ifndef IN6_IS_ADDR_UNSPECIFIED
158 #define IN6_IS_ADDR_UNSPECIFIED(a) \
159 IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
162 #ifndef IN6_IS_ADDR_LOOPBACK
163 extern const struct in6_addr isc_in6addr_loopback
;
164 #define IN6_IS_ADDR_LOOPBACK(a) \
165 IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback)
168 #ifndef IN6_IS_ADDR_V4MAPPED
169 #define IN6_IS_ADDR_V4MAPPED(a) \
170 ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
171 (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
172 (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
173 (a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \
174 (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
175 (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
178 #ifndef IN6_IS_ADDR_SITELOCAL
179 #define IN6_IS_ADDR_SITELOCAL(a) \
180 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
183 #ifndef IN6_IS_ADDR_LINKLOCAL
184 #define IN6_IS_ADDR_LINKLOCAL(a) \
185 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
188 #ifndef IN6_IS_ADDR_MULTICAST
189 #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
192 #ifndef __IPV6_ADDR_MC_SCOPE
193 #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
196 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
197 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
199 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
200 #define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08
203 #ifndef IN6_IS_ADDR_MC_SITELOCAL
204 #define IN6_IS_ADDR_MC_SITELOCAL(a) \
205 (IN6_IS_ADDR_MULTICAST(a) && \
206 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
209 #ifndef IN6_IS_ADDR_MC_ORGLOCAL
210 #define IN6_IS_ADDR_MC_ORGLOCAL(a) \
211 (IN6_IS_ADDR_MULTICAST(a) && \
212 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
216 #define INADDR_NONE 0xffffffff
219 #ifndef MAXHOSTNAMELEN
220 #define MAXHOSTNAMELEN 256
223 #ifndef INET6_ADDRSTRLEN
224 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
225 #define INET6_ADDRSTRLEN 46
229 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
233 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
237 int daemon(int nochdir
, int noclose
);
241 char * strsep(char **stringp
, const char *delim
);
245 #define ALIGN(p) (((unsigned int)(p) + (sizeof(int) - 1)) & ~(sizeof(int) - 1))
248 #ifdef NEED_SETGROUPENT
249 int setgroupent(int stayopen
);
252 #ifdef NEED_GETGROUPLIST
253 int getgrouplist(GETGROUPLIST_ARGS
);
256 #ifdef POSIX_GETGRNAM_R
258 __posix_getgrnam_r(const char *, struct group
*, char *, int, struct group
**);
261 #ifdef NEED_GETGRNAM_R
263 getgrnam_r(const char *, struct group
*, char *, size_t, struct group
**);
266 #ifdef POSIX_GETGRGID_R
268 __posix_getgrgid_r(gid_t
, struct group
*, char *, int, struct group
**) ;
271 #ifdef NEED_GETGRGID_R
273 getgrgid_r(gid_t
, struct group
*, char *, size_t, struct group
**);
276 #ifdef NEED_GETGRENT_R
277 GROUP_R_RETURN
getgrent_r(struct group
*gptr
, GROUP_R_ARGS
);
280 #ifdef NEED_SETGRENT_R
281 GROUP_R_SET_RETURN
setgrent_r(GROUP_R_ENT_ARGS
);
284 #ifdef NEED_ENDGRENT_R
285 GROUP_R_END_RETURN
endgrent_r(GROUP_R_ENT_ARGS
);
288 #ifdef NEED_INNETGR_R
290 innetgr_r(const char *, const char *, const char *, const char *);
293 #ifdef NEED_SETNETGRENT_R
294 #ifdef NGR_R_ENT_ARGS
295 NGR_R_SET_RETURN
setnetgrent_r(const char *netgroup
, NGR_R_ENT_ARGS
);
297 NGR_R_SET_RETURN
setnetgrent_r(const char *netgroup
);
301 #ifdef NEED_ENDNETGRENT_R
302 #ifdef NGR_R_ENT_ARGS
303 NGR_R_END_RETURN
endnetgrent_r(NGR_R_ENT_ARGS
);
305 NGR_R_END_RETURN
endnetgrent_r(void);
309 #ifdef POSIX_GETPWNAM_R
311 __posix_getpwnam_r(const char *login
, struct passwd
*pwptr
,
312 char *buf
, size_t buflen
, struct passwd
**result
);
315 #ifdef NEED_GETPWNAM_R
317 getpwnam_r(const char *login
, struct passwd
*pwptr
,
318 char *buf
, size_t buflen
, struct passwd
**result
);
321 #ifdef POSIX_GETPWUID_R
323 __posix_getpwuid_r(uid_t uid
, struct passwd
*pwptr
,
324 char *buf
, int buflen
, struct passwd
**result
);
327 #ifdef NEED_GETPWUID_R
329 getpwuid_r(uid_t uid
, struct passwd
*pwptr
,
330 char *buf
, size_t buflen
, struct passwd
**result
);
333 #ifdef NEED_SETPWENT_R
334 #ifdef PASS_R_ENT_ARGS
335 PASS_R_SET_RETURN
setpwent_r(PASS_R_ENT_ARGS
);
337 PASS_R_SET_RETURN
setpwent_r(void);
342 #ifdef NEED_SETPASSENT_R
343 #ifdef PASS_R_ENT_ARGS
344 PASS_R_SET_RETURN
setpassent_r(int stayopen
, PASS_R_ENT_ARGS
);
346 PASS_R_SET_RETURN
setpassent_r(int stayopen
);
350 #ifdef NEED_GETPWENT_R
351 PASS_R_RETURN
getpwent_r(struct passwd
*pwptr
, PASS_R_ARGS
);
354 #ifdef NEED_ENDPWENT_R
355 void endpwent_r(void);
358 #ifdef NEED_SETPASSENT
359 int setpassent(int stayopen
);
362 #define gettimeofday isc__gettimeofday
363 #ifdef NEED_GETTIMEOFDAY
364 int isc__gettimeofday(struct timeval
*tvp
, struct _TIMEZONE
*tzp
);
366 int isc__gettimeofday(struct timeval
*tp
, struct timezone
*tzp
);
369 int getnetgrent(char **machinep
, char **userp
, char **domainp
);
371 int getnetgrent_r(char **machinep
, char **userp
, char **domainp
, NGR_R_ARGS
);
373 #ifdef SETNETGRENT_ARGS
374 void setnetgrent(SETNETGRENT_ARGS
);
376 void setnetgrent(const char *netgroup
);
379 void endnetgrent(void);
382 int innetgr(INNETGR_ARGS
);
384 int innetgr(const char *netgroup
, const char *machine
,
385 const char *user
, const char *domain
);
388 #ifdef NGR_R_ENT_ARGS
390 setnetgrent_r(const char *netgroup
, NGR_R_ENT_ARGS
);
393 setnetgrent_r(const char *netgroup
);