1 /* $NetBSD: osdep.h,v 1.1.1.3 2014/07/12 11:57:56 spz Exp $ */
4 Operating system dependencies... */
7 * Copyright (c) 2004-2005,2007-2010,2014 by Internet Systems Consortium,
9 * Copyright (c) 1996-2003 by Internet Software Consortium
11 * Permission to use, copy, modify, and distribute this software for any
12 * purpose with or without fee is hereby granted, provided that the above
13 * copyright notice and this permission notice appear in all copies.
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.
23 * Internet Systems Consortium, Inc.
25 * Redwood City, CA 94063
27 * https://www.isc.org/
31 #if !defined (__ISC_DHCP_OSDEP_H__)
32 #define __ISC_DHCP_OSDEP_H__
41 #define LITTLE_ENDIAN 1234
42 #endif /* LITTLE_ENDIAN */
45 #define BIG_ENDIAN 4321
46 #endif /* BIG_ENDIAN */
49 #define BYTE_ORDER DHCP_BYTE_ORDER
50 #endif /* BYTE_ORDER */
54 If you add a new network API, you must add a check for it below: */
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)
76 # elif defined(HAVE_LPF)
78 # elif defined(HAVE_DLPI)
83 #if !defined (TIME_MAX)
84 # define TIME_MAX 2147483647
87 /* snprintf/vsnprintf hacks. for systems with no libc versions only. */
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
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: */
102 # define USE_SOCKET_SEND
103 # define USE_SOCKET_RECEIVE
104 # if defined(HAVE_DLPI)
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
113 #ifdef USE_RAW_SOCKETS
114 # define USE_RAW_SEND
115 # define USE_SOCKET_RECEIVE
119 # define USE_BPF_SEND
120 # define USE_BPF_RECEIVE
124 # define USE_LPF_SEND
125 # define USE_LPF_RECEIVE
129 # define USE_NIT_SEND
130 # define USE_NIT_RECEIVE
134 # define USE_DLPI_SEND
135 # define USE_DLPI_RECEIVE
139 # define USE_UPF_SEND
140 # define USE_UPF_RECEIVE
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
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
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. */
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
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. */
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
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
189 /* jmp_buf is assumed to be a struct unless otherwise defined in the
192 # define jbp_decl(x) jmp_buf *x
195 # define jref(x) (&(x))
198 # define jdref(x) (*(x))
201 # define jrefproto jmp_buf *
205 # define BPF_FORMAT "/dev/bpf%d"
208 #if defined (F_SETFD) && !defined (HAVE_SETFD)
212 #if defined (IFF_POINTOPOINT) && !defined (HAVE_IFF_POINTOPOINT)
213 # define HAVE_IFF_POINTOPOINT
216 #if defined (AF_LINK) && !defined (HAVE_AF_LINK)
217 # define HAVE_AF_LINK
220 #if defined (ARPHRD_TUNNEL) && !defined (HAVE_ARPHRD_TUNNEL)
221 # define HAVE_ARPHRD_TUNNEL
224 #if defined (ARPHRD_LOOPBACK) && !defined (HAVE_ARPHRD_LOOPBACK)
225 # define HAVE_ARPHRD_LOOPBACK
228 #if defined (ARPHRD_ROSE) && !defined (HAVE_ARPHRD_ROSE)
229 # define HAVE_ARPHRD_ROSE
232 #if defined (ARPHRD_IRDA) && !defined (HAVE_ARPHRD_IRDA)
233 # define HAVE_ARPHRD_IRDA
236 #if defined (ARPHRD_SIT) && !defined (HAVE_ARPHRD_SIT)
237 # define HAVE_ARPHRD_SIT
240 #if defined (ARPHRD_IEEE1394) & !defined (HAVE_ARPHRD_IEEE1394)
241 # define HAVE_ARPHRD_IEEE1394
244 #if defined (ARPHRD_IEEE802) && !defined (HAVE_ARPHRD_IEEE802)
245 # define HAVE_ARPHRD_IEEE802
248 #if defined (ARPHRD_IEEE802_TR) && !defined (HAVE_ARPHRD_IEEE802_TR)
249 # define HAVE_ARPHRD_IEEE802_TR
252 #if defined (ARPHRD_FDDI) && !defined (HAVE_ARPHRD_FDDI)
253 # define HAVE_ARPHRD_FDDI
256 #if defined (ARPHRD_AX25) && !defined (HAVE_ARPHRD_AX25)
257 # define HAVE_ARPHRD_AX25
260 #if defined (ARPHRD_NETROM) && !defined (HAVE_ARPHRD_NETROM)
261 # define HAVE_ARPHRD_NETROM
264 #if defined (ARPHRD_METRICOM) && !defined (HAVE_ARPHRD_METRICOM)
265 # define HAVE_ARPHRD_METRICOM
268 #if defined (SO_BINDTODEVICE) && !defined (HAVE_SO_BINDTODEVICE)
269 # define HAVE_SO_BINDTODEVICE
272 #if defined (AF_LINK) && !defined (HAVE_AF_LINK)
273 # define HAVE_AF_LINK
276 /* Linux needs to define SHUT_* in /usr/include/sys/socket.h someday... */
277 #if !defined (SHUT_RD)
281 #if !defined (SOCKLEN_T)
282 # define SOCKLEN_T socklen_t
285 #define SOCKLEN_T socklen_t
288 #if !defined (STDERR_FILENO)
289 # define STDERR_FILENO 2
292 #endif /* __ISC_DHCP_OSDEP_H__ */