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