]>
Commit | Line | Data |
---|---|---|
d7837182 TL |
1 | /* osdep.h |
2 | ||
3 | Operating system dependencies... */ | |
4 | ||
5 | /* | |
7512d88b | 6 | * Copyright (c) 2004-2017 by Internet Systems Consortium,Inc. ("ISC") |
98311e4b | 7 | * Copyright (c) 1996-2003 by Internet Software Consortium |
d7837182 | 8 | * |
7512d88b TM |
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/. | |
d7837182 | 12 | * |
98311e4b DH |
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. | |
d7837182 | 20 | * |
98311e4b DH |
21 | * Internet Systems Consortium, Inc. |
22 | * 950 Charter Street | |
23 | * Redwood City, CA 94063 | |
24 | * <info@isc.org> | |
2c85ac9b | 25 | * https://www.isc.org/ |
49733f31 | 26 | * |
d7837182 TL |
27 | */ |
28 | ||
bfc3d448 TL |
29 | #if !defined (__ISC_DHCP_OSDEP_H__) |
30 | #define __ISC_DHCP_OSDEP_H__ | |
31 | ||
a04c50cd TL |
32 | #include "site.h" |
33 | ||
fe5b0fdd DH |
34 | #include "config.h" |
35 | ||
36 | #include <inttypes.h> | |
fe5b0fdd DH |
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 | ||
af0ef363 TL |
50 | /* Porting:: |
51 | ||
52 | If you add a new network API, you must add a check for it below: */ | |
53 | ||
a04c50cd TL |
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) && \ | |
d2bc90bd TL |
63 | !defined (USE_LPF) && \ |
64 | !defined (USE_LPF_SEND) && \ | |
65 | !defined (USE_LPF_RECEIVE) && \ | |
a04c50cd TL |
66 | !defined (USE_NIT) && \ |
67 | !defined (USE_NIT_SEND) && \ | |
961ea0f7 | 68 | !defined (USE_NIT_RECEIVE) && \ |
fe5b0fdd | 69 | !defined (USE_DLPI_SEND) && \ |
961ea0f7 | 70 | !defined (USE_DLPI_RECEIVE) |
a57df74a DH |
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 | |
a04c50cd TL |
79 | #endif |
80 | ||
d2bc90bd TL |
81 | #if !defined (TIME_MAX) |
82 | # define TIME_MAX 2147483647 | |
83 | #endif | |
a04c50cd | 84 | |
98311e4b DH |
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 | ||
af0ef363 TL |
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 | ||
98078fdb | 99 | #ifdef USE_SOCKETS |
a04c50cd TL |
100 | # define USE_SOCKET_SEND |
101 | # define USE_SOCKET_RECEIVE | |
be3ee1b9 | 102 | # if defined(HAVE_DLPI) && !defined(sun) && !defined(USE_V4_PKTINFO) |
a57df74a | 103 | # define USE_DLPI_HWADDR |
32e651c4 SR |
104 | # elif defined(HAVE_LPF) |
105 | # define USE_LPF_HWADDR | |
106 | # elif defined(HAVE_BPF) | |
107 | # define USE_BPF_HWADDR | |
a57df74a | 108 | # endif |
98078fdb TL |
109 | #endif |
110 | ||
111 | #ifdef USE_RAW_SOCKETS | |
a04c50cd TL |
112 | # define USE_RAW_SEND |
113 | # define USE_SOCKET_RECEIVE | |
98078fdb TL |
114 | #endif |
115 | ||
116 | #ifdef USE_BPF | |
a04c50cd TL |
117 | # define USE_BPF_SEND |
118 | # define USE_BPF_RECEIVE | |
98078fdb TL |
119 | #endif |
120 | ||
d2bc90bd TL |
121 | #ifdef USE_LPF |
122 | # define USE_LPF_SEND | |
123 | # define USE_LPF_RECEIVE | |
124 | #endif | |
125 | ||
98078fdb | 126 | #ifdef USE_NIT |
a04c50cd TL |
127 | # define USE_NIT_SEND |
128 | # define USE_NIT_RECEIVE | |
98078fdb | 129 | #endif |
b7c4d8d5 | 130 | |
961ea0f7 TL |
131 | #ifdef USE_DLPI |
132 | # define USE_DLPI_SEND | |
133 | # define USE_DLPI_RECEIVE | |
134 | #endif | |
135 | ||
2f26c2dc TL |
136 | #ifdef USE_UPF |
137 | # define USE_UPF_SEND | |
138 | # define USE_UPF_RECEIVE | |
139 | #endif | |
140 | ||
0cd94b5e TM |
141 | #if defined (SO_BINDTODEVICE) && !defined (HAVE_SO_BINDTODEVICE) |
142 | # define HAVE_SO_BINDTODEVICE | |
143 | #endif | |
144 | ||
b7c4d8d5 TL |
145 | /* Porting:: |
146 | ||
147 | If you add support for sending packets directly out an interface, | |
148 | and your support does not do ARP or routing, you must use a fallback | |
149 | mechanism to deal with packets that need to be sent to routers. | |
150 | Currently, all low-level packet interfaces use BSD sockets as a | |
151 | fallback. */ | |
152 | ||
961ea0f7 | 153 | #if defined (USE_BPF_SEND) || defined (USE_NIT_SEND) || \ |
5d4afdbc TL |
154 | defined (USE_DLPI_SEND) || defined (USE_UPF_SEND) || \ |
155 | defined (USE_LPF_SEND) || \ | |
d758ad8c | 156 | (defined (USE_SOCKET_SEND) && defined (HAVE_SO_BINDTODEVICE)) |
b7c4d8d5 TL |
157 | # define USE_SOCKET_FALLBACK |
158 | # define USE_FALLBACK | |
159 | #endif | |
10e99bf1 | 160 | |
af0ef363 TL |
161 | /* Porting:: |
162 | ||
163 | If you add support for sending packets directly out an interface | |
164 | and need to be able to assemble packets, add the USE_XXX_SEND | |
165 | definition for your interface to the list tested below. */ | |
166 | ||
2f26c2dc | 167 | #if defined (USE_RAW_SEND) || defined (USE_BPF_SEND) || \ |
961ea0f7 | 168 | defined (USE_NIT_SEND) || defined (USE_UPF_SEND) || \ |
d2bc90bd | 169 | defined (USE_DLPI_SEND) || defined (USE_LPF_SEND) |
af0ef363 TL |
170 | # define PACKET_ASSEMBLY |
171 | #endif | |
172 | ||
173 | /* Porting:: | |
174 | ||
175 | If you add support for receiving packets directly from an interface | |
176 | and need to be able to decode raw packets, add the USE_XXX_RECEIVE | |
177 | definition for your interface to the list tested below. */ | |
178 | ||
2f26c2dc | 179 | #if defined (USE_RAW_RECEIVE) || defined (USE_BPF_SEND) || \ |
961ea0f7 | 180 | defined (USE_NIT_RECEIVE) || defined (USE_UPF_RECEIVE) || \ |
5d4afdbc | 181 | defined (USE_DLPI_RECEIVE) || defined (USE_LPF_RECEIVE) |
af0ef363 TL |
182 | # define PACKET_DECODING |
183 | #endif | |
184 | ||
44947018 TL |
185 | /* If we don't have a DLPI packet filter, we have to filter in userland. |
186 | Probably not worth doing, actually. */ | |
187 | #if defined (USE_DLPI_RECEIVE) && !defined (USE_DLPI_PFMOD) | |
188 | # define USERLAND_FILTER | |
189 | #endif | |
190 | ||
10e99bf1 TL |
191 | /* jmp_buf is assumed to be a struct unless otherwise defined in the |
192 | system header. */ | |
193 | #ifndef jbp_decl | |
194 | # define jbp_decl(x) jmp_buf *x | |
195 | #endif | |
196 | #ifndef jref | |
197 | # define jref(x) (&(x)) | |
198 | #endif | |
199 | #ifndef jdref | |
200 | # define jdref(x) (*(x)) | |
201 | #endif | |
b1af589d TL |
202 | #ifndef jrefproto |
203 | # define jrefproto jmp_buf * | |
204 | #endif | |
10e99bf1 | 205 | |
58a4aa84 TL |
206 | #ifndef BPF_FORMAT |
207 | # define BPF_FORMAT "/dev/bpf%d" | |
208 | #endif | |
74f45f96 | 209 | |
06d04870 TL |
210 | #if defined (F_SETFD) && !defined (HAVE_SETFD) |
211 | # define HAVE_SETFD | |
212 | #endif | |
213 | ||
74f45f96 TL |
214 | #if defined (IFF_POINTOPOINT) && !defined (HAVE_IFF_POINTOPOINT) |
215 | # define HAVE_IFF_POINTOPOINT | |
216 | #endif | |
217 | ||
218 | #if defined (AF_LINK) && !defined (HAVE_AF_LINK) | |
219 | # define HAVE_AF_LINK | |
220 | #endif | |
221 | ||
222 | #if defined (ARPHRD_TUNNEL) && !defined (HAVE_ARPHRD_TUNNEL) | |
223 | # define HAVE_ARPHRD_TUNNEL | |
224 | #endif | |
225 | ||
226 | #if defined (ARPHRD_LOOPBACK) && !defined (HAVE_ARPHRD_LOOPBACK) | |
227 | # define HAVE_ARPHRD_LOOPBACK | |
228 | #endif | |
229 | ||
2d1b06e0 TL |
230 | #if defined (ARPHRD_ROSE) && !defined (HAVE_ARPHRD_ROSE) |
231 | # define HAVE_ARPHRD_ROSE | |
232 | #endif | |
233 | ||
88cd8aca DH |
234 | #if defined (ARPHRD_IRDA) && !defined (HAVE_ARPHRD_IRDA) |
235 | # define HAVE_ARPHRD_IRDA | |
236 | #endif | |
237 | ||
238 | #if defined (ARPHRD_SIT) && !defined (HAVE_ARPHRD_SIT) | |
239 | # define HAVE_ARPHRD_SIT | |
240 | #endif | |
241 | ||
242 | #if defined (ARPHRD_IEEE1394) & !defined (HAVE_ARPHRD_IEEE1394) | |
243 | # define HAVE_ARPHRD_IEEE1394 | |
244 | #endif | |
245 | ||
2d1b06e0 TL |
246 | #if defined (ARPHRD_IEEE802) && !defined (HAVE_ARPHRD_IEEE802) |
247 | # define HAVE_ARPHRD_IEEE802 | |
248 | #endif | |
249 | ||
98311e4b DH |
250 | #if defined (ARPHRD_IEEE802_TR) && !defined (HAVE_ARPHRD_IEEE802_TR) |
251 | # define HAVE_ARPHRD_IEEE802_TR | |
252 | #endif | |
253 | ||
2d1b06e0 TL |
254 | #if defined (ARPHRD_FDDI) && !defined (HAVE_ARPHRD_FDDI) |
255 | # define HAVE_ARPHRD_FDDI | |
256 | #endif | |
257 | ||
258 | #if defined (ARPHRD_AX25) && !defined (HAVE_ARPHRD_AX25) | |
259 | # define HAVE_ARPHRD_AX25 | |
260 | #endif | |
261 | ||
262 | #if defined (ARPHRD_NETROM) && !defined (HAVE_ARPHRD_NETROM) | |
263 | # define HAVE_ARPHRD_NETROM | |
264 | #endif | |
265 | ||
74f45f96 TL |
266 | #if defined (ARPHRD_METRICOM) && !defined (HAVE_ARPHRD_METRICOM) |
267 | # define HAVE_ARPHRD_METRICOM | |
268 | #endif | |
269 | ||
74f45f96 TL |
270 | #if defined (AF_LINK) && !defined (HAVE_AF_LINK) |
271 | # define HAVE_AF_LINK | |
272 | #endif | |
273 | ||
06d04870 TL |
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 | ||
d1ddd6bf | 279 | #if !defined (SOCKLEN_T) |
98311e4b | 280 | # define SOCKLEN_T socklen_t |
b8c0eda0 MA |
281 | #elif defined(_AIX) |
282 | #undef SOCKLEN_T | |
283 | #define SOCKLEN_T socklen_t | |
98311e4b DH |
284 | #endif |
285 | ||
286 | #if !defined (STDERR_FILENO) | |
287 | # define STDERR_FILENO 2 | |
d1ddd6bf TL |
288 | #endif |
289 | ||
bfc3d448 | 290 | #endif /* __ISC_DHCP_OSDEP_H__ */ |