xref: /titanic_44/usr/src/lib/libresolv2/include/port_after.h (revision 634e26ec75c89095090605284938356a3145f2b8)
1 /*
2  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 
7 /*
8  * Copyright (C) 2004-2008  Internet Systems Consortium, Inc. ("ISC")
9  * Copyright (C) 2001-2003  Internet Software Consortium.
10  *
11  * Permission to use, copy, modify, and/or distribute this software for any
12  * purpose with or without fee is hereby granted, provided that the above
13  * copyright notice and this permission notice appear in all copies.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
16  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
17  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
18  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
19  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
20  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21  * PERFORMANCE OF THIS SOFTWARE.
22  */
23 
24 /* $Id: port_after.h.in,v 1.60 2008/02/28 05:34:17 marka Exp $ */
25 
26 #ifndef port_after_h
27 #define port_after_h
28 
29 #include <stdio.h>
30 #include <sys/types.h>
31 #include <sys/socket.h>
32 #include <sys/param.h>
33 #include <sys/time.h>
34 #if (!defined(BSD)) || (BSD < 199306)
35 #include <sys/bitypes.h>
36 #endif
37 #ifdef HAVE_INTTYPES_H
38 #include <inttypes.h>
39 #endif
40 #ifdef HAVE_SYS_SELECT_H
41 #include <sys/select.h>
42 #endif /* HAVE_SYS_SELECT_H */
43 
44 #ifdef REENABLE_SEND
45 #undef send
46 #endif
47 
48 #undef NEED_PSELECT
49 #undef HAVE_SA_LEN
50 #undef HAVE_MINIMUM_IFREQ
51 #define NEED_DAEMON 1
52 #undef NEED_STRSEP
53 #undef NEED_STRERROR
54 #ifdef NEED_STRERROR
55 const char *isc_strerror(int);
56 #define strerror isc_strerror
57 #endif
58 /* HAS_INET6_STRUCTS and HAVE_SIN6_SCOPE_ID are defined by port_ipv6.h
59  * #define HAS_INET6_STRUCTS 1
60  * #define HAVE_SIN6_SCOPE_ID 1
61  */
62 #include <port_ipv6.h>
63 
64 #undef NEED_IN6ADDR_ANY
65 #undef HAS_IN_ADDR6
66 #define HAVE_SOCKADDR_STORAGE 1
67 #undef NEED_GETTIMEOFDAY
68 #undef HAVE_STRNDUP
69 #undef USE_FIONBIO_IOCTL
70 #undef INNETGR_ARGS
71 
72 #undef USE_IFNAMELINKID
73 #define PORT_NONBLOCK O_NONBLOCK
74 
75 #ifndef _POSIX_PATH_MAX
76 #define _POSIX_PATH_MAX 255
77 #endif
78 #ifndef PATH_MAX
79 #define PATH_MAX _POSIX_PATH_MAX
80 #endif
81 
82 /*
83  * We need to know the IPv6 address family number even on IPv4-only systems.
84  * Note that this is NOT a protocol constant, and that if the system has its
85  * own AF_INET6, different from ours below, all of BIND's libraries and
86  * executables will need to be recompiled after the system <sys/socket.h>
87  * has had this type added.  The type number below is correct on most BSD-
88  * derived systems for which AF_INET6 is defined.
89  */
90 #ifndef AF_INET6
91 #define AF_INET6        24
92 #endif
93 
94 #ifndef PF_INET6
95 #define PF_INET6        AF_INET6
96 #endif
97 
98 #ifdef HAS_IN_ADDR6
99 /* Map to pre-RFC structure. */
100 #define in6_addr in_addr6
101 #endif
102 
103 #ifndef HAS_INET6_STRUCTS
104 /* Replace with structure from later rev of O/S if known. */
105 struct in6_addr {
106 	u_int8_t        s6_addr[16];
107 };
108 
109 #define IN6ADDR_ANY_INIT \
110 	{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
111 	   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
112 
113 #define IN6ADDR_LOOPBACK_INIT \
114 	{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
115 	   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
116 
117 /* Replace with structure from later rev of O/S if known. */
118 struct sockaddr_in6 {
119 #ifdef  HAVE_SA_LEN
120 	u_int8_t        sin6_len;       /* length of this struct */
121 	u_int8_t        sin6_family;    /* AF_INET6 */
122 #else
123 	u_int16_t       sin6_family;    /* AF_INET6 */
124 #endif
125 	u_int16_t       sin6_port;      /* transport layer port # */
126 	u_int32_t       sin6_flowinfo;  /* IPv6 flow information */
127 	struct in6_addr sin6_addr;      /* IPv6 address */
128 	u_int32_t       sin6_scope_id;  /* set of interfaces for a scope */
129 };
130 #endif  /* HAS_INET6_STRUCTS */
131 
132 #ifdef BROKEN_IN6ADDR_INIT_MACROS
133 #undef IN6ADDR_ANY_INIT
134 #undef IN6ADDR_LOOPBACK_INIT
135 #endif
136 
137 #ifdef _AIX
138 #ifndef IN6ADDR_ANY_INIT
139 #define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}}
140 #endif
141 #ifndef IN6ADDR_LOOPBACK_INIT
142 #if BYTE_ORDER == BIG_ENDIAN
143 #define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}}
144 #else
145 #define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}}
146 #endif
147 #endif
148 #endif
149 
150 #ifndef IN6ADDR_ANY_INIT
151 #ifdef s6_addr
152 #define IN6ADDR_ANY_INIT \
153 	{{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
154 	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
155 #else
156 #define IN6ADDR_ANY_INIT \
157 	{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
158 	   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
159 #endif
160 
161 #endif
162 #ifndef IN6ADDR_LOOPBACK_INIT
163 #ifdef s6_addr
164 #define IN6ADDR_LOOPBACK_INIT \
165 	{{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
166 	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
167 #else
168 #define IN6ADDR_LOOPBACK_INIT \
169 	{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
170 	   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
171 #endif
172 #endif
173 
174 #ifndef HAVE_SOCKADDR_STORAGE
175 #define __SS_MAXSIZE 128
176 #define __SS_ALLIGSIZE (sizeof (long))
177 
178 struct sockaddr_storage {
179 #ifdef  HAVE_SA_LEN
180 	u_int8_t        ss_len;       /* address length */
181 	u_int8_t        ss_family;    /* address family */
182 	char            __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof(u_int8_t)];
183 	long            __ss_align;
184 	char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
185 #else
186 	u_int16_t       ss_family;    /* address family */
187 	char            __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)];
188 	long            __ss_align;
189 	char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
190 #endif
191 };
192 #endif
193 
194 
195 #if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY)
196 #define in6addr_any isc_in6addr_any
197 extern const struct in6_addr in6addr_any;
198 #endif
199 
200 /*
201  * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and
202  * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1.
203  */
204 #ifdef __GLIBC__
205 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2)
206 #undef IN6_ARE_ADDR_EQUAL
207 #undef IN6_IS_ADDR_UNSPECIFIED
208 #undef IN6_IS_ADDR_V4COMPAT
209 #undef IN6_IS_ADDR_V4MAPPED
210 #endif
211 #endif
212 
213 #ifndef IN6_ARE_ADDR_EQUAL
214 #define IN6_ARE_ADDR_EQUAL(a,b) \
215    (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
216 #endif
217 
218 #ifndef IN6_IS_ADDR_UNSPECIFIED
219 #define IN6_IS_ADDR_UNSPECIFIED(a)      \
220 	IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
221 #endif
222 
223 #ifndef IN6_IS_ADDR_LOOPBACK
224 extern const struct in6_addr isc_in6addr_loopback;
225 #define IN6_IS_ADDR_LOOPBACK(a) \
226 	IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback)
227 #endif
228 
229 #ifndef IN6_IS_ADDR_V4MAPPED
230 #define IN6_IS_ADDR_V4MAPPED(a)	\
231 	((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
232 	(a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
233 	(a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
234 	(a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \
235 	(a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
236 	(a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
237 #endif
238 
239 #ifndef IN6_IS_ADDR_SITELOCAL
240 #define IN6_IS_ADDR_SITELOCAL(a)        \
241 	(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
242 #endif
243 
244 #ifndef IN6_IS_ADDR_LINKLOCAL
245 #define IN6_IS_ADDR_LINKLOCAL(a)        \
246 	(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
247 #endif
248 
249 #ifndef IN6_IS_ADDR_MULTICAST
250 #define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
251 #endif
252 
253 #ifndef __IPV6_ADDR_MC_SCOPE
254 #define __IPV6_ADDR_MC_SCOPE(a)         ((a)->s6_addr[1] & 0x0f)
255 #endif
256 
257 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
258 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
259 #endif
260 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
261 #define __IPV6_ADDR_SCOPE_ORGLOCAL  0x08
262 #endif
263 
264 #ifndef IN6_IS_ADDR_MC_SITELOCAL
265 #define IN6_IS_ADDR_MC_SITELOCAL(a)     \
266 	(IN6_IS_ADDR_MULTICAST(a) &&    \
267 	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
268 #endif
269 
270 #ifndef IN6_IS_ADDR_MC_ORGLOCAL
271 #define IN6_IS_ADDR_MC_ORGLOCAL(a)      \
272 	(IN6_IS_ADDR_MULTICAST(a) &&    \
273 	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
274 #endif
275 
276 #ifndef INADDR_NONE
277 #define INADDR_NONE 0xffffffff
278 #endif
279 
280 #ifndef MAXHOSTNAMELEN
281 #define MAXHOSTNAMELEN 256
282 #endif
283 
284 #ifndef INET6_ADDRSTRLEN
285 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
286 #define INET6_ADDRSTRLEN 46
287 #endif
288 
289 #ifndef MIN
290 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
291 #endif
292 
293 #ifndef MAX
294 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
295 #endif
296 
297 #ifdef NEED_DAEMON
298 int daemon(int nochdir, int noclose);
299 #endif
300 
301 #ifdef NEED_STRSEP
302 char * strsep(char **stringp, const char *delim);
303 #endif
304 
305 #ifndef ALIGN
306 #define ALIGN(p) (((uintptr_t)(p) + (sizeof(long) - 1)) & ~(sizeof(long) - 1))
307 #endif
308 
309 #ifdef NEED_SETGROUPENT
310 int setgroupent(int stayopen);
311 #endif
312 
313 #ifdef NEED_GETGROUPLIST
314 int getgrouplist(GETGROUPLIST_ARGS);
315 #endif
316 
317 #ifdef POSIX_GETGRNAM_R
318 int
319 __posix_getgrnam_r(const char *, struct group *, char *, int, struct group **);
320 #endif
321 
322 #ifdef NEED_GETGRNAM_R
323 int
324 getgrnam_r(const char *,  struct group *, char *, size_t, struct group **);
325 #endif
326 
327 #ifdef POSIX_GETGRGID_R
328 int
329 __posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ;
330 #endif
331 
332 #ifdef NEED_GETGRGID_R
333 int
334 getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
335 #endif
336 
337 #ifdef NEED_GETGRENT_R
338 GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS);
339 #endif
340 
341 #ifdef NEED_SETGRENT_R
342 GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS);
343 #endif
344 
345 #ifdef NEED_ENDGRENT_R
346 GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS);
347 #endif
348 
349 #if defined(NEED_INNETGR_R) && defined(NGR_R_RETURN)
350 NGR_R_RETURN
351 innetgr_r(const char *, const char *, const char *, const char *);
352 #endif
353 
354 #ifdef NEED_SETNETGRENT_R
355 #ifdef NGR_R_SET_ARGS
356 NGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS);
357 #else
358 NGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup);
359 #endif
360 #endif
361 
362 #ifdef NEED_ENDNETGRENT_R
363 #ifdef NGR_R_END_ARGS
364 NGR_R_END_RETURN endnetgrent_r(NGR_R_END_ARGS);
365 #else
366 NGR_R_END_RETURN endnetgrent_r(void);
367 #endif
368 #endif
369 
370 #ifdef POSIX_GETPWNAM_R
371 int
372 __posix_getpwnam_r(const char *login,  struct passwd *pwptr,
373 		char *buf, size_t buflen, struct passwd **result);
374 #endif
375 
376 #ifdef NEED_GETPWNAM_R
377 int
378 getpwnam_r(const char *login,  struct passwd *pwptr,
379 		char *buf, size_t buflen, struct passwd **result);
380 #endif
381 
382 #ifdef POSIX_GETPWUID_R
383 int
384 __posix_getpwuid_r(uid_t uid, struct passwd *pwptr,
385 		char *buf, int buflen, struct passwd **result);
386 #endif
387 
388 #ifdef NEED_GETPWUID_R
389 int
390 getpwuid_r(uid_t uid, struct passwd *pwptr,
391 		char *buf, size_t buflen, struct passwd **result);
392 #endif
393 
394 #ifdef NEED_SETPWENT_R
395 #ifdef PASS_R_ENT_ARGS
396 PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS);
397 #else
398 PASS_R_SET_RETURN setpwent_r(void);
399 #endif
400 
401 #endif
402 
403 #ifdef NEED_SETPASSENT_R
404 #ifdef PASS_R_ENT_ARGS
405 PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS);
406 #else
407 PASS_R_SET_RETURN setpassent_r(int stayopen);
408 #endif
409 #endif
410 
411 #ifdef NEED_GETPWENT_R
412 PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS);
413 #endif
414 
415 #ifdef NEED_ENDPWENT_R
416 void endpwent_r(void);
417 #endif
418 
419 #ifdef NEED_SETPASSENT
420 int setpassent(int stayopen);
421 #endif
422 
423 #define gettimeofday isc__gettimeofday
424 #ifdef NEED_GETTIMEOFDAY
425 int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp);
426 #else
427 int isc__gettimeofday(struct timeval *tp, struct timezone *tzp);
428 #endif
429 
430 int getnetgrent(NGR_R_CONST char **machinep, NGR_R_CONST char **userp,
431 		NGR_R_CONST char **domainp);
432 
433 #ifdef NGR_R_ARGS
434 int getnetgrent_r(NGR_R_CONST char **machinep, NGR_R_CONST char **userp,
435 		  NGR_R_CONST char **domainp, NGR_R_ARGS);
436 #endif
437 
438 /* setnetgrent and endnetgrent are defined in sunw_port_after.h
439 #ifdef SETNETGRENT_ARGS
440 void setnetgrent(SETNETGRENT_ARGS);
441 #else
442 void setnetgrent(const char *netgroup);
443 #endif
444 
445 void endnetgrent(void);
446 */
447 
448 #ifdef INNETGR_ARGS
449 int innetgr(INNETGR_ARGS);
450 #else
451 int innetgr(const char *netgroup, const char *machine,
452 	    const char *user, const char *domain);
453 #endif
454 
455 #ifdef NGR_R_SET_ARGS
456 NGR_R_SET_RETURN
457 setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS);
458 #else
459 NGR_R_SET_RETURN
460 setnetgrent_r(NGR_R_SET_CONST char *netgroup);
461 #endif
462 
463 #ifdef NEED_STRTOUL
464 unsigned long strtoul(const char *, char **, int);
465 #endif
466 
467 #ifdef NEED_SUN4PROTOS
468 #include <stdarg.h>
469 #ifndef __SIZE_TYPE__
470 #define __SIZE_TYPE__ int
471 #endif
472 struct sockaddr;
473 struct iovec;
474 struct timeval;
475 struct timezone;
476 int fprintf(FILE *, const char *, ...);
477 int getsockname(int, struct sockaddr *, int *);
478 int getpeername(int, struct sockaddr *, int *);
479 int socket(int, int, int);
480 int connect(int, const struct sockaddr *, int);
481 int writev(int, struct iovec *, int);
482 int readv(int, struct iovec *, int);
483 int send(int, const char *, int, int);
484 void bzero(char *, int);
485 int recvfrom(int, char *, int, int, struct sockaddr *, int *);
486 int syslog(int, const char *, ... );
487 int printf(const char *, ...);
488 __SIZE_TYPE__ fread(void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *);
489 __SIZE_TYPE__ fwrite(const void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *);
490 int fclose(FILE *);
491 int ungetc(int, FILE *);
492 int scanf(const char *, ...);
493 int sscanf(const char *, const char *, ... );
494 int tolower(int);
495 int toupper(int);
496 int strcasecmp(const char *, const char *);
497 int strncasecmp(const char *, const char *, int);
498 int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
499 #ifdef gettimeofday
500 #undef gettimeofday
501 int gettimeofday(struct timeval *, struct timezone *);
502 #define gettimeofday isc__gettimeofday
503 #else
504 int gettimeofday(struct timeval *, struct timezone *);
505 #endif
506 long strtol(const char*, char **, int);
507 int fseek(FILE *, long, int);
508 int setsockopt(int, int, int, const char *, int);
509 int bind(int, const struct sockaddr *, int);
510 void bcopy(char *, char *, int);
511 int fputc(char, FILE *);
512 int listen(int, int);
513 int accept(int, struct sockaddr *, int *);
514 int getsockopt(int, int, int, char *, int *);
515 int vfprintf(FILE *, const char *, va_list);
516 int fflush(FILE *);
517 int fgetc(FILE *);
518 int fputs(const char *, FILE *);
519 int fchown(int, int, int);
520 void setbuf(FILE *, char *);
521 int gethostname(char *, int);
522 int rename(const char *, const char *);
523 time_t time(time_t *);
524 int fscanf(FILE *, const char *, ...);
525 int sscanf(const char *, const char *, ...);
526 int ioctl(int, int, caddr_t);
527 void perror(const char *);
528 
529 #if !defined(__USE_FIXED_PROTOTYPES__) && !defined(__cplusplus) && !defined(__STRICT_ANSI__)
530 /*
531  * 'gcc -ansi' changes the prototype for vsprintf().
532  * Use this prototype when 'gcc -ansi' is not in effect.
533  */
534 char *vsprintf(char *, const char *, va_list);
535 #endif
536 #endif
537 
538 /* Solaris-specific changes */
539 #include "sunw_port_after.h"
540 
541 #endif
542