Add BIND 9.2.4rc7.
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / bind / port_after.h.in
blob6d5f4dca667dfb3d8e236988d1ad771d5c585632
1 #ifndef port_after_h
2 #define port_after_h
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
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@
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.
42 #ifndef AF_INET6
43 #define AF_INET6 24
44 #endif
46 #ifndef PF_INET6
47 #define PF_INET6 AF_INET6
48 #endif
50 #ifdef HAS_IN_ADDR6
51 /* Map to pre-RFC structure. */
52 #define in6_addr in_addr6
53 #endif
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];
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. */
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 */
82 #endif /* HAS_INET6_STRUCTS */
84 #ifdef BROKEN_IN6ADDR_INIT_MACROS
85 #undef IN6ADDR_ANY_INIT
86 #undef IN6ADDR_LOOPBACK_INIT
87 #endif
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
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
113 #ifndef HAVE_SOCKADDR_STORAGE
114 #define __SS_MAXSIZE 128
115 #define __SS_ALLIGSIZE (sizeof (long))
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
131 #endif
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
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.
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
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
157 #ifndef IN6_IS_ADDR_UNSPECIFIED
158 #define IN6_IS_ADDR_UNSPECIFIED(a) \
159 IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
160 #endif
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
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
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
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
188 #ifndef IN6_IS_ADDR_MULTICAST
189 #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
190 #endif
192 #ifndef __IPV6_ADDR_MC_SCOPE
193 #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
194 #endif
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
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
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
215 #ifndef INADDR_NONE
216 #define INADDR_NONE 0xffffffff
217 #endif
219 #ifndef MAXHOSTNAMELEN
220 #define MAXHOSTNAMELEN 256
221 #endif
223 #ifndef INET6_ADDRSTRLEN
224 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
225 #define INET6_ADDRSTRLEN 46
226 #endif
228 #ifndef MIN
229 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
230 #endif
232 #ifndef MAX
233 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
234 #endif
236 #ifdef NEED_DAEMON
237 int daemon(int nochdir, int noclose);
238 #endif
240 #ifdef NEED_STRSEP
241 char * strsep(char **stringp, const char *delim);
242 #endif
244 #ifndef ALIGN
245 #define ALIGN(p) (((unsigned int)(p) + (sizeof(int) - 1)) & ~(sizeof(int) - 1))
246 #endif
248 #ifdef NEED_SETGROUPENT
249 int setgroupent(int stayopen);
250 #endif
252 #ifdef NEED_GETGROUPLIST
253 int getgrouplist(GETGROUPLIST_ARGS);
254 #endif
256 #ifdef POSIX_GETGRNAM_R
258 __posix_getgrnam_r(const char *, struct group *, char *, int, struct group **);
259 #endif
261 #ifdef NEED_GETGRNAM_R
263 getgrnam_r(const char *, struct group *, char *, size_t, struct group **);
264 #endif
266 #ifdef POSIX_GETGRGID_R
268 __posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ;
269 #endif
271 #ifdef NEED_GETGRGID_R
273 getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
274 #endif
276 #ifdef NEED_GETGRENT_R
277 GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS);
278 #endif
280 #ifdef NEED_SETGRENT_R
281 GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS);
282 #endif
284 #ifdef NEED_ENDGRENT_R
285 GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS);
286 #endif
288 #ifdef NEED_INNETGR_R
289 NGR_R_RETURN
290 innetgr_r(const char *, const char *, const char *, const char *);
291 #endif
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
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
309 #ifdef POSIX_GETPWNAM_R
311 __posix_getpwnam_r(const char *login, struct passwd *pwptr,
312 char *buf, size_t buflen, struct passwd **result);
313 #endif
315 #ifdef NEED_GETPWNAM_R
317 getpwnam_r(const char *login, struct passwd *pwptr,
318 char *buf, size_t buflen, struct passwd **result);
319 #endif
321 #ifdef POSIX_GETPWUID_R
323 __posix_getpwuid_r(uid_t uid, struct passwd *pwptr,
324 char *buf, int buflen, struct passwd **result);
325 #endif
327 #ifdef NEED_GETPWUID_R
329 getpwuid_r(uid_t uid, struct passwd *pwptr,
330 char *buf, size_t buflen, struct passwd **result);
331 #endif
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
340 #endif
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
350 #ifdef NEED_GETPWENT_R
351 PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS);
352 #endif
354 #ifdef NEED_ENDPWENT_R
355 void endpwent_r(void);
356 #endif
358 #ifdef NEED_SETPASSENT
359 int setpassent(int stayopen);
360 #endif
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
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);
375 #else
376 void setnetgrent(const char *netgroup);
377 #endif
379 void endnetgrent(void);
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
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