]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/bind/bind/port_after.h
merge fix for boot-time hang on centos' xen
[FreeBSD/FreeBSD.git] / lib / bind / bind / port_after.h
1 /* $FreeBSD$ */
2
3 #ifndef port_after_h
4 #define port_after_h
5
6 #include <stdio.h>
7 #include <sys/types.h>
8 #include <sys/socket.h>
9 #include <sys/param.h>
10 #include <sys/time.h>
11 #if (!defined(BSD)) || (BSD < 199306)
12 #include <sys/bitypes.h>
13 #endif
14 #ifdef HAVE_INTTYPES_H
15 #include <inttypes.h>
16 #endif
17 #ifdef HAVE_SYS_SELECT_H
18 #include <sys/select.h>
19 #endif /* HAVE_SYS_SELECT_H */
20
21 #undef NEED_PSELECT
22 #define HAVE_SA_LEN 1
23 #define HAVE_MINIMUM_IFREQ 1
24 #undef NEED_DAEMON
25 #undef NEED_STRSEP
26 #undef NEED_STRERROR
27 #define HAS_INET6_STRUCTS 1
28 #define HAVE_SIN6_SCOPE_ID 1
29 #undef NEED_IN6ADDR_ANY
30 #undef HAS_IN_ADDR6
31 #define HAVE_SOCKADDR_STORAGE 1
32 #undef NEED_GETTIMEOFDAY
33 #undef HAVE_STRNDUP
34 #undef USE_FIONBIO_IOCTL
35 #undef USE_SYSERROR_LIST
36 #undef INNETGR_ARGS
37 #undef SETNETGRENT_ARGS
38 #define USE_IFNAMELINKID 1
39 #define PORT_NONBLOCK O_NONBLOCK
40
41 #ifndef _POSIX_PATH_MAX
42 #define _POSIX_PATH_MAX 255
43 #endif
44 #ifndef PATH_MAX
45 #define PATH_MAX _POSIX_PATH_MAX
46 #endif
47
48 /*
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.
55  */
56 #ifndef AF_INET6
57 #define AF_INET6        24
58 #endif
59
60 #ifndef PF_INET6
61 #define PF_INET6        AF_INET6
62 #endif
63
64 #ifdef HAS_IN_ADDR6
65 /* Map to pre-RFC structure. */
66 #define in6_addr in_addr6
67 #endif
68
69 #ifndef HAS_INET6_STRUCTS
70 /* Replace with structure from later rev of O/S if known. */
71 struct in6_addr {
72         u_int8_t        s6_addr[16];
73 };
74
75 #define IN6ADDR_ANY_INIT \
76         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
77            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
78
79 #define IN6ADDR_LOOPBACK_INIT \
80         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
81            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
82
83 /* Replace with structure from later rev of O/S if known. */
84 struct sockaddr_in6 {
85 #ifdef  HAVE_SA_LEN
86         u_int8_t        sin6_len;       /* length of this struct */
87         u_int8_t        sin6_family;    /* AF_INET6 */
88 #else
89         u_int16_t       sin6_family;    /* AF_INET6 */
90 #endif
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 */
95 };
96 #endif  /* HAS_INET6_STRUCTS */
97
98 #ifdef BROKEN_IN6ADDR_INIT_MACROS
99 #undef IN6ADDR_ANY_INIT
100 #undef IN6ADDR_LOOPBACK_INIT
101 #endif
102
103 #ifdef _AIX
104 #ifndef IN6ADDR_ANY_INIT
105 #define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}}
106 #endif
107 #ifndef IN6ADDR_LOOPBACK_INIT
108 #if BYTE_ORDER == BIG_ENDIAN
109 #define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}}
110 #else
111 #define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}}
112 #endif
113 #endif
114 #endif
115
116 #ifndef IN6ADDR_ANY_INIT
117 #ifdef s6_addr
118 #define IN6ADDR_ANY_INIT \
119         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
120             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
121 #else
122 #define IN6ADDR_ANY_INIT \
123         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
124            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
125 #endif
126
127 #endif
128 #ifndef IN6ADDR_LOOPBACK_INIT
129 #ifdef s6_addr
130 #define IN6ADDR_LOOPBACK_INIT \
131         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
132             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
133 #else
134 #define IN6ADDR_LOOPBACK_INIT \
135         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
136            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
137 #endif
138 #endif
139
140 #ifndef HAVE_SOCKADDR_STORAGE
141 #define __SS_MAXSIZE 128 
142 #define __SS_ALLIGSIZE (sizeof (long)) 
143
144 struct sockaddr_storage {
145 #ifdef  HAVE_SA_LEN
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)];
149         long            __ss_align;
150         char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
151 #else   
152         u_int16_t       ss_family;    /* address family */
153         char            __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)];
154         long            __ss_align;
155         char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
156 #endif
157 };
158 #endif
159
160
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;
164 #endif
165
166 /*
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.
169  */
170 #ifdef __GLIBC__
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
176 #endif
177 #endif
178
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)
182 #endif
183
184 #ifndef IN6_IS_ADDR_UNSPECIFIED
185 #define IN6_IS_ADDR_UNSPECIFIED(a)      \
186         IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
187 #endif
188
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)
193 #endif
194
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)
203 #endif
204
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))
208 #endif
209
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))
213 #endif
214
215 #ifndef IN6_IS_ADDR_MULTICAST
216 #define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
217 #endif
218
219 #ifndef __IPV6_ADDR_MC_SCOPE
220 #define __IPV6_ADDR_MC_SCOPE(a)         ((a)->s6_addr[1] & 0x0f)
221 #endif
222
223 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
224 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
225 #endif
226 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
227 #define __IPV6_ADDR_SCOPE_ORGLOCAL  0x08
228 #endif
229
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))
234 #endif
235
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))
240 #endif
241
242 #ifndef INADDR_NONE
243 #define INADDR_NONE 0xffffffff
244 #endif
245
246 #ifndef MAXHOSTNAMELEN
247 #define MAXHOSTNAMELEN 256
248 #endif
249
250 #ifndef INET6_ADDRSTRLEN
251 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
252 #define INET6_ADDRSTRLEN 46
253 #endif
254
255 #ifndef MIN
256 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
257 #endif
258
259 #ifndef MAX
260 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
261 #endif
262
263 #ifdef NEED_DAEMON
264 int daemon(int nochdir, int noclose);
265 #endif
266   
267 #ifdef NEED_STRSEP
268 char * strsep(char **stringp, const char *delim);
269 #endif
270
271 #ifndef ALIGN
272 #define ALIGN(p) (((uintptr_t)(p) + (sizeof(long) - 1)) & ~(sizeof(long) - 1))
273 #endif
274
275 #ifdef NEED_SETGROUPENT
276 int setgroupent(int stayopen);
277 #endif
278
279 #ifdef NEED_GETGROUPLIST
280 int getgrouplist(GETGROUPLIST_ARGS);
281 #endif
282
283 #ifdef POSIX_GETGRNAM_R
284 int
285 __posix_getgrnam_r(const char *, struct group *, char *, int, struct group **);
286 #endif
287
288 #ifdef NEED_GETGRNAM_R
289 int
290 getgrnam_r(const char *,  struct group *, char *, size_t, struct group **);
291 #endif
292
293 #ifdef POSIX_GETGRGID_R
294 int
295 __posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ;
296 #endif
297
298 #ifdef NEED_GETGRGID_R
299 int
300 getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
301 #endif
302
303 #ifdef NEED_GETGRENT_R
304 GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS);
305 #endif
306
307 #ifdef NEED_SETGRENT_R
308 GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS);
309 #endif
310
311 #ifdef NEED_ENDGRENT_R
312 GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS);
313 #endif
314
315 #if defined(NEED_INNETGR_R) && defined(NGR_R_RETURN)
316 NGR_R_RETURN
317 innetgr_r(const char *, const char *, const char *, const char *);
318 #endif
319
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);
323 #else
324 NGR_R_SET_RETURN setnetgrent_r(const char *netgroup);
325 #endif
326 #endif
327
328 #ifdef NEED_ENDNETGRENT_R
329 #ifdef NGR_R_ENT_ARGS
330 NGR_R_END_RETURN endnetgrent_r(NGR_R_ENT_ARGS);
331 #else
332 NGR_R_END_RETURN endnetgrent_r(void);
333 #endif
334 #endif
335
336 #ifdef POSIX_GETPWNAM_R
337 int
338 __posix_getpwnam_r(const char *login,  struct passwd *pwptr,
339                 char *buf, size_t buflen, struct passwd **result);
340 #endif
341
342 #ifdef NEED_GETPWNAM_R
343 int
344 getpwnam_r(const char *login,  struct passwd *pwptr,
345                 char *buf, size_t buflen, struct passwd **result);
346 #endif
347
348 #ifdef POSIX_GETPWUID_R
349 int
350 __posix_getpwuid_r(uid_t uid, struct passwd *pwptr,
351                 char *buf, int buflen, struct passwd **result);
352 #endif
353
354 #ifdef NEED_GETPWUID_R
355 int
356 getpwuid_r(uid_t uid, struct passwd *pwptr,
357                 char *buf, size_t buflen, struct passwd **result);
358 #endif
359
360 #ifdef NEED_SETPWENT_R
361 #ifdef PASS_R_ENT_ARGS
362 PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS);
363 #else
364 PASS_R_SET_RETURN setpwent_r(void);
365 #endif
366
367 #endif
368
369 #ifdef NEED_SETPASSENT_R
370 #ifdef PASS_R_ENT_ARGS
371 PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS);
372 #else
373 PASS_R_SET_RETURN setpassent_r(int stayopen);
374 #endif
375 #endif
376
377 #ifdef NEED_GETPWENT_R
378 PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS);
379 #endif
380
381 #ifdef NEED_ENDPWENT_R
382 void endpwent_r(void);
383 #endif
384
385 #ifdef NEED_SETPASSENT
386 int setpassent(int stayopen);
387 #endif
388
389 #define gettimeofday isc__gettimeofday
390 #ifdef NEED_GETTIMEOFDAY
391 int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp);
392 #else
393 int isc__gettimeofday(struct timeval *tp, struct timezone *tzp);
394 #endif
395
396 int getnetgrent(char **machinep, char **userp, char **domainp);
397
398 #ifdef NGR_R_ARGS
399 int getnetgrent_r(char **machinep, char **userp, char **domainp, NGR_R_ARGS);
400 #endif
401
402 #ifdef SETNETGRENT_ARGS
403 void setnetgrent(SETNETGRENT_ARGS);
404 #else
405 void setnetgrent(const char *netgroup);
406 #endif
407
408 void endnetgrent(void);
409
410 #ifdef INNETGR_ARGS
411 int innetgr(INNETGR_ARGS);
412 #else
413 int innetgr(const char *netgroup, const char *machine,
414             const char *user, const char *domain);
415 #endif
416
417 #ifdef NGR_R_ENT_ARGS
418 NGR_R_SET_RETURN
419 setnetgrent_r(const char *netgroup, NGR_R_ENT_ARGS);
420 #else
421 NGR_R_SET_RETURN
422 setnetgrent_r(const char *netgroup);
423 #endif
424 #endif