includes/osdep.h

Go to the documentation of this file.
00001 /* osdep.h
00002 
00003    Operating system dependencies... */
00004 
00005 /*
00006  * Copyright (c) 2004-2005,2007-2010,2014 by Internet Systems Consortium,
00007  *                                        Inc. ("ISC")
00008  * Copyright (c) 1996-2003 by Internet Software Consortium
00009  *
00010  * Permission to use, copy, modify, and distribute this software for any
00011  * purpose with or without fee is hereby granted, provided that the above
00012  * copyright notice and this permission notice appear in all copies.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
00015  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00016  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
00017  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00018  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00019  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
00020  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00021  *
00022  *   Internet Systems Consortium, Inc.
00023  *   950 Charter Street
00024  *   Redwood City, CA 94063
00025  *   <info@isc.org>
00026  *   https://www.isc.org/
00027  *
00028  */
00029 
00030 #if !defined (__ISC_DHCP_OSDEP_H__)
00031 #define __ISC_DHCP_OSDEP_H__
00032 
00033 #include "site.h"
00034 
00035 #include "config.h"
00036 
00037 #include <inttypes.h>
00038 
00039 #ifndef LITTLE_ENDIAN
00040 #define LITTLE_ENDIAN 1234
00041 #endif /* LITTLE_ENDIAN */
00042 
00043 #ifndef BIG_ENDIAN
00044 #define BIG_ENDIAN 4321
00045 #endif /* BIG_ENDIAN */
00046 
00047 #ifndef BYTE_ORDER
00048 #define BYTE_ORDER DHCP_BYTE_ORDER
00049 #endif /* BYTE_ORDER */
00050 
00051 /* Porting::
00052 
00053    If you add a new network API, you must add a check for it below: */
00054 
00055 #if !defined (USE_SOCKETS) && \
00056     !defined (USE_SOCKET_SEND) && \
00057     !defined (USE_SOCKET_RECEIVE) && \
00058     !defined (USE_RAW_SOCKETS) && \
00059     !defined (USE_RAW_SEND) && \
00060     !defined (USE_SOCKET_RECEIVE) && \
00061     !defined (USE_BPF) && \
00062     !defined (USE_BPF_SEND) && \
00063     !defined (USE_BPF_RECEIVE) && \
00064     !defined (USE_LPF) && \
00065     !defined (USE_LPF_SEND) && \
00066     !defined (USE_LPF_RECEIVE) && \
00067     !defined (USE_NIT) && \
00068     !defined (USE_NIT_SEND) && \
00069     !defined (USE_NIT_RECEIVE) && \
00070     !defined (USE_DLPI_SEND) && \
00071     !defined (USE_DLPI_RECEIVE)
00072 /* Determine default socket API to USE. */
00073 # if defined(HAVE_BPF)
00074 #  define USE_BPF 1
00075 # elif defined(HAVE_LPF)
00076 #  define USE_LPF 1
00077 # elif defined(HAVE_DLPI)
00078 #  define USE_DLPI 1
00079 # endif
00080 #endif
00081 
00082 #if !defined (TIME_MAX)
00083 # define TIME_MAX 2147483647
00084 #endif
00085 
00086 /* snprintf/vsnprintf hacks.  for systems with no libc versions only. */
00087 #ifdef NO_SNPRINTF
00088   extern int isc_print_snprintf(char *, size_t, const char *, ...);
00089   extern int isc_print_vsnprintf(char *, size_t, const char *, va_list ap);
00090 # define snprintf  isc_print_snprintf
00091 # define vsnprintf isc_print_vsnprintf
00092 #endif
00093 
00094 /* Porting::
00095 
00096    If you add a new network API, and have it set up so that it can be
00097    used for sending or receiving, but doesn't have to be used for both,
00098    then set up an ifdef like the ones below: */
00099 
00100 #ifdef USE_SOCKETS
00101 #  define USE_SOCKET_SEND
00102 #  define USE_SOCKET_RECEIVE
00103 #  if defined(HAVE_DLPI)
00104 #    define USE_DLPI_HWADDR
00105 #  elif defined(HAVE_LPF)
00106 #    define USE_LPF_HWADDR
00107 #  elif defined(HAVE_BPF)
00108 #    define USE_BPF_HWADDR
00109 #  endif
00110 #endif
00111 
00112 #ifdef USE_RAW_SOCKETS
00113 #  define USE_RAW_SEND
00114 #  define USE_SOCKET_RECEIVE
00115 #endif
00116 
00117 #ifdef USE_BPF
00118 #  define USE_BPF_SEND
00119 #  define USE_BPF_RECEIVE
00120 #endif
00121 
00122 #ifdef USE_LPF
00123 #  define USE_LPF_SEND
00124 #  define USE_LPF_RECEIVE
00125 #endif
00126 
00127 #ifdef USE_NIT
00128 #  define USE_NIT_SEND
00129 #  define USE_NIT_RECEIVE
00130 #endif
00131 
00132 #ifdef USE_DLPI
00133 #  define USE_DLPI_SEND
00134 #  define USE_DLPI_RECEIVE
00135 #endif
00136 
00137 #ifdef USE_UPF
00138 #  define USE_UPF_SEND
00139 #  define USE_UPF_RECEIVE
00140 #endif
00141 
00142 /* Porting::
00143 
00144    If you add support for sending packets directly out an interface,
00145    and your support does not do ARP or routing, you must use a fallback
00146    mechanism to deal with packets that need to be sent to routers.
00147    Currently, all low-level packet interfaces use BSD sockets as a
00148    fallback. */
00149 
00150 #if defined (USE_BPF_SEND) || defined (USE_NIT_SEND) || \
00151     defined (USE_DLPI_SEND) || defined (USE_UPF_SEND) || \
00152     defined (USE_LPF_SEND) || \
00153     (defined (USE_SOCKET_SEND) && defined (HAVE_SO_BINDTODEVICE))
00154 #  define USE_SOCKET_FALLBACK
00155 #  define USE_FALLBACK
00156 #endif
00157 
00158 /* Porting::
00159 
00160    If you add support for sending packets directly out an interface
00161    and need to be able to assemble packets, add the USE_XXX_SEND
00162    definition for your interface to the list tested below. */
00163 
00164 #if defined (USE_RAW_SEND) || defined (USE_BPF_SEND) || \
00165                 defined (USE_NIT_SEND) || defined (USE_UPF_SEND) || \
00166                 defined (USE_DLPI_SEND) || defined (USE_LPF_SEND)
00167 #  define PACKET_ASSEMBLY
00168 #endif
00169 
00170 /* Porting::
00171 
00172    If you add support for receiving packets directly from an interface
00173    and need to be able to decode raw packets, add the USE_XXX_RECEIVE
00174    definition for your interface to the list tested below. */
00175 
00176 #if defined (USE_RAW_RECEIVE) || defined (USE_BPF_SEND) || \
00177                 defined (USE_NIT_RECEIVE) || defined (USE_UPF_RECEIVE) || \
00178                 defined (USE_DLPI_RECEIVE) || defined (USE_LPF_RECEIVE)
00179 #  define PACKET_DECODING
00180 #endif
00181 
00182 /* If we don't have a DLPI packet filter, we have to filter in userland.
00183    Probably not worth doing, actually. */
00184 #if defined (USE_DLPI_RECEIVE) && !defined (USE_DLPI_PFMOD)
00185 #  define USERLAND_FILTER
00186 #endif
00187 
00188 /* jmp_buf is assumed to be a struct unless otherwise defined in the
00189    system header. */
00190 #ifndef jbp_decl
00191 # define jbp_decl(x)    jmp_buf *x
00192 #endif
00193 #ifndef jref
00194 # define jref(x)        (&(x))
00195 #endif
00196 #ifndef jdref
00197 # define jdref(x)       (*(x))
00198 #endif
00199 #ifndef jrefproto
00200 # define jrefproto      jmp_buf *
00201 #endif
00202 
00203 #ifndef BPF_FORMAT
00204 # define BPF_FORMAT "/dev/bpf%d"
00205 #endif
00206 
00207 #if defined (F_SETFD) && !defined (HAVE_SETFD)
00208 # define HAVE_SETFD
00209 #endif
00210 
00211 #if defined (IFF_POINTOPOINT) && !defined (HAVE_IFF_POINTOPOINT)
00212 # define HAVE_IFF_POINTOPOINT
00213 #endif
00214 
00215 #if defined (AF_LINK) && !defined (HAVE_AF_LINK)
00216 # define HAVE_AF_LINK
00217 #endif
00218 
00219 #if defined (ARPHRD_TUNNEL) && !defined (HAVE_ARPHRD_TUNNEL)
00220 # define HAVE_ARPHRD_TUNNEL
00221 #endif
00222 
00223 #if defined (ARPHRD_LOOPBACK) && !defined (HAVE_ARPHRD_LOOPBACK)
00224 # define HAVE_ARPHRD_LOOPBACK
00225 #endif
00226 
00227 #if defined (ARPHRD_ROSE) && !defined (HAVE_ARPHRD_ROSE)
00228 # define HAVE_ARPHRD_ROSE
00229 #endif
00230 
00231 #if defined (ARPHRD_IRDA) && !defined (HAVE_ARPHRD_IRDA)
00232 # define HAVE_ARPHRD_IRDA
00233 #endif
00234 
00235 #if defined (ARPHRD_SIT) && !defined (HAVE_ARPHRD_SIT)
00236 # define HAVE_ARPHRD_SIT
00237 #endif
00238 
00239 #if defined (ARPHRD_IEEE1394) & !defined (HAVE_ARPHRD_IEEE1394)
00240 # define HAVE_ARPHRD_IEEE1394
00241 #endif
00242 
00243 #if defined (ARPHRD_IEEE802) && !defined (HAVE_ARPHRD_IEEE802)
00244 # define HAVE_ARPHRD_IEEE802
00245 #endif
00246 
00247 #if defined (ARPHRD_IEEE802_TR) && !defined (HAVE_ARPHRD_IEEE802_TR)
00248 # define HAVE_ARPHRD_IEEE802_TR
00249 #endif
00250 
00251 #if defined (ARPHRD_FDDI) && !defined (HAVE_ARPHRD_FDDI)
00252 # define HAVE_ARPHRD_FDDI
00253 #endif
00254 
00255 #if defined (ARPHRD_AX25) && !defined (HAVE_ARPHRD_AX25)
00256 # define HAVE_ARPHRD_AX25
00257 #endif
00258 
00259 #if defined (ARPHRD_NETROM) && !defined (HAVE_ARPHRD_NETROM)
00260 # define HAVE_ARPHRD_NETROM
00261 #endif
00262 
00263 #if defined (ARPHRD_METRICOM) && !defined (HAVE_ARPHRD_METRICOM)
00264 # define HAVE_ARPHRD_METRICOM
00265 #endif
00266 
00267 #if defined (SO_BINDTODEVICE) && !defined (HAVE_SO_BINDTODEVICE)
00268 # define HAVE_SO_BINDTODEVICE
00269 #endif
00270 
00271 #if defined (AF_LINK) && !defined (HAVE_AF_LINK)
00272 # define HAVE_AF_LINK
00273 #endif
00274 
00275 /* Linux needs to define SHUT_* in /usr/include/sys/socket.h someday... */
00276 #if !defined (SHUT_RD)
00277 # define SHUT_RD 0
00278 #endif
00279 
00280 #if !defined (SOCKLEN_T)
00281 # define SOCKLEN_T socklen_t
00282 #elif defined(_AIX)
00283 #undef SOCKLEN_T
00284 #define SOCKLEN_T socklen_t
00285 #endif
00286 
00287 #if !defined (STDERR_FILENO)
00288 # define STDERR_FILENO 2
00289 #endif
00290 
00291 #endif /* __ISC_DHCP_OSDEP_H__ */

Generated on 5 Apr 2014 for ISC DHCP by  doxygen 1.6.1