Annotation of src/external/mpl/dhcp/dist/includes/osdep.h, Revision 1.1
1.1 ! christos 1: /* $NetBSD$ */
! 2:
! 3: /* osdep.h
! 4:
! 5: Operating system dependencies... */
! 6:
! 7: /*
! 8: * Copyright (c) 2004-2017 by Internet Systems Consortium,Inc. ("ISC")
! 9: * Copyright (c) 1996-2003 by Internet Software Consortium
! 10: *
! 11: * This Source Code Form is subject to the terms of the Mozilla Public
! 12: * License, v. 2.0. If a copy of the MPL was not distributed with this
! 13: * file, You can obtain one at http://mozilla.org/MPL/2.0/.
! 14: *
! 15: * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
! 16: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
! 17: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
! 18: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
! 19: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
! 20: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
! 21: * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
! 22: *
! 23: * Internet Systems Consortium, Inc.
! 24: * 950 Charter Street
! 25: * Redwood City, CA 94063
! 26: * <info@isc.org>
! 27: * https://www.isc.org/
! 28: *
! 29: */
! 30:
! 31: #if !defined (__ISC_DHCP_OSDEP_H__)
! 32: #define __ISC_DHCP_OSDEP_H__
! 33:
! 34: #include "site.h"
! 35:
! 36: #include "config.h"
! 37:
! 38: #include <inttypes.h>
! 39:
! 40: #ifndef LITTLE_ENDIAN
! 41: #define LITTLE_ENDIAN 1234
! 42: #endif /* LITTLE_ENDIAN */
! 43:
! 44: #ifndef BIG_ENDIAN
! 45: #define BIG_ENDIAN 4321
! 46: #endif /* BIG_ENDIAN */
! 47:
! 48: #ifndef BYTE_ORDER
! 49: #define BYTE_ORDER DHCP_BYTE_ORDER
! 50: #endif /* BYTE_ORDER */
! 51:
! 52: /* Porting::
! 53:
! 54: If you add a new network API, you must add a check for it below: */
! 55:
! 56: #if !defined (USE_SOCKETS) && \
! 57: !defined (USE_SOCKET_SEND) && \
! 58: !defined (USE_SOCKET_RECEIVE) && \
! 59: !defined (USE_RAW_SOCKETS) && \
! 60: !defined (USE_RAW_SEND) && \
! 61: !defined (USE_SOCKET_RECEIVE) && \
! 62: !defined (USE_BPF) && \
! 63: !defined (USE_BPF_SEND) && \
! 64: !defined (USE_BPF_RECEIVE) && \
! 65: !defined (USE_LPF) && \
! 66: !defined (USE_LPF_SEND) && \
! 67: !defined (USE_LPF_RECEIVE) && \
! 68: !defined (USE_NIT) && \
! 69: !defined (USE_NIT_SEND) && \
! 70: !defined (USE_NIT_RECEIVE) && \
! 71: !defined (USE_DLPI_SEND) && \
! 72: !defined (USE_DLPI_RECEIVE)
! 73: /* Determine default socket API to USE. */
! 74: # if defined(HAVE_BPF)
! 75: # define USE_BPF 1
! 76: # elif defined(HAVE_LPF)
! 77: # define USE_LPF 1
! 78: # elif defined(HAVE_DLPI)
! 79: # define USE_DLPI 1
! 80: # endif
! 81: #endif
! 82:
! 83: #if !defined (TIME_MAX)
! 84: # define TIME_MAX 2147483647
! 85: #endif
! 86:
! 87: /* snprintf/vsnprintf hacks. for systems with no libc versions only. */
! 88: #ifdef NO_SNPRINTF
! 89: extern int isc_print_snprintf(char *, size_t, const char *, ...);
! 90: extern int isc_print_vsnprintf(char *, size_t, const char *, va_list ap);
! 91: # define snprintf isc_print_snprintf
! 92: # define vsnprintf isc_print_vsnprintf
! 93: #endif
! 94:
! 95: /* Porting::
! 96:
! 97: If you add a new network API, and have it set up so that it can be
! 98: used for sending or receiving, but doesn't have to be used for both,
! 99: then set up an ifdef like the ones below: */
! 100:
! 101: #ifdef USE_SOCKETS
! 102: # define USE_SOCKET_SEND
! 103: # define USE_SOCKET_RECEIVE
! 104: # if defined(HAVE_DLPI) && !defined(sun) && !defined(USE_V4_PKTINFO)
! 105: # define USE_DLPI_HWADDR
! 106: # elif defined(HAVE_LPF)
! 107: # define USE_LPF_HWADDR
! 108: # elif defined(HAVE_BPF)
! 109: # define USE_BPF_HWADDR
! 110: # endif
! 111: #endif
! 112:
! 113: #ifdef USE_RAW_SOCKETS
! 114: # define USE_RAW_SEND
! 115: # define USE_SOCKET_RECEIVE
! 116: #endif
! 117:
! 118: #ifdef USE_BPF
! 119: # define USE_BPF_SEND
! 120: # define USE_BPF_RECEIVE
! 121: #endif
! 122:
! 123: #ifdef USE_LPF
! 124: # define USE_LPF_SEND
! 125: # define USE_LPF_RECEIVE
! 126: #endif
! 127:
! 128: #ifdef USE_NIT
! 129: # define USE_NIT_SEND
! 130: # define USE_NIT_RECEIVE
! 131: #endif
! 132:
! 133: #ifdef USE_DLPI
! 134: # define USE_DLPI_SEND
! 135: # define USE_DLPI_RECEIVE
! 136: #endif
! 137:
! 138: #ifdef USE_UPF
! 139: # define USE_UPF_SEND
! 140: # define USE_UPF_RECEIVE
! 141: #endif
! 142:
! 143: /* Porting::
! 144:
! 145: If you add support for sending packets directly out an interface,
! 146: and your support does not do ARP or routing, you must use a fallback
! 147: mechanism to deal with packets that need to be sent to routers.
! 148: Currently, all low-level packet interfaces use BSD sockets as a
! 149: fallback. */
! 150:
! 151: #if defined (USE_BPF_SEND) || defined (USE_NIT_SEND) || \
! 152: defined (USE_DLPI_SEND) || defined (USE_UPF_SEND) || \
! 153: defined (USE_LPF_SEND) || \
! 154: (defined (USE_SOCKET_SEND) && defined (HAVE_SO_BINDTODEVICE))
! 155: # define USE_SOCKET_FALLBACK
! 156: # define USE_FALLBACK
! 157: #endif
! 158:
! 159: /* Porting::
! 160:
! 161: If you add support for sending packets directly out an interface
! 162: and need to be able to assemble packets, add the USE_XXX_SEND
! 163: definition for your interface to the list tested below. */
! 164:
! 165: #if defined (USE_RAW_SEND) || defined (USE_BPF_SEND) || \
! 166: defined (USE_NIT_SEND) || defined (USE_UPF_SEND) || \
! 167: defined (USE_DLPI_SEND) || defined (USE_LPF_SEND)
! 168: # define PACKET_ASSEMBLY
! 169: #endif
! 170:
! 171: /* Porting::
! 172:
! 173: If you add support for receiving packets directly from an interface
! 174: and need to be able to decode raw packets, add the USE_XXX_RECEIVE
! 175: definition for your interface to the list tested below. */
! 176:
! 177: #if defined (USE_RAW_RECEIVE) || defined (USE_BPF_SEND) || \
! 178: defined (USE_NIT_RECEIVE) || defined (USE_UPF_RECEIVE) || \
! 179: defined (USE_DLPI_RECEIVE) || defined (USE_LPF_RECEIVE)
! 180: # define PACKET_DECODING
! 181: #endif
! 182:
! 183: /* If we don't have a DLPI packet filter, we have to filter in userland.
! 184: Probably not worth doing, actually. */
! 185: #if defined (USE_DLPI_RECEIVE) && !defined (USE_DLPI_PFMOD)
! 186: # define USERLAND_FILTER
! 187: #endif
! 188:
! 189: /* jmp_buf is assumed to be a struct unless otherwise defined in the
! 190: system header. */
! 191: #ifndef jbp_decl
! 192: # define jbp_decl(x) jmp_buf *x
! 193: #endif
! 194: #ifndef jref
! 195: # define jref(x) (&(x))
! 196: #endif
! 197: #ifndef jdref
! 198: # define jdref(x) (*(x))
! 199: #endif
! 200: #ifndef jrefproto
! 201: # define jrefproto jmp_buf *
! 202: #endif
! 203:
! 204: #ifndef BPF_FORMAT
! 205: # define BPF_FORMAT "/dev/bpf%d"
! 206: #endif
! 207:
! 208: #if defined (F_SETFD) && !defined (HAVE_SETFD)
! 209: # define HAVE_SETFD
! 210: #endif
! 211:
! 212: #if defined (IFF_POINTOPOINT) && !defined (HAVE_IFF_POINTOPOINT)
! 213: # define HAVE_IFF_POINTOPOINT
! 214: #endif
! 215:
! 216: #if defined (AF_LINK) && !defined (HAVE_AF_LINK)
! 217: # define HAVE_AF_LINK
! 218: #endif
! 219:
! 220: #if defined (ARPHRD_TUNNEL) && !defined (HAVE_ARPHRD_TUNNEL)
! 221: # define HAVE_ARPHRD_TUNNEL
! 222: #endif
! 223:
! 224: #if defined (ARPHRD_LOOPBACK) && !defined (HAVE_ARPHRD_LOOPBACK)
! 225: # define HAVE_ARPHRD_LOOPBACK
! 226: #endif
! 227:
! 228: #if defined (ARPHRD_ROSE) && !defined (HAVE_ARPHRD_ROSE)
! 229: # define HAVE_ARPHRD_ROSE
! 230: #endif
! 231:
! 232: #if defined (ARPHRD_IRDA) && !defined (HAVE_ARPHRD_IRDA)
! 233: # define HAVE_ARPHRD_IRDA
! 234: #endif
! 235:
! 236: #if defined (ARPHRD_SIT) && !defined (HAVE_ARPHRD_SIT)
! 237: # define HAVE_ARPHRD_SIT
! 238: #endif
! 239:
! 240: #if defined (ARPHRD_IEEE1394) & !defined (HAVE_ARPHRD_IEEE1394)
! 241: # define HAVE_ARPHRD_IEEE1394
! 242: #endif
! 243:
! 244: #if defined (ARPHRD_IEEE802) && !defined (HAVE_ARPHRD_IEEE802)
! 245: # define HAVE_ARPHRD_IEEE802
! 246: #endif
! 247:
! 248: #if defined (ARPHRD_IEEE802_TR) && !defined (HAVE_ARPHRD_IEEE802_TR)
! 249: # define HAVE_ARPHRD_IEEE802_TR
! 250: #endif
! 251:
! 252: #if defined (ARPHRD_FDDI) && !defined (HAVE_ARPHRD_FDDI)
! 253: # define HAVE_ARPHRD_FDDI
! 254: #endif
! 255:
! 256: #if defined (ARPHRD_AX25) && !defined (HAVE_ARPHRD_AX25)
! 257: # define HAVE_ARPHRD_AX25
! 258: #endif
! 259:
! 260: #if defined (ARPHRD_NETROM) && !defined (HAVE_ARPHRD_NETROM)
! 261: # define HAVE_ARPHRD_NETROM
! 262: #endif
! 263:
! 264: #if defined (ARPHRD_METRICOM) && !defined (HAVE_ARPHRD_METRICOM)
! 265: # define HAVE_ARPHRD_METRICOM
! 266: #endif
! 267:
! 268: #if defined (SO_BINDTODEVICE) && !defined (HAVE_SO_BINDTODEVICE)
! 269: # define HAVE_SO_BINDTODEVICE
! 270: #endif
! 271:
! 272: #if defined (AF_LINK) && !defined (HAVE_AF_LINK)
! 273: # define HAVE_AF_LINK
! 274: #endif
! 275:
! 276: /* Linux needs to define SHUT_* in /usr/include/sys/socket.h someday... */
! 277: #if !defined (SHUT_RD)
! 278: # define SHUT_RD 0
! 279: #endif
! 280:
! 281: #if !defined (SOCKLEN_T)
! 282: # define SOCKLEN_T socklen_t
! 283: #elif defined(_AIX)
! 284: #undef SOCKLEN_T
! 285: #define SOCKLEN_T socklen_t
! 286: #endif
! 287:
! 288: #if !defined (STDERR_FILENO)
! 289: # define STDERR_FILENO 2
! 290: #endif
! 291:
! 292: #endif /* __ISC_DHCP_OSDEP_H__ */
CVSweb <webmaster@jp.NetBSD.org>