osdep.h revision 1.3
1/* osdep.h 2 3 Operating system dependencies... */ 4 5/* 6 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") 7 * Copyright (c) 1996-2003 by Internet Software Consortium 8 * 9 * Permission to use, copy, modify, and distribute this software for any 10 * purpose with or without fee is hereby granted, provided that the above 11 * copyright notice and this permission notice appear in all copies. 12 * 13 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 19 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20 * 21 * Internet Systems Consortium, Inc. 22 * 950 Charter Street 23 * Redwood City, CA 94063 24 * <info@isc.org> 25 * http://www.isc.org/ 26 * 27 * This software has been written for Internet Systems Consortium 28 * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc. 29 * To learn more about Internet Systems Consortium, see 30 * ``http://www.isc.org/''. To learn more about Vixie Enterprises, 31 * see ``http://www.vix.com''. To learn more about Nominum, Inc., see 32 * ``http://www.nominum.com''. 33 */ 34 35#if !defined (__ISC_DHCP_OSDEP_H__) 36#define __ISC_DHCP_OSDEP_H__ 37 38#include "site.h" 39 40/* Porting:: 41 42 If you add a new network API, you must add a check for it below: */ 43 44#if !defined (USE_SOCKETS) && \ 45 !defined (USE_SOCKET_SEND) && \ 46 !defined (USE_SOCKET_RECEIVE) && \ 47 !defined (USE_RAW_SOCKETS) && \ 48 !defined (USE_RAW_SEND) && \ 49 !defined (USE_SOCKET_RECEIVE) && \ 50 !defined (USE_BPF) && \ 51 !defined (USE_BPF_SEND) && \ 52 !defined (USE_BPF_RECEIVE) && \ 53 !defined (USE_LPF) && \ 54 !defined (USE_LPF_SEND) && \ 55 !defined (USE_LPF_RECEIVE) && \ 56 !defined (USE_NIT) && \ 57 !defined (USE_NIT_SEND) && \ 58 !defined (USE_NIT_RECEIVE) && \ 59 !defined (USR_DLPI_SEND) && \ 60 !defined (USE_DLPI_RECEIVE) 61# define USE_DEFAULT_NETWORK 62#endif 63 64#if !defined (TIME_MAX) 65# define TIME_MAX 2147483647 66#endif 67 68/* Porting:: 69 70 If you add a new system configuration file, include it here: */ 71 72#if defined (sun) 73# if defined (__svr4__) || defined (__SVR4) 74# include "cf/sunos5-5.h" 75# else 76# include "cf/sunos4.h" 77# endif 78#endif 79 80#ifdef aix 81# include "cf/aix.h" 82#endif 83 84#ifdef bsdi 85# include "cf/bsdos.h" 86#endif 87 88#ifdef __NetBSD__ 89# include "cf/netbsd.h" 90#endif 91 92#ifdef __FreeBSD__ 93# include "cf/freebsd.h" 94#endif 95 96#ifdef OpenBSD 97# include "cf/openbsd.h" 98#endif 99 100#if defined (__osf__) && defined (__alpha) 101# include "cf/alphaosf.h" 102#endif 103 104#ifdef ultrix 105# include "cf/ultrix.h" 106#endif 107 108#ifdef linux 109# include "cf/linux.h" 110#endif 111 112#ifdef SCO 113# include "cf/sco.h" 114#endif 115 116#if defined (hpux) || defined (__hpux) 117# include "cf/hpux.h" 118#endif 119 120#ifdef __QNX__ 121# include "cf/qnx.h" 122#endif 123 124#ifdef __CYGWIN32__ 125# include "cf/cygwin32.h" 126#endif 127 128#ifdef __APPLE__ 129# include "cf/rhapsody.h" 130#else 131# if defined (NeXT) 132# include "cf/nextstep.h" 133# endif 134#endif 135 136/* snprintf/vsnprintf hacks. for systems with no libc versions only. */ 137#ifdef NO_SNPRINTF 138 extern int isc_print_snprintf(char *, size_t, const char *, ...); 139 extern int isc_print_vsnprintf(char *, size_t, const char *, va_list ap); 140# define snprintf isc_print_snprintf 141# define vsnprintf isc_print_vsnprintf 142#endif 143 144/* Porting:: 145 146 If you add a new network API, and have it set up so that it can be 147 used for sending or receiving, but doesn't have to be used for both, 148 then set up an ifdef like the ones below: */ 149 150#ifdef USE_SOCKETS 151# define USE_SOCKET_SEND 152# define USE_SOCKET_RECEIVE 153#endif 154 155#ifdef USE_RAW_SOCKETS 156# define USE_RAW_SEND 157# define USE_SOCKET_RECEIVE 158#endif 159 160#ifdef USE_BPF 161# define USE_BPF_SEND 162# define USE_BPF_RECEIVE 163#endif 164 165#ifdef USE_LPF 166# define USE_LPF_SEND 167# define USE_LPF_RECEIVE 168#endif 169 170#ifdef USE_NIT 171# define USE_NIT_SEND 172# define USE_NIT_RECEIVE 173#endif 174 175#ifdef USE_DLPI 176# define USE_DLPI_SEND 177# define USE_DLPI_RECEIVE 178#endif 179 180#ifdef USE_UPF 181# define USE_UPF_SEND 182# define USE_UPF_RECEIVE 183#endif 184 185/* Porting:: 186 187 If you add support for sending packets directly out an interface, 188 and your support does not do ARP or routing, you must use a fallback 189 mechanism to deal with packets that need to be sent to routers. 190 Currently, all low-level packet interfaces use BSD sockets as a 191 fallback. */ 192 193#if defined (USE_BPF_SEND) || defined (USE_NIT_SEND) || \ 194 defined (USE_DLPI_SEND) || defined (USE_UPF_SEND) || \ 195 defined (USE_LPF_SEND) || \ 196 (defined (USE_SOCKET_SEND) && defined (HAVE_SO_BINDTODEVICE)) 197# define USE_SOCKET_FALLBACK 198# define USE_FALLBACK 199#endif 200 201/* Porting:: 202 203 If you add support for sending packets directly out an interface 204 and need to be able to assemble packets, add the USE_XXX_SEND 205 definition for your interface to the list tested below. */ 206 207#if defined (USE_RAW_SEND) || defined (USE_BPF_SEND) || \ 208 defined (USE_NIT_SEND) || defined (USE_UPF_SEND) || \ 209 defined (USE_DLPI_SEND) || defined (USE_LPF_SEND) 210# define PACKET_ASSEMBLY 211#endif 212 213/* Porting:: 214 215 If you add support for receiving packets directly from an interface 216 and need to be able to decode raw packets, add the USE_XXX_RECEIVE 217 definition for your interface to the list tested below. */ 218 219#if defined (USE_RAW_RECEIVE) || defined (USE_BPF_SEND) || \ 220 defined (USE_NIT_RECEIVE) || defined (USE_UPF_RECEIVE) || \ 221 defined (USE_DLPI_RECEIVE) || defined (USE_LPF_RECEIVE) 222# define PACKET_DECODING 223#endif 224 225/* If we don't have a DLPI packet filter, we have to filter in userland. 226 Probably not worth doing, actually. */ 227#if defined (USE_DLPI_RECEIVE) && !defined (USE_DLPI_PFMOD) 228# define USERLAND_FILTER 229#endif 230 231/* jmp_buf is assumed to be a struct unless otherwise defined in the 232 system header. */ 233#ifndef jbp_decl 234# define jbp_decl(x) jmp_buf *x 235#endif 236#ifndef jref 237# define jref(x) (&(x)) 238#endif 239#ifndef jdref 240# define jdref(x) (*(x)) 241#endif 242#ifndef jrefproto 243# define jrefproto jmp_buf * 244#endif 245 246#ifndef BPF_FORMAT 247# define BPF_FORMAT "/dev/bpf%d" 248#endif 249 250#if defined (F_SETFD) && !defined (HAVE_SETFD) 251# define HAVE_SETFD 252#endif 253 254#if defined (IFF_POINTOPOINT) && !defined (HAVE_IFF_POINTOPOINT) 255# define HAVE_IFF_POINTOPOINT 256#endif 257 258#if defined (AF_LINK) && !defined (HAVE_AF_LINK) 259# define HAVE_AF_LINK 260#endif 261 262#if defined (ARPHRD_TUNNEL) && !defined (HAVE_ARPHRD_TUNNEL) 263# define HAVE_ARPHRD_TUNNEL 264#endif 265 266#if defined (ARPHRD_LOOPBACK) && !defined (HAVE_ARPHRD_LOOPBACK) 267# define HAVE_ARPHRD_LOOPBACK 268#endif 269 270#if defined (ARPHRD_ROSE) && !defined (HAVE_ARPHRD_ROSE) 271# define HAVE_ARPHRD_ROSE 272#endif 273 274#if defined (ARPHRD_IEEE802) && !defined (HAVE_ARPHRD_IEEE802) 275# define HAVE_ARPHRD_IEEE802 276#endif 277 278#if defined (ARPHRD_IEEE802_TR) && !defined (HAVE_ARPHRD_IEEE802_TR) 279# define HAVE_ARPHRD_IEEE802_TR 280#endif 281 282#if defined (ARPHRD_FDDI) && !defined (HAVE_ARPHRD_FDDI) 283# define HAVE_ARPHRD_FDDI 284#endif 285 286#if defined (ARPHRD_AX25) && !defined (HAVE_ARPHRD_AX25) 287# define HAVE_ARPHRD_AX25 288#endif 289 290#if defined (ARPHRD_NETROM) && !defined (HAVE_ARPHRD_NETROM) 291# define HAVE_ARPHRD_NETROM 292#endif 293 294#if defined (ARPHRD_METRICOM) && !defined (HAVE_ARPHRD_METRICOM) 295# define HAVE_ARPHRD_METRICOM 296#endif 297 298#if defined (SO_BINDTODEVICE) && !defined (HAVE_SO_BINDTODEVICE) 299# define HAVE_SO_BINDTODEVICE 300#endif 301 302#if defined (AF_LINK) && !defined (HAVE_AF_LINK) 303# define HAVE_AF_LINK 304#endif 305 306/* Linux needs to define SHUT_* in /usr/include/sys/socket.h someday... */ 307#if !defined (SHUT_RD) 308# define SHUT_RD 0 309#endif 310 311#if !defined (SOCKLEN_T) 312# define SOCKLEN_T socklen_t 313#endif 314 315#if !defined (STDERR_FILENO) 316# define STDERR_FILENO 2 317#endif 318 319#endif /* __ISC_DHCP_OSDEP_H__ */ 320