Merge from vendor branch BIND:
[dragonfly.git] / contrib / bind-9.2.4rc7 / 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
12 @NEED_PSELECT@
13 @HAVE_SA_LEN@
14 @HAVE_MINIMUM_IFREQ@
15 @NEED_DAEMON@
16 @NEED_STRSEP@
17 @NEED_STRERROR@
18 @HAS_INET6_STRUCTS@
19 @HAVE_SIN6_SCOPE_ID@
20 @NEED_IN6ADDR_ANY@
21 @HAS_IN_ADDR6@
22 @HAVE_SOCKADDR_STORAGE@
23 @NEED_GETTIMEOFDAY@
24 @HAVE_STRNDUP@
25 @USE_FIONBIO_IOCTL@
26 @USE_SYSERROR_LIST@
27 @INNETGR_ARGS@
28 @SETNETGRENT_ARGS@
29 @USE_IFNAMELINKID@
30
31 /* XXX sunos and cygwin needs O_NDELAY */
32 #define PORT_NONBLOCK O_NONBLOCK
33
34 /*
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.
41  */
42 #ifndef AF_INET6
43 #define AF_INET6        24
44 #endif
45
46 #ifndef PF_INET6
47 #define PF_INET6        AF_INET6
48 #endif
49
50 #ifdef HAS_IN_ADDR6
51 /* Map to pre-RFC structure. */
52 #define in6_addr in_addr6
53 #endif
54
55 #ifndef HAS_INET6_STRUCTS
56 /* Replace with structure from later rev of O/S if known. */
57 struct in6_addr {
58         u_int8_t        s6_addr[16];
59 };
60
61 #define IN6ADDR_ANY_INIT \
62         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
63            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
64
65 #define IN6ADDR_LOOPBACK_INIT \
66         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
67            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
68
69 /* Replace with structure from later rev of O/S if known. */
70 struct sockaddr_in6 {
71 #ifdef  HAVE_SA_LEN
72         u_int8_t        sin6_len;       /* length of this struct */
73         u_int8_t        sin6_family;    /* AF_INET6 */
74 #else
75         u_int16_t       sin6_family;    /* AF_INET6 */
76 #endif
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 */
81 };
82 #endif  /* HAS_INET6_STRUCTS */
83
84 #ifdef BROKEN_IN6ADDR_INIT_MACROS
85 #undef IN6ADDR_ANY_INIT
86 #undef IN6ADDR_LOOPBACK_INIT
87 #endif
88
89 #ifndef IN6ADDR_ANY_INIT
90 #ifdef s6_addr
91 #define IN6ADDR_ANY_INIT \
92         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
93             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
94 #else
95 #define IN6ADDR_ANY_INIT \
96         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
97            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
98 #endif
99
100 #endif
101 #ifndef IN6ADDR_LOOPBACK_INIT
102 #ifdef s6_addr
103 #define IN6ADDR_LOOPBACK_INIT \
104         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
105             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
106 #else
107 #define IN6ADDR_LOOPBACK_INIT \
108         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
109            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
110 #endif
111 #endif
112
113 #ifndef HAVE_SOCKADDR_STORAGE
114 #define __SS_MAXSIZE 128 
115 #define __SS_ALLIGSIZE (sizeof (long)) 
116
117 struct sockaddr_storage {
118 #ifdef  HAVE_SA_LEN
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)];
122         long            __ss_align;
123         char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
124 #else   
125         u_int16_t       ss_family;    /* address family */
126         char            __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)];
127         long            __ss_align;
128         char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
129 #endif
130 };
131 #endif
132
133
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;
137 #endif
138
139 /*
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.
142  */
143 #ifdef __GLIBC__
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
149 #endif
150 #endif
151
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)
155 #endif
156
157 #ifndef IN6_IS_ADDR_UNSPECIFIED
158 #define IN6_IS_ADDR_UNSPECIFIED(a)      \
159         IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
160 #endif
161
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)
166 #endif
167
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)
176 #endif
177
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))
181 #endif
182
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))
186 #endif
187
188 #ifndef IN6_IS_ADDR_MULTICAST
189 #define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
190 #endif
191
192 #ifndef __IPV6_ADDR_MC_SCOPE
193 #define __IPV6_ADDR_MC_SCOPE(a)         ((a)->s6_addr[1] & 0x0f)
194 #endif
195
196 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
197 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
198 #endif
199 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
200 #define __IPV6_ADDR_SCOPE_ORGLOCAL  0x08
201 #endif
202
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))
207 #endif
208
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))
213 #endif
214
215 #ifndef INADDR_NONE
216 #define INADDR_NONE 0xffffffff
217 #endif
218
219 #ifndef MAXHOSTNAMELEN
220 #define MAXHOSTNAMELEN 256
221 #endif
222
223 #ifndef INET6_ADDRSTRLEN
224 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
225 #define INET6_ADDRSTRLEN 46
226 #endif
227
228 #ifndef MIN
229 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
230 #endif
231
232 #ifndef MAX
233 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
234 #endif
235
236 #ifdef NEED_DAEMON
237 int daemon(int nochdir, int noclose);
238 #endif
239   
240 #ifdef NEED_STRSEP
241 char * strsep(char **stringp, const char *delim);
242 #endif
243
244 #ifndef ALIGN
245 #define ALIGN(p) (((unsigned int)(p) + (sizeof(int) - 1)) & ~(sizeof(int) - 1))
246 #endif
247
248 #ifdef NEED_SETGROUPENT
249 int setgroupent(int stayopen);
250 #endif
251
252 #ifdef NEED_GETGROUPLIST
253 int getgrouplist(GETGROUPLIST_ARGS);
254 #endif
255
256 #ifdef POSIX_GETGRNAM_R
257 int
258 __posix_getgrnam_r(const char *, struct group *, char *, int, struct group **);
259 #endif
260
261 #ifdef NEED_GETGRNAM_R
262 int
263 getgrnam_r(const char *,  struct group *, char *, size_t, struct group **);
264 #endif
265
266 #ifdef POSIX_GETGRGID_R
267 int
268 __posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ;
269 #endif
270
271 #ifdef NEED_GETGRGID_R
272 int
273 getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
274 #endif
275
276 #ifdef NEED_GETGRENT_R
277 GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS);
278 #endif
279
280 #ifdef NEED_SETGRENT_R
281 GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS);
282 #endif
283
284 #ifdef NEED_ENDGRENT_R
285 GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS);
286 #endif
287
288 #ifdef NEED_INNETGR_R
289 NGR_R_RETURN
290 innetgr_r(const char *, const char *, const char *, const char *);
291 #endif
292
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);
296 #else
297 NGR_R_SET_RETURN setnetgrent_r(const char *netgroup);
298 #endif
299 #endif
300
301 #ifdef NEED_ENDNETGRENT_R
302 #ifdef NGR_R_ENT_ARGS
303 NGR_R_END_RETURN endnetgrent_r(NGR_R_ENT_ARGS);
304 #else
305 NGR_R_END_RETURN endnetgrent_r(void);
306 #endif
307 #endif
308
309 #ifdef POSIX_GETPWNAM_R
310 int
311 __posix_getpwnam_r(const char *login,  struct passwd *pwptr,
312                 char *buf, size_t buflen, struct passwd **result);
313 #endif
314
315 #ifdef NEED_GETPWNAM_R
316 int
317 getpwnam_r(const char *login,  struct passwd *pwptr,
318                 char *buf, size_t buflen, struct passwd **result);
319 #endif
320
321 #ifdef POSIX_GETPWUID_R
322 int
323 __posix_getpwuid_r(uid_t uid, struct passwd *pwptr,
324                 char *buf, int buflen, struct passwd **result);
325 #endif
326
327 #ifdef NEED_GETPWUID_R
328 int
329 getpwuid_r(uid_t uid, struct passwd *pwptr,
330                 char *buf, size_t buflen, struct passwd **result);
331 #endif
332
333 #ifdef NEED_SETPWENT_R
334 #ifdef PASS_R_ENT_ARGS
335 PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS);
336 #else
337 PASS_R_SET_RETURN setpwent_r(void);
338 #endif
339
340 #endif
341
342 #ifdef NEED_SETPASSENT_R
343 #ifdef PASS_R_ENT_ARGS
344 PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS);
345 #else
346 PASS_R_SET_RETURN setpassent_r(int stayopen);
347 #endif
348 #endif
349
350 #ifdef NEED_GETPWENT_R
351 PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS);
352 #endif
353
354 #ifdef NEED_ENDPWENT_R
355 void endpwent_r(void);
356 #endif
357
358 #ifdef NEED_SETPASSENT
359 int setpassent(int stayopen);
360 #endif
361
362 #define gettimeofday isc__gettimeofday
363 #ifdef NEED_GETTIMEOFDAY
364 int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp);
365 #else
366 int isc__gettimeofday(struct timeval *tp, struct timezone *tzp);
367 #endif
368
369 int getnetgrent(char **machinep, char **userp, char **domainp);
370
371 int getnetgrent_r(char **machinep, char **userp, char **domainp, NGR_R_ARGS);
372
373 #ifdef SETNETGRENT_ARGS
374 void setnetgrent(SETNETGRENT_ARGS);
375 #else
376 void setnetgrent(const char *netgroup);
377 #endif
378
379 void endnetgrent(void);
380
381 #ifdef INNETGR_ARGS
382 int innetgr(INNETGR_ARGS);
383 #else
384 int innetgr(const char *netgroup, const char *machine,
385             const char *user, const char *domain);
386 #endif
387
388 #ifdef NGR_R_ENT_ARGS
389 NGR_R_SET_RETURN
390 setnetgrent_r(const char *netgroup, NGR_R_ENT_ARGS);
391 #else
392 NGR_R_SET_RETURN
393 setnetgrent_r(const char *netgroup);
394 #endif
395 #endif