Annotation of embedaddon/dhcp/includes/osdep.h, revision 1.1.1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>