Merge from vendor branch GCC:
[dragonfly.git] / contrib / bind-9.3 / lib / bind / port_after.h.in
1 #ifndef port_after_h
2 #define port_after_h
3
4 #include <stdio.h>
5 #include <sys/types.h>
6 #include <sys/socket.h>
7 #include <sys/param.h>
8 #if (!defined(BSD)) || (BSD < 199306)
9 #include <sys/bitypes.h>
10 #endif
11 #ifdef HAVE_INTTYPES_H
12 #include <inttypes.h>
13 #endif
14
15 @NEED_PSELECT@
16 @HAVE_SA_LEN@
17 @HAVE_MINIMUM_IFREQ@
18 @NEED_DAEMON@
19 @NEED_STRSEP@
20 @NEED_STRERROR@
21 @HAS_INET6_STRUCTS@
22 @HAVE_SIN6_SCOPE_ID@
23 @NEED_IN6ADDR_ANY@
24 @HAS_IN_ADDR6@
25 @HAVE_SOCKADDR_STORAGE@
26 @NEED_GETTIMEOFDAY@
27 @HAVE_STRNDUP@
28 @USE_FIONBIO_IOCTL@
29 @USE_SYSERROR_LIST@
30 @INNETGR_ARGS@
31 @SETNETGRENT_ARGS@
32 @USE_IFNAMELINKID@
33 @PORT_NONBLOCK@
34
35 /*
36  * We need to know the IPv6 address family number even on IPv4-only systems.
37  * Note that this is NOT a protocol constant, and that if the system has its
38  * own AF_INET6, different from ours below, all of BIND's libraries and
39  * executables will need to be recompiled after the system <sys/socket.h>
40  * has had this type added.  The type number below is correct on most BSD-
41  * derived systems for which AF_INET6 is defined.
42  */
43 #ifndef AF_INET6
44 #define AF_INET6        24
45 #endif
46
47 #ifndef PF_INET6
48 #define PF_INET6        AF_INET6
49 #endif
50
51 #ifdef HAS_IN_ADDR6
52 /* Map to pre-RFC structure. */
53 #define in6_addr in_addr6
54 #endif
55
56 #ifndef HAS_INET6_STRUCTS
57 /* Replace with structure from later rev of O/S if known. */
58 struct in6_addr {
59         u_int8_t        s6_addr[16];
60 };
61
62 #define IN6ADDR_ANY_INIT \
63         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
64            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
65
66 #define IN6ADDR_LOOPBACK_INIT \
67         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
68            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
69
70 /* Replace with structure from later rev of O/S if known. */
71 struct sockaddr_in6 {
72 #ifdef  HAVE_SA_LEN
73         u_int8_t        sin6_len;       /* length of this struct */
74         u_int8_t        sin6_family;    /* AF_INET6 */
75 #else
76         u_int16_t       sin6_family;    /* AF_INET6 */
77 #endif
78         u_int16_t       sin6_port;      /* transport layer port # */
79         u_int32_t       sin6_flowinfo;  /* IPv6 flow information */
80         struct in6_addr sin6_addr;      /* IPv6 address */
81         u_int32_t       sin6_scope_id;  /* set of interfaces for a scope */
82 };
83 #endif  /* HAS_INET6_STRUCTS */
84
85 #ifdef BROKEN_IN6ADDR_INIT_MACROS
86 #undef IN6ADDR_ANY_INIT
87 #undef IN6ADDR_LOOPBACK_INIT
88 #endif
89
90 #ifdef _AIX
91 #ifndef IN6ADDR_ANY_INIT
92 #define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}}
93 #endif
94 #ifndef IN6ADDR_LOOPBACK_INIT
95 #if BYTE_ORDER == BIG_ENDIAN
96 #define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}}
97 #else
98 #define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}}
99 #endif
100 #endif
101 #endif
102
103 #ifndef IN6ADDR_ANY_INIT
104 #ifdef s6_addr
105 #define IN6ADDR_ANY_INIT \
106         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
107             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
108 #else
109 #define IN6ADDR_ANY_INIT \
110         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
111            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
112 #endif
113
114 #endif
115 #ifndef IN6ADDR_LOOPBACK_INIT
116 #ifdef s6_addr
117 #define IN6ADDR_LOOPBACK_INIT \
118         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
119             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
120 #else
121 #define IN6ADDR_LOOPBACK_INIT \
122         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
123            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
124 #endif
125 #endif
126
127 #ifndef HAVE_SOCKADDR_STORAGE
128 #define __SS_MAXSIZE 128 
129 #define __SS_ALLIGSIZE (sizeof (long)) 
130
131 struct sockaddr_storage {
132 #ifdef  HAVE_SA_LEN
133         u_int8_t        ss_len;       /* address length */
134         u_int8_t        ss_family;    /* address family */
135         char            __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof(u_int8_t)];
136         long            __ss_align;
137         char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
138 #else   
139         u_int16_t       ss_family;    /* address family */
140         char            __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)];
141         long            __ss_align;
142         char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
143 #endif
144 };
145 #endif
146
147
148 #if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY)
149 #define in6addr_any isc_in6addr_any
150 extern const struct in6_addr in6addr_any;
151 #endif
152
153 /*
154  * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and
155  * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1.
156  */
157 #ifdef __GLIBC__
158 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2)
159 #undef IN6_ARE_ADDR_EQUAL
160 #undef IN6_IS_ADDR_UNSPECIFIED
161 #undef IN6_IS_ADDR_V4COMPAT
162 #undef IN6_IS_ADDR_V4MAPPED
163 #endif
164 #endif
165
166 #ifndef IN6_ARE_ADDR_EQUAL
167 #define IN6_ARE_ADDR_EQUAL(a,b) \
168    (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
169 #endif
170
171 #ifndef IN6_IS_ADDR_UNSPECIFIED
172 #define IN6_IS_ADDR_UNSPECIFIED(a)      \
173         IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
174 #endif
175
176 #ifndef IN6_IS_ADDR_LOOPBACK
177 extern const struct in6_addr isc_in6addr_loopback;
178 #define IN6_IS_ADDR_LOOPBACK(a) \
179         IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback)
180 #endif
181
182 #ifndef IN6_IS_ADDR_V4MAPPED
183 #define IN6_IS_ADDR_V4MAPPED(a) \
184         ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
185         (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
186         (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
187         (a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \
188         (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
189         (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
190 #endif
191
192 #ifndef IN6_IS_ADDR_SITELOCAL
193 #define IN6_IS_ADDR_SITELOCAL(a)        \
194         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
195 #endif
196
197 #ifndef IN6_IS_ADDR_LINKLOCAL
198 #define IN6_IS_ADDR_LINKLOCAL(a)        \
199         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
200 #endif
201
202 #ifndef IN6_IS_ADDR_MULTICAST
203 #define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
204 #endif
205
206 #ifndef __IPV6_ADDR_MC_SCOPE
207 #define __IPV6_ADDR_MC_SCOPE(a)         ((a)->s6_addr[1] & 0x0f)
208 #endif
209
210 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
211 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
212 #endif
213 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
214 #define __IPV6_ADDR_SCOPE_ORGLOCAL  0x08
215 #endif
216
217 #ifndef IN6_IS_ADDR_MC_SITELOCAL
218 #define IN6_IS_ADDR_MC_SITELOCAL(a)     \
219         (IN6_IS_ADDR_MULTICAST(a) &&    \
220          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
221 #endif
222
223 #ifndef IN6_IS_ADDR_MC_ORGLOCAL
224 #define IN6_IS_ADDR_MC_ORGLOCAL(a)      \
225         (IN6_IS_ADDR_MULTICAST(a) &&    \
226          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
227 #endif
228
229 #ifndef INADDR_NONE
230 #define INADDR_NONE 0xffffffff
231 #endif
232
233 #ifndef MAXHOSTNAMELEN
234 #define MAXHOSTNAMELEN 256
235 #endif
236
237 #ifndef INET6_ADDRSTRLEN
238 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
239 #define INET6_ADDRSTRLEN 46
240 #endif
241
242 #ifndef MIN
243 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
244 #endif
245
246 #ifndef MAX
247 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
248 #endif
249
250 #ifdef NEED_DAEMON
251 int daemon(int nochdir, int noclose);
252 #endif
253   
254 #ifdef NEED_STRSEP
255 char * strsep(char **stringp, const char *delim);
256 #endif
257
258 #ifndef ALIGN
259 #define ALIGN(p) (((uintptr_t)(p) + (sizeof(long) - 1)) & ~(sizeof(long) - 1))
260 #endif
261
262 #ifdef NEED_SETGROUPENT
263 int setgroupent(int stayopen);
264 #endif
265
266 #ifdef NEED_GETGROUPLIST
267 int getgrouplist(GETGROUPLIST_ARGS);
268 #endif
269
270 #ifdef POSIX_GETGRNAM_R
271 int
272 __posix_getgrnam_r(const char *, struct group *, char *, int, struct group **);
273 #endif
274
275 #ifdef NEED_GETGRNAM_R
276 int
277 getgrnam_r(const char *,  struct group *, char *, size_t, struct group **);
278 #endif
279
280 #ifdef POSIX_GETGRGID_R
281 int
282 __posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ;
283 #endif
284
285 #ifdef NEED_GETGRGID_R
286 int
287 getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
288 #endif
289
290 #ifdef NEED_GETGRENT_R
291 GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS);
292 #endif
293
294 #ifdef NEED_SETGRENT_R
295 GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS);
296 #endif
297
298 #ifdef NEED_ENDGRENT_R
299 GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS);
300 #endif
301
302 #if defined(NEED_INNETGR_R) && defined(NGR_R_RETURN)
303 NGR_R_RETURN
304 innetgr_r(const char *, const char *, const char *, const char *);
305 #endif
306
307 #ifdef NEED_SETNETGRENT_R
308 #ifdef NGR_R_ENT_ARGS
309 NGR_R_SET_RETURN setnetgrent_r(const char *netgroup, NGR_R_ENT_ARGS);
310 #else
311 NGR_R_SET_RETURN setnetgrent_r(const char *netgroup);
312 #endif
313 #endif
314
315 #ifdef NEED_ENDNETGRENT_R
316 #ifdef NGR_R_ENT_ARGS
317 NGR_R_END_RETURN endnetgrent_r(NGR_R_ENT_ARGS);
318 #else
319 NGR_R_END_RETURN endnetgrent_r(void);
320 #endif
321 #endif
322
323 #ifdef POSIX_GETPWNAM_R
324 int
325 __posix_getpwnam_r(const char *login,  struct passwd *pwptr,
326                 char *buf, size_t buflen, struct passwd **result);
327 #endif
328
329 #ifdef NEED_GETPWNAM_R
330 int
331 getpwnam_r(const char *login,  struct passwd *pwptr,
332                 char *buf, size_t buflen, struct passwd **result);
333 #endif
334
335 #ifdef POSIX_GETPWUID_R
336 int
337 __posix_getpwuid_r(uid_t uid, struct passwd *pwptr,
338                 char *buf, int buflen, struct passwd **result);
339 #endif
340
341 #ifdef NEED_GETPWUID_R
342 int
343 getpwuid_r(uid_t uid, struct passwd *pwptr,
344                 char *buf, size_t buflen, struct passwd **result);
345 #endif
346
347 #ifdef NEED_SETPWENT_R
348 #ifdef PASS_R_ENT_ARGS
349 PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS);
350 #else
351 PASS_R_SET_RETURN setpwent_r(void);
352 #endif
353
354 #endif
355
356 #ifdef NEED_SETPASSENT_R
357 #ifdef PASS_R_ENT_ARGS
358 PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS);
359 #else
360 PASS_R_SET_RETURN setpassent_r(int stayopen);
361 #endif
362 #endif
363
364 #ifdef NEED_GETPWENT_R
365 PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS);
366 #endif
367
368 #ifdef NEED_ENDPWENT_R
369 void endpwent_r(void);
370 #endif
371
372 #ifdef NEED_SETPASSENT
373 int setpassent(int stayopen);
374 #endif
375
376 #define gettimeofday isc__gettimeofday
377 #ifdef NEED_GETTIMEOFDAY
378 int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp);
379 #else
380 int isc__gettimeofday(struct timeval *tp, struct timezone *tzp);
381 #endif
382
383 int getnetgrent(char **machinep, char **userp, char **domainp);
384
385 #ifdef NGR_R_ARGS
386 int getnetgrent_r(char **machinep, char **userp, char **domainp, NGR_R_ARGS);
387 #endif
388
389 #ifdef SETNETGRENT_ARGS
390 void setnetgrent(SETNETGRENT_ARGS);
391 #else
392 void setnetgrent(const char *netgroup);
393 #endif
394
395 void endnetgrent(void);
396
397 #ifdef INNETGR_ARGS
398 int innetgr(INNETGR_ARGS);
399 #else
400 int innetgr(const char *netgroup, const char *machine,
401             const char *user, const char *domain);
402 #endif
403
404 #ifdef NGR_R_ENT_ARGS
405 NGR_R_SET_RETURN
406 setnetgrent_r(const char *netgroup, NGR_R_ENT_ARGS);
407 #else
408 NGR_R_SET_RETURN
409 setnetgrent_r(const char *netgroup);
410 #endif
411 #endif