defines.h revision 240075
1124208Sdes/* 2124208Sdes * Copyright (c) 1999-2003 Damien Miller. All rights reserved. 3124208Sdes * 4124208Sdes * Redistribution and use in source and binary forms, with or without 5124208Sdes * modification, are permitted provided that the following conditions 6124208Sdes * are met: 7124208Sdes * 1. Redistributions of source code must retain the above copyright 8124208Sdes * notice, this list of conditions and the following disclaimer. 9124208Sdes * 2. Redistributions in binary form must reproduce the above copyright 10124208Sdes * notice, this list of conditions and the following disclaimer in the 11124208Sdes * documentation and/or other materials provided with the distribution. 12124208Sdes * 13124208Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14124208Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15124208Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16124208Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17124208Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18124208Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19124208Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20124208Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21124208Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22124208Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23124208Sdes */ 24124208Sdes 2598937Sdes#ifndef _DEFINES_H 2698937Sdes#define _DEFINES_H 2798937Sdes 28197679Sdes/* $Id: defines.h,v 1.169 2012/02/15 04:13:06 tim Exp $ */ 2998937Sdes 3098937Sdes 3198937Sdes/* Constants */ 3298937Sdes 33162852Sdes#if defined(HAVE_DECL_SHUT_RD) && HAVE_DECL_SHUT_RD == 0 3498937Sdesenum 3598937Sdes{ 3698937Sdes SHUT_RD = 0, /* No more receptions. */ 3798937Sdes SHUT_WR, /* No more transmissions. */ 3898937Sdes SHUT_RDWR /* No more receptions or transmissions. */ 3998937Sdes}; 4098937Sdes# define SHUT_RD SHUT_RD 4198937Sdes# define SHUT_WR SHUT_WR 4298937Sdes# define SHUT_RDWR SHUT_RDWR 4398937Sdes#endif 4498937Sdes 4598937Sdes/* 4698937Sdes * Definitions for IP type of service (ip_tos) 4798937Sdes */ 4898937Sdes#include <netinet/in_systm.h> 4998937Sdes#include <netinet/ip.h> 5098937Sdes#ifndef IPTOS_LOWDELAY 5198937Sdes# define IPTOS_LOWDELAY 0x10 5298937Sdes# define IPTOS_THROUGHPUT 0x08 5398937Sdes# define IPTOS_RELIABILITY 0x04 5498937Sdes# define IPTOS_LOWCOST 0x02 5598937Sdes# define IPTOS_MINCOST IPTOS_LOWCOST 5698937Sdes#endif /* IPTOS_LOWDELAY */ 57149749Sdes 58149749Sdes/* 59149749Sdes * Definitions for DiffServ Codepoints as per RFC2474 60149749Sdes */ 61149749Sdes#ifndef IPTOS_DSCP_AF11 6298937Sdes# define IPTOS_DSCP_AF11 0x28 6398937Sdes# define IPTOS_DSCP_AF12 0x30 6498937Sdes# define IPTOS_DSCP_AF13 0x38 65149749Sdes# define IPTOS_DSCP_AF21 0x48 66149749Sdes# define IPTOS_DSCP_AF22 0x50 67149749Sdes# define IPTOS_DSCP_AF23 0x58 68149749Sdes# define IPTOS_DSCP_AF31 0x68 69149749Sdes# define IPTOS_DSCP_AF32 0x70 70149749Sdes# define IPTOS_DSCP_AF33 0x78 71181111Sdes# define IPTOS_DSCP_AF41 0x88 72149749Sdes# define IPTOS_DSCP_AF42 0x90 73149749Sdes# define IPTOS_DSCP_AF43 0x98 74149749Sdes# define IPTOS_DSCP_EF 0xb8 7598937Sdes#endif /* IPTOS_DSCP_AF11 */ 7698937Sdes#ifndef IPTOS_DSCP_CS0 7798937Sdes# define IPTOS_DSCP_CS0 0x00 7898937Sdes# define IPTOS_DSCP_CS1 0x20 7998937Sdes# define IPTOS_DSCP_CS2 0x40 8098937Sdes# define IPTOS_DSCP_CS3 0x60 8198937Sdes# define IPTOS_DSCP_CS4 0x80 8298937Sdes# define IPTOS_DSCP_CS5 0xa0 8398937Sdes# define IPTOS_DSCP_CS6 0xc0 8498937Sdes# define IPTOS_DSCP_CS7 0xe0 8598937Sdes#endif /* IPTOS_DSCP_CS0 */ 8698937Sdes#ifndef IPTOS_DSCP_EF 8798937Sdes# define IPTOS_DSCP_EF 0xb8 8898937Sdes#endif /* IPTOS_DSCP_EF */ 8998937Sdes 9098937Sdes#ifndef PATH_MAX 9198937Sdes# ifdef _POSIX_PATH_MAX 9298937Sdes# define PATH_MAX _POSIX_PATH_MAX 93162852Sdes# endif 94162852Sdes#endif 9598937Sdes 9698937Sdes#ifndef MAXPATHLEN 9798937Sdes# ifdef PATH_MAX 9898937Sdes# define MAXPATHLEN PATH_MAX 9998937Sdes# else /* PATH_MAX */ 10098937Sdes# define MAXPATHLEN 64 101126274Sdes/* realpath uses a fixed buffer of size MAXPATHLEN, so force use of ours */ 10298937Sdes# ifndef BROKEN_REALPATH 10398937Sdes# define BROKEN_REALPATH 1 10498937Sdes# endif /* BROKEN_REALPATH */ 10598937Sdes# endif /* PATH_MAX */ 10698937Sdes#endif /* MAXPATHLEN */ 10798937Sdes 10898937Sdes#if defined(HAVE_DECL_MAXSYMLINKS) && HAVE_DECL_MAXSYMLINKS == 0 10998937Sdes# define MAXSYMLINKS 5 11098937Sdes#endif 11198937Sdes 11298937Sdes#ifndef STDIN_FILENO 11398937Sdes# define STDIN_FILENO 0 11498937Sdes#endif 11598937Sdes#ifndef STDOUT_FILENO 11698937Sdes# define STDOUT_FILENO 1 11798937Sdes#endif 11898937Sdes#ifndef STDERR_FILENO 11998937Sdes# define STDERR_FILENO 2 12098937Sdes#endif 12198937Sdes 12298937Sdes#ifndef NGROUPS_MAX /* Disable groupaccess if NGROUP_MAX is not set */ 12398937Sdes#ifdef NGROUPS 12498937Sdes#define NGROUPS_MAX NGROUPS 12598937Sdes#else 12698937Sdes#define NGROUPS_MAX 0 12798937Sdes#endif 12898937Sdes#endif 12998937Sdes 13098937Sdes#if defined(HAVE_DECL_O_NONBLOCK) && HAVE_DECL_O_NONBLOCK == 0 13198937Sdes# define O_NONBLOCK 00004 /* Non Blocking Open */ 13298937Sdes#endif 13398937Sdes 13498937Sdes#ifndef S_IFSOCK 13598937Sdes# define S_IFSOCK 0 13698937Sdes#endif /* S_IFSOCK */ 13798937Sdes 13898937Sdes#ifndef S_ISDIR 13998937Sdes# define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR)) 14098937Sdes#endif /* S_ISDIR */ 14198937Sdes 14298937Sdes#ifndef S_ISREG 143106121Sdes# define S_ISREG(mode) (((mode) & (_S_IFMT)) == (_S_IFREG)) 14498937Sdes#endif /* S_ISREG */ 14598937Sdes 14698937Sdes#ifndef S_ISLNK 14798937Sdes# define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) 14898937Sdes#endif /* S_ISLNK */ 14998937Sdes 15098937Sdes#ifndef S_IXUSR 15198937Sdes# define S_IXUSR 0000100 /* execute/search permission, */ 15298937Sdes# define S_IXGRP 0000010 /* execute/search permission, */ 15398937Sdes# define S_IXOTH 0000001 /* execute/search permission, */ 15498937Sdes# define _S_IWUSR 0000200 /* write permission, */ 15598937Sdes# define S_IWUSR _S_IWUSR /* write permission, owner */ 15698937Sdes# define S_IWGRP 0000020 /* write permission, group */ 15798937Sdes# define S_IWOTH 0000002 /* write permission, other */ 15898937Sdes# define S_IRUSR 0000400 /* read permission, owner */ 15998937Sdes# define S_IRGRP 0000040 /* read permission, group */ 16098937Sdes# define S_IROTH 0000004 /* read permission, other */ 16198937Sdes# define S_IRWXU 0000700 /* read, write, execute */ 16298937Sdes# define S_IRWXG 0000070 /* read, write, execute */ 16398937Sdes# define S_IRWXO 0000007 /* read, write, execute */ 164106121Sdes#endif /* S_IXUSR */ 16598937Sdes 16698937Sdes#if !defined(MAP_ANON) && defined(MAP_ANONYMOUS) 16798937Sdes#define MAP_ANON MAP_ANONYMOUS 16898937Sdes#endif 16998937Sdes 17098937Sdes#ifndef MAP_FAILED 17198937Sdes# define MAP_FAILED ((void *)-1) 172106121Sdes#endif 17398937Sdes 17498937Sdes/* *-*-nto-qnx doesn't define this constant in the system headers */ 17598937Sdes#ifdef MISSING_NFDBITS 17698937Sdes# define NFDBITS (8 * sizeof(unsigned long)) 177106121Sdes#endif 17898937Sdes 17998937Sdes/* 18098937SdesSCO Open Server 3 has INADDR_LOOPBACK defined in rpc/rpc.h but 181106121Sdesincluding rpc/rpc.h breaks Solaris 6 18298937Sdes*/ 18398937Sdes#ifndef INADDR_LOOPBACK 18498937Sdes#define INADDR_LOOPBACK ((u_long)0x7f000001) 18598937Sdes#endif 18698937Sdes 18798937Sdes/* Types */ 18898937Sdes 18998937Sdes/* If sys/types.h does not supply intXX_t, supply them ourselves */ 19098937Sdes/* (or die trying) */ 19198937Sdes 19298937Sdes#ifndef HAVE_U_INT 19398937Sdestypedef unsigned int u_int; 19498937Sdes#endif 19598937Sdes 19698937Sdes#ifndef HAVE_INTXX_T 19798937Sdestypedef signed char int8_t; 19898937Sdes# if (SIZEOF_SHORT_INT == 2) 19998937Sdestypedef short int int16_t; 20098937Sdes# else 201106121Sdes# ifdef _UNICOS 20298937Sdes# if (SIZEOF_SHORT_INT == 4) 20398937Sdestypedef short int16_t; 20498937Sdes# else 20598937Sdestypedef long int16_t; 20698937Sdes# endif 20798937Sdes# else 20898937Sdes# error "16 bit int type not found." 20998937Sdes# endif /* _UNICOS */ 21098937Sdes# endif 21198937Sdes# if (SIZEOF_INT == 4) 21298937Sdestypedef int int32_t; 21398937Sdes# else 214106121Sdes# ifdef _UNICOS 21598937Sdestypedef long int32_t; 21698937Sdes# else 21798937Sdes# error "32 bit int type not found." 21898937Sdes# endif /* _UNICOS */ 21998937Sdes# endif 22098937Sdes#endif 22198937Sdes 22298937Sdes/* If sys/types.h does not supply u_intXX_t, supply them ourselves */ 22398937Sdes#ifndef HAVE_U_INTXX_T 22498937Sdes# ifdef HAVE_UINTXX_T 22598937Sdestypedef uint8_t u_int8_t; 22698937Sdestypedef uint16_t u_int16_t; 22798937Sdestypedef uint32_t u_int32_t; 22898937Sdes# define HAVE_U_INTXX_T 1 22998937Sdes# else 23098937Sdes# if (SIZEOF_CHAR == 1) 23198937Sdestypedef unsigned char u_int8_t; 23298937Sdes# else 23398937Sdes# error "8 bit int type not found." 23498937Sdes# endif 23598937Sdes# if (SIZEOF_SHORT_INT == 2) 23698937Sdestypedef unsigned short int u_int16_t; 23798937Sdes# else 23898937Sdes# ifdef _UNICOS 23998937Sdes# if (SIZEOF_SHORT_INT == 4) 24098937Sdestypedef unsigned short u_int16_t; 24198937Sdes# else 24298937Sdestypedef unsigned long u_int16_t; 24398937Sdes# endif 24498937Sdes# else 24598937Sdes# error "16 bit int type not found." 24698937Sdes# endif 24798937Sdes# endif 24898937Sdes# if (SIZEOF_INT == 4) 249106121Sdestypedef unsigned int u_int32_t; 250106121Sdes# else 251106121Sdes# ifdef _UNICOS 252106121Sdestypedef unsigned long u_int32_t; 25398937Sdes# else 25498937Sdes# error "32 bit int type not found." 25598937Sdes# endif 256126274Sdes# endif 25798937Sdes# endif 25898937Sdes#define __BIT_TYPES_DEFINED__ 25998937Sdes#endif 26098937Sdes 26198937Sdes/* 64-bit types */ 26298937Sdes#ifndef HAVE_INT64_T 26398937Sdes# if (SIZEOF_LONG_INT == 8) 26498937Sdestypedef long int int64_t; 26598937Sdes# else 26698937Sdes# if (SIZEOF_LONG_LONG_INT == 8) 26798937Sdestypedef long long int int64_t; 26898937Sdes# endif 26998937Sdes# endif 27098937Sdes#endif 27198937Sdes#ifndef HAVE_U_INT64_T 27298937Sdes# if (SIZEOF_LONG_INT == 8) 27398937Sdestypedef unsigned long int u_int64_t; 27498937Sdes# else 27598937Sdes# if (SIZEOF_LONG_LONG_INT == 8) 27698937Sdestypedef unsigned long long int u_int64_t; 27798937Sdes# endif 27898937Sdes# endif 27998937Sdes#endif 28098937Sdes 28198937Sdes#ifndef HAVE_U_CHAR 28298937Sdestypedef unsigned char u_char; 28398937Sdes# define HAVE_U_CHAR 28498937Sdes#endif /* HAVE_U_CHAR */ 28598937Sdes 28698937Sdes#ifndef SIZE_T_MAX 28798937Sdes#define SIZE_T_MAX ULONG_MAX 28898937Sdes#endif /* SIZE_T_MAX */ 28998937Sdes 29098937Sdes#ifndef HAVE_SIZE_T 29198937Sdestypedef unsigned int size_t; 29298937Sdes# define HAVE_SIZE_T 29398937Sdes# define SIZE_T_MAX UINT_MAX 29498937Sdes#endif /* HAVE_SIZE_T */ 29598937Sdes 29698937Sdes#ifndef SIZE_MAX 29798937Sdes#define SIZE_MAX SIZE_T_MAX 29898937Sdes#endif 29998937Sdes 300146998Sdes#ifndef HAVE_SSIZE_T 301146998Sdestypedef int ssize_t; 302146998Sdes# define HAVE_SSIZE_T 303197679Sdes#endif /* HAVE_SSIZE_T */ 304197679Sdes 305197679Sdes#ifndef HAVE_CLOCK_T 306146998Sdestypedef long clock_t; 30798937Sdes# define HAVE_CLOCK_T 30898937Sdes#endif /* HAVE_CLOCK_T */ 30998937Sdes 31098937Sdes#ifndef HAVE_SA_FAMILY_T 31198937Sdestypedef int sa_family_t; 31298937Sdes# define HAVE_SA_FAMILY_T 31398937Sdes#endif /* HAVE_SA_FAMILY_T */ 31498937Sdes 31598937Sdes#ifndef HAVE_PID_T 31698937Sdestypedef int pid_t; 31798937Sdes# define HAVE_PID_T 31898937Sdes#endif /* HAVE_PID_T */ 31998937Sdes 32098937Sdes#ifndef HAVE_SIG_ATOMIC_T 32198937Sdestypedef int sig_atomic_t; 32298937Sdes# define HAVE_SIG_ATOMIC_T 32398937Sdes#endif /* HAVE_SIG_ATOMIC_T */ 32498937Sdes 32598937Sdes#ifndef HAVE_MODE_T 32698937Sdestypedef int mode_t; 32798937Sdes# define HAVE_MODE_T 32898937Sdes#endif /* HAVE_MODE_T */ 32998937Sdes 33098937Sdes#if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS) 33198937Sdes# define ss_family __ss_family 33298937Sdes#endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */ 33398937Sdes 33498937Sdes#ifndef HAVE_SYS_UN_H 33598937Sdesstruct sockaddr_un { 33698937Sdes short sun_family; /* AF_UNIX */ 33798937Sdes char sun_path[108]; /* path name (gag) */ 33898937Sdes}; 339124208Sdes#endif /* HAVE_SYS_UN_H */ 340124208Sdes 341124208Sdes#ifndef HAVE_IN_ADDR_T 342124208Sdestypedef u_int32_t in_addr_t; 34398937Sdes#endif 34498937Sdes#ifndef HAVE_IN_PORT_T 34598937Sdestypedef u_int16_t in_port_t; 34698937Sdes#endif 34798937Sdes 34898937Sdes#if defined(BROKEN_SYS_TERMIO_H) && !defined(_STRUCT_WINSIZE) 34998937Sdes#define _STRUCT_WINSIZE 35098937Sdesstruct winsize { 35198937Sdes unsigned short ws_row; /* rows, in characters */ 35298937Sdes unsigned short ws_col; /* columns, in character */ 35398937Sdes unsigned short ws_xpixel; /* horizontal size, pixels */ 35498937Sdes unsigned short ws_ypixel; /* vertical size, pixels */ 35598937Sdes}; 35698937Sdes#endif 35798937Sdes 35898937Sdes/* *-*-nto-qnx does not define this type in the system headers */ 35998937Sdes#ifdef MISSING_FD_MASK 36098937Sdes typedef unsigned long int fd_mask; 36198937Sdes#endif 36298937Sdes 36398937Sdes/* Paths */ 36498937Sdes 36598937Sdes#ifndef _PATH_BSHELL 36698937Sdes# define _PATH_BSHELL "/bin/sh" 36798937Sdes#endif 36898937Sdes 36998937Sdes#ifdef USER_PATH 37098937Sdes# ifdef _PATH_STDPATH 37198937Sdes# undef _PATH_STDPATH 37298937Sdes# endif 37398937Sdes# define _PATH_STDPATH USER_PATH 37498937Sdes#endif 37598937Sdes 37698937Sdes#ifndef _PATH_STDPATH 37798937Sdes# define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin" 37898937Sdes#endif 37998937Sdes 38098937Sdes#ifndef SUPERUSER_PATH 38198937Sdes# define SUPERUSER_PATH _PATH_STDPATH 38298937Sdes#endif 38398937Sdes 38498937Sdes#ifndef _PATH_DEVNULL 38598937Sdes# define _PATH_DEVNULL "/dev/null" 38698937Sdes#endif 38798937Sdes 38898937Sdes/* user may have set a different path */ 38998937Sdes#if defined(_PATH_MAILDIR) && defined(MAIL_DIRECTORY) 39098937Sdes# undef _PATH_MAILDIR MAILDIR 39198937Sdes#endif /* defined(_PATH_MAILDIR) && defined(MAIL_DIRECTORY) */ 39298937Sdes 39398937Sdes#ifdef MAIL_DIRECTORY 39498937Sdes# define _PATH_MAILDIR MAIL_DIRECTORY 39598937Sdes#endif 39698937Sdes 39798937Sdes#ifndef _PATH_NOLOGIN 39898937Sdes# define _PATH_NOLOGIN "/etc/nologin" 39998937Sdes#endif 40098937Sdes 40198937Sdes/* Define this to be the path of the xauth program. */ 40298937Sdes#ifdef XAUTH_PATH 40398937Sdes#define _PATH_XAUTH XAUTH_PATH 40498937Sdes#endif /* XAUTH_PATH */ 40598937Sdes 40698937Sdes/* derived from XF4/xc/lib/dps/Xlibnet.h */ 40798937Sdes#ifndef X_UNIX_PATH 40898937Sdes# ifdef __hpux 409113908Sdes# define X_UNIX_PATH "/var/spool/sockets/X11/%u" 410113908Sdes# else 411113908Sdes# define X_UNIX_PATH "/tmp/.X11-unix/X%u" 412113908Sdes# endif 413113908Sdes#endif /* X_UNIX_PATH */ 414113908Sdes#define _PATH_UNIX_X X_UNIX_PATH 415113908Sdes 416113908Sdes#ifndef _PATH_TTY 417113908Sdes# define _PATH_TTY "/dev/tty" 418113908Sdes#endif 419113908Sdes 420113908Sdes/* Macros */ 421113908Sdes 422113908Sdes#if defined(HAVE_LOGIN_GETCAPBOOL) && defined(HAVE_LOGIN_CAP_H) 42398937Sdes# define HAVE_LOGIN_CAP 42498937Sdes#endif 42598937Sdes 42698937Sdes#ifndef MAX 42798937Sdes# define MAX(a,b) (((a)>(b))?(a):(b)) 42898937Sdes# define MIN(a,b) (((a)<(b))?(a):(b)) 42998937Sdes#endif 43098937Sdes 43198937Sdes#ifndef roundup 43298937Sdes# define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 43398937Sdes#endif 43498937Sdes 43598937Sdes#ifndef timersub 43698937Sdes#define timersub(a, b, result) \ 437149749Sdes do { \ 438149749Sdes (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ 439149749Sdes (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ 440149749Sdes if ((result)->tv_usec < 0) { \ 441157016Sdes --(result)->tv_sec; \ 442157016Sdes (result)->tv_usec += 1000000; \ 443157016Sdes } \ 444157016Sdes } while (0) 445181111Sdes#endif 446181111Sdes 447181111Sdes#ifndef TIMEVAL_TO_TIMESPEC 448181111Sdes#define TIMEVAL_TO_TIMESPEC(tv, ts) { \ 44998937Sdes (ts)->tv_sec = (tv)->tv_sec; \ 45098937Sdes (ts)->tv_nsec = (tv)->tv_usec * 1000; \ 45198937Sdes} 45298937Sdes#endif 45398937Sdes 45498937Sdes#ifndef TIMESPEC_TO_TIMEVAL 45598937Sdes#define TIMESPEC_TO_TIMEVAL(tv, ts) { \ 45698937Sdes (tv)->tv_sec = (ts)->tv_sec; \ 45798937Sdes (tv)->tv_usec = (ts)->tv_nsec / 1000; \ 45898937Sdes} 45998937Sdes#endif 46098937Sdes 46198937Sdes#ifndef __P 46298937Sdes# define __P(x) x 46398937Sdes#endif 46498937Sdes 46598937Sdes#if !defined(IN6_IS_ADDR_V4MAPPED) 46698937Sdes# define IN6_IS_ADDR_V4MAPPED(a) \ 46798937Sdes ((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \ 46898937Sdes (((u_int32_t *) (a))[2] == htonl (0xffff))) 46998937Sdes#endif /* !defined(IN6_IS_ADDR_V4MAPPED) */ 47098937Sdes 471124208Sdes#if !defined(__GNUC__) || (__GNUC__ < 2) 472124208Sdes# define __attribute__(x) 473124208Sdes#endif /* !defined(__GNUC__) || (__GNUC__ < 2) */ 474124208Sdes 475124208Sdes#if !defined(HAVE_ATTRIBUTE__SENTINEL__) && !defined(__sentinel__) 476124208Sdes# define __sentinel__ 477124208Sdes#endif 478124208Sdes 479124208Sdes#if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__bounded__) 480124208Sdes# define __bounded__(x, y, z) 481124208Sdes#endif 482124208Sdes 483124208Sdes#if !defined(HAVE_ATTRIBUTE__NONNULL__) && !defined(__nonnull__) 484124208Sdes# define __nonnull__(x) 485124208Sdes#endif 486124208Sdes 487181111Sdes/* *-*-nto-qnx doesn't define this macro in the system headers */ 488137015Sdes#ifdef MISSING_HOWMANY 489137015Sdes# define howmany(x,y) (((x)+((y)-1))/(y)) 490124208Sdes#endif 491162852Sdes 492162852Sdes#ifndef OSSH_ALIGNBYTES 493162852Sdes#define OSSH_ALIGNBYTES (sizeof(int) - 1) 494162852Sdes#endif 495162852Sdes#ifndef __CMSG_ALIGN 496162852Sdes#define __CMSG_ALIGN(p) (((u_int)(p) + OSSH_ALIGNBYTES) &~ OSSH_ALIGNBYTES) 497162852Sdes#endif 498162852Sdes 499162852Sdes/* Length of the contents of a control message of length len */ 500162852Sdes#ifndef CMSG_LEN 501162852Sdes#define CMSG_LEN(len) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + (len)) 502162852Sdes#endif 503162852Sdes 504162852Sdes/* Length of the space taken up by a padded control message of length len */ 505162852Sdes#ifndef CMSG_SPACE 506162852Sdes#define CMSG_SPACE(len) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + __CMSG_ALIGN(len)) 50798937Sdes#endif 50898937Sdes 50998937Sdes/* given pointer to struct cmsghdr, return pointer to data */ 51098937Sdes#ifndef CMSG_DATA 51198937Sdes#define CMSG_DATA(cmsg) ((u_char *)(cmsg) + __CMSG_ALIGN(sizeof(struct cmsghdr))) 51298937Sdes#endif /* CMSG_DATA */ 51398937Sdes 51499060Sdes/* 51599060Sdes * RFC 2292 requires to check msg_controllen, in case that the kernel returns 51699060Sdes * an empty list for some reasons. 51799060Sdes */ 51899060Sdes#ifndef CMSG_FIRSTHDR 51999060Sdes#define CMSG_FIRSTHDR(mhdr) \ 52099060Sdes ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ 52199060Sdes (struct cmsghdr *)(mhdr)->msg_control : \ 52299060Sdes (struct cmsghdr *)NULL) 52399060Sdes#endif /* CMSG_FIRSTHDR */ 52499060Sdes 52599060Sdes#if defined(HAVE_DECL_OFFSETOF) && HAVE_DECL_OFFSETOF == 0 52698937Sdes# define offsetof(type, member) ((size_t) &((type *)0)->member) 52798937Sdes#endif 52898937Sdes 52998937Sdes/* Set up BSD-style BYTE_ORDER definition if it isn't there already */ 53098937Sdes/* XXX: doesn't try to cope with strange byte orders (PDP_ENDIAN) */ 53198937Sdes#ifndef BYTE_ORDER 53298937Sdes# ifndef LITTLE_ENDIAN 53398937Sdes# define LITTLE_ENDIAN 1234 53498937Sdes# endif /* LITTLE_ENDIAN */ 53598937Sdes# ifndef BIG_ENDIAN 53698937Sdes# define BIG_ENDIAN 4321 53798937Sdes# endif /* BIG_ENDIAN */ 538128456Sdes# ifdef WORDS_BIGENDIAN 539128456Sdes# define BYTE_ORDER BIG_ENDIAN 540128456Sdes# else /* WORDS_BIGENDIAN */ 541128456Sdes# define BYTE_ORDER LITTLE_ENDIAN 542181111Sdes# endif /* WORDS_BIGENDIAN */ 543181111Sdes#endif /* BYTE_ORDER */ 544181111Sdes 545181111Sdes/* Function replacement / compatibility hacks */ 546162852Sdes 547162852Sdes#if !defined(HAVE_GETADDRINFO) && (defined(HAVE_OGETADDRINFO) || defined(HAVE_NGETADDRINFO)) 548162852Sdes# define HAVE_GETADDRINFO 549162852Sdes#endif 550162852Sdes 55198937Sdes#ifndef HAVE_GETOPT_OPTRESET 55298937Sdes# undef getopt 55398937Sdes# undef opterr 55498937Sdes# undef optind 55598937Sdes# undef optopt 55698937Sdes# undef optreset 55798937Sdes# undef optarg 55898937Sdes# define getopt(ac, av, o) BSDgetopt(ac, av, o) 55998937Sdes# define opterr BSDopterr 560162852Sdes# define optind BSDoptind 56198937Sdes# define optopt BSDoptopt 56298937Sdes# define optreset BSDoptreset 56398937Sdes# define optarg BSDoptarg 564146998Sdes#endif 565146998Sdes 566146998Sdes#if defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO) 567146998Sdes# undef HAVE_GETADDRINFO 568146998Sdes#endif 56998937Sdes#if defined(BROKEN_GETADDRINFO) && defined(HAVE_FREEADDRINFO) 57098937Sdes# undef HAVE_FREEADDRINFO 57198937Sdes#endif 57298937Sdes#if defined(BROKEN_GETADDRINFO) && defined(HAVE_GAI_STRERROR) 57398937Sdes# undef HAVE_GAI_STRERROR 57498937Sdes#endif 575124208Sdes 576124208Sdes#if defined(BROKEN_UPDWTMPX) && defined(HAVE_UPDWTMPX) 577124208Sdes# undef HAVE_UPDWTMPX 578124208Sdes#endif 579128456Sdes 580128456Sdes#if defined(BROKEN_SHADOW_EXPIRE) && defined(HAS_SHADOW_EXPIRE) 581128456Sdes# undef HAS_SHADOW_EXPIRE 582128456Sdes#endif 583128456Sdes 584128456Sdes#if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT) && \ 585126274Sdes defined(SYSLOG_R_SAFE_IN_SIGHAND) 586126274Sdes# define DO_LOG_SAFE_IN_SIGHAND 587126274Sdes#endif 588126274Sdes 589126274Sdes#if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) 590126274Sdes# define memmove(s1, s2, n) bcopy((s2), (s1), (n)) 591126274Sdes#endif /* !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) */ 592181111Sdes 593181111Sdes#if defined(HAVE_VHANGUP) && !defined(HAVE_DEV_PTMX) 594181111Sdes# define USE_VHANGUP 595181111Sdes#endif /* defined(HAVE_VHANGUP) && !defined(HAVE_DEV_PTMX) */ 596181111Sdes 597197679Sdes#ifndef GETPGRP_VOID 598197679Sdes# include <unistd.h> 599197679Sdes# define getpgrp() getpgrp(0) 600197679Sdes#endif 601181111Sdes 602181111Sdes#ifdef USE_BSM_AUDIT 603181111Sdes# define SSH_AUDIT_EVENTS 604181111Sdes# define CUSTOM_SSH_AUDIT_EVENTS 605149749Sdes#endif 606149749Sdes 607149749Sdes#ifdef USE_LINUX_AUDIT 608149749Sdes# define SSH_AUDIT_EVENTS 609149749Sdes# define CUSTOM_SSH_AUDIT_EVENTS 610149749Sdes#endif 611149749Sdes 612149749Sdes#if !defined(HAVE___func__) && defined(HAVE___FUNCTION__) 613149749Sdes# define __func__ __FUNCTION__ 614149749Sdes#elif !defined(HAVE___func__) 615149749Sdes# define __func__ "" 616149749Sdes#endif 617149749Sdes 618149749Sdes#if defined(KRB5) && !defined(HEIMDAL) 619149749Sdes# define krb5_get_err_text(context,code) error_message(code) 620149749Sdes#endif 621149749Sdes 622126274Sdes#if defined(SKEYCHALLENGE_4ARG) 62398937Sdes# define _compat_skeychallenge(a,b,c,d) skeychallenge(a,b,c,d) 62498937Sdes#else 62598937Sdes# define _compat_skeychallenge(a,b,c,d) skeychallenge(a,b,c) 62698937Sdes#endif 62798937Sdes 62898937Sdes/* Maximum number of file descriptors available */ 62998937Sdes#ifdef HAVE_SYSCONF 63098937Sdes# define SSH_SYSFDMAX sysconf(_SC_OPEN_MAX) 63198937Sdes#else 63298937Sdes# define SSH_SYSFDMAX 10000 63398937Sdes#endif 63498937Sdes 63598937Sdes#ifdef FSID_HAS_VAL 63698937Sdes/* encode f_fsid into a 64 bit value */ 63798937Sdes#define FSID_TO_ULONG(f) \ 63898937Sdes ((((u_int64_t)(f).val[0] & 0xffffffffUL) << 32) | \ 63998937Sdes ((f).val[1] & 0xffffffffUL)) 64098937Sdes#elif defined(FSID_HAS___VAL) 64198937Sdes#define FSID_TO_ULONG(f) \ 64298937Sdes ((((u_int64_t)(f).__val[0] & 0xffffffffUL) << 32) | \ 64398937Sdes ((f).__val[1] & 0xffffffffUL)) 64498937Sdes#else 64598937Sdes# define FSID_TO_ULONG(f) ((f)) 64698937Sdes#endif 64798937Sdes 64898937Sdes#if defined(__Lynx__) 64998937Sdes /* 65098937Sdes * LynxOS defines these in param.h which we do not want to include since 65198937Sdes * it will also pull in a bunch of kernel definitions. 65298937Sdes */ 65398937Sdes# define ALIGNBYTES (sizeof(int) - 1) 65498937Sdes# define ALIGN(p) (((unsigned)p + ALIGNBYTES) & ~ALIGNBYTES) 65598937Sdes /* Missing prototypes on LynxOS */ 65698937Sdes int snprintf (char *, size_t, const char *, ...); 65798937Sdes int mkstemp (char *); 65898937Sdes char *crypt (const char *, const char *); 65998937Sdes int seteuid (uid_t); 66098937Sdes int setegid (gid_t); 66198937Sdes char *mkdtemp (char *); 66298937Sdes int rresvport_af (int *, sa_family_t); 66398937Sdes int innetgr (const char *, const char *, const char *, const char *); 66498937Sdes#endif 66598937Sdes 666126274Sdes/* 667126274Sdes * Define this to use pipes instead of socketpairs for communicating with the 668126274Sdes * client program. Socketpairs do not seem to work on all systems. 66998937Sdes * 67098937Sdes * configure.ac sets this for a few OS's which are known to have problems 67198937Sdes * but you may need to set it yourself 67298937Sdes */ 67398937Sdes/* #define USE_PIPES 1 */ 67498937Sdes 67598937Sdes/** 67698937Sdes ** login recorder definitions 677202213Sed **/ 67898937Sdes 67998937Sdes/* FIXME: put default paths back in */ 68098937Sdes#ifndef UTMP_FILE 68198937Sdes# ifdef _PATH_UTMP 68298937Sdes# define UTMP_FILE _PATH_UTMP 68398937Sdes# else 68498937Sdes# ifdef CONF_UTMP_FILE 68598937Sdes# define UTMP_FILE CONF_UTMP_FILE 68698937Sdes# endif 68798937Sdes# endif 68898937Sdes#endif 68998937Sdes#ifndef WTMP_FILE 69098937Sdes# ifdef _PATH_WTMP 69198937Sdes# define WTMP_FILE _PATH_WTMP 692128456Sdes# else 693128456Sdes# ifdef CONF_WTMP_FILE 694128456Sdes# define WTMP_FILE CONF_WTMP_FILE 695128456Sdes# endif 69698937Sdes# endif 69798937Sdes#endif 69898937Sdes/* pick up the user's location for lastlog if given */ 69998937Sdes#ifndef LASTLOG_FILE 70098937Sdes# ifdef _PATH_LASTLOG 701128456Sdes# define LASTLOG_FILE _PATH_LASTLOG 702128456Sdes# else 703128456Sdes# ifdef CONF_LASTLOG_FILE 704128456Sdes# define LASTLOG_FILE CONF_LASTLOG_FILE 705128456Sdes# endif 706128456Sdes# endif 707128456Sdes#endif 708192595Sdes 709149749Sdes#if defined(HAVE_SHADOW_H) && !defined(DISABLE_SHADOW) 710149749Sdes# define USE_SHADOW 711181111Sdes#endif 712181111Sdes 713181111Sdes/* The login() library function in libutil is first choice */ 714149749Sdes#if defined(HAVE_LOGIN) && !defined(DISABLE_LOGIN) 715146998Sdes# define USE_LOGIN 716146998Sdes 717146998Sdes#else 718146998Sdes/* Simply select your favourite login types. */ 719146998Sdes/* Can't do if-else because some systems use several... <sigh> */ 720146998Sdes# if !defined(DISABLE_UTMPX) 721146998Sdes# define USE_UTMPX 722146998Sdes# endif 723146998Sdes# if defined(UTMP_FILE) && !defined(DISABLE_UTMP) 72498937Sdes# define USE_UTMP 72598937Sdes# endif 726149749Sdes# if defined(WTMPX_FILE) && !defined(DISABLE_WTMPX) 727149749Sdes# define USE_WTMPX 728149749Sdes# endif 729149749Sdes# if defined(WTMP_FILE) && !defined(DISABLE_WTMP) 730149749Sdes# define USE_WTMP 731149749Sdes# endif 732149749Sdes 733149749Sdes#endif 734162852Sdes 735162852Sdes#ifndef UT_LINESIZE 736162852Sdes# define UT_LINESIZE 8 737162852Sdes#endif 738162852Sdes 739162852Sdes/* I hope that the presence of LASTLOG_FILE is enough to detect this */ 740162852Sdes#if defined(LASTLOG_FILE) && !defined(DISABLE_LASTLOG) 741162852Sdes# define USE_LASTLOG 742157016Sdes#endif 743157016Sdes 744181111Sdes#ifdef HAVE_OSF_SIA 745181111Sdes# ifdef USE_SHADOW 746181111Sdes# undef USE_SHADOW 747181111Sdes# endif 748192595Sdes# define CUSTOM_SYS_AUTH_PASSWD 1 749192595Sdes#endif 750192595Sdes 751192595Sdes#if defined(HAVE_LIBIAF) && defined(HAVE_SET_ID) && !defined(HAVE_SECUREWARE) 752197679Sdes# define CUSTOM_SYS_AUTH_PASSWD 1 753197679Sdes#endif 754197679Sdes#if defined(HAVE_LIBIAF) && defined(HAVE_SET_ID) && !defined(BROKEN_LIBIAF) 755197679Sdes# define USE_LIBIAF 75698937Sdes#endif 757 758/* HP-UX 11.11 */ 759#ifdef BTMP_FILE 760# define _PATH_BTMP BTMP_FILE 761#endif 762 763#if defined(USE_BTMP) && defined(_PATH_BTMP) 764# define CUSTOM_FAILED_LOGIN 765#endif 766 767/** end of login recorder definitions */ 768 769#ifdef BROKEN_GETGROUPS 770# define getgroups(a,b) ((a)==0 && (b)==NULL ? NGROUPS_MAX : getgroups((a),(b))) 771#endif 772 773#if defined(HAVE_MMAP) && defined(BROKEN_MMAP) 774# undef HAVE_MMAP 775#endif 776 777#ifndef IOV_MAX 778# if defined(_XOPEN_IOV_MAX) 779# define IOV_MAX _XOPEN_IOV_MAX 780# elif defined(DEF_IOV_MAX) 781# define IOV_MAX DEF_IOV_MAX 782# else 783# define IOV_MAX 16 784# endif 785#endif 786 787#ifndef EWOULDBLOCK 788# define EWOULDBLOCK EAGAIN 789#endif 790 791#ifndef INET6_ADDRSTRLEN /* for non IPv6 machines */ 792#define INET6_ADDRSTRLEN 46 793#endif 794 795#ifndef SSH_IOBUFSZ 796# define SSH_IOBUFSZ 8192 797#endif 798 799#ifndef _NSIG 800# ifdef NSIG 801# define _NSIG NSIG 802# else 803# define _NSIG 128 804# endif 805#endif 806 807#endif /* _DEFINES_H */ 808