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