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