10Sstevel@tonic-gate /* 2*13093SRoger.Faulkner@Oracle.COM * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 30Sstevel@tonic-gate */ 40Sstevel@tonic-gate 511038SRao.Shoaib@Sun.COM /* 611038SRao.Shoaib@Sun.COM * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") 711038SRao.Shoaib@Sun.COM * Copyright (C) 2001-2003 Internet Software Consortium. 811038SRao.Shoaib@Sun.COM * 911038SRao.Shoaib@Sun.COM * Permission to use, copy, modify, and/or distribute this software for any 1011038SRao.Shoaib@Sun.COM * purpose with or without fee is hereby granted, provided that the above 1111038SRao.Shoaib@Sun.COM * copyright notice and this permission notice appear in all copies. 1211038SRao.Shoaib@Sun.COM * 1311038SRao.Shoaib@Sun.COM * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 1411038SRao.Shoaib@Sun.COM * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 1511038SRao.Shoaib@Sun.COM * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 1611038SRao.Shoaib@Sun.COM * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 1711038SRao.Shoaib@Sun.COM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 1811038SRao.Shoaib@Sun.COM * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 1911038SRao.Shoaib@Sun.COM * PERFORMANCE OF THIS SOFTWARE. 2011038SRao.Shoaib@Sun.COM */ 210Sstevel@tonic-gate 2211038SRao.Shoaib@Sun.COM /* $Id: port_after.h.in,v 1.60 2008/02/28 05:34:17 marka Exp $ */ 230Sstevel@tonic-gate 2411038SRao.Shoaib@Sun.COM #ifndef port_after_h 2511038SRao.Shoaib@Sun.COM #define port_after_h 2611038SRao.Shoaib@Sun.COM 2711038SRao.Shoaib@Sun.COM #include <stdio.h> 280Sstevel@tonic-gate #include <sys/types.h> 290Sstevel@tonic-gate #include <sys/socket.h> 300Sstevel@tonic-gate #include <sys/param.h> 3111038SRao.Shoaib@Sun.COM #include <sys/time.h> 320Sstevel@tonic-gate #if (!defined(BSD)) || (BSD < 199306) 330Sstevel@tonic-gate #include <sys/bitypes.h> 340Sstevel@tonic-gate #endif 3511038SRao.Shoaib@Sun.COM #ifdef HAVE_INTTYPES_H 3611038SRao.Shoaib@Sun.COM #include <inttypes.h> 3711038SRao.Shoaib@Sun.COM #endif 3811038SRao.Shoaib@Sun.COM #ifdef HAVE_SYS_SELECT_H 3911038SRao.Shoaib@Sun.COM #include <sys/select.h> 4011038SRao.Shoaib@Sun.COM #endif /* HAVE_SYS_SELECT_H */ 4111038SRao.Shoaib@Sun.COM 4211038SRao.Shoaib@Sun.COM #ifdef REENABLE_SEND 4311038SRao.Shoaib@Sun.COM #undef send 4411038SRao.Shoaib@Sun.COM #endif 450Sstevel@tonic-gate 4611038SRao.Shoaib@Sun.COM #undef NEED_PSELECT 4711038SRao.Shoaib@Sun.COM #undef HAVE_SA_LEN 4811038SRao.Shoaib@Sun.COM #undef HAVE_MINIMUM_IFREQ 4911038SRao.Shoaib@Sun.COM #define NEED_DAEMON 1 5011038SRao.Shoaib@Sun.COM #undef NEED_STRSEP 5111038SRao.Shoaib@Sun.COM #undef NEED_STRERROR 5211038SRao.Shoaib@Sun.COM #ifdef NEED_STRERROR 5311038SRao.Shoaib@Sun.COM const char *isc_strerror(int); 5411038SRao.Shoaib@Sun.COM #define strerror isc_strerror 550Sstevel@tonic-gate #endif 5611038SRao.Shoaib@Sun.COM /* HAS_INET6_STRUCTS and HAVE_SIN6_SCOPE_ID are defined by port_ipv6.h 5711038SRao.Shoaib@Sun.COM * #define HAS_INET6_STRUCTS 1 5811038SRao.Shoaib@Sun.COM * #define HAVE_SIN6_SCOPE_ID 1 5911038SRao.Shoaib@Sun.COM */ 6011038SRao.Shoaib@Sun.COM #include <port_ipv6.h> 6111038SRao.Shoaib@Sun.COM 6211038SRao.Shoaib@Sun.COM #undef NEED_IN6ADDR_ANY 6311038SRao.Shoaib@Sun.COM #undef HAS_IN_ADDR6 6411038SRao.Shoaib@Sun.COM #define HAVE_SOCKADDR_STORAGE 1 6511038SRao.Shoaib@Sun.COM #undef NEED_GETTIMEOFDAY 66*13093SRoger.Faulkner@Oracle.COM #define HAVE_STRNDUP 6711038SRao.Shoaib@Sun.COM #undef USE_FIONBIO_IOCTL 6811038SRao.Shoaib@Sun.COM #undef INNETGR_ARGS 6911038SRao.Shoaib@Sun.COM 7011038SRao.Shoaib@Sun.COM #undef USE_IFNAMELINKID 7111038SRao.Shoaib@Sun.COM #define PORT_NONBLOCK O_NONBLOCK 7211038SRao.Shoaib@Sun.COM 7311038SRao.Shoaib@Sun.COM #ifndef _POSIX_PATH_MAX 7411038SRao.Shoaib@Sun.COM #define _POSIX_PATH_MAX 255 7511038SRao.Shoaib@Sun.COM #endif 7611038SRao.Shoaib@Sun.COM #ifndef PATH_MAX 7711038SRao.Shoaib@Sun.COM #define PATH_MAX _POSIX_PATH_MAX 780Sstevel@tonic-gate #endif 790Sstevel@tonic-gate 800Sstevel@tonic-gate /* 810Sstevel@tonic-gate * We need to know the IPv6 address family number even on IPv4-only systems. 820Sstevel@tonic-gate * Note that this is NOT a protocol constant, and that if the system has its 830Sstevel@tonic-gate * own AF_INET6, different from ours below, all of BIND's libraries and 840Sstevel@tonic-gate * executables will need to be recompiled after the system <sys/socket.h> 850Sstevel@tonic-gate * has had this type added. The type number below is correct on most BSD- 860Sstevel@tonic-gate * derived systems for which AF_INET6 is defined. 870Sstevel@tonic-gate */ 880Sstevel@tonic-gate #ifndef AF_INET6 8911038SRao.Shoaib@Sun.COM #define AF_INET6 24 900Sstevel@tonic-gate #endif 910Sstevel@tonic-gate 9211038SRao.Shoaib@Sun.COM #ifndef PF_INET6 9311038SRao.Shoaib@Sun.COM #define PF_INET6 AF_INET6 940Sstevel@tonic-gate #endif 9511038SRao.Shoaib@Sun.COM 9611038SRao.Shoaib@Sun.COM #ifdef HAS_IN_ADDR6 9711038SRao.Shoaib@Sun.COM /* Map to pre-RFC structure. */ 9811038SRao.Shoaib@Sun.COM #define in6_addr in_addr6 9911038SRao.Shoaib@Sun.COM #endif 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate #ifndef HAS_INET6_STRUCTS 1020Sstevel@tonic-gate /* Replace with structure from later rev of O/S if known. */ 1030Sstevel@tonic-gate struct in6_addr { 10411038SRao.Shoaib@Sun.COM u_int8_t s6_addr[16]; 1050Sstevel@tonic-gate }; 1060Sstevel@tonic-gate 10711038SRao.Shoaib@Sun.COM #define IN6ADDR_ANY_INIT \ 10811038SRao.Shoaib@Sun.COM {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 10911038SRao.Shoaib@Sun.COM 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }} 11011038SRao.Shoaib@Sun.COM 11111038SRao.Shoaib@Sun.COM #define IN6ADDR_LOOPBACK_INIT \ 11211038SRao.Shoaib@Sun.COM {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 11311038SRao.Shoaib@Sun.COM 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }} 11411038SRao.Shoaib@Sun.COM 1150Sstevel@tonic-gate /* Replace with structure from later rev of O/S if known. */ 1160Sstevel@tonic-gate struct sockaddr_in6 { 11711038SRao.Shoaib@Sun.COM #ifdef HAVE_SA_LEN 11811038SRao.Shoaib@Sun.COM u_int8_t sin6_len; /* length of this struct */ 11911038SRao.Shoaib@Sun.COM u_int8_t sin6_family; /* AF_INET6 */ 1200Sstevel@tonic-gate #else 12111038SRao.Shoaib@Sun.COM u_int16_t sin6_family; /* AF_INET6 */ 1220Sstevel@tonic-gate #endif 12311038SRao.Shoaib@Sun.COM u_int16_t sin6_port; /* transport layer port # */ 12411038SRao.Shoaib@Sun.COM u_int32_t sin6_flowinfo; /* IPv6 flow information */ 12511038SRao.Shoaib@Sun.COM struct in6_addr sin6_addr; /* IPv6 address */ 12611038SRao.Shoaib@Sun.COM u_int32_t sin6_scope_id; /* set of interfaces for a scope */ 1270Sstevel@tonic-gate }; 12811038SRao.Shoaib@Sun.COM #endif /* HAS_INET6_STRUCTS */ 12911038SRao.Shoaib@Sun.COM 13011038SRao.Shoaib@Sun.COM #ifdef BROKEN_IN6ADDR_INIT_MACROS 13111038SRao.Shoaib@Sun.COM #undef IN6ADDR_ANY_INIT 13211038SRao.Shoaib@Sun.COM #undef IN6ADDR_LOOPBACK_INIT 13311038SRao.Shoaib@Sun.COM #endif 13411038SRao.Shoaib@Sun.COM 13511038SRao.Shoaib@Sun.COM #ifdef _AIX 13611038SRao.Shoaib@Sun.COM #ifndef IN6ADDR_ANY_INIT 13711038SRao.Shoaib@Sun.COM #define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}} 13811038SRao.Shoaib@Sun.COM #endif 13911038SRao.Shoaib@Sun.COM #ifndef IN6ADDR_LOOPBACK_INIT 14011038SRao.Shoaib@Sun.COM #if BYTE_ORDER == BIG_ENDIAN 14111038SRao.Shoaib@Sun.COM #define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}} 14211038SRao.Shoaib@Sun.COM #else 14311038SRao.Shoaib@Sun.COM #define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}} 14411038SRao.Shoaib@Sun.COM #endif 14511038SRao.Shoaib@Sun.COM #endif 14611038SRao.Shoaib@Sun.COM #endif 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate #ifndef IN6ADDR_ANY_INIT 14911038SRao.Shoaib@Sun.COM #ifdef s6_addr 15011038SRao.Shoaib@Sun.COM #define IN6ADDR_ANY_INIT \ 15111038SRao.Shoaib@Sun.COM {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 15211038SRao.Shoaib@Sun.COM 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} 15311038SRao.Shoaib@Sun.COM #else 15411038SRao.Shoaib@Sun.COM #define IN6ADDR_ANY_INIT \ 15511038SRao.Shoaib@Sun.COM {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 15611038SRao.Shoaib@Sun.COM 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }} 15711038SRao.Shoaib@Sun.COM #endif 15811038SRao.Shoaib@Sun.COM 1590Sstevel@tonic-gate #endif 1600Sstevel@tonic-gate #ifndef IN6ADDR_LOOPBACK_INIT 16111038SRao.Shoaib@Sun.COM #ifdef s6_addr 16211038SRao.Shoaib@Sun.COM #define IN6ADDR_LOOPBACK_INIT \ 16311038SRao.Shoaib@Sun.COM {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 16411038SRao.Shoaib@Sun.COM 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} 16511038SRao.Shoaib@Sun.COM #else 16611038SRao.Shoaib@Sun.COM #define IN6ADDR_LOOPBACK_INIT \ 16711038SRao.Shoaib@Sun.COM {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 16811038SRao.Shoaib@Sun.COM 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }} 1690Sstevel@tonic-gate #endif 17011038SRao.Shoaib@Sun.COM #endif 1710Sstevel@tonic-gate 17211038SRao.Shoaib@Sun.COM #ifndef HAVE_SOCKADDR_STORAGE 17311038SRao.Shoaib@Sun.COM #define __SS_MAXSIZE 128 17411038SRao.Shoaib@Sun.COM #define __SS_ALLIGSIZE (sizeof (long)) 1750Sstevel@tonic-gate 1760Sstevel@tonic-gate struct sockaddr_storage { 1770Sstevel@tonic-gate #ifdef HAVE_SA_LEN 17811038SRao.Shoaib@Sun.COM u_int8_t ss_len; /* address length */ 17911038SRao.Shoaib@Sun.COM u_int8_t ss_family; /* address family */ 18011038SRao.Shoaib@Sun.COM char __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof(u_int8_t)]; 18111038SRao.Shoaib@Sun.COM long __ss_align; 18211038SRao.Shoaib@Sun.COM char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE]; 1830Sstevel@tonic-gate #else 18411038SRao.Shoaib@Sun.COM u_int16_t ss_family; /* address family */ 18511038SRao.Shoaib@Sun.COM char __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)]; 18611038SRao.Shoaib@Sun.COM long __ss_align; 18711038SRao.Shoaib@Sun.COM char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE]; 1880Sstevel@tonic-gate #endif 1890Sstevel@tonic-gate }; 1900Sstevel@tonic-gate #endif 1910Sstevel@tonic-gate 1920Sstevel@tonic-gate 1930Sstevel@tonic-gate #if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY) 19411038SRao.Shoaib@Sun.COM #define in6addr_any isc_in6addr_any 1950Sstevel@tonic-gate extern const struct in6_addr in6addr_any; 1960Sstevel@tonic-gate #endif 1970Sstevel@tonic-gate 19811038SRao.Shoaib@Sun.COM /* 19911038SRao.Shoaib@Sun.COM * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and 20011038SRao.Shoaib@Sun.COM * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1. 20111038SRao.Shoaib@Sun.COM */ 20211038SRao.Shoaib@Sun.COM #ifdef __GLIBC__ 20311038SRao.Shoaib@Sun.COM #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2) 20411038SRao.Shoaib@Sun.COM #undef IN6_ARE_ADDR_EQUAL 20511038SRao.Shoaib@Sun.COM #undef IN6_IS_ADDR_UNSPECIFIED 20611038SRao.Shoaib@Sun.COM #undef IN6_IS_ADDR_V4COMPAT 20711038SRao.Shoaib@Sun.COM #undef IN6_IS_ADDR_V4MAPPED 20811038SRao.Shoaib@Sun.COM #endif 20911038SRao.Shoaib@Sun.COM #endif 21011038SRao.Shoaib@Sun.COM 2110Sstevel@tonic-gate #ifndef IN6_ARE_ADDR_EQUAL 21211038SRao.Shoaib@Sun.COM #define IN6_ARE_ADDR_EQUAL(a,b) \ 21311038SRao.Shoaib@Sun.COM (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0) 2140Sstevel@tonic-gate #endif 2150Sstevel@tonic-gate 2160Sstevel@tonic-gate #ifndef IN6_IS_ADDR_UNSPECIFIED 21711038SRao.Shoaib@Sun.COM #define IN6_IS_ADDR_UNSPECIFIED(a) \ 2180Sstevel@tonic-gate IN6_ARE_ADDR_EQUAL(a, &in6addr_any) 2190Sstevel@tonic-gate #endif 2200Sstevel@tonic-gate 2210Sstevel@tonic-gate #ifndef IN6_IS_ADDR_LOOPBACK 2220Sstevel@tonic-gate extern const struct in6_addr isc_in6addr_loopback; 22311038SRao.Shoaib@Sun.COM #define IN6_IS_ADDR_LOOPBACK(a) \ 2240Sstevel@tonic-gate IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback) 2250Sstevel@tonic-gate #endif 2260Sstevel@tonic-gate 22711038SRao.Shoaib@Sun.COM #ifndef IN6_IS_ADDR_V4MAPPED 22811038SRao.Shoaib@Sun.COM #define IN6_IS_ADDR_V4MAPPED(a) \ 2290Sstevel@tonic-gate ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \ 2300Sstevel@tonic-gate (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \ 2310Sstevel@tonic-gate (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \ 23211038SRao.Shoaib@Sun.COM (a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \ 2330Sstevel@tonic-gate (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \ 2340Sstevel@tonic-gate (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff) 2350Sstevel@tonic-gate #endif 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate #ifndef IN6_IS_ADDR_SITELOCAL 23811038SRao.Shoaib@Sun.COM #define IN6_IS_ADDR_SITELOCAL(a) \ 2390Sstevel@tonic-gate (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0)) 2400Sstevel@tonic-gate #endif 2410Sstevel@tonic-gate 2420Sstevel@tonic-gate #ifndef IN6_IS_ADDR_LINKLOCAL 24311038SRao.Shoaib@Sun.COM #define IN6_IS_ADDR_LINKLOCAL(a) \ 2440Sstevel@tonic-gate (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80)) 2450Sstevel@tonic-gate #endif 2460Sstevel@tonic-gate 2470Sstevel@tonic-gate #ifndef IN6_IS_ADDR_MULTICAST 24811038SRao.Shoaib@Sun.COM #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) 2490Sstevel@tonic-gate #endif 2500Sstevel@tonic-gate 2510Sstevel@tonic-gate #ifndef __IPV6_ADDR_MC_SCOPE 25211038SRao.Shoaib@Sun.COM #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) 2530Sstevel@tonic-gate #endif 2540Sstevel@tonic-gate 2550Sstevel@tonic-gate #ifndef __IPV6_ADDR_SCOPE_SITELOCAL 25611038SRao.Shoaib@Sun.COM #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05 2570Sstevel@tonic-gate #endif 2580Sstevel@tonic-gate #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL 25911038SRao.Shoaib@Sun.COM #define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08 2600Sstevel@tonic-gate #endif 2610Sstevel@tonic-gate 2620Sstevel@tonic-gate #ifndef IN6_IS_ADDR_MC_SITELOCAL 26311038SRao.Shoaib@Sun.COM #define IN6_IS_ADDR_MC_SITELOCAL(a) \ 2640Sstevel@tonic-gate (IN6_IS_ADDR_MULTICAST(a) && \ 26511038SRao.Shoaib@Sun.COM (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL)) 2660Sstevel@tonic-gate #endif 2670Sstevel@tonic-gate 2680Sstevel@tonic-gate #ifndef IN6_IS_ADDR_MC_ORGLOCAL 26911038SRao.Shoaib@Sun.COM #define IN6_IS_ADDR_MC_ORGLOCAL(a) \ 2700Sstevel@tonic-gate (IN6_IS_ADDR_MULTICAST(a) && \ 27111038SRao.Shoaib@Sun.COM (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL)) 27211038SRao.Shoaib@Sun.COM #endif 27311038SRao.Shoaib@Sun.COM 27411038SRao.Shoaib@Sun.COM #ifndef INADDR_NONE 27511038SRao.Shoaib@Sun.COM #define INADDR_NONE 0xffffffff 27611038SRao.Shoaib@Sun.COM #endif 27711038SRao.Shoaib@Sun.COM 27811038SRao.Shoaib@Sun.COM #ifndef MAXHOSTNAMELEN 27911038SRao.Shoaib@Sun.COM #define MAXHOSTNAMELEN 256 2800Sstevel@tonic-gate #endif 2810Sstevel@tonic-gate 2820Sstevel@tonic-gate #ifndef INET6_ADDRSTRLEN 28311038SRao.Shoaib@Sun.COM /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */ 28411038SRao.Shoaib@Sun.COM #define INET6_ADDRSTRLEN 46 28511038SRao.Shoaib@Sun.COM #endif 28611038SRao.Shoaib@Sun.COM 28711038SRao.Shoaib@Sun.COM #ifndef MIN 28811038SRao.Shoaib@Sun.COM #define MIN(x,y) (((x) <= (y)) ? (x) : (y)) 28911038SRao.Shoaib@Sun.COM #endif 29011038SRao.Shoaib@Sun.COM 29111038SRao.Shoaib@Sun.COM #ifndef MAX 29211038SRao.Shoaib@Sun.COM #define MAX(x,y) (((x) >= (y)) ? (x) : (y)) 2930Sstevel@tonic-gate #endif 2940Sstevel@tonic-gate 29511038SRao.Shoaib@Sun.COM #ifdef NEED_DAEMON 29611038SRao.Shoaib@Sun.COM int daemon(int nochdir, int noclose); 29711038SRao.Shoaib@Sun.COM #endif 29811038SRao.Shoaib@Sun.COM 29911038SRao.Shoaib@Sun.COM #ifdef NEED_STRSEP 30011038SRao.Shoaib@Sun.COM char * strsep(char **stringp, const char *delim); 3010Sstevel@tonic-gate #endif 30211038SRao.Shoaib@Sun.COM 30311038SRao.Shoaib@Sun.COM #ifndef ALIGN 30411038SRao.Shoaib@Sun.COM #define ALIGN(p) (((uintptr_t)(p) + (sizeof(long) - 1)) & ~(sizeof(long) - 1)) 30511038SRao.Shoaib@Sun.COM #endif 30611038SRao.Shoaib@Sun.COM 30711038SRao.Shoaib@Sun.COM #ifdef NEED_SETGROUPENT 30811038SRao.Shoaib@Sun.COM int setgroupent(int stayopen); 3090Sstevel@tonic-gate #endif 3100Sstevel@tonic-gate 31111038SRao.Shoaib@Sun.COM #ifdef NEED_GETGROUPLIST 31211038SRao.Shoaib@Sun.COM int getgrouplist(GETGROUPLIST_ARGS); 31311038SRao.Shoaib@Sun.COM #endif 3140Sstevel@tonic-gate 31511038SRao.Shoaib@Sun.COM #ifdef POSIX_GETGRNAM_R 31611038SRao.Shoaib@Sun.COM int 31711038SRao.Shoaib@Sun.COM __posix_getgrnam_r(const char *, struct group *, char *, int, struct group **); 31811038SRao.Shoaib@Sun.COM #endif 31911038SRao.Shoaib@Sun.COM 32011038SRao.Shoaib@Sun.COM #ifdef NEED_GETGRNAM_R 32111038SRao.Shoaib@Sun.COM int 32211038SRao.Shoaib@Sun.COM getgrnam_r(const char *, struct group *, char *, size_t, struct group **); 3230Sstevel@tonic-gate #endif 3240Sstevel@tonic-gate 32511038SRao.Shoaib@Sun.COM #ifdef POSIX_GETGRGID_R 32611038SRao.Shoaib@Sun.COM int 32711038SRao.Shoaib@Sun.COM __posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ; 32811038SRao.Shoaib@Sun.COM #endif 32911038SRao.Shoaib@Sun.COM 33011038SRao.Shoaib@Sun.COM #ifdef NEED_GETGRGID_R 33111038SRao.Shoaib@Sun.COM int 33211038SRao.Shoaib@Sun.COM getgrgid_r(gid_t, struct group *, char *, size_t, struct group **); 33311038SRao.Shoaib@Sun.COM #endif 33411038SRao.Shoaib@Sun.COM 33511038SRao.Shoaib@Sun.COM #ifdef NEED_GETGRENT_R 33611038SRao.Shoaib@Sun.COM GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS); 33711038SRao.Shoaib@Sun.COM #endif 33811038SRao.Shoaib@Sun.COM 33911038SRao.Shoaib@Sun.COM #ifdef NEED_SETGRENT_R 34011038SRao.Shoaib@Sun.COM GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS); 3410Sstevel@tonic-gate #endif 3420Sstevel@tonic-gate 34311038SRao.Shoaib@Sun.COM #ifdef NEED_ENDGRENT_R 34411038SRao.Shoaib@Sun.COM GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS); 34511038SRao.Shoaib@Sun.COM #endif 3460Sstevel@tonic-gate 34711038SRao.Shoaib@Sun.COM #if defined(NEED_INNETGR_R) && defined(NGR_R_RETURN) 34811038SRao.Shoaib@Sun.COM NGR_R_RETURN 34911038SRao.Shoaib@Sun.COM innetgr_r(const char *, const char *, const char *, const char *); 3500Sstevel@tonic-gate #endif 3510Sstevel@tonic-gate 35211038SRao.Shoaib@Sun.COM #ifdef NEED_SETNETGRENT_R 35311038SRao.Shoaib@Sun.COM #ifdef NGR_R_SET_ARGS 35411038SRao.Shoaib@Sun.COM NGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS); 35511038SRao.Shoaib@Sun.COM #else 35611038SRao.Shoaib@Sun.COM NGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup); 35711038SRao.Shoaib@Sun.COM #endif 35811038SRao.Shoaib@Sun.COM #endif 35911038SRao.Shoaib@Sun.COM 36011038SRao.Shoaib@Sun.COM #ifdef NEED_ENDNETGRENT_R 36111038SRao.Shoaib@Sun.COM #ifdef NGR_R_END_ARGS 36211038SRao.Shoaib@Sun.COM NGR_R_END_RETURN endnetgrent_r(NGR_R_END_ARGS); 36311038SRao.Shoaib@Sun.COM #else 36411038SRao.Shoaib@Sun.COM NGR_R_END_RETURN endnetgrent_r(void); 36511038SRao.Shoaib@Sun.COM #endif 36611038SRao.Shoaib@Sun.COM #endif 36711038SRao.Shoaib@Sun.COM 36811038SRao.Shoaib@Sun.COM #ifdef POSIX_GETPWNAM_R 36911038SRao.Shoaib@Sun.COM int 37011038SRao.Shoaib@Sun.COM __posix_getpwnam_r(const char *login, struct passwd *pwptr, 37111038SRao.Shoaib@Sun.COM char *buf, size_t buflen, struct passwd **result); 3720Sstevel@tonic-gate #endif 3730Sstevel@tonic-gate 37411038SRao.Shoaib@Sun.COM #ifdef NEED_GETPWNAM_R 37511038SRao.Shoaib@Sun.COM int 37611038SRao.Shoaib@Sun.COM getpwnam_r(const char *login, struct passwd *pwptr, 37711038SRao.Shoaib@Sun.COM char *buf, size_t buflen, struct passwd **result); 37811038SRao.Shoaib@Sun.COM #endif 3790Sstevel@tonic-gate 38011038SRao.Shoaib@Sun.COM #ifdef POSIX_GETPWUID_R 38111038SRao.Shoaib@Sun.COM int 38211038SRao.Shoaib@Sun.COM __posix_getpwuid_r(uid_t uid, struct passwd *pwptr, 38311038SRao.Shoaib@Sun.COM char *buf, int buflen, struct passwd **result); 3840Sstevel@tonic-gate #endif 3850Sstevel@tonic-gate 38611038SRao.Shoaib@Sun.COM #ifdef NEED_GETPWUID_R 38711038SRao.Shoaib@Sun.COM int 38811038SRao.Shoaib@Sun.COM getpwuid_r(uid_t uid, struct passwd *pwptr, 38911038SRao.Shoaib@Sun.COM char *buf, size_t buflen, struct passwd **result); 3900Sstevel@tonic-gate #endif 39111038SRao.Shoaib@Sun.COM 39211038SRao.Shoaib@Sun.COM #ifdef NEED_SETPWENT_R 39311038SRao.Shoaib@Sun.COM #ifdef PASS_R_ENT_ARGS 39411038SRao.Shoaib@Sun.COM PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS); 39511038SRao.Shoaib@Sun.COM #else 39611038SRao.Shoaib@Sun.COM PASS_R_SET_RETURN setpwent_r(void); 39711038SRao.Shoaib@Sun.COM #endif 398237Sanay 39911038SRao.Shoaib@Sun.COM #endif 40011038SRao.Shoaib@Sun.COM 40111038SRao.Shoaib@Sun.COM #ifdef NEED_SETPASSENT_R 40211038SRao.Shoaib@Sun.COM #ifdef PASS_R_ENT_ARGS 40311038SRao.Shoaib@Sun.COM PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS); 404237Sanay #else 40511038SRao.Shoaib@Sun.COM PASS_R_SET_RETURN setpassent_r(int stayopen); 406237Sanay #endif 407237Sanay #endif 408237Sanay 40911038SRao.Shoaib@Sun.COM #ifdef NEED_GETPWENT_R 41011038SRao.Shoaib@Sun.COM PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS); 41111038SRao.Shoaib@Sun.COM #endif 41211038SRao.Shoaib@Sun.COM 41311038SRao.Shoaib@Sun.COM #ifdef NEED_ENDPWENT_R 41411038SRao.Shoaib@Sun.COM void endpwent_r(void); 41511038SRao.Shoaib@Sun.COM #endif 41611038SRao.Shoaib@Sun.COM 41711038SRao.Shoaib@Sun.COM #ifdef NEED_SETPASSENT 41811038SRao.Shoaib@Sun.COM int setpassent(int stayopen); 41911038SRao.Shoaib@Sun.COM #endif 42011038SRao.Shoaib@Sun.COM 42111038SRao.Shoaib@Sun.COM #define gettimeofday isc__gettimeofday 42211038SRao.Shoaib@Sun.COM #ifdef NEED_GETTIMEOFDAY 42311038SRao.Shoaib@Sun.COM int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp); 42411038SRao.Shoaib@Sun.COM #else 42511038SRao.Shoaib@Sun.COM int isc__gettimeofday(struct timeval *tp, struct timezone *tzp); 42611038SRao.Shoaib@Sun.COM #endif 42711038SRao.Shoaib@Sun.COM 42811038SRao.Shoaib@Sun.COM int getnetgrent(NGR_R_CONST char **machinep, NGR_R_CONST char **userp, 42911038SRao.Shoaib@Sun.COM NGR_R_CONST char **domainp); 43011038SRao.Shoaib@Sun.COM 43111038SRao.Shoaib@Sun.COM #ifdef NGR_R_ARGS 43211038SRao.Shoaib@Sun.COM int getnetgrent_r(NGR_R_CONST char **machinep, NGR_R_CONST char **userp, 43311038SRao.Shoaib@Sun.COM NGR_R_CONST char **domainp, NGR_R_ARGS); 43411038SRao.Shoaib@Sun.COM #endif 43511038SRao.Shoaib@Sun.COM 43611038SRao.Shoaib@Sun.COM /* setnetgrent and endnetgrent are defined in sunw_port_after.h 43711038SRao.Shoaib@Sun.COM #ifdef SETNETGRENT_ARGS 43811038SRao.Shoaib@Sun.COM void setnetgrent(SETNETGRENT_ARGS); 43911038SRao.Shoaib@Sun.COM #else 44011038SRao.Shoaib@Sun.COM void setnetgrent(const char *netgroup); 44111038SRao.Shoaib@Sun.COM #endif 44211038SRao.Shoaib@Sun.COM 44311038SRao.Shoaib@Sun.COM void endnetgrent(void); 44411038SRao.Shoaib@Sun.COM */ 44511038SRao.Shoaib@Sun.COM 44611038SRao.Shoaib@Sun.COM #ifdef INNETGR_ARGS 44711038SRao.Shoaib@Sun.COM int innetgr(INNETGR_ARGS); 44811038SRao.Shoaib@Sun.COM #else 44911038SRao.Shoaib@Sun.COM int innetgr(const char *netgroup, const char *machine, 45011038SRao.Shoaib@Sun.COM const char *user, const char *domain); 45111038SRao.Shoaib@Sun.COM #endif 45211038SRao.Shoaib@Sun.COM 45311038SRao.Shoaib@Sun.COM #ifdef NGR_R_SET_ARGS 45411038SRao.Shoaib@Sun.COM NGR_R_SET_RETURN 45511038SRao.Shoaib@Sun.COM setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS); 45611038SRao.Shoaib@Sun.COM #else 45711038SRao.Shoaib@Sun.COM NGR_R_SET_RETURN 45811038SRao.Shoaib@Sun.COM setnetgrent_r(NGR_R_SET_CONST char *netgroup); 45911038SRao.Shoaib@Sun.COM #endif 46011038SRao.Shoaib@Sun.COM 46111038SRao.Shoaib@Sun.COM #ifdef NEED_STRTOUL 46211038SRao.Shoaib@Sun.COM unsigned long strtoul(const char *, char **, int); 46311038SRao.Shoaib@Sun.COM #endif 46411038SRao.Shoaib@Sun.COM 46511038SRao.Shoaib@Sun.COM #ifdef NEED_SUN4PROTOS 46611038SRao.Shoaib@Sun.COM #include <stdarg.h> 46711038SRao.Shoaib@Sun.COM #ifndef __SIZE_TYPE__ 46811038SRao.Shoaib@Sun.COM #define __SIZE_TYPE__ int 46911038SRao.Shoaib@Sun.COM #endif 47011038SRao.Shoaib@Sun.COM struct sockaddr; 47111038SRao.Shoaib@Sun.COM struct iovec; 47211038SRao.Shoaib@Sun.COM struct timeval; 47311038SRao.Shoaib@Sun.COM struct timezone; 47411038SRao.Shoaib@Sun.COM int fprintf(FILE *, const char *, ...); 47511038SRao.Shoaib@Sun.COM int getsockname(int, struct sockaddr *, int *); 47611038SRao.Shoaib@Sun.COM int getpeername(int, struct sockaddr *, int *); 47711038SRao.Shoaib@Sun.COM int socket(int, int, int); 47811038SRao.Shoaib@Sun.COM int connect(int, const struct sockaddr *, int); 47911038SRao.Shoaib@Sun.COM int writev(int, struct iovec *, int); 48011038SRao.Shoaib@Sun.COM int readv(int, struct iovec *, int); 48111038SRao.Shoaib@Sun.COM int send(int, const char *, int, int); 48211038SRao.Shoaib@Sun.COM void bzero(char *, int); 48311038SRao.Shoaib@Sun.COM int recvfrom(int, char *, int, int, struct sockaddr *, int *); 48411038SRao.Shoaib@Sun.COM int syslog(int, const char *, ... ); 48511038SRao.Shoaib@Sun.COM int printf(const char *, ...); 48611038SRao.Shoaib@Sun.COM __SIZE_TYPE__ fread(void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *); 48711038SRao.Shoaib@Sun.COM __SIZE_TYPE__ fwrite(const void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *); 48811038SRao.Shoaib@Sun.COM int fclose(FILE *); 48911038SRao.Shoaib@Sun.COM int ungetc(int, FILE *); 49011038SRao.Shoaib@Sun.COM int scanf(const char *, ...); 49111038SRao.Shoaib@Sun.COM int sscanf(const char *, const char *, ... ); 49211038SRao.Shoaib@Sun.COM int tolower(int); 49311038SRao.Shoaib@Sun.COM int toupper(int); 49411038SRao.Shoaib@Sun.COM int strcasecmp(const char *, const char *); 49511038SRao.Shoaib@Sun.COM int strncasecmp(const char *, const char *, int); 49611038SRao.Shoaib@Sun.COM int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); 49711038SRao.Shoaib@Sun.COM #ifdef gettimeofday 49811038SRao.Shoaib@Sun.COM #undef gettimeofday 49911038SRao.Shoaib@Sun.COM int gettimeofday(struct timeval *, struct timezone *); 50011038SRao.Shoaib@Sun.COM #define gettimeofday isc__gettimeofday 50111038SRao.Shoaib@Sun.COM #else 50211038SRao.Shoaib@Sun.COM int gettimeofday(struct timeval *, struct timezone *); 50311038SRao.Shoaib@Sun.COM #endif 50411038SRao.Shoaib@Sun.COM long strtol(const char*, char **, int); 50511038SRao.Shoaib@Sun.COM int fseek(FILE *, long, int); 50611038SRao.Shoaib@Sun.COM int setsockopt(int, int, int, const char *, int); 50711038SRao.Shoaib@Sun.COM int bind(int, const struct sockaddr *, int); 50811038SRao.Shoaib@Sun.COM void bcopy(char *, char *, int); 50911038SRao.Shoaib@Sun.COM int fputc(char, FILE *); 51011038SRao.Shoaib@Sun.COM int listen(int, int); 51111038SRao.Shoaib@Sun.COM int accept(int, struct sockaddr *, int *); 51211038SRao.Shoaib@Sun.COM int getsockopt(int, int, int, char *, int *); 51311038SRao.Shoaib@Sun.COM int vfprintf(FILE *, const char *, va_list); 51411038SRao.Shoaib@Sun.COM int fflush(FILE *); 51511038SRao.Shoaib@Sun.COM int fgetc(FILE *); 51611038SRao.Shoaib@Sun.COM int fputs(const char *, FILE *); 51711038SRao.Shoaib@Sun.COM int fchown(int, int, int); 51811038SRao.Shoaib@Sun.COM void setbuf(FILE *, char *); 51911038SRao.Shoaib@Sun.COM int gethostname(char *, int); 52011038SRao.Shoaib@Sun.COM int rename(const char *, const char *); 52111038SRao.Shoaib@Sun.COM time_t time(time_t *); 52211038SRao.Shoaib@Sun.COM int fscanf(FILE *, const char *, ...); 52311038SRao.Shoaib@Sun.COM int sscanf(const char *, const char *, ...); 52411038SRao.Shoaib@Sun.COM int ioctl(int, int, caddr_t); 52511038SRao.Shoaib@Sun.COM void perror(const char *); 52611038SRao.Shoaib@Sun.COM 52711038SRao.Shoaib@Sun.COM #if !defined(__USE_FIXED_PROTOTYPES__) && !defined(__cplusplus) && !defined(__STRICT_ANSI__) 52811038SRao.Shoaib@Sun.COM /* 52911038SRao.Shoaib@Sun.COM * 'gcc -ansi' changes the prototype for vsprintf(). 53011038SRao.Shoaib@Sun.COM * Use this prototype when 'gcc -ansi' is not in effect. 53111038SRao.Shoaib@Sun.COM */ 53211038SRao.Shoaib@Sun.COM char *vsprintf(char *, const char *, va_list); 53311038SRao.Shoaib@Sun.COM #endif 53411038SRao.Shoaib@Sun.COM #endif 53511038SRao.Shoaib@Sun.COM 53611038SRao.Shoaib@Sun.COM /* Solaris-specific changes */ 53711038SRao.Shoaib@Sun.COM #include "sunw_port_after.h" 53811038SRao.Shoaib@Sun.COM 539*13093SRoger.Faulkner@Oracle.COM #endif /* port_after_h */ 540