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