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