]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bind9/lib/bind/port_after.h.in
This commit was generated by cvs2svn to compensate for changes in r146901,
[FreeBSD/FreeBSD.git] / contrib / bind9 / 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 #ifdef _AIX
90 #ifndef IN6ADDR_ANY_INIT
91 #define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}}
92 #endif
93 #ifndef IN6ADDR_LOOPBACK_INIT
94 #if BYTE_ORDER == BIG_ENDIAN
95 #define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}}
96 #else
97 #define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}}
98 #endif
99 #endif
100 #endif
101
102 #ifndef IN6ADDR_ANY_INIT
103 #ifdef s6_addr
104 #define IN6ADDR_ANY_INIT \
105         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
106             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
107 #else
108 #define IN6ADDR_ANY_INIT \
109         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
110            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
111 #endif
112
113 #endif
114 #ifndef IN6ADDR_LOOPBACK_INIT
115 #ifdef s6_addr
116 #define IN6ADDR_LOOPBACK_INIT \
117         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
118             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
119 #else
120 #define IN6ADDR_LOOPBACK_INIT \
121         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
122            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
123 #endif
124 #endif
125
126 #ifndef HAVE_SOCKADDR_STORAGE
127 #define __SS_MAXSIZE 128 
128 #define __SS_ALLIGSIZE (sizeof (long)) 
129
130 struct sockaddr_storage {
131 #ifdef  HAVE_SA_LEN
132         u_int8_t        ss_len;       /* address length */
133         u_int8_t        ss_family;    /* address family */
134         char            __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof(u_int8_t)];
135         long            __ss_align;
136         char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
137 #else   
138         u_int16_t       ss_family;    /* address family */
139         char            __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)];
140         long            __ss_align;
141         char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
142 #endif
143 };
144 #endif
145
146
147 #if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY)
148 #define in6addr_any isc_in6addr_any
149 extern const struct in6_addr in6addr_any;
150 #endif
151
152 /*
153  * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and
154  * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1.
155  */
156 #ifdef __GLIBC__
157 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2)
158 #undef IN6_ARE_ADDR_EQUAL
159 #undef IN6_IS_ADDR_UNSPECIFIED
160 #undef IN6_IS_ADDR_V4COMPAT
161 #undef IN6_IS_ADDR_V4MAPPED
162 #endif
163 #endif
164
165 #ifndef IN6_ARE_ADDR_EQUAL
166 #define IN6_ARE_ADDR_EQUAL(a,b) \
167    (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
168 #endif
169
170 #ifndef IN6_IS_ADDR_UNSPECIFIED
171 #define IN6_IS_ADDR_UNSPECIFIED(a)      \
172         IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
173 #endif
174
175 #ifndef IN6_IS_ADDR_LOOPBACK
176 extern const struct in6_addr isc_in6addr_loopback;
177 #define IN6_IS_ADDR_LOOPBACK(a) \
178         IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback)
179 #endif
180
181 #ifndef IN6_IS_ADDR_V4MAPPED
182 #define IN6_IS_ADDR_V4MAPPED(a) \
183         ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
184         (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
185         (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
186         (a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \
187         (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
188         (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
189 #endif
190
191 #ifndef IN6_IS_ADDR_SITELOCAL
192 #define IN6_IS_ADDR_SITELOCAL(a)        \
193         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
194 #endif
195
196 #ifndef IN6_IS_ADDR_LINKLOCAL
197 #define IN6_IS_ADDR_LINKLOCAL(a)        \
198         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
199 #endif
200
201 #ifndef IN6_IS_ADDR_MULTICAST
202 #define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
203 #endif
204
205 #ifndef __IPV6_ADDR_MC_SCOPE
206 #define __IPV6_ADDR_MC_SCOPE(a)         ((a)->s6_addr[1] & 0x0f)
207 #endif
208
209 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
210 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
211 #endif
212 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
213 #define __IPV6_ADDR_SCOPE_ORGLOCAL  0x08
214 #endif
215
216 #ifndef IN6_IS_ADDR_MC_SITELOCAL
217 #define IN6_IS_ADDR_MC_SITELOCAL(a)     \
218         (IN6_IS_ADDR_MULTICAST(a) &&    \
219          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
220 #endif
221
222 #ifndef IN6_IS_ADDR_MC_ORGLOCAL
223 #define IN6_IS_ADDR_MC_ORGLOCAL(a)      \
224         (IN6_IS_ADDR_MULTICAST(a) &&    \
225          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
226 #endif
227
228 #ifndef INADDR_NONE
229 #define INADDR_NONE 0xffffffff
230 #endif
231
232 #ifndef MAXHOSTNAMELEN
233 #define MAXHOSTNAMELEN 256
234 #endif
235
236 #ifndef INET6_ADDRSTRLEN
237 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
238 #define INET6_ADDRSTRLEN 46
239 #endif
240
241 #ifndef MIN
242 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
243 #endif
244
245 #ifndef MAX
246 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
247 #endif
248
249 #ifdef NEED_DAEMON
250 int daemon(int nochdir, int noclose);
251 #endif
252   
253 #ifdef NEED_STRSEP
254 char * strsep(char **stringp, const char *delim);
255 #endif
256
257 #ifndef ALIGN
258 #define ALIGN(p) (((unsigned int)(p) + (sizeof(int) - 1)) & ~(sizeof(int) - 1))
259 #endif
260
261 #ifdef NEED_SETGROUPENT
262 int setgroupent(int stayopen);
263 #endif
264
265 #ifdef NEED_GETGROUPLIST
266 int getgrouplist(GETGROUPLIST_ARGS);
267 #endif
268
269 #ifdef POSIX_GETGRNAM_R
270 int
271 __posix_getgrnam_r(const char *, struct group *, char *, int, struct group **);
272 #endif
273
274 #ifdef NEED_GETGRNAM_R
275 int
276 getgrnam_r(const char *,  struct group *, char *, size_t, struct group **);
277 #endif
278
279 #ifdef POSIX_GETGRGID_R
280 int
281 __posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ;
282 #endif
283
284 #ifdef NEED_GETGRGID_R
285 int
286 getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
287 #endif
288
289 #ifdef NEED_GETGRENT_R
290 GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS);
291 #endif
292
293 #ifdef NEED_SETGRENT_R
294 GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS);
295 #endif
296
297 #ifdef NEED_ENDGRENT_R
298 GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS);
299 #endif
300
301 #ifdef NEED_INNETGR_R
302 NGR_R_RETURN
303 innetgr_r(const char *, const char *, const char *, const char *);
304 #endif
305
306 #ifdef NEED_SETNETGRENT_R
307 #ifdef NGR_R_ENT_ARGS
308 NGR_R_SET_RETURN setnetgrent_r(const char *netgroup, NGR_R_ENT_ARGS);
309 #else
310 NGR_R_SET_RETURN setnetgrent_r(const char *netgroup);
311 #endif
312 #endif
313
314 #ifdef NEED_ENDNETGRENT_R
315 #ifdef NGR_R_ENT_ARGS
316 NGR_R_END_RETURN endnetgrent_r(NGR_R_ENT_ARGS);
317 #else
318 NGR_R_END_RETURN endnetgrent_r(void);
319 #endif
320 #endif
321
322 #ifdef POSIX_GETPWNAM_R
323 int
324 __posix_getpwnam_r(const char *login,  struct passwd *pwptr,
325                 char *buf, size_t buflen, struct passwd **result);
326 #endif
327
328 #ifdef NEED_GETPWNAM_R
329 int
330 getpwnam_r(const char *login,  struct passwd *pwptr,
331                 char *buf, size_t buflen, struct passwd **result);
332 #endif
333
334 #ifdef POSIX_GETPWUID_R
335 int
336 __posix_getpwuid_r(uid_t uid, struct passwd *pwptr,
337                 char *buf, int buflen, struct passwd **result);
338 #endif
339
340 #ifdef NEED_GETPWUID_R
341 int
342 getpwuid_r(uid_t uid, struct passwd *pwptr,
343                 char *buf, size_t buflen, struct passwd **result);
344 #endif
345
346 #ifdef NEED_SETPWENT_R
347 #ifdef PASS_R_ENT_ARGS
348 PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS);
349 #else
350 PASS_R_SET_RETURN setpwent_r(void);
351 #endif
352
353 #endif
354
355 #ifdef NEED_SETPASSENT_R
356 #ifdef PASS_R_ENT_ARGS
357 PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS);
358 #else
359 PASS_R_SET_RETURN setpassent_r(int stayopen);
360 #endif
361 #endif
362
363 #ifdef NEED_GETPWENT_R
364 PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS);
365 #endif
366
367 #ifdef NEED_ENDPWENT_R
368 void endpwent_r(void);
369 #endif
370
371 #ifdef NEED_SETPASSENT
372 int setpassent(int stayopen);
373 #endif
374
375 #define gettimeofday isc__gettimeofday
376 #ifdef NEED_GETTIMEOFDAY
377 int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp);
378 #else
379 int isc__gettimeofday(struct timeval *tp, struct timezone *tzp);
380 #endif
381
382 int getnetgrent(char **machinep, char **userp, char **domainp);
383
384 int getnetgrent_r(char **machinep, char **userp, char **domainp, NGR_R_ARGS);
385
386 #ifdef SETNETGRENT_ARGS
387 void setnetgrent(SETNETGRENT_ARGS);
388 #else
389 void setnetgrent(const char *netgroup);
390 #endif
391
392 void endnetgrent(void);
393
394 #ifdef INNETGR_ARGS
395 int innetgr(INNETGR_ARGS);
396 #else
397 int innetgr(const char *netgroup, const char *machine,
398             const char *user, const char *domain);
399 #endif
400
401 #ifdef NGR_R_ENT_ARGS
402 NGR_R_SET_RETURN
403 setnetgrent_r(const char *netgroup, NGR_R_ENT_ARGS);
404 #else
405 NGR_R_SET_RETURN
406 setnetgrent_r(const char *netgroup);
407 #endif
408 #endif