ip_compat.h revision 1.6 1 1.6 christos /* $NetBSD: ip_compat.h,v 1.6 2013/01/09 13:23:20 christos Exp $ */
2 1.1 christos
3 1.1 christos /*
4 1.1 christos * Copyright (C) 2012 by Darren Reed.
5 1.1 christos *
6 1.1 christos * See the IPFILTER.LICENCE file for details on licencing.
7 1.1 christos *
8 1.1 christos * @(#)ip_compat.h 1.8 1/14/96
9 1.3 darrenr * Id: ip_compat.h,v 1.1.1.2 2012/07/22 13:45:09 darrenr Exp
10 1.1 christos */
11 1.1 christos
12 1.2 christos #ifndef _NETINET_IP_COMPAT_H_
13 1.2 christos #define _NETINET_IP_COMPAT_H_
14 1.1 christos
15 1.1 christos #ifndef __STDC__
16 1.1 christos # undef const
17 1.1 christos # define const
18 1.1 christos #endif
19 1.1 christos
20 1.1 christos #if defined(_KERNEL) || defined(KERNEL) || defined(__KERNEL__)
21 1.1 christos # undef KERNEL
22 1.1 christos # undef _KERNEL
23 1.1 christos # undef __KERNEL__
24 1.1 christos # define KERNEL
25 1.1 christos # define _KERNEL
26 1.1 christos # define __KERNEL__
27 1.1 christos #endif
28 1.1 christos
29 1.1 christos #ifndef SOLARIS
30 1.4 plunky # if (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
31 1.4 plunky # define SOLARIS 1
32 1.4 plunky # else
33 1.4 plunky # define SOLARIS 0
34 1.4 plunky # endif
35 1.1 christos #endif
36 1.1 christos #if (defined(SOLARIS2) && (SOLARIS2 >= 8))
37 1.1 christos # ifndef USE_INET6
38 1.1 christos # define USE_INET6
39 1.1 christos # endif
40 1.1 christos #endif
41 1.1 christos #if defined(__FreeBSD_version) && (__FreeBSD_version >= 400000) && \
42 1.1 christos !defined(_KERNEL) && !defined(USE_INET6) && !defined(NOINET6)
43 1.1 christos # define USE_INET6
44 1.1 christos #endif
45 1.1 christos #if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 105000000) && \
46 1.2 christos !defined(_KERNEL) && !defined(USE_INET6) && !defined(NOINET6)
47 1.1 christos # define USE_INET6
48 1.1 christos #endif
49 1.1 christos #if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 106140000) && \
50 1.1 christos defined(_KERNEL) && \
51 1.1 christos (!defined(IPFILTER_LKM) || (__NetBSD_Version__ >= 399000100))
52 1.1 christos # define IPFILTER_M_IPFILTER
53 1.1 christos #endif
54 1.1 christos #if !defined(USE_INET6)
55 1.1 christos # if defined(OpenBSD) && (OpenBSD >= 200206) && \
56 1.1 christos !defined(_KERNEL) && !defined(USE_INET6)
57 1.1 christos # define USE_INET6
58 1.1 christos # endif
59 1.1 christos # if defined(__osf__)
60 1.1 christos # define USE_INET6 1
61 1.1 christos # endif
62 1.1 christos # if defined(linux) && (!defined(_KERNEL) || defined(CONFIG_IPV6))
63 1.1 christos # define USE_INET6
64 1.1 christos # endif
65 1.1 christos # if defined(HPUXREV) && (HPUXREV >= 1111)
66 1.1 christos # define USE_INET6
67 1.1 christos # endif
68 1.1 christos #endif
69 1.1 christos
70 1.1 christos #if defined(BSD) && (BSD < 199103) && defined(__osf__)
71 1.1 christos # undef BSD
72 1.1 christos # define BSD 199103
73 1.1 christos #endif
74 1.1 christos
75 1.1 christos #if defined(__SVR4) || defined(__svr4__) || defined(__sgi)
76 1.1 christos # define index strchr
77 1.1 christos # if !defined(_KERNEL)
78 1.1 christos # define bzero(a,b) memset(a,0,b)
79 1.1 christos # define bcmp memcmp
80 1.1 christos # define bcopy(a,b,c) memmove(b,a,c)
81 1.1 christos # endif
82 1.1 christos #endif
83 1.1 christos
84 1.1 christos #ifndef LIFNAMSIZ
85 1.1 christos # ifdef IF_NAMESIZE
86 1.1 christos # define LIFNAMSIZ IF_NAMESIZE
87 1.1 christos # else
88 1.1 christos # ifdef IFNAMSIZ
89 1.1 christos # define LIFNAMSIZ IFNAMSIZ
90 1.1 christos # else
91 1.1 christos # define LIFNAMSIZ 16
92 1.1 christos # endif
93 1.1 christos # endif
94 1.1 christos #endif
95 1.1 christos
96 1.1 christos #if defined(__sgi) || defined(bsdi) || defined(__hpux) || defined(hpux)
97 1.1 christos struct ether_addr {
98 1.1 christos u_char ether_addr_octet[6];
99 1.1 christos };
100 1.1 christos #endif
101 1.1 christos
102 1.1 christos #if defined(__sgi) && !defined(IPFILTER_LKM)
103 1.1 christos # ifdef __STDC__
104 1.1 christos # define IPL_EXTERN(ep) ipfilter##ep
105 1.1 christos # else
106 1.1 christos # define IPL_EXTERN(ep) ipfilter/**/ep
107 1.1 christos # endif
108 1.1 christos #else
109 1.1 christos # ifdef __STDC__
110 1.1 christos # define IPL_EXTERN(ep) ipl##ep
111 1.1 christos # else
112 1.1 christos # define IPL_EXTERN(ep) ipl/**/ep
113 1.1 christos # endif
114 1.1 christos #endif
115 1.1 christos
116 1.1 christos /*
117 1.1 christos * This is a workaround for <sys/uio.h> troubles on FreeBSD and OpenBSD.
118 1.1 christos */
119 1.1 christos #ifndef linux
120 1.1 christos # ifndef _KERNEL
121 1.1 christos # define ADD_KERNEL
122 1.1 christos # define _KERNEL
123 1.1 christos # define KERNEL
124 1.1 christos # endif
125 1.1 christos # ifdef __OpenBSD__
126 1.1 christos struct file;
127 1.1 christos # endif
128 1.1 christos # include <sys/uio.h>
129 1.1 christos # ifdef ADD_KERNEL
130 1.1 christos # undef _KERNEL
131 1.1 christos # undef KERNEL
132 1.1 christos # endif
133 1.1 christos #endif
134 1.1 christos
135 1.4 plunky #if defined(__NetBSD_Version__)
136 1.4 plunky # define NETBSD_GE_REV(x) (__NetBSD_Version__ >= (x))
137 1.4 plunky # define NETBSD_GT_REV(x) (__NetBSD_Version__ > (x))
138 1.4 plunky # define NETBSD_LT_REV(x) (__NetBSD_Version__ < (x))
139 1.4 plunky #else
140 1.4 plunky # define NETBSD_GE_REV(x) 0
141 1.4 plunky # define NETBSD_GT_REV(x) 0
142 1.4 plunky # define NETBSD_LT_REV(x) 0
143 1.4 plunky #endif
144 1.4 plunky
145 1.4 plunky #if defined(__FreeBSD_version)
146 1.4 plunky # define FREEBSD_GE_REV(x) (__FreeBSD_version >= (x))
147 1.4 plunky # define FREEBSD_GT_REV(x) (__FreeBSD_version > (x))
148 1.4 plunky # define FREEBSD_LT_REV(x) (__FreeBSD_version < (x))
149 1.4 plunky #else
150 1.4 plunky # define FREEBSD_GE_REV(x) 0
151 1.4 plunky # define FREEBSD_GT_REV(x) 0
152 1.4 plunky # define FREEBSD_LT_REV(x) 0
153 1.4 plunky #endif
154 1.4 plunky
155 1.4 plunky #if defined(_BSDI_VERSION)
156 1.4 plunky # define BSDOS_GE_REV(x) (_BSDI_VERSION >= (x))
157 1.4 plunky # define BSDOS_GT_REV(x) (_BSDI_VERSION > (x))
158 1.4 plunky # define BSDOS_LT_REV(x) (_BSDI_VERSION < (x))
159 1.4 plunky #else
160 1.4 plunky # define BSDOS_GE_REV(x) 0
161 1.4 plunky # define BSDOS_GT_REV(x) 0
162 1.4 plunky # define BSDOS_LT_REV(x) 0
163 1.4 plunky #endif
164 1.4 plunky
165 1.4 plunky #if defined(OpenBSD)
166 1.4 plunky # define OPENBSD_GE_REV(x) (OpenBSD >= (x))
167 1.4 plunky # define OPENBSD_GT_REV(x) (OpenBSD > (x))
168 1.4 plunky # define OPENBSD_LT_REV(x) (OpenBSD < (x))
169 1.4 plunky #else
170 1.4 plunky # define OPENBSD_GE_REV(x) 0
171 1.4 plunky # define OPENBSD_GT_REV(x) 0
172 1.4 plunky # define OPENBSD_LT_REV(x) 0
173 1.4 plunky #endif
174 1.4 plunky
175 1.4 plunky #if defined(BSD)
176 1.4 plunky # define BSD_GE_YEAR(x) (BSD >= (x))
177 1.4 plunky # define BSD_GT_YEAR(x) (BSD > (x))
178 1.4 plunky # define BSD_LT_YEAR(x) (BSD < (x))
179 1.4 plunky #else
180 1.4 plunky # define BSD_GE_YEAR(x) 0
181 1.4 plunky # define BSD_GT_YEAR(x) 0
182 1.4 plunky # define BSD_LT_YEAR(x) 0
183 1.4 plunky #endif
184 1.1 christos
185 1.1 christos
186 1.1 christos /* ----------------------------------------------------------------------- */
187 1.1 christos /* S O L A R I S */
188 1.1 christos /* ----------------------------------------------------------------------- */
189 1.1 christos #if SOLARIS
190 1.1 christos # define MENTAT 1
191 1.1 christos # include <sys/cmn_err.h>
192 1.1 christos # include <sys/isa_defs.h>
193 1.1 christos # include <sys/stream.h>
194 1.1 christos # include <sys/ioccom.h>
195 1.1 christos # include <sys/sysmacros.h>
196 1.1 christos # include <sys/kmem.h>
197 1.1 christos # if SOLARIS2 >= 10
198 1.1 christos # include <sys/procset.h>
199 1.1 christos # include <sys/proc.h>
200 1.1 christos # include <sys/devops.h>
201 1.1 christos # include <sys/ddi_impldefs.h>
202 1.1 christos # include <sys/sdt.h>
203 1.1 christos # endif
204 1.1 christos /*
205 1.1 christos * because Solaris 2 defines these in two places :-/
206 1.1 christos */
207 1.1 christos # ifndef _KERNEL
208 1.1 christos # define ADD_KERNEL
209 1.1 christos # define _KERNEL
210 1.1 christos # undef RES_INIT
211 1.1 christos # endif /* _KERNEL */
212 1.1 christos
213 1.1 christos # if SOLARIS2 >= 8
214 1.1 christos # include <netinet/ip6.h>
215 1.1 christos # include <netinet/icmp6.h>
216 1.1 christos # endif
217 1.1 christos
218 1.1 christos # include <inet/common.h>
219 1.1 christos /* These 5 are defined in <inet/ip.h> and <netinet/ip.h> */
220 1.1 christos # undef IPOPT_EOL
221 1.1 christos # undef IPOPT_NOP
222 1.1 christos # undef IPOPT_LSRR
223 1.1 christos # undef IPOPT_RR
224 1.1 christos # undef IPOPT_SSRR
225 1.1 christos # ifdef i386
226 1.1 christos # define _SYS_PROMIF_H
227 1.1 christos # endif
228 1.1 christos # ifdef ADD_KERNEL
229 1.1 christos # undef _KERNEL
230 1.1 christos # endif
231 1.1 christos # include <inet/mib2.h>
232 1.1 christos # include <inet/ip.h>
233 1.1 christos # undef COPYOUT
234 1.1 christos # if !defined(_SYS_NETI_H)
235 1.1 christos # include <inet/ip_ire.h>
236 1.1 christos # endif
237 1.1 christos # if SOLARIS2 >= 8
238 1.1 christos # define SNPRINTF snprintf
239 1.1 christos
240 1.1 christos # include <inet/ip_if.h>
241 1.1 christos # define ipif_local_addr ipif_lcl_addr
242 1.1 christos /* Only defined in private include file */
243 1.1 christos # ifndef V4_PART_OF_V6
244 1.1 christos # define V4_PART_OF_V6(v6) v6.s6_addr32[3]
245 1.1 christos # endif
246 1.1 christos struct ip6_ext {
247 1.1 christos u_char ip6e_nxt;
248 1.1 christos u_char ip6e_len;
249 1.1 christos };
250 1.1 christos # endif /* SOLARIS2 >= 8 */
251 1.1 christos
252 1.1 christos # if SOLARIS2 >= 6
253 1.1 christos # include <sys/atomic.h>
254 1.1 christos typedef uint8_t u_int8_t;
255 1.1 christos typedef uint32_t u_32_t;
256 1.1 christos # else
257 1.1 christos typedef unsigned char u_int8_t;
258 1.1 christos typedef unsigned int u_32_t;
259 1.1 christos # endif
260 1.1 christos # define U_32_T 1
261 1.1 christos # if SOLARIS2 >= 7
262 1.1 christos # define USE_QUAD_T 1
263 1.1 christos # define U_QUAD_T uint64_t
264 1.1 christos # define QUAD_T int64_t
265 1.1 christos # endif
266 1.1 christos
267 1.1 christos # ifdef _KERNEL
268 1.1 christos # define NEED_LOCAL_RAND 1
269 1.1 christos # define KRWLOCK_T krwlock_t
270 1.1 christos # define KMUTEX_T kmutex_t
271 1.1 christos # if !defined(FW_HOOKS)
272 1.1 christos # include "qif.h"
273 1.1 christos # include "pfil.h"
274 1.1 christos # endif
275 1.1 christos # if SOLARIS2 >= 6
276 1.1 christos # if SOLARIS2 == 6
277 1.1 christos # define ATOMIC_INCL(x) atomic_add_long((uint32_t*)&(x), 1)
278 1.1 christos # define ATOMIC_DECL(x) atomic_add_long((uint32_t*)&(x), -1)
279 1.1 christos # else
280 1.1 christos # define ATOMIC_INCL(x) atomic_add_long(&(x), 1)
281 1.1 christos # define ATOMIC_DECL(x) atomic_add_long(&(x), -1)
282 1.1 christos # endif /* SOLARIS2 == 6 */
283 1.1 christos # define ATOMIC_INC64(x) atomic_add_64((uint64_t*)&(x), 1)
284 1.1 christos # define ATOMIC_INC32(x) atomic_add_32((uint32_t*)&(x), 1)
285 1.1 christos # define ATOMIC_DEC64(x) atomic_add_64((uint64_t*)&(x), -1)
286 1.1 christos # define ATOMIC_DEC32(x) atomic_add_32((uint32_t*)&(x), -1)
287 1.1 christos # else
288 1.1 christos # define ATOMIC_INC(x) { mutex_enter(&softc->ipf_rw); (x)++; \
289 1.1 christos mutex_exit(&softc->ipf_rw); }
290 1.1 christos # define ATOMIC_DEC(x) { mutex_enter(&softc->ipf_rw); (x)--; \
291 1.1 christos mutex_exit(&softc->ipf_rw); }
292 1.1 christos # endif /* SOLARIS2 >= 6 */
293 1.1 christos # define USE_MUTEXES
294 1.1 christos # define MUTEX_ENTER(x) mutex_enter(&(x)->ipf_lk)
295 1.1 christos # define READ_ENTER(x) rw_enter(&(x)->ipf_lk, RW_READER)
296 1.1 christos # define WRITE_ENTER(x) rw_enter(&(x)->ipf_lk, RW_WRITER)
297 1.1 christos # define MUTEX_DOWNGRADE(x) rw_downgrade(&(x)->ipf_lk)
298 1.1 christos # define RWLOCK_INIT(x, y) rw_init(&(x)->ipf_lk, (y), \
299 1.1 christos RW_DRIVER, NULL)
300 1.1 christos # define RWLOCK_EXIT(x) rw_exit(&(x)->ipf_lk)
301 1.1 christos # define RW_DESTROY(x) rw_destroy(&(x)->ipf_lk)
302 1.1 christos # define MUTEX_INIT(x, y) mutex_init(&(x)->ipf_lk, (y), \
303 1.1 christos MUTEX_DRIVER, NULL)
304 1.1 christos # define MUTEX_DESTROY(x) mutex_destroy(&(x)->ipf_lk)
305 1.1 christos # define MUTEX_NUKE(x) bzero((x), sizeof(*(x)))
306 1.1 christos # define MUTEX_EXIT(x) mutex_exit(&(x)->ipf_lk)
307 1.1 christos # define COPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c))
308 1.1 christos # define COPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c))
309 1.1 christos # define BCOPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c))
310 1.1 christos # define BCOPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c))
311 1.1 christos # define UIOMOVE(a,b,c,d) uiomove((caddr_t)a,b,c,d)
312 1.1 christos # define KFREE(x) kmem_free((char *)(x), sizeof(*(x)))
313 1.1 christos # define KFREES(x,s) kmem_free((char *)(x), (s))
314 1.1 christos # define SPL_SCHED(x) ;
315 1.1 christos # define SPL_NET(x) ;
316 1.1 christos # define SPL_IMP(x) ;
317 1.1 christos # undef SPL_X
318 1.1 christos # define SPL_X(x) ;
319 1.1 christos # ifdef sparc
320 1.1 christos # define ntohs(x) (x)
321 1.1 christos # define ntohl(x) (x)
322 1.1 christos # define htons(x) (x)
323 1.1 christos # define htonl(x) (x)
324 1.1 christos # endif /* sparc */
325 1.1 christos # define KMALLOC(a,b) (a) = (b)kmem_alloc(sizeof(*(a)), KM_NOSLEEP)
326 1.1 christos # define KMALLOCS(a,b,c) (a) = (b)kmem_alloc((c), KM_NOSLEEP)
327 1.1 christos # define GET_MINOR(x) getminor(x)
328 1.2 christos extern void *get_unit(void *, char *, int);
329 1.1 christos # define GETIFP(n, v) get_unit(softc, n, v)
330 1.1 christos # if defined(INSTANCES)
331 1.1 christos # include <sys/hook.h>
332 1.1 christos # include <sys/neti.h>
333 1.1 christos typedef struct qpktinfo {
334 1.1 christos void *qpi_real; /* the real one on the STREAM */
335 1.1 christos void *qpi_ill; /* COPIED */
336 1.1 christos mblk_t *qpi_m;
337 1.1 christos queue_t *qpi_q;
338 1.1 christos void *qpi_data; /* where layer 3 header starts */
339 1.1 christos size_t qpi_off;
340 1.1 christos int qpi_flags; /* COPIED */
341 1.1 christos } qpktinfo_t;
342 1.1 christos
343 1.3 darrenr #define QF_MULTICAST 0x0001
344 1.3 darrenr #define QF_BROADCAST 0x0002
345 1.1 christos
346 1.1 christos typedef struct qifpkt {
347 1.1 christos struct qifpkt *qp_next;
348 1.1 christos char qp_ifname[LIFNAMSIZ];
349 1.1 christos int qp_sap;
350 1.1 christos mblk_t *qp_mb;
351 1.1 christos int qp_inout;
352 1.1 christos } qifpkt_t;
353 1.1 christos
354 1.1 christos # define COPYIFNAME(v, x,b) \
355 1.1 christos do { \
356 1.1 christos if ((v) == 4) { \
357 1.1 christos net_getifname(softc->ipf_nd_v4, \
358 1.1 christos (phy_if_t)x, b, \
359 1.1 christos sizeof(b)); \
360 1.1 christos } else { \
361 1.1 christos net_getifname(softc->ipf_nd_v6, \
362 1.1 christos (phy_if_t)x, b, \
363 1.1 christos sizeof(b)); \
364 1.1 christos } \
365 1.1 christos } while (0)
366 1.1 christos # define GETIFMTU_4(x) net_getmtu(softc->ipf_nd_v4, (phy_if_t)x, 0)
367 1.1 christos # define GETIFMTU_6(x) net_getmtu(softc->ipf_nd_v6, (phy_if_t)x, 0)
368 1.1 christos # define GET_SOFTC(x) ipf_find_softc(x)
369 1.1 christos # else
370 1.1 christos # define FASTROUTE_RECURSION 1
371 1.1 christos # define GET_SOFTC(x) &ipfmain
372 1.1 christos # define GETIFMTU_4(x) ((qif_t *)x)->qf_max_frag
373 1.1 christos # define GETIFMTU_6(x) ((qif_t *)x)->qf_max_frag
374 1.1 christos # define IFNAME(x) ((qif_t *)x)->qf_name
375 1.1 christos # define COPYIFNAME(v, x, b) \
376 1.1 christos (void) strncpy(b, ((qif_t *)x)->qf_name, \
377 1.1 christos LIFNAMSIZ)
378 1.1 christos # endif
379 1.1 christos # define GETKTIME(x) uniqtime((struct timeval *)x)
380 1.3 darrenr # define MSGDSIZE(m) msgdsize(m)
381 1.3 darrenr # define M_LEN(m) ((m)->b_wptr - (m)->b_rptr)
382 1.1 christos # define M_ADJ(m,x) adjmsg(m, x)
383 1.1 christos # define M_COPY(x) dupmsg((x))
384 1.1 christos # define MTOD(m,t) ((t)((m)->b_rptr))
385 1.1 christos # define MTYPE(m) ((m)->b_datap->db_type)
386 1.1 christos # define FREE_MB_T(m) freemsg(m)
387 1.1 christos # define ALLOC_MB_T(m,l) (m) = allocmbt(l)
388 1.1 christos # define PREP_MB_T(f,m) ipf_prependmbt(f, m)
389 1.1 christos # define M_DUP(m) copymsg(m)
390 1.1 christos # define m_next b_cont
391 1.1 christos # define IPF_PANIC(x,y) if (x) { printf y; cmn_err(CE_PANIC, "ipf_panic"); }
392 1.1 christos typedef mblk_t mb_t;
393 1.3 darrenr extern void mb_copydata __P((mblk_t *, size_t, size_t, char *));
394 1.3 darrenr extern void mb_copyback __P((mblk_t *, size_t, size_t, char *));
395 1.1 christos # endif /* _KERNEL */
396 1.1 christos
397 1.1 christos # if (SOLARIS2 >= 7)
398 1.1 christos # ifdef lint
399 1.1 christos # define ALIGN32(ptr) (ptr ? 0L : 0L)
400 1.1 christos # define ALIGN16(ptr) (ptr ? 0L : 0L)
401 1.1 christos # else
402 1.1 christos # define ALIGN32(ptr) (ptr)
403 1.1 christos # define ALIGN16(ptr) (ptr)
404 1.1 christos # endif
405 1.1 christos # endif
406 1.1 christos
407 1.1 christos # if SOLARIS2 < 6
408 1.1 christos typedef struct uio uio_t;
409 1.1 christos # endif
410 1.1 christos typedef int ioctlcmd_t;
411 1.1 christos
412 1.1 christos # define OS_RECOGNISED 1
413 1.1 christos
414 1.1 christos #endif /* SOLARIS */
415 1.1 christos
416 1.1 christos /* ----------------------------------------------------------------------- */
417 1.1 christos /* H P U X */
418 1.1 christos /* ----------------------------------------------------------------------- */
419 1.1 christos #ifdef __hpux
420 1.1 christos # define MENTAT 1
421 1.1 christos # include <sys/sysmacros.h>
422 1.1 christos # include <sys/spinlock.h>
423 1.1 christos # include <sys/lock.h>
424 1.1 christos # include <sys/stream.h>
425 1.1 christos # ifdef USE_INET6
426 1.1 christos # include <netinet/if_ether.h>
427 1.1 christos # include <netinet/ip6.h>
428 1.1 christos # include <netinet/icmp6.h>
429 1.1 christos typedef struct ip6_hdr ip6_t;
430 1.1 christos # endif
431 1.1 christos
432 1.1 christos # ifdef _KERNEL
433 1.1 christos # define FASTROUTE_RECURSION 1
434 1.1 christos # define SNPRINTF sprintf
435 1.1 christos # if (HPUXREV >= 1111)
436 1.1 christos # define IPL_SELECT
437 1.1 christos # ifdef IPL_SELECT
438 1.1 christos # include <machine/sys/user.h>
439 1.1 christos # include <sys/kthread_iface.h>
440 1.1 christos # define READ_COLLISION 0x01
441 1.1 christos
442 1.1 christos typedef struct iplog_select_s {
443 1.1 christos kthread_t *read_waiter;
444 1.1 christos int state;
445 1.1 christos } iplog_select_t;
446 1.1 christos # endif
447 1.1 christos # endif
448 1.1 christos
449 1.1 christos # define GETKTIME(x) uniqtime((struct timeval *)x)
450 1.1 christos
451 1.1 christos # if HPUXREV == 1111
452 1.1 christos # include "kern_svcs.h"
453 1.1 christos # else
454 1.1 christos # include <sys/kern_svcs.h>
455 1.1 christos # endif
456 1.1 christos # undef ti_flags
457 1.1 christos # undef TCP_NODELAY
458 1.1 christos # undef TCP_MAXSEG
459 1.1 christos # include <sys/reg.h>
460 1.1 christos # include "../netinet/ip_info.h"
461 1.1 christos /*
462 1.1 christos * According to /usr/include/sys/spinlock.h on HP-UX 11.00, these functions
463 1.1 christos * are available. Attempting to use them actually results in unresolved
464 1.1 christos * symbols when it comes time to load the module.
465 1.1 christos * This has been fixed! Yipee!
466 1.1 christos */
467 1.1 christos # if 1
468 1.1 christos # ifdef __LP64__
469 1.1 christos # define ATOMIC_INCL(x) lock_and_incr_int64(&softc->ipf_rw.ipf_lk, &(x), 1)
470 1.1 christos # define ATOMIC_DECL(x) lock_and_incr_int64(&softc->ipf_rw.ipf_lk, &(x), -1)
471 1.1 christos # else
472 1.1 christos # define ATOMIC_INCL(x) lock_and_incr_int32(&softc->ipf_rw.ipf_lk, &(x), 1)
473 1.1 christos # define ATOMIC_DECL(x) lock_and_incr_int32(&softc->ipf_rw.ipf_lk, &(x), -1)
474 1.1 christos # endif
475 1.1 christos # define ATOMIC_INC64(x) lock_and_incr_int64(&softc->ipf_rw.ipf_lk, &(x), 1)
476 1.1 christos # define ATOMIC_INC32(x) lock_and_incr_int32(&softc->ipf_rw.ipf_lk, &(x), 1)
477 1.1 christos # define ATOMIC_DEC64(x) lock_and_incr_int64(&softc->ipf_rw.ipf_lk, &(x), -1)
478 1.1 christos # define ATOMIC_DEC32(x) lock_and_incr_int32(&softc->ipf_rw.ipf_lk, &(x), -1)
479 1.1 christos # else /* 0 */
480 1.1 christos # define ATOMIC_INC64(x) { MUTEX_ENTER(&softc->ipf_rw); (x)++; \
481 1.1 christos MUTEX_EXIT(&softc->ipf_rw); }
482 1.1 christos # define ATOMIC_DEC64(x) { MUTEX_ENTER(&softc->ipf_rw); (x)--; \
483 1.1 christos MUTEX_EXIT(&softc->ipf_rw); }
484 1.1 christos # define ATOMIC_INC32(x) { MUTEX_ENTER(&softc->ipf_rw); (x)++; \
485 1.1 christos MUTEX_EXIT(&softc->ipf_rw); }
486 1.1 christos # define ATOMIC_DEC32(x) { MUTEX_ENTER(&softc->ipf_rw); (x)--; \
487 1.1 christos MUTEX_EXIT(&softc->ipf_rw); }
488 1.1 christos # define ATOMIC_INCL(x) { MUTEX_ENTER(&softc->ipf_rw); (x)++; \
489 1.1 christos MUTEX_EXIT(&softc->ipf_rw); }
490 1.1 christos # define ATOMIC_DECL(x) { MUTEX_ENTER(&softc->ipf_rw); (x)--; \
491 1.1 christos MUTEX_EXIT(&softc->ipf_rw); }
492 1.1 christos # define ATOMIC_INC(x) { MUTEX_ENTER(&softc->ipf_rw); (x)++; \
493 1.1 christos MUTEX_EXIT(&softc->ipf_rw); }
494 1.1 christos # define ATOMIC_DEC(x) { MUTEX_ENTER(&softc->ipf_rw); (x)--; \
495 1.1 christos MUTEX_EXIT(&softc->ipf_rw); }
496 1.1 christos # endif
497 1.1 christos # define ip_cksum ip_csuma
498 1.2 christos # define memcpy(a,b,c) bcopy((void *)b, (void *)a, c)
499 1.1 christos # define USE_MUTEXES
500 1.1 christos # define MUTEX_INIT(x, y) initlock(&(x)->ipf_lk, 0, 0, (y))
501 1.1 christos # define MUTEX_ENTER(x) spinlock(&(x)->ipf_lk)
502 1.1 christos # define MUTEX_EXIT(x) spinunlock(&(x)->ipf_lk);
503 1.1 christos # define MUTEX_DESTROY(x)
504 1.1 christos # define MUTEX_NUKE(x) bzero((char *)(x), sizeof(*(x)))
505 1.1 christos # define KMUTEX_T lock_t
506 1.1 christos # define kmutex_t lock_t /* for pfil.h */
507 1.1 christos # define krwlock_t lock_t /* for pfil.h */
508 1.1 christos /*
509 1.1 christos * The read-write lock implementation in HP-UX 11.0 is crippled - it can
510 1.1 christos * only be used by threads working in a user context!
511 1.1 christos * This has been fixed! Yipee! (Or at least it does in 11.00, not 11.11..)
512 1.1 christos */
513 1.1 christos # if HPUXREV < 1111
514 1.1 christos # define MUTEX_DOWNGRADE(x) lock_write_to_read(x)
515 1.1 christos # define KRWLOCK_T struct rw_lock
516 1.1 christos # define READ_ENTER(x) lock_read(&(x)->ipf_lk)
517 1.1 christos # define WRITE_ENTER(x) lock_write(&(x)->ipf_lk)
518 1.1 christos # if HPUXREV >= 1111
519 1.1 christos # define RWLOCK_INIT(x, y) rwlock_init4(&(x)->ipf_lk, 0, RWLCK_CANSLEEP, 0, y)
520 1.1 christos # else
521 1.1 christos # define RWLOCK_INIT(x, y) lock_init3(&(x)->ipf_lk, 0, 1, 0, 0, y)
522 1.1 christos # endif
523 1.1 christos # define RWLOCK_EXIT(x) lock_done(&(x)->ipf_lk)
524 1.1 christos # else
525 1.1 christos # define KRWLOCK_T lock_t
526 1.1 christos # define KMUTEX_T lock_t
527 1.1 christos # define READ_ENTER(x) MUTEX_ENTER(x)
528 1.1 christos # define WRITE_ENTER(x) MUTEX_ENTER(x)
529 1.1 christos # define MUTEX_DOWNGRADE(x)
530 1.1 christos # define RWLOCK_INIT(x, y) initlock(&(x)->ipf_lk, 0, 0, y)
531 1.1 christos # define RWLOCK_EXIT(x) MUTEX_EXIT(x)
532 1.1 christos # endif
533 1.1 christos # define RW_DESTROY(x)
534 1.1 christos # define COPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c))
535 1.1 christos # define COPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c))
536 1.1 christos # define SPL_SCHED(x) ;
537 1.1 christos # define SPL_NET(x) ;
538 1.1 christos # define SPL_IMP(x) ;
539 1.1 christos # undef SPL_X
540 1.1 christos # define SPL_X(x) ;
541 1.2 christos extern void *get_unit(char *, int);
542 1.1 christos # define GETIFP(n, v) get_unit(n, v)
543 1.1 christos # define GETIFMTU_4(x) ((ill_t *)x)->ill_mtu
544 1.1 christos # define GETIFMTU_6(x) ((ill_t *)x)->ill_mtu
545 1.1 christos # define IFNAME(x, b) ((ill_t *)x)->ill_name
546 1.1 christos # define COPYIFNAME(v, x, b) \
547 1.1 christos (void) strncpy(b, ((qif_t *)x)->qf_name, \
548 1.1 christos LIFNAMSIZ)
549 1.2 christos # define UIOMOVE(a,b,c,d) uiomove((void *)a,b,c,d)
550 1.2 christos # define SLEEP(id, n) { lock_t *_l = get_sleep_lock((void *)id); \
551 1.1 christos sleep(id, PZERO+1); \
552 1.1 christos spinunlock(_l); \
553 1.1 christos }
554 1.2 christos # define WAKEUP(id,x) { lock_t *_l = get_sleep_lock((void *)id); \
555 1.1 christos wakeup(id + x); \
556 1.1 christos spinunlock(_l); \
557 1.1 christos }
558 1.1 christos # define POLLWAKEUP(x) ;
559 1.1 christos # define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), M_IOSYS, M_NOWAIT)
560 1.2 christos # define KMALLOCS(a, b, c) (a) = (b)malloc((c), M_IOSYS, M_NOWAIT)
561 1.1 christos # define KFREE(x) kmem_free((char *)(x), sizeof(*(x)))
562 1.1 christos # define KFREES(x,s) kmem_free((char *)(x), (s))
563 1.3 darrenr # define MSGDSIZE(m) msgdsize(m)
564 1.1 christos # define M_ADJ(m,x) adjmsg(m, x)
565 1.3 darrenr # define M_LEN(m) ((m)->b_wptr - (m)->b_rptr)
566 1.3 darrenr # define M_COPY(m) copymsg((m))
567 1.1 christos # define M_DUP(m) dupmsg(m)
568 1.1 christos # define MTOD(m,t) ((t)((m)->b_rptr))
569 1.1 christos # define MTYPE(m) ((m)->b_datap->db_type)
570 1.1 christos # define FREE_MB_T(m) freemsg(m)
571 1.1 christos # define m_next b_cont
572 1.1 christos # define IPF_PANIC(x,y) if (x) { printf y; panic("ipf_panic"); }
573 1.1 christos typedef mblk_t mb_t;
574 1.1 christos
575 1.1 christos # include "qif.h"
576 1.1 christos # include "pfil.h"
577 1.1 christos
578 1.1 christos # else /* _KERNEL */
579 1.1 christos
580 1.1 christos typedef unsigned char uchar_t;
581 1.1 christos
582 1.1 christos # ifndef _SYS_STREAM_INCLUDED
583 1.1 christos typedef char * mblk_t;
584 1.2 christos typedef void *queue_t;
585 1.1 christos typedef u_long ulong;
586 1.1 christos # endif
587 1.1 christos # include <netinet/ip_info.h>
588 1.1 christos
589 1.1 christos # endif /* _KERNEL */
590 1.1 christos
591 1.1 christos # ifdef lint
592 1.1 christos # define ALIGN32(ptr) (ptr ? 0L : 0L)
593 1.1 christos # define ALIGN16(ptr) (ptr ? 0L : 0L)
594 1.1 christos # else
595 1.1 christos # define ALIGN32(ptr) (ptr)
596 1.1 christos # define ALIGN16(ptr) (ptr)
597 1.1 christos # endif
598 1.1 christos
599 1.1 christos typedef struct uio uio_t;
600 1.1 christos typedef int ioctlcmd_t;
601 1.1 christos typedef int minor_t;
602 1.1 christos typedef unsigned int u_32_t;
603 1.1 christos # define U_32_T 1
604 1.1 christos
605 1.1 christos # define OS_RECOGNISED 1
606 1.1 christos
607 1.1 christos #endif /* __hpux */
608 1.1 christos
609 1.1 christos /* ----------------------------------------------------------------------- */
610 1.1 christos /* I R I X */
611 1.1 christos /* ----------------------------------------------------------------------- */
612 1.1 christos #ifdef __sgi
613 1.1 christos # undef MENTAT
614 1.1 christos # if IRIX < 60500
615 1.1 christos typedef struct uio uio_t;
616 1.1 christos # endif
617 1.1 christos typedef int ioctlcmd_t;
618 1.1 christos typedef u_int32_t u_32_t;
619 1.1 christos # define U_32_T 1
620 1.1 christos
621 1.1 christos # ifdef INET6
622 1.1 christos # define USE_INET6
623 1.1 christos # endif
624 1.1 christos
625 1.1 christos # define hz HZ
626 1.1 christos # include <sys/ksynch.h>
627 1.1 christos # define IPF_LOCK_PL plhi
628 1.1 christos # include <sys/sema.h>
629 1.1 christos # undef kmutex_t
630 1.1 christos typedef struct {
631 1.1 christos lock_t *l;
632 1.1 christos int pl;
633 1.1 christos } kmutex_t;
634 1.1 christos
635 1.1 christos # ifdef MUTEX_INIT
636 1.1 christos # define KMUTEX_T mutex_t
637 1.1 christos # else
638 1.1 christos # define KMUTEX_T kmutex_t
639 1.1 christos # define KRWLOCK_T kmutex_t
640 1.1 christos # endif
641 1.1 christos
642 1.1 christos # ifdef _KERNEL
643 1.1 christos # define NEED_LOCAL_RAND 1
644 1.1 christos # define ATOMIC_INC(x) { MUTEX_ENTER(&softc->ipf_rw); \
645 1.1 christos (x)++; MUTEX_EXIT(&softc->ipf_rw); }
646 1.1 christos # define ATOMIC_DEC(x) { MUTEX_ENTER(&softc->ipf_rw); \
647 1.1 christos (x)--; MUTEX_EXIT(&softc->ipf_rw); }
648 1.1 christos # define USE_MUTEXES
649 1.1 christos # ifdef MUTEX_INIT
650 1.1 christos # include <sys/atomic_ops.h>
651 1.1 christos # define ATOMIC_INCL(x) atomicAddUlong(&(x), 1)
652 1.1 christos # define ATOMIC_INC64(x) atomicAddUint64(&(x), 1)
653 1.1 christos # define ATOMIC_INC32(x) atomicAddUint(&(x), 1)
654 1.1 christos # define ATOMIC_DECL(x) atomicAddUlong(&(x), -1)
655 1.1 christos # define ATOMIC_DEC64(x) atomicAddUint64(&(x), -1)
656 1.1 christos # define ATOMIC_DEC32(x) atomicAddUint(&(x), -1)
657 1.1 christos # undef MUTEX_INIT
658 1.1 christos # define MUTEX_INIT(x, y) mutex_init(&(x)->ipf_lk, \
659 1.1 christos MUTEX_DEFAULT, y)
660 1.1 christos # undef MUTEX_ENTER
661 1.1 christos # define MUTEX_ENTER(x) mutex_lock(&(x)->ipf_lk, 0)
662 1.1 christos # undef MUTEX_EXIT
663 1.1 christos # define MUTEX_EXIT(x) mutex_unlock(&(x)->ipf_lk)
664 1.1 christos # undef MUTEX_DESTROY
665 1.1 christos # define MUTEX_DESTROY(x) mutex_destroy(&(x)->ipf_lk)
666 1.1 christos # define MUTEX_DOWNGRADE(x) mrdemote(&(x)->ipf_lk)
667 1.1 christos # define KRWLOCK_T mrlock_t
668 1.1 christos # define RWLOCK_INIT(x, y) mrinit(&(x)->ipf_lk, y)
669 1.1 christos # undef RW_DESTROY
670 1.1 christos # define RW_DESTROY(x) mrfree(&(x)->ipf_lk)
671 1.1 christos # define READ_ENTER(x) RW_RDLOCK(&(x)->ipf_lk)
672 1.1 christos # define WRITE_ENTER(x) RW_WRLOCK(&(x)->ipf_lk)
673 1.1 christos # define RWLOCK_EXIT(x) RW_UNLOCK(&(x)->ipf_lk)
674 1.1 christos # else
675 1.1 christos # define READ_ENTER(x) MUTEX_ENTER(&(x)->ipf_lk)
676 1.1 christos # define WRITE_ENTER(x) MUTEX_ENTER(&(x)->ipf_lk)
677 1.1 christos # define MUTEX_DOWNGRADE(x) ;
678 1.1 christos # define RWLOCK_EXIT(x) MUTEX_EXIT(&(x)->ipf_lk)
679 1.1 christos # define MUTEX_EXIT(x) UNLOCK((x)->ipf_lk.l, (x)->ipf_lk.pl);
680 1.1 christos # define MUTEX_INIT(x,y) (x)->ipf_lk.l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP)
681 1.1 christos # define MUTEX_DESTROY(x) LOCK_DEALLOC((x)->ipf_lk.l)
682 1.1 christos # define MUTEX_ENTER(x) (x)->ipf_lk.pl = LOCK((x)->ipf_lk.l, \
683 1.1 christos IPF_LOCK_PL);
684 1.1 christos # endif
685 1.1 christos # define MUTEX_NUKE(x) bzero((x), sizeof(*(x)))
686 1.1 christos # define FREE_MB_T(m) m_freem(m)
687 1.1 christos # define MTOD(m,t) mtod(m,t)
688 1.1 christos # define COPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
689 1.1 christos # define COPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
690 1.1 christos # define UIOMOVE(a,b,c,d) uiomove((caddr_t)a,b,c,d)
691 1.1 christos # define SLEEP(id, n) sleep((id), PZERO+1)
692 1.1 christos # define WAKEUP(id,x) wakeup(id+x)
693 1.1 christos # define POLLWAKEUP(x) ;
694 1.1 christos # define KFREE(x) kmem_free((char *)(x), sizeof(*(x)))
695 1.1 christos # define KFREES(x,s) kmem_free((char *)(x), (s))
696 1.1 christos # define GETIFP(n,v) ifunit(n)
697 1.1 christos # define GETIFMTU_4(x) ((struct ifnet *)x)->if_mtu
698 1.1 christos # define GETIFMTU_6(x) ((struct ifnet *)x)->if_mtu
699 1.1 christos # include <sys/kmem.h>
700 1.1 christos # include <sys/ddi.h>
701 1.1 christos # define KMALLOC(a,b) (a) = (b)kmem_alloc(sizeof(*(a)), KM_NOSLEEP)
702 1.1 christos # define KMALLOCS(a,b,c) (a) = (b)kmem_alloc((c), KM_NOSLEEP)
703 1.1 christos # define GET_MINOR(x) getminor(x)
704 1.1 christos # define USE_SPL 1
705 1.1 christos # define SPL_IMP(x) (x) = splimp()
706 1.1 christos # define SPL_NET(x) (x) = splnet()
707 1.1 christos # define SPL_SCHED(x) (x) = splsched()
708 1.1 christos # define SPL_X(x) (void) splx(x)
709 1.2 christos extern void m_copydata(struct mbuf *, int, int, void *);
710 1.2 christos extern void m_copyback(struct mbuf *, int, int, void *);
711 1.1 christos # define M_ADJ(m,x) m_adj(m, x)
712 1.1 christos # define M_LEN(x) (x)->m_len
713 1.3 darrenr # define M_COPY(m) m_copy((m), 0, M_COPYALL)
714 1.1 christos # define GETKTIME(x) microtime((struct timeval *)x)
715 1.1 christos # define IFNAME(x) ((struct ifnet *)x)->if_name
716 1.1 christos # define IPF_PANIC(x,y) if (x) { printf y; panic("ipf_panic"); }
717 1.1 christos typedef struct mbuf mb_t;
718 1.1 christos # else
719 1.1 christos # undef RW_DESTROY
720 1.1 christos # undef MUTEX_INIT
721 1.1 christos # undef MUTEX_DESTROY
722 1.1 christos # endif /* _KERNEL */
723 1.1 christos
724 1.1 christos # define OS_RECOGNISED 1
725 1.1 christos
726 1.1 christos #endif /* __sgi */
727 1.1 christos
728 1.1 christos /* ----------------------------------------------------------------------- */
729 1.1 christos /* T R U 6 4 */
730 1.1 christos /* ----------------------------------------------------------------------- */
731 1.1 christos #ifdef __osf__
732 1.1 christos # undef MENTAT
733 1.1 christos
734 1.1 christos # include <kern/lock.h>
735 1.1 christos # include <sys/sysmacros.h>
736 1.1 christos
737 1.1 christos # ifdef _KERNEL
738 1.1 christos # define NEED_LOCAL_RAND 1
739 1.1 christos # define KMUTEX_T simple_lock_data_t
740 1.1 christos # define KRWLOCK_T lock_data_t
741 1.1 christos # include <net/net_globals.h>
742 1.1 christos # define USE_MUTEXES
743 1.1 christos # define READ_ENTER(x) lock_read(&(x)->ipf_lk)
744 1.1 christos # define WRITE_ENTER(x) lock_write(&(x)->ipf_lk)
745 1.1 christos # define MUTEX_DOWNGRADE(x) lock_write_to_read(&(x)->ipf_lk)
746 1.1 christos # define RWLOCK_INIT(x, y) lock_init(&(x)->ipf_lk, TRUE)
747 1.1 christos # define RWLOCK_EXIT(x) lock_done(&(x)->ipf_lk)
748 1.1 christos # define RW_DESTROY(x) lock_terminate(&(x)->ipf_lk)
749 1.1 christos # define MUTEX_ENTER(x) simple_lock(&(x)->ipf_lk)
750 1.1 christos # define MUTEX_INIT(x, y) simple_lock_init(&(x)->ipf_lk)
751 1.1 christos # define MUTEX_DESTROY(x) simple_lock_terminate(&(x)->ipf_lk)
752 1.1 christos # define MUTEX_EXIT(x) simple_unlock(&(x)->ipf_lk)
753 1.1 christos # define MUTEX_NUKE(x) bzero(x, sizeof(*(x)))
754 1.1 christos # define ATOMIC_INC64(x) atomic_incq((uint64_t*)&(x))
755 1.1 christos # define ATOMIC_DEC64(x) atomic_decq((uint64_t*)&(x))
756 1.1 christos # define ATOMIC_INC32(x) atomic_incl((uint32_t*)&(x))
757 1.1 christos # define ATOMIC_DEC32(x) atomic_decl((uint32_t*)&(x))
758 1.1 christos # define ATOMIC_INCL(x) atomic_incl((uint32_t*)&(x))
759 1.1 christos # define ATOMIC_DECL(x) atomic_decl((uint32_t*)&(x))
760 1.1 christos # define ATOMIC_INC(x) { simple_lock(&softc->ipf_rw); (x)++; \
761 1.1 christos simple_unlock(&softc->ipf_rw); }
762 1.1 christos # define ATOMIC_DEC(x) { simple_lock(&softc->ipf_rw); (x)--; \
763 1.1 christos simple_unlock(&softc->ipf_rw); }
764 1.1 christos # define SPL_SCHED(x) ;
765 1.1 christos # define SPL_NET(x) ;
766 1.1 christos # define SPL_IMP(x) ;
767 1.1 christos # undef SPL_X
768 1.1 christos # define SPL_X(x) ;
769 1.2 christos # define UIOMOVE(a,b,c,d) uiomove((void *)a, b, d)
770 1.1 christos # define FREE_MB_T(m) m_freem(m)
771 1.1 christos # define MTOD(m,t) mtod(m,t)
772 1.1 christos # define GETIFP(n, v) ifunit(n)
773 1.1 christos # define GETIFMTU_4(x) ((struct ifnet *)x)->if_mtu
774 1.1 christos # define GETIFMTU_6(x) ((struct ifnet *)x)->if_mtu
775 1.1 christos # define GET_MINOR getminor
776 1.1 christos # define WAKEUP(id,x) wakeup(id + x)
777 1.1 christos # define POLLWAKEUP(x) ;
778 1.1 christos # define COPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c))
779 1.1 christos # define COPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c))
780 1.1 christos # define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), M_PFILT, M_NOWAIT)
781 1.2 christos # define KMALLOCS(a, b, c) (a) = (b)malloc((c), M_PFILT, \
782 1.1 christos ((c) > 4096) ? M_WAITOK : M_NOWAIT)
783 1.1 christos # define KFREE(x) FREE((x), M_PFILT)
784 1.1 christos # define KFREES(x,s) FREE((x), M_PFILT)
785 1.3 darrenr # define MSGDSIZE(m) mbufchainlen(m)
786 1.3 darrenr # define M_LEN(m) (m)->m_len
787 1.1 christos # define M_ADJ(m,x) m_adj(m, x)
788 1.3 darrenr # define M_COPY(m) m_copy((m), 0, M_COPYALL)
789 1.3 darrenr # define M_DUP(m) m_copy((m), 0, M_COPYALL)
790 1.1 christos # define GETKTIME(x) microtime((struct timeval *)x)
791 1.1 christos # define IFNAME(x) ((struct ifnet *)x)->if_name
792 1.1 christos # define IPF_PANIC(x,y) if (x) { printf y; panic("ipf_panic"); }
793 1.1 christos # define selinfo sel_queue
794 1.1 christos typedef struct mbuf mb_t;
795 1.1 christos # endif /* _KERNEL */
796 1.1 christos
797 1.1 christos # if (defined(_KERNEL) || defined(_NO_BITFIELDS) || (__STDC__ == 1))
798 1.1 christos # define IP_V(x) ((x)->ip_vhl >> 4)
799 1.1 christos # define IP_HL(x) ((x)->ip_vhl & 0xf)
800 1.1 christos # define IP_V_A(x,y) (x)->ip_vhl |= (((y) << 4) & 0xf0)
801 1.1 christos # define IP_HL_A(x,y) (x)->ip_vhl |= ((y) & 0xf)
802 1.1 christos # define TCP_X2(x) ((x)->th_xoff & 0xf)
803 1.1 christos # define TCP_X2_A(x,y) (x)->th_xoff |= ((y) & 0xf)
804 1.1 christos # define TCP_OFF(x) ((x)->th_xoff >> 4)
805 1.1 christos # define TCP_OFF_A(x,y) (x)->th_xoff |= (((y) << 4) & 0xf0)
806 1.1 christos # endif
807 1.1 christos # if TRU64 <= 1885
808 1.1 christos # define ip6_vfc ip6_vcf
809 1.1 christos # endif
810 1.1 christos
811 1.1 christos /*
812 1.1 christos * These are from's Solaris' #defines for little endian.
813 1.1 christos */
814 1.1 christos #define IP6F_MORE_FRAG 0x0100
815 1.1 christos #define IP6F_RESERVED_MASK 0x0600
816 1.1 christos #define IP6F_OFF_MASK 0xf8ff
817 1.1 christos
818 1.1 christos struct ip6_ext {
819 1.1 christos u_char ip6e_nxt;
820 1.1 christos u_char ip6e_len;
821 1.1 christos };
822 1.1 christos
823 1.1 christos typedef int ioctlcmd_t;
824 1.1 christos /*
825 1.1 christos * Really, any arch where sizeof(long) != sizeof(int).
826 1.1 christos */
827 1.1 christos typedef unsigned int u_32_t;
828 1.1 christos # define U_32_T 1
829 1.1 christos
830 1.1 christos # define OS_RECOGNISED 1
831 1.1 christos #endif /* __osf__ */
832 1.1 christos
833 1.1 christos /* ----------------------------------------------------------------------- */
834 1.1 christos /* N E T B S D */
835 1.1 christos /* ----------------------------------------------------------------------- */
836 1.1 christos #ifdef __NetBSD__
837 1.1 christos # define HAS_SYS_MD5_H 1
838 1.1 christos # if (NetBSD >= 199905) && !defined(IPFILTER_LKM) && defined(_KERNEL)
839 1.1 christos # if (__NetBSD_Version__ < 399001400)
840 1.1 christos # include "opt_ipfilter_log.h"
841 1.1 christos # else
842 1.1 christos # include "opt_ipfilter.h"
843 1.1 christos # endif
844 1.1 christos # endif
845 1.1 christos # if defined(_KERNEL)
846 1.1 christos # include <sys/systm.h>
847 1.1 christos # include <sys/malloc.h>
848 1.1 christos # if (__NetBSD_Version__ > 500000000)
849 1.1 christos # include <sys/kauth.h>
850 1.1 christos # endif
851 1.1 christos # else
852 1.1 christos # include <stddef.h>
853 1.1 christos # include <stdbool.h>
854 1.1 christos # endif
855 1.1 christos # if defined(_KERNEL) && !defined(IPFILTER_LKM)
856 1.2 christos # if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 599002300)
857 1.2 christos # define NBPFILTER 1
858 1.2 christos # else
859 1.2 christos # include "bpfilter.h"
860 1.2 christos # endif
861 1.1 christos # if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 104110000)
862 1.1 christos # include "opt_inet.h"
863 1.1 christos # endif
864 1.1 christos # ifdef INET6
865 1.1 christos # define USE_INET6
866 1.1 christos # endif
867 1.1 christos # if (__NetBSD_Version__ >= 105000000)
868 1.1 christos # define HAVE_M_PULLDOWN 1
869 1.1 christos # endif
870 1.1 christos # endif
871 1.1 christos
872 1.2 christos #ifndef _KERNEL
873 1.2 christos # define ipf_random arc4random
874 1.2 christos #endif
875 1.2 christos
876 1.1 christos # if (__NetBSD_Version__ >= 499000000)
877 1.1 christos # ifdef _KERNEL
878 1.1 christos # include <sys/rwlock.h>
879 1.1 christos # define USE_MUTEXES 1
880 1.1 christos # define KMUTEX_T kmutex_t
881 1.1 christos # define KRWLOCK_T krwlock_t
882 1.1 christos # define MUTEX_DESTROY(x) mutex_destroy(&(x)->ipf_lk)
883 1.1 christos # define MUTEX_DOWNGRADE(x) rw_downgrade(&(x)->ipf_lk)
884 1.1 christos # define MUTEX_ENTER(x) mutex_enter(&(x)->ipf_lk)
885 1.1 christos # define MUTEX_EXIT(x) mutex_exit(&(x)->ipf_lk)
886 1.1 christos # define MUTEX_INIT(x,y) mutex_init(&(x)->ipf_lk, MUTEX_DRIVER,\
887 1.1 christos IPL_SOFTNET)
888 1.1 christos # define MUTEX_NUKE(x) bzero((x), sizeof(*(x)))
889 1.1 christos # define READ_ENTER(x) rw_enter(&(x)->ipf_lk, RW_READER)
890 1.1 christos # define RWLOCK_INIT(x, y) rw_init(&(x)->ipf_lk)
891 1.1 christos # define RWLOCK_EXIT(x) rw_exit(&(x)->ipf_lk)
892 1.1 christos # define RW_DESTROY(x) rw_destroy(&(x)->ipf_lk)
893 1.1 christos # define WRITE_ENTER(x) rw_enter(&(x)->ipf_lk, RW_WRITER)
894 1.1 christos # define SPL_SCHED(x) ;
895 1.1 christos # define SPL_NET(x) ;
896 1.1 christos # define SPL_IMP(x) ;
897 1.1 christos # define SPL_X(x) ;
898 1.1 christos # endif
899 1.1 christos # endif
900 1.1 christos
901 1.5 christos #if (__NetBSD_Version__ >= 699000000)
902 1.5 christos # define HAVE_RBTREE 1
903 1.5 christos #endif
904 1.5 christos
905 1.1 christos # ifdef _KERNEL
906 1.2 christos # include <sys/cprng.h>
907 1.1 christos # if (__NetBSD_Version__ >= 399001400)
908 1.1 christos # include <sys/selinfo.h> /* Not in NetBSD 3.1 */
909 1.1 christos # define PROC_T struct lwp
910 1.1 christos # define KFREE(a) free((a), _M_IPF)
911 1.1 christos # define KFREES(a, b) free((a), _M_IPF)
912 1.1 christos # define KMALLOC(a, b) (a) = (b)malloc(sizeof (*(a)), \
913 1.1 christos _M_IPF, M_NOWAIT)
914 1.1 christos # define KMALLOCS(a, b, c) (a) = (b)malloc((c), _M_IPF, M_NOWAIT)
915 1.1 christos # else
916 1.1 christos # define PROC_T struct proc
917 1.1 christos # endif
918 1.3 darrenr # define MSGDSIZE(m) mbufchainlen(m)
919 1.3 darrenr # define M_LEN(m) (m)->m_len
920 1.1 christos # define M_ADJ(m,x) m_adj(m, x)
921 1.1 christos # define M_COPY(x) m_copy((x), 0, M_COPYALL)
922 1.1 christos # define GETKTIME(x) microtime((struct timeval *)x)
923 1.1 christos # define IPF_PANIC(x,y) if (x) { printf y; panic("ipf_panic"); }
924 1.2 christos # define COPYIN(a,b,c) copyin((void *)(a), (void *)(b), (c))
925 1.2 christos # define COPYOUT(a,b,c) copyout((void *)(a), (void *)(b), (c))
926 1.2 christos # define BCOPYIN(a,b,c) (bcopy((void *)(a), (void *)(b), (c)), 0)
927 1.2 christos # define BCOPYOUT(a,b,c) (bcopy((void *)(a), (void *)(b), (c)), 0)
928 1.1 christos # if (defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 499004900))
929 1.1 christos # define POLLWAKEUP(x) selnotify(softc->ipf_selwait+x, 0, 0)
930 1.1 christos # endif
931 1.6 christos # define ASSERT(x) KASSERT(x)
932 1.1 christos typedef struct mbuf mb_t;
933 1.1 christos # endif /* _KERNEL */
934 1.1 christos # if (NetBSD <= 1991011) && (NetBSD >= 199606)
935 1.1 christos # define IFNAME(x) ((struct ifnet *)x)->if_xname
936 1.1 christos # define COPYIFNAME(v, x, b) \
937 1.1 christos (void) strncpy(b, \
938 1.1 christos ((struct ifnet *)x)->if_xname, \
939 1.1 christos LIFNAMSIZ)
940 1.1 christos # else
941 1.1 christos # define IFNAME(x) ((struct ifnet *)x)->if_name
942 1.1 christos # endif
943 1.1 christos typedef struct uio uio_t;
944 1.1 christos typedef u_long ioctlcmd_t;
945 1.1 christos typedef int minor_t;
946 1.1 christos typedef u_int32_t u_32_t;
947 1.1 christos # define U_32_T 1
948 1.1 christos
949 1.1 christos # define OS_RECOGNISED 1
950 1.1 christos #endif /* __NetBSD__ */
951 1.1 christos
952 1.1 christos
953 1.1 christos /* ----------------------------------------------------------------------- */
954 1.1 christos /* F R E E B S D */
955 1.1 christos /* ----------------------------------------------------------------------- */
956 1.1 christos #ifdef __FreeBSD__
957 1.1 christos # if (__FreeBSD_version < 400000)
958 1.1 christos # define NEED_LOCAL_RAND 1
959 1.1 christos # endif
960 1.1 christos # if defined(_KERNEL)
961 1.1 christos # if (__FreeBSD_version >= 500000)
962 1.1 christos # include "opt_bpf.h"
963 1.1 christos # endif
964 1.1 christos # if defined(__FreeBSD_version) && (__FreeBSD_version >= 500000)
965 1.1 christos # include "opt_inet6.h"
966 1.1 christos # endif
967 1.1 christos # if defined(INET6) && !defined(USE_INET6)
968 1.1 christos # define USE_INET6
969 1.1 christos # endif
970 1.1 christos # endif
971 1.1 christos
972 1.1 christos # if defined(_KERNEL)
973 1.1 christos # include <netinet/ip_var.h>
974 1.1 christos # if (__FreeBSD_version >= 500024)
975 1.1 christos # if (__FreeBSD_version >= 500043)
976 1.1 christos # define p_cred td_ucred
977 1.1 christos # define p_uid td_ucred->cr_ruid
978 1.1 christos # else
979 1.1 christos # define p_cred t_proc->p_cred
980 1.1 christos # define p_uid t_proc->p_cred->p_ruid
981 1.1 christos # endif
982 1.1 christos # else
983 1.1 christos # define p_uid p_cred->p_ruid
984 1.1 christos # endif /* __FreeBSD_version >= 500024 */
985 1.1 christos
986 1.1 christos # if (__FreeBSD_version >= 400000)
987 1.1 christos /*
988 1.1 christos * When #define'd, the 5.2.1 kernel panics when used with the ftp proxy.
989 1.1 christos * There may be other, safe, kernels but this is not extensively tested yet.
990 1.1 christos */
991 1.1 christos # define HAVE_M_PULLDOWN
992 1.1 christos # endif
993 1.1 christos # if !defined(IPFILTER_LKM) && (__FreeBSD_version >= 300000)
994 1.1 christos # include "opt_ipfilter.h"
995 1.1 christos # endif
996 1.1 christos # define COPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c))
997 1.1 christos # define COPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c))
998 1.1 christos
999 1.1 christos # if (__FreeBSD_version >= 500043)
1000 1.1 christos # define NETBSD_PF
1001 1.1 christos # endif
1002 1.1 christos # else
1003 1.1 christos # include <inttypes.h>
1004 1.1 christos # endif /* _KERNEL */
1005 1.1 christos
1006 1.1 christos # if (__FreeBSD_version >= 700000)
1007 1.1 christos # include <sys/selinfo.h>
1008 1.1 christos # endif
1009 1.1 christos # if (__FreeBSD_version >= 500043)
1010 1.1 christos # include <sys/mutex.h>
1011 1.1 christos # if (__FreeBSD_version >= 700014)
1012 1.3 darrenr # define KRWLOCK_FILL_SZ 36
1013 1.3 darrenr # define KMUTEX_FILL_SZ 24
1014 1.1 christos # include <sys/rwlock.h>
1015 1.1 christos # ifdef _KERNEL
1016 1.1 christos # define KMUTEX_T struct mtx
1017 1.1 christos # define KRWLOCK_T struct rwlock
1018 1.1 christos # define READ_ENTER(x) rw_rlock(&(x)->ipf_lk)
1019 1.1 christos # define WRITE_ENTER(x) rw_wlock(&(x)->ipf_lk)
1020 1.1 christos # define MUTEX_DOWNGRADE(x) rw_downgrade(&(x)->ipf_lk)
1021 1.1 christos # define RWLOCK_INIT(x,y) rw_init(&(x)->ipf_lk, (y))
1022 1.1 christos # define RW_DESTROY(x) rw_destroy(&(x)->ipf_lk)
1023 1.1 christos # define RWLOCK_EXIT(x) do { \
1024 1.1 christos if (rw_wowned(&(x)->ipf_lk)) \
1025 1.1 christos rw_wunlock(&(x)->ipf_lk); \
1026 1.1 christos else \
1027 1.1 christos rw_runlock(&(x)->ipf_lk); \
1028 1.1 christos } while (0)
1029 1.1 christos # endif
1030 1.1 christos # else
1031 1.1 christos # include <sys/sx.h>
1032 1.1 christos /*
1033 1.1 christos * Whilst the sx(9) locks on FreeBSD have the right semantics and interface
1034 1.1 christos * for what we want to use them for, despite testing showing they work -
1035 1.1 christos * with a WITNESS kernel, it generates LOR messages.
1036 1.1 christos */
1037 1.1 christos # if (__FreeBSD_version < 700000)
1038 1.1 christos # ifdef _KERNEL
1039 1.1 christos # define KMUTEX_T struct mtx
1040 1.1 christos # define KRWLOCK_T struct mtx
1041 1.1 christos # define READ_ENTER(x) mtx_lock(&(x)->ipf_lk)
1042 1.1 christos # define WRITE_ENTER(x) mtx_lock(&(x)->ipf_lk)
1043 1.1 christos # define RWLOCK_EXIT(x) mtx_unlock(&(x)->ipf_lk)
1044 1.1 christos # define MUTEX_DOWNGRADE(x) ;
1045 1.1 christos # define RWLOCK_INIT(x,y) mtx_init(&(x)->ipf_lk, (y), NULL,\
1046 1.1 christos MTX_DEF)
1047 1.1 christos # define RW_DESTROY(x) mtx_destroy(&(x)->ipf_lk)
1048 1.1 christos # endif
1049 1.1 christos # else
1050 1.1 christos # ifdef _KERNEL
1051 1.1 christos # define KRWLOCK_T struct sx
1052 1.1 christos # define KMUTEX_T struct mtx
1053 1.1 christos # define READ_ENTER(x) sx_slock(&(x)->ipf_lk)
1054 1.1 christos # define WRITE_ENTER(x) sx_xlock(&(x)->ipf_lk)
1055 1.1 christos # define MUTEX_DOWNGRADE(x) sx_downgrade(&(x)->ipf_lk)
1056 1.1 christos # define RWLOCK_INIT(x, y) sx_init(&(x)->ipf_lk, (y))
1057 1.1 christos # define RW_DESTROY(x) sx_destroy(&(x)->ipf_lk)
1058 1.1 christos # ifdef sx_unlock
1059 1.1 christos # define RWLOCK_EXIT(x) sx_unlock(&(x)->ipf_lk)
1060 1.1 christos # else
1061 1.1 christos # define RWLOCK_EXIT(x) do { \
1062 1.1 christos if ((x)->ipf_lk.sx_cnt < 0) \
1063 1.1 christos sx_xunlock(&(x)->ipf_lk); \
1064 1.1 christos else \
1065 1.1 christos sx_sunlock(&(x)->ipf_lk); \
1066 1.1 christos } while (0)
1067 1.1 christos # endif
1068 1.1 christos # endif
1069 1.1 christos # endif
1070 1.1 christos # endif
1071 1.1 christos # endif
1072 1.1 christos
1073 1.1 christos # if (__FreeBSD_version >= 501113)
1074 1.1 christos # include <net/if_var.h>
1075 1.1 christos # define IFNAME(x) ((struct ifnet *)x)->if_xname
1076 1.1 christos # define COPYIFNAME(v, x, b) \
1077 1.1 christos (void) strncpy(b, \
1078 1.1 christos ((struct ifnet *)x)->if_xname, \
1079 1.1 christos LIFNAMSIZ)
1080 1.1 christos # endif
1081 1.1 christos # if (__FreeBSD_version >= 500043)
1082 1.1 christos # else
1083 1.1 christos # define IFNAME(x) ((struct ifnet *)x)->if_name
1084 1.1 christos # endif
1085 1.1 christos
1086 1.1 christos # ifdef _KERNEL
1087 1.1 christos # define GETKTIME(x) microtime((struct timeval *)x)
1088 1.1 christos
1089 1.1 christos # if (__FreeBSD_version >= 500002)
1090 1.1 christos # include <netinet/in_systm.h>
1091 1.1 christos # include <netinet/ip.h>
1092 1.1 christos # include <machine/in_cksum.h>
1093 1.1 christos # endif
1094 1.1 christos
1095 1.1 christos # if (__FreeBSD_version >= 500043)
1096 1.1 christos # define USE_MUTEXES
1097 1.1 christos # define MUTEX_ENTER(x) mtx_lock(&(x)->ipf_lk)
1098 1.1 christos # define MUTEX_EXIT(x) mtx_unlock(&(x)->ipf_lk)
1099 1.1 christos # define MUTEX_INIT(x,y) mtx_init(&(x)->ipf_lk, (y), NULL,\
1100 1.1 christos MTX_DEF)
1101 1.1 christos # define MUTEX_DESTROY(x) mtx_destroy(&(x)->ipf_lk)
1102 1.1 christos # define MUTEX_NUKE(x) bzero((x), sizeof(*(x)))
1103 1.1 christos /*
1104 1.1 christos * Whilst the sx(9) locks on FreeBSD have the right semantics and interface
1105 1.1 christos * for what we want to use them for, despite testing showing they work -
1106 1.1 christos * with a WITNESS kernel, it generates LOR messages.
1107 1.1 christos */
1108 1.1 christos # include <machine/atomic.h>
1109 1.1 christos # define ATOMIC_INC(x) { mtx_lock(&softc->ipf_rw.ipf_lk); (x)++; \
1110 1.1 christos mtx_unlock(&softc->ipf_rw.ipf_lk); }
1111 1.1 christos # define ATOMIC_DEC(x) { mtx_lock(&softc->ipf_rw.ipf_lk); (x)--; \
1112 1.1 christos mtx_unlock(&softc->ipf_rw.ipf_lk); }
1113 1.1 christos # define ATOMIC_INCL(x) atomic_add_long(&(x), 1)
1114 1.1 christos # define ATOMIC_INC64(x) ATOMIC_INC(x)
1115 1.1 christos # define ATOMIC_INC32(x) atomic_add_32((u_int *)&(x), 1)
1116 1.1 christos # define ATOMIC_DECL(x) atomic_add_long(&(x), -1)
1117 1.1 christos # define ATOMIC_DEC64(x) ATOMIC_DEC(x)
1118 1.1 christos # define ATOMIC_DEC32(x) atomic_add_32((u_int *)&(x), -1)
1119 1.1 christos # define SPL_X(x) ;
1120 1.1 christos # define SPL_NET(x) ;
1121 1.1 christos # define SPL_IMP(x) ;
1122 1.1 christos # define SPL_SCHED(x) ;
1123 1.2 christos extern int in_cksum(struct mbuf *, int);
1124 1.1 christos # else
1125 1.1 christos # define SPL_SCHED(x) x = splhigh()
1126 1.1 christos # endif /* __FreeBSD_version >= 500043 */
1127 1.1 christos # if (__FreeBSD_version >= 500024)
1128 1.1 christos # define GET_MINOR dev2unit
1129 1.1 christos # endif
1130 1.3 darrenr # define MSGDSIZE(m) mbufchainlen(m)
1131 1.3 darrenr # define M_LEN(m) (m)->m_len
1132 1.1 christos # define M_ADJ(m,x) m_adj(m, x)
1133 1.1 christos # define M_COPY(x) m_copy((x), 0, M_COPYALL)
1134 1.1 christos # define M_DUP(m) m_dup(m, M_NOWAIT)
1135 1.1 christos # define IPF_PANIC(x,y) if (x) { printf y; panic("ipf_panic"); }
1136 1.1 christos typedef struct mbuf mb_t;
1137 1.1 christos # endif /* _KERNEL */
1138 1.1 christos
1139 1.1 christos # if __FreeBSD__ < 3
1140 1.1 christos # include <machine/spl.h>
1141 1.1 christos # else
1142 1.1 christos # if __FreeBSD__ == 3
1143 1.1 christos # if defined(IPFILTER_LKM) && !defined(ACTUALLY_LKM_NOT_KERNEL)
1144 1.1 christos # define ACTUALLY_LKM_NOT_KERNEL
1145 1.1 christos # endif
1146 1.1 christos # endif
1147 1.1 christos # endif
1148 1.1 christos
1149 1.1 christos # if (__FreeBSD_version >= 300000)
1150 1.1 christos typedef u_long ioctlcmd_t;
1151 1.1 christos # else
1152 1.1 christos typedef int ioctlcmd_t;
1153 1.1 christos # endif
1154 1.1 christos typedef struct uio uio_t;
1155 1.1 christos typedef int minor_t;
1156 1.1 christos typedef u_int32_t u_32_t;
1157 1.1 christos # define U_32_T 1
1158 1.1 christos
1159 1.1 christos # define OS_RECOGNISED 1
1160 1.1 christos #endif /* __FreeBSD__ */
1161 1.1 christos
1162 1.1 christos
1163 1.1 christos /* ----------------------------------------------------------------------- */
1164 1.1 christos /* O P E N B S D */
1165 1.1 christos /* ----------------------------------------------------------------------- */
1166 1.1 christos #ifdef __OpenBSD__
1167 1.1 christos # ifdef INET6
1168 1.1 christos # define USE_INET6
1169 1.1 christos # endif
1170 1.1 christos
1171 1.1 christos # ifdef _KERNEL
1172 1.1 christos # if !defined(IPFILTER_LKM)
1173 1.1 christos # include "bpfilter.h"
1174 1.1 christos # endif
1175 1.1 christos # if (OpenBSD >= 200311)
1176 1.1 christos # define SNPRINTF snprintf
1177 1.1 christos # if defined(USE_INET6)
1178 1.1 christos # include "netinet6/in6_var.h"
1179 1.1 christos # include "netinet6/nd6.h"
1180 1.1 christos # endif
1181 1.1 christos # endif
1182 1.1 christos # if (OpenBSD >= 200012)
1183 1.1 christos # define HAVE_M_PULLDOWN 1
1184 1.1 christos # endif
1185 1.1 christos # define COPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c))
1186 1.1 christos # define COPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c))
1187 1.1 christos # define GETKTIME(x) microtime((struct timeval *)x)
1188 1.3 darrenr # define MSGDSIZE(m) mbufchainlen(m)
1189 1.3 darrenr # define M_LEN(m) (m)->m_len
1190 1.1 christos # define M_ADJ(m,x) m_adj(m, x)
1191 1.3 darrenr # define M_COPY(m) m_copy((m), 0, M_COPYALL)
1192 1.1 christos # define IPF_PANIC(x,y) if (x) { printf y; panic("ipf_panic"); }
1193 1.1 christos typedef struct mbuf mb_t;
1194 1.1 christos # endif /* _KERNEL */
1195 1.1 christos # if (OpenBSD >= 199603)
1196 1.1 christos # define IFNAME(x, b) ((struct ifnet *)x)->if_xname
1197 1.1 christos # define COPYIFNAME(v, x, b) \
1198 1.1 christos (void) strncpy(b, \
1199 1.1 christos ((struct ifnet *)x)->if_xname, \
1200 1.1 christos LIFNAMSIZ)
1201 1.1 christos # else
1202 1.1 christos # define IFNAME(x) ((struct ifnet *)x)->if_name
1203 1.1 christos # endif
1204 1.1 christos typedef struct uio uio_t;
1205 1.1 christos typedef u_long ioctlcmd_t;
1206 1.1 christos typedef int minor_t;
1207 1.1 christos typedef u_int32_t u_32_t;
1208 1.1 christos # define U_32_T 1
1209 1.1 christos
1210 1.1 christos # define OS_RECOGNISED 1
1211 1.1 christos #endif /* __OpenBSD__ */
1212 1.1 christos
1213 1.1 christos
1214 1.1 christos /* ----------------------------------------------------------------------- */
1215 1.1 christos /* B S D O S */
1216 1.1 christos /* ----------------------------------------------------------------------- */
1217 1.1 christos #ifdef _BSDI_VERSION
1218 1.1 christos # ifdef INET6
1219 1.1 christos # define USE_INET6
1220 1.1 christos # endif
1221 1.1 christos
1222 1.1 christos # ifdef _KERNEL
1223 1.1 christos # define GETKTIME(x) microtime((struct timeval *)x)
1224 1.3 darrenr # define MSGDSIZE(m) mbufchainlen(m)
1225 1.3 darrenr # define M_LEN(m) (m)->m_len
1226 1.1 christos # define M_ADJ(m,x) m_adj(m, x)
1227 1.3 darrenr # define M_COPY(m) m_copy((m), 0, M_COPYALL)
1228 1.1 christos # define IFNAME(x) ((struct ifnet *)x)->if_name
1229 1.1 christos typedef struct mbuf mb_t;
1230 1.1 christos # endif /* _KERNEL */
1231 1.1 christos
1232 1.1 christos # if (_BSDI_VERSION >= 199701)
1233 1.1 christos typedef u_long ioctlcmd_t;
1234 1.1 christos # else
1235 1.1 christos typedef int ioctlcmd_t;
1236 1.1 christos # endif
1237 1.1 christos typedef u_int32_t u_32_t;
1238 1.1 christos # define U_32_T 1
1239 1.1 christos
1240 1.1 christos #endif /* _BSDI_VERSION */
1241 1.1 christos
1242 1.1 christos
1243 1.1 christos /* ----------------------------------------------------------------------- */
1244 1.1 christos /* S U N O S 4 */
1245 1.1 christos /* ----------------------------------------------------------------------- */
1246 1.1 christos #if defined(sun) && !defined(OS_RECOGNISED) /* SunOS4 */
1247 1.1 christos # ifdef _KERNEL
1248 1.1 christos # include <sys/kmem_alloc.h>
1249 1.1 christos # define GETKTIME(x) uniqtime((struct timeval *)x)
1250 1.3 darrenr # define MSGDSIZE(m) mbufchainlen(m)
1251 1.3 darrenr # define M_LEN(m) (m)->m_len
1252 1.1 christos # define M_ADJ(m,x) m_adj(m, x)
1253 1.3 darrenr # define M_COPY(m) m_copy((m), 0, M_COPYALL)
1254 1.1 christos # define IFNAME(x) ((struct ifnet *)x)->if_name
1255 1.1 christos # define GETIFP(n, v) ifunit(n, IFNAMSIZ)
1256 1.1 christos # define GETIFMTU_4(x) ((struct ifnet *)x)->if_mtu
1257 1.1 christos # define KFREE(x) kmem_free((char *)(x), sizeof(*(x)))
1258 1.1 christos # define KFREES(x,s) kmem_free((char *)(x), (s))
1259 1.1 christos # define SLEEP(id, n) sleep((id), PZERO+1)
1260 1.1 christos # define WAKEUP(id,x) wakeup(id + x)
1261 1.1 christos # define POLLWAKEUP(x) ;
1262 1.2 christos # define UIOMOVE(a,b,c,d) uiomove((void *)a,b,c,d)
1263 1.1 christos # define IPF_PANIC(x,y) if (x) { printf y; panic("ipf_panic"); }
1264 1.1 christos
1265 1.2 christos extern void m_copydata(struct mbuf *, int, int, void *);
1266 1.2 christos extern void m_copyback(struct mbuf *, int, int, void *);
1267 1.1 christos
1268 1.1 christos typedef struct mbuf mb_t;
1269 1.1 christos # endif
1270 1.1 christos
1271 1.1 christos typedef struct uio uio_t;
1272 1.1 christos typedef int ioctlcmd_t;
1273 1.1 christos typedef int minor_t;
1274 1.1 christos typedef unsigned int u_32_t;
1275 1.1 christos # define U_32_T 1
1276 1.1 christos
1277 1.1 christos # define OS_RECOGNISED 1
1278 1.1 christos
1279 1.1 christos #endif /* SunOS 4 */
1280 1.1 christos
1281 1.1 christos /* ----------------------------------------------------------------------- */
1282 1.1 christos /* L I N U X */
1283 1.1 christos /* ----------------------------------------------------------------------- */
1284 1.1 christos #if defined(linux) && !defined(OS_RECOGNISED)
1285 1.1 christos # include <linux/version.h>
1286 1.1 christos # if (LINUX >= 20600) && defined(_KERNEL)
1287 1.1 christos # define HDR_T_PRIVATE 1
1288 1.1 christos # endif
1289 1.1 christos # undef USE_INET6
1290 1.1 christos # ifdef USE_INET6
1291 1.1 christos struct ip6_ext {
1292 1.1 christos u_char ip6e_nxt;
1293 1.1 christos u_char ip6e_len;
1294 1.1 christos };
1295 1.1 christos # endif
1296 1.1 christos
1297 1.1 christos # ifdef _KERNEL
1298 1.1 christos # include <asm/byteorder.h>
1299 1.1 christos # ifdef __LITTLE_ENDIAN
1300 1.1 christos # define BIG_ENDIAN 0
1301 1.1 christos # define LITTLE_ENDIAN 1
1302 1.1 christos # define BYTE_ORDER LITTLE_ENDIAN
1303 1.1 christos # else
1304 1.1 christos # define BIG_ENDIAN 1
1305 1.1 christos # define LITTLE_ENDIAN 0
1306 1.1 christos # define BYTE_ORDER BIG_ENDIAN
1307 1.1 christos # endif
1308 1.1 christos # define IPF_PANIC(x,y) if (x) { printf y; panic("ipf_panic"); }
1309 1.1 christos # define COPYIN(a,b,c) copy_from_user((caddr_t)(b), (caddr_t)(a), (c))
1310 1.1 christos # define COPYOUT(a,b,c) copy_to_user((caddr_t)(b), (caddr_t)(a), (c))
1311 1.1 christos # define FREE_MB_T(m) kfree_skb(m)
1312 1.1 christos # define GETKTIME(x) do_gettimeofday((struct timeval *)x)
1313 1.1 christos # define POLLWAKEUP(x) ;
1314 1.1 christos # ifdef wait_event_interruptible
1315 1.1 christos # define SLEEP(x,s) wait_event_interruptible((*(x##_linux)), 0)
1316 1.1 christos # else
1317 1.1 christos # define SLEEP(x,s) 0, interruptible_sleep_on(x##_linux)
1318 1.1 christos # endif
1319 1.1 christos # define WAKEUP(x,y) wake_up(x##_linux + y)
1320 1.1 christos # define UIOMOVE(a,b,c,d) uiomove((caddr_t)a,b,c,d)
1321 1.1 christos # define USE_MUTEXES
1322 1.1 christos # define KRWLOCK_T rwlock_t
1323 1.1 christos # define KMUTEX_T spinlock_t
1324 1.1 christos # define MUTEX_INIT(x,y) spin_lock_init(&(x)->ipf_lk)
1325 1.1 christos # define MUTEX_ENTER(x) spin_lock_bh(&(x)->ipf_lk)
1326 1.1 christos # define MUTEX_EXIT(x) spin_unlock_bh(&(x)->ipf_lk)
1327 1.1 christos # define MUTEX_DESTROY(x) do { } while (0)
1328 1.1 christos # define MUTEX_NUKE(x) bzero(&(x)->ipf_lk, sizeof((x)->ipf_lk))
1329 1.1 christos # define READ_ENTER(x) ipf_read_enter(x)
1330 1.1 christos # define WRITE_ENTER(x) ipf_write_enter(x)
1331 1.1 christos # define RWLOCK_INIT(x,y) ipf_rw_init(x, y)
1332 1.1 christos # define RW_DESTROY(x) do { } while (0)
1333 1.1 christos # define RWLOCK_EXIT(x) ipf_rw_exit(x)
1334 1.1 christos # define MUTEX_DOWNGRADE(x) ipf_rw_downgrade(x)
1335 1.1 christos # define ATOMIC_INCL(x) atomic_long_inc((atomic_long_t *)&(x))
1336 1.1 christos # define ATOMIC_DECL(x) atomic_long_dec((atomic_long_t *)&(x))
1337 1.1 christos # define ATOMIC_INC32(x) atomic_inc((atomic_t *)&(x))
1338 1.1 christos # define ATOMIC_DEC32(x) atomic_dec((atomic_t *)&(x))
1339 1.1 christos # ifdef CONFIG_X86_32
1340 1.1 christos # define ATOMIC_INC64(x) do { MUTEX_ENTER(&softc->ipf_rw); \
1341 1.1 christos (x)++; \
1342 1.1 christos MUTEX_EXIT(&softc->ipf_rw); \
1343 1.1 christos } while (0)
1344 1.1 christos # define ATOMIC_DEC64(x) do { MUTEX_ENTER(&softc->ipf_rw); \
1345 1.1 christos (x)--; \
1346 1.1 christos MUTEX_EXIT(&softc->ipf_rw); \
1347 1.1 christos } while (0)
1348 1.1 christos # else
1349 1.1 christos # define ATOMIC_INC64(x) atomic64_inc((atomic64_t *)&(x))
1350 1.1 christos # define ATOMIC_DEC64(x) atomic64_dec((atomic64_t *)&(x))
1351 1.1 christos # endif
1352 1.1 christos # define U_QUAD_T u_int64_t
1353 1.1 christos # define QUAD_T int64_t
1354 1.1 christos # define SPL_SCHED(x) do { } while (0)
1355 1.1 christos # define SPL_IMP(x) do { } while (0)
1356 1.1 christos # define SPL_NET(x) do { } while (0)
1357 1.1 christos # define SPL_X(x) do { } while (0)
1358 1.1 christos # define IFNAME(x) ((struct net_device*)x)->name
1359 1.1 christos typedef struct sk_buff mb_t;
1360 1.2 christos extern void m_copydata(mb_t *, int, int, void *);
1361 1.2 christos extern void m_copyback(mb_t *, int, int, void *);
1362 1.2 christos extern void m_adj(mb_t *, int);
1363 1.2 christos extern mb_t *m_pullup(mb_t *, int);
1364 1.1 christos # define mbuf sk_buff
1365 1.1 christos
1366 1.1 christos # define mtod(m, t) ((t)(m)->data)
1367 1.1 christos # define m_adj(m, x) skb_trim((m), (m)->len + (x))
1368 1.1 christos # define m_data data
1369 1.1 christos # define m_len len
1370 1.1 christos # define m_next next
1371 1.1 christos # define M_COPY(m) skb_clone((m), in_interrupt() ? GFP_ATOMIC : \
1372 1.1 christos GFP_KERNEL)
1373 1.1 christos # define MSGDSIZE(m) (m)->len
1374 1.1 christos # define M_LEN(m) (m)->len
1375 1.1 christos # define M_ADJ(m,x) m_adj(m, x)
1376 1.1 christos # define M_DUP(m) skb_copy((m), in_interrupt() ? GFP_ATOMIC : \
1377 1.1 christos GFP_KERNEL)
1378 1.1 christos # define PREP_MB_T(f, m) do { \
1379 1.1 christos (m)->next = *(f)->fin_mp; \
1380 1.1 christos *(fin)->fin_mp = (m); \
1381 1.1 christos (f)->fin_m = (m); \
1382 1.1 christos } while (0)
1383 1.1 christos # define ALLOC_MB_T(m,l) (m) = alloc_skb((l), \
1384 1.1 christos in_interrupt() ? GFP_ATOMIC : \
1385 1.1 christos GFP_KERNEL)
1386 1.1 christos
1387 1.1 christos # define splnet(x) ;
1388 1.1 christos # define printf printk
1389 1.1 christos # define bcopy(s,d,z) memmove(d, s, z)
1390 1.1 christos # define bzero(s,z) memset(s, 0, z)
1391 1.1 christos # define bcmp(a,b,z) memcmp(a, b, z)
1392 1.1 christos # if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
1393 1.1 christos # define ipf_random random32
1394 1.1 christos # define arc4random random32
1395 1.1 christos # else
1396 1.1 christos # include <linux/random.h>
1397 1.1 christos # define ipf_random get_random_int
1398 1.1 christos # define arc4random get_random_int
1399 1.1 christos # endif
1400 1.1 christos
1401 1.1 christos # define ifnet net_device
1402 1.1 christos # define if_xname name
1403 1.1 christos # define if_unit ifindex
1404 1.1 christos
1405 1.1 christos # define KMALLOC(x,t) (x) = (t)kmalloc(sizeof(*(x)), \
1406 1.1 christos in_interrupt() ? GFP_ATOMIC : GFP_KERNEL)
1407 1.1 christos # define KFREE(x) kfree(x)
1408 1.1 christos # define KMALLOCS(x,t,s) (x) = (t)kmalloc((s), \
1409 1.1 christos in_interrupt() ? GFP_ATOMIC : GFP_KERNEL)
1410 1.1 christos # define KFREES(x,s) kfree(x)
1411 1.1 christos
1412 1.1 christos # if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)
1413 1.1 christos # define f_uid f_owner.uid
1414 1.1 christos # define GETIFP(n,v) dev_get_by_name(&init_net, n)
1415 1.1 christos # else
1416 1.1 christos # define GETIFP(n,v) dev_get_by_name(n)
1417 1.1 christos # endif
1418 1.1 christos # define GETIFMTU_4(x) ((struct net_device *)x)->mtu
1419 1.1 christos # define GETIFMTU_6(x) ((struct net_device *)x)->mtu
1420 1.1 christos
1421 1.1 christos # else
1422 1.1 christos # include <net/ethernet.h>
1423 1.1 christos
1424 1.1 christos struct mbuf {
1425 1.1 christos };
1426 1.1 christos
1427 1.1 christos # ifndef _NET_ROUTE_H
1428 1.1 christos struct rtentry {
1429 1.1 christos };
1430 1.1 christos # endif
1431 1.1 christos
1432 1.1 christos struct ifnet {
1433 1.1 christos char if_xname[IFNAMSIZ];
1434 1.1 christos int if_unit;
1435 1.2 christos int (* if_output)(struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *);
1436 1.1 christos struct ifaddr *if_addrlist;
1437 1.1 christos };
1438 1.1 christos # define IFNAME(x) ((struct ifnet *)x)->if_xname
1439 1.1 christos
1440 1.1 christos # endif /* _KERNEL */
1441 1.1 christos
1442 1.1 christos # define COPYIFNAME(v, x, b) \
1443 1.1 christos (void) strncpy(b, \
1444 1.1 christos ((struct ifnet *)x)->if_xname, \
1445 1.1 christos LIFNAMSIZ)
1446 1.1 christos
1447 1.1 christos # include <linux/fs.h>
1448 1.1 christos # define FWRITE FMODE_WRITE
1449 1.1 christos # define FREAD FMODE_READ
1450 1.1 christos
1451 1.1 christos # define __USE_MISC 1
1452 1.1 christos # define __FAVOR_BSD 1
1453 1.1 christos
1454 1.1 christos typedef struct uio {
1455 1.1 christos struct iovec *uio_iov;
1456 1.1 christos void *uio_file;
1457 1.1 christos char *uio_buf;
1458 1.1 christos int uio_iovcnt;
1459 1.1 christos int uio_offset;
1460 1.1 christos size_t uio_resid;
1461 1.1 christos int uio_rw;
1462 1.1 christos } uio_t;
1463 1.1 christos
1464 1.2 christos extern int uiomove(void *, size_t, int, struct uio *);
1465 1.1 christos
1466 1.1 christos # define UIO_READ 1
1467 1.1 christos # define UIO_WRITE 2
1468 1.1 christos
1469 1.1 christos # if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) && !defined(_KERNEL)
1470 1.1 christos typedef int fmode_t;
1471 1.1 christos # endif
1472 1.1 christos
1473 1.1 christos typedef u_long ioctlcmd_t;
1474 1.1 christos typedef int minor_t;
1475 1.1 christos typedef u_int32_t u_32_t;
1476 1.1 christos # define U_32_T 1
1477 1.1 christos
1478 1.1 christos # define OS_RECOGNISED 1
1479 1.1 christos
1480 1.1 christos #endif
1481 1.1 christos
1482 1.1 christos
1483 1.1 christos /* ----------------------------------------------------------------------- */
1484 1.1 christos /* A I X */
1485 1.1 christos /* ----------------------------------------------------------------------- */
1486 1.1 christos #if defined(_AIX51)
1487 1.1 christos # undef MENTAT
1488 1.1 christos
1489 1.1 christos # include <sys/lock.h>
1490 1.1 christos # include <sys/sysmacros.h>
1491 1.1 christos
1492 1.1 christos # ifdef _KERNEL
1493 1.1 christos # define rw_read_locked(x) 0
1494 1.1 christos # include <net/net_globals.h>
1495 1.1 christos # include <net/net_malloc.h>
1496 1.1 christos # define KMUTEX_T simple_lock_t
1497 1.1 christos # define KRWLOCK_T complex_lock_t
1498 1.1 christos # define USE_MUTEXES 1
1499 1.1 christos # define USE_SPL 1
1500 1.1 christos # define READ_ENTER(x) lock_read((x)->ipf_lk)
1501 1.1 christos # define WRITE_ENTER(x) lock_write((x)->ipf_lk)
1502 1.1 christos # define MUTEX_DOWNGRADE(x) lock_write_to_read((x)->ipf_lk)
1503 1.1 christos # define RWLOCK_INIT(x, y) lock_alloc(&(x)->ipf_lk, \
1504 1.1 christos LOCK_ALLOC_PIN, \
1505 1.1 christos (u_short)y, 0); \
1506 1.1 christos lock_init((x)->ipf_lk, TRUE)
1507 1.1 christos # define RWLOCK_EXIT(x) lock_done((x)->ipf_lk)
1508 1.1 christos # define RW_DESTROY(x) lock_free(&(x)->ipf_lk)
1509 1.1 christos # define MUTEX_ENTER(x) simple_lock((x)->ipf_lk)
1510 1.1 christos # define MUTEX_INIT(x, y) lock_alloc(&(x)->ipf_lk, \
1511 1.1 christos LOCK_ALLOC_PIN, \
1512 1.1 christos (u_short)y, 0); \
1513 1.1 christos simple_lock_init((x)->ipf_lk)
1514 1.1 christos # define MUTEX_DESTROY(x) lock_free(&(x)->ipf_lk)
1515 1.1 christos # define MUTEX_EXIT(x) simple_unlock((x)->ipf_lk)
1516 1.1 christos # define MUTEX_NUKE(x) bzero(&(x)->ipf_lk, sizeof((x)->ipf_lk))
1517 1.1 christos # define ATOMIC_INC64(x) { MUTEX_ENTER(&softc->ipf_rw); (x)++; \
1518 1.1 christos MUTEX_EXIT(&softc->ipf_rw); }
1519 1.1 christos # define ATOMIC_DEC64(x) { MUTEX_ENTER(&softc->ipf_rw); (x)--; \
1520 1.1 christos MUTEX_EXIT(&softc->ipf_rw); }
1521 1.1 christos # define ATOMIC_INC32(x) { MUTEX_ENTER(&softc->ipf_rw); (x)++; \
1522 1.1 christos MUTEX_EXIT(&softc->ipf_rw); }
1523 1.1 christos # define ATOMIC_DEC32(x) { MUTEX_ENTER(&softc->ipf_rw); (x)--; \
1524 1.1 christos MUTEX_EXIT(&softc->ipf_rw); }
1525 1.1 christos # define ATOMIC_INCL(x) { MUTEX_ENTER(&softc->ipf_rw); (x)++; \
1526 1.1 christos MUTEX_EXIT(&softc->ipf_rw); }
1527 1.1 christos # define ATOMIC_DECL(x) { MUTEX_ENTER(&softc->ipf_rw); (x)--; \
1528 1.1 christos MUTEX_EXIT(&softc->ipf_rw); }
1529 1.1 christos # define ATOMIC_INC(x) { MUTEX_ENTER(&softc->ipf_rw); (x)++; \
1530 1.1 christos MUTEX_EXIT(&softc->ipf_rw); }
1531 1.1 christos # define ATOMIC_DEC(x) { MUTEX_ENTER(&softc->ipf_rw); (x)--; \
1532 1.1 christos MUTEX_EXIT(&softc->ipf_rw); }
1533 1.1 christos # define SPL_SCHED(x) x = splsched()
1534 1.1 christos # define SPL_NET(x) x = splnet()
1535 1.1 christos # define SPL_IMP(x) x = splimp()
1536 1.1 christos # undef SPL_X
1537 1.1 christos # define SPL_X(x) splx(x)
1538 1.2 christos # define UIOMOVE(a,b,c,d) uiomove((void *)a,b,c,d)
1539 1.2 christos extern void* getifp(char *, int);
1540 1.1 christos # define GETIFP(n, v) getifp(n, v)
1541 1.1 christos # define GETIFMTU_4(x) ((struct ifnet *)x)->if_mtu
1542 1.1 christos # define GETIFMTU_6(x) ((struct ifnet *)x)->if_mtu
1543 1.1 christos # define GET_MINOR minor
1544 1.1 christos # define SLEEP(id, n) sleepx((id), PZERO+1, 0)
1545 1.1 christos # define WAKEUP(id,x) wakeup(id)
1546 1.1 christos # define POLLWAKEUP(x) ;
1547 1.1 christos # define COPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c))
1548 1.1 christos # define COPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c))
1549 1.1 christos # define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), M_TEMP, M_NOWAIT)
1550 1.1 christos # define KMALLOCS(a, b, c) MALLOC((a), b, (c), M_TEMP, \
1551 1.1 christos ((c) > 4096) ? M_WAITOK : M_NOWAIT)
1552 1.1 christos # define KFREE(x) FREE((x), M_TEMP)
1553 1.1 christos # define KFREES(x,s) FREE((x), M_TEMP)
1554 1.3 darrenr # define MSGDSIZE(m) mbufchainlen(m)
1555 1.3 darrenr # define M_LEN(m) (m)->m_len
1556 1.1 christos # define M_ADJ(m,x) m_adj(m, x)
1557 1.3 darrenr # define M_COPY(m) m_copy((m), 0, M_COPYALL)
1558 1.1 christos # define GETKTIME(x)
1559 1.1 christos # define IPF_PANIC(x,y)
1560 1.1 christos typedef struct mbuf mb_t;
1561 1.1 christos # endif /* _KERNEL */
1562 1.1 christos
1563 1.1 christos /*
1564 1.1 christos * These are from's Solaris' #defines for little endian.
1565 1.1 christos */
1566 1.1 christos #if !defined(IP6F_MORE_FRAG)
1567 1.1 christos # define IP6F_MORE_FRAG 0x0100
1568 1.1 christos #endif
1569 1.1 christos #if !defined(IP6F_RESERVED_MASK)
1570 1.1 christos # define IP6F_RESERVED_MASK 0x0600
1571 1.1 christos #endif
1572 1.1 christos #if !defined(IP6F_OFF_MASK)
1573 1.1 christos # define IP6F_OFF_MASK 0xf8ff
1574 1.1 christos #endif
1575 1.1 christos
1576 1.1 christos struct ip6_ext {
1577 1.1 christos u_char ip6e_nxt;
1578 1.1 christos u_char ip6e_len;
1579 1.1 christos };
1580 1.1 christos
1581 1.1 christos typedef int ioctlcmd_t;
1582 1.1 christos typedef int minor_t;
1583 1.1 christos /*
1584 1.1 christos * Really, any arch where sizeof(long) != sizeof(int).
1585 1.1 christos */
1586 1.1 christos typedef unsigned int u_32_t;
1587 1.1 christos # define U_32_T 1
1588 1.1 christos
1589 1.1 christos # define OS_RECOGNISED 1
1590 1.1 christos #endif /* _AIX51 */
1591 1.1 christos
1592 1.1 christos
1593 1.1 christos #ifndef OS_RECOGNISED
1594 1.1 christos #error ip_compat.h does not recognise this platform/OS.
1595 1.1 christos #endif
1596 1.1 christos
1597 1.1 christos
1598 1.1 christos /* ----------------------------------------------------------------------- */
1599 1.1 christos /* G E N E R I C */
1600 1.1 christos /* ----------------------------------------------------------------------- */
1601 1.1 christos #ifndef OS_RECOGNISED
1602 1.1 christos #endif
1603 1.1 christos
1604 1.1 christos /*
1605 1.1 christos * For BSD kernels, if bpf is in the kernel, enable ipfilter to use bpf in
1606 1.1 christos * filter rules.
1607 1.1 christos */
1608 1.1 christos #if !defined(IPFILTER_BPF)
1609 1.1 christos # if (defined(NBPF) && (NBPF > 0)) || (defined(DEV_BPF) && (DEV_BPF > 0)) || \
1610 1.1 christos (defined(NBPFILTER) && (NBPFILTER > 0))
1611 1.1 christos # define IPFILTER_BPF
1612 1.1 christos # endif
1613 1.1 christos #endif
1614 1.1 christos
1615 1.1 christos /*
1616 1.1 christos * Userland locking primitives
1617 1.1 christos */
1618 1.3 darrenr #if !defined(KMUTEX_FILL_SZ)
1619 1.3 darrenr # define KMUTEX_FILL_SZ 1
1620 1.3 darrenr #endif
1621 1.3 darrenr #if !defined(KRWLOCK_FILL_SZ)
1622 1.3 darrenr # define KRWLOCK_FILL_SZ 1
1623 1.3 darrenr #endif
1624 1.3 darrenr
1625 1.1 christos typedef struct {
1626 1.1 christos char *eMm_owner;
1627 1.1 christos char *eMm_heldin;
1628 1.1 christos u_int eMm_magic;
1629 1.1 christos int eMm_held;
1630 1.1 christos int eMm_heldat;
1631 1.1 christos } eMmutex_t;
1632 1.1 christos
1633 1.1 christos typedef struct {
1634 1.1 christos char *eMrw_owner;
1635 1.1 christos char *eMrw_heldin;
1636 1.1 christos u_int eMrw_magic;
1637 1.1 christos short eMrw_read;
1638 1.1 christos short eMrw_write;
1639 1.1 christos int eMrw_heldat;
1640 1.1 christos } eMrwlock_t;
1641 1.1 christos
1642 1.1 christos typedef union {
1643 1.3 darrenr char _fill[KMUTEX_FILL_SZ];
1644 1.1 christos #ifdef KMUTEX_T
1645 1.1 christos struct {
1646 1.1 christos KMUTEX_T ipf_slk;
1647 1.1 christos const char *ipf_lname;
1648 1.1 christos } ipf_lkun_s;
1649 1.1 christos #endif
1650 1.1 christos eMmutex_t ipf_emu;
1651 1.1 christos } ipfmutex_t;
1652 1.1 christos
1653 1.1 christos typedef union {
1654 1.3 darrenr char _fill[KRWLOCK_FILL_SZ];
1655 1.1 christos #ifdef KRWLOCK_T
1656 1.1 christos struct {
1657 1.1 christos KRWLOCK_T ipf_slk;
1658 1.1 christos const char *ipf_lname;
1659 1.1 christos int ipf_sr;
1660 1.1 christos int ipf_sw;
1661 1.1 christos u_int ipf_magic;
1662 1.1 christos } ipf_lkun_s;
1663 1.1 christos #endif
1664 1.1 christos eMrwlock_t ipf_emu;
1665 1.1 christos } ipfrwlock_t;
1666 1.1 christos
1667 1.1 christos #define ipf_lk ipf_lkun_s.ipf_slk
1668 1.1 christos #define ipf_lname ipf_lkun_s.ipf_lname
1669 1.1 christos #define ipf_isr ipf_lkun_s.ipf_sr
1670 1.1 christos #define ipf_isw ipf_lkun_s.ipf_sw
1671 1.1 christos #define ipf_magic ipf_lkun_s.ipf_magic
1672 1.1 christos
1673 1.1 christos #if !defined(__GNUC__) || \
1674 1.1 christos (defined(__FreeBSD_version) && (__FreeBSD_version >= 503000))
1675 1.1 christos # ifndef INLINE
1676 1.1 christos # define INLINE
1677 1.1 christos # endif
1678 1.1 christos #else
1679 1.1 christos # define INLINE __inline__
1680 1.1 christos #endif
1681 1.1 christos
1682 1.2 christos #ifndef EXTERN_INLINE
1683 1.2 christos # if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
1684 1.2 christos # define EXTERN_INLINE inline
1685 1.2 christos # else
1686 1.2 christos # define EXTERN_INLINE extern inline
1687 1.2 christos # endif
1688 1.2 christos #endif
1689 1.2 christos
1690 1.1 christos #if defined(linux) && defined(_KERNEL)
1691 1.2 christos extern void ipf_read_enter(ipfrwlock_t *);
1692 1.2 christos extern void ipf_write_enter(ipfrwlock_t *);
1693 1.2 christos extern void ipf_rw_exit(ipfrwlock_t *);
1694 1.2 christos extern void ipf_rw_init(ipfrwlock_t *, char *);
1695 1.2 christos extern void ipf_rw_downgrade(ipfrwlock_t *);
1696 1.1 christos #endif
1697 1.1 christos
1698 1.1 christos /*
1699 1.1 christos * In a non-kernel environment, there are a lot of macros that need to be
1700 1.1 christos * filled in to be null-ops or to point to some compatibility function,
1701 1.1 christos * somewhere in userland.
1702 1.1 christos */
1703 1.1 christos #ifndef _KERNEL
1704 1.1 christos typedef struct mb_s {
1705 1.1 christos struct mb_s *mb_next;
1706 1.1 christos char *mb_data;
1707 1.1 christos void *mb_ifp;
1708 1.1 christos int mb_len;
1709 1.1 christos int mb_flags;
1710 1.1 christos u_long mb_buf[2048];
1711 1.1 christos } mb_t;
1712 1.1 christos # undef m_next
1713 1.1 christos # define m_next mb_next
1714 1.1 christos # undef m_len
1715 1.1 christos # define m_len mb_len
1716 1.1 christos # undef m_flags
1717 1.1 christos # define m_flags mb_flags
1718 1.1 christos # undef m_data
1719 1.1 christos # define m_data mb_data
1720 1.1 christos # undef M_MCAST
1721 1.1 christos # define M_MCAST 0x01
1722 1.1 christos # undef M_BCAST
1723 1.1 christos # define M_BCAST 0x02
1724 1.1 christos # undef M_MBCAST
1725 1.1 christos # define M_MBCAST 0x04
1726 1.3 darrenr # define MSGDSIZE(m) msgdsize(m)
1727 1.3 darrenr # define M_LEN(m) (m)->mb_len
1728 1.3 darrenr # define M_ADJ(m,x) (m)->mb_len += x
1729 1.3 darrenr # define M_COPY(m) dupmbt(m)
1730 1.3 darrenr # define M_DUP(m) dupmbt(m)
1731 1.1 christos # define GETKTIME(x) gettimeofday((struct timeval *)(x), NULL)
1732 1.1 christos # define MTOD(m, t) ((t)(m)->mb_data)
1733 1.3 darrenr # define FREE_MB_T(m) freembt(m)
1734 1.1 christos # define ALLOC_MB_T(m,l) (m) = allocmbt(l)
1735 1.1 christos # define PREP_MB_T(f, m) do { \
1736 1.1 christos (m)->mb_next = *(f)->fin_mp; \
1737 1.1 christos *(fin)->fin_mp = (m); \
1738 1.1 christos (f)->fin_m = (m); \
1739 1.1 christos } while (0)
1740 1.1 christos # define SLEEP(x,y) 1;
1741 1.1 christos # define WAKEUP(x,y) ;
1742 1.1 christos # define POLLWAKEUP(y) ;
1743 1.1 christos # define IPF_PANIC(x,y) ;
1744 1.1 christos # define PANIC(x,y) ;
1745 1.1 christos # define SPL_SCHED(x) ;
1746 1.1 christos # define SPL_NET(x) ;
1747 1.1 christos # define SPL_IMP(x) ;
1748 1.1 christos # define SPL_X(x) ;
1749 1.1 christos # define KMALLOC(a,b) (a) = (b)malloc(sizeof(*a))
1750 1.1 christos # define KMALLOCS(a,b,c) (a) = (b)malloc(c)
1751 1.1 christos # define KFREE(x) free(x)
1752 1.1 christos # define KFREES(x,s) free(x)
1753 1.1 christos # define GETIFP(x, v) get_unit(x,v)
1754 1.1 christos # define GETIFMTU_4(x) 2048
1755 1.1 christos # define GETIFMTU_6(x) 2048
1756 1.1 christos # define COPYIN(a,b,c) bcopywrap((a), (b), (c))
1757 1.1 christos # define COPYOUT(a,b,c) bcopywrap((a), (b), (c))
1758 1.1 christos # define COPYDATA(m, o, l, b) bcopy(MTOD((mb_t *)m, char *) + (o), \
1759 1.1 christos (b), (l))
1760 1.1 christos # define COPYBACK(m, o, l, b) bcopy((b), \
1761 1.1 christos MTOD((mb_t *)m, char *) + (o), \
1762 1.1 christos (l))
1763 1.2 christos # define UIOMOVE(a,b,c,d) ipfuiomove(a,b,c,d)
1764 1.2 christos extern void m_copydata(mb_t *, int, int, void *);
1765 1.2 christos extern int ipfuiomove(void *, int, int, struct uio *);
1766 1.2 christos extern int bcopywrap(void *, void *, size_t);
1767 1.2 christos extern mb_t *allocmbt(size_t);
1768 1.2 christos extern mb_t *dupmbt(mb_t *);
1769 1.2 christos extern void freembt(mb_t *);
1770 1.1 christos
1771 1.1 christos # define MUTEX_DESTROY(x) eMmutex_destroy(&(x)->ipf_emu, \
1772 1.1 christos __FILE__, __LINE__)
1773 1.1 christos # define MUTEX_ENTER(x) eMmutex_enter(&(x)->ipf_emu, \
1774 1.1 christos __FILE__, __LINE__)
1775 1.1 christos # define MUTEX_EXIT(x) eMmutex_exit(&(x)->ipf_emu, \
1776 1.1 christos __FILE__, __LINE__)
1777 1.1 christos # define MUTEX_INIT(x,y) eMmutex_init(&(x)->ipf_emu, y, \
1778 1.1 christos __FILE__, __LINE__)
1779 1.1 christos # define MUTEX_NUKE(x) bzero((x), sizeof(*(x)))
1780 1.1 christos
1781 1.1 christos # define MUTEX_DOWNGRADE(x) eMrwlock_downgrade(&(x)->ipf_emu, \
1782 1.1 christos __FILE__, __LINE__)
1783 1.1 christos # define READ_ENTER(x) eMrwlock_read_enter(&(x)->ipf_emu, \
1784 1.1 christos __FILE__, __LINE__)
1785 1.1 christos # define RWLOCK_INIT(x, y) eMrwlock_init(&(x)->ipf_emu, y)
1786 1.1 christos # define RWLOCK_EXIT(x) eMrwlock_exit(&(x)->ipf_emu)
1787 1.1 christos # define RW_DESTROY(x) eMrwlock_destroy(&(x)->ipf_emu)
1788 1.1 christos # define WRITE_ENTER(x) eMrwlock_write_enter(&(x)->ipf_emu, \
1789 1.1 christos __FILE__, \
1790 1.1 christos __LINE__)
1791 1.1 christos
1792 1.1 christos # define USE_MUTEXES 1
1793 1.1 christos
1794 1.2 christos extern void eMmutex_destroy(eMmutex_t *, char *, int);
1795 1.2 christos extern void eMmutex_enter(eMmutex_t *, char *, int);
1796 1.2 christos extern void eMmutex_exit(eMmutex_t *, char *, int);
1797 1.2 christos extern void eMmutex_init(eMmutex_t *, char *, char *, int);
1798 1.2 christos extern void eMrwlock_destroy(eMrwlock_t *);
1799 1.2 christos extern void eMrwlock_exit(eMrwlock_t *);
1800 1.2 christos extern void eMrwlock_init(eMrwlock_t *, char *);
1801 1.2 christos extern void eMrwlock_read_enter(eMrwlock_t *, char *, int);
1802 1.2 christos extern void eMrwlock_write_enter(eMrwlock_t *, char *, int);
1803 1.2 christos extern void eMrwlock_downgrade(eMrwlock_t *, char *, int);
1804 1.1 christos
1805 1.1 christos #endif
1806 1.1 christos
1807 1.1 christos extern mb_t *allocmbt(size_t);
1808 1.1 christos
1809 1.1 christos #define MAX_IPV4HDR ((0xf << 2) + sizeof(struct icmp) + sizeof(ip_t) + 8)
1810 1.1 christos
1811 1.1 christos #ifndef IP_OFFMASK
1812 1.1 christos # define IP_OFFMASK 0x1fff
1813 1.1 christos #endif
1814 1.1 christos
1815 1.1 christos
1816 1.1 christos /*
1817 1.1 christos * On BSD's use quad_t as a guarantee for getting at least a 64bit sized
1818 1.1 christos * object.
1819 1.1 christos */
1820 1.1 christos #if !defined(__amd64__) && BSD_GT_YEAR(199306)
1821 1.1 christos # define USE_QUAD_T
1822 1.1 christos # define U_QUAD_T u_quad_t
1823 1.1 christos # define QUAD_T quad_t
1824 1.1 christos #else /* BSD > 199306 */
1825 1.1 christos # if !defined(U_QUAD_T)
1826 1.1 christos # define U_QUAD_T u_long
1827 1.1 christos # define QUAD_T long
1828 1.1 christos # endif
1829 1.1 christos #endif /* BSD > 199306 */
1830 1.1 christos
1831 1.1 christos
1832 1.1 christos #ifdef USE_INET6
1833 1.1 christos # if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || \
1834 1.1 christos defined(__osf__) || defined(linux)
1835 1.1 christos # include <netinet/ip6.h>
1836 1.1 christos # include <netinet/icmp6.h>
1837 1.1 christos # if !defined(linux)
1838 1.1 christos # if defined(_KERNEL) && !defined(__osf__)
1839 1.1 christos # include <netinet6/ip6_var.h>
1840 1.1 christos # endif
1841 1.1 christos # endif
1842 1.1 christos typedef struct ip6_hdr ip6_t;
1843 1.1 christos # endif
1844 1.1 christos #endif
1845 1.1 christos
1846 1.1 christos #ifndef MAX
1847 1.1 christos # define MAX(a,b) (((a) > (b)) ? (a) : (b))
1848 1.1 christos #endif
1849 1.1 christos
1850 1.1 christos #if defined(_KERNEL)
1851 1.1 christos # if defined(MENTAT) && !defined(INSTANCES)
1852 1.1 christos # define COPYDATA mb_copydata
1853 1.1 christos # define COPYBACK mb_copyback
1854 1.1 christos # else
1855 1.1 christos # define COPYDATA m_copydata
1856 1.1 christos # define COPYBACK m_copyback
1857 1.1 christos # endif
1858 1.1 christos # if BSD_GE_YEAR(199306) || defined(__FreeBSD__)
1859 1.1 christos # if (defined(__NetBSD_Version__) && (__NetBSD_Version__ < 105180000)) || \
1860 1.1 christos defined(__FreeBSD__) || (defined(OpenBSD) && (OpenBSD < 200206)) || \
1861 1.1 christos defined(_BSDI_VERSION)
1862 1.1 christos # include <vm/vm.h>
1863 1.1 christos # endif
1864 1.1 christos # if !defined(__FreeBSD__) || FREEBSD_GE_REV(300000)
1865 1.1 christos # if NETBSD_GE_REV(105180000) || OPENBSD_GE_REV(200111)
1866 1.2 christos /* # include <uvm/uvm_extern.h> */
1867 1.1 christos # else
1868 1.1 christos # include <vm/vm_extern.h>
1869 1.1 christos extern vm_map_t kmem_map;
1870 1.1 christos # endif
1871 1.1 christos # include <sys/proc.h>
1872 1.1 christos # else /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD_version >= 300000) */
1873 1.1 christos # include <vm/vm_kern.h>
1874 1.1 christos # endif /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD_version >= 300000) */
1875 1.1 christos
1876 1.1 christos # ifdef IPFILTER_M_IPFILTER
1877 1.1 christos # include <sys/malloc.h>
1878 1.1 christos MALLOC_DECLARE(M_IPFILTER);
1879 1.1 christos # define _M_IPF M_IPFILTER
1880 1.1 christos # else /* IPFILTER_M_IPFILTER */
1881 1.1 christos # ifdef M_PFIL
1882 1.1 christos # define _M_IPF M_PFIL
1883 1.1 christos # else
1884 1.1 christos # ifdef M_IPFILTER
1885 1.1 christos # define _M_IPF M_IPFILTER
1886 1.1 christos # else
1887 1.1 christos # define _M_IPF M_TEMP
1888 1.1 christos # endif /* M_IPFILTER */
1889 1.1 christos # endif /* M_PFIL */
1890 1.1 christos # endif /* IPFILTER_M_IPFILTER */
1891 1.1 christos # if !defined(KMALLOC)
1892 1.2 christos # define KMALLOC(a, b) (a) = (b)malloc(sizeof(*(a)), _M_IPF, M_NOWAIT)
1893 1.1 christos # endif
1894 1.1 christos # if !defined(KMALLOCS)
1895 1.2 christos # define KMALLOCS(a, b, c) (a) = (b)malloc((c), _M_IPF, M_NOWAIT)
1896 1.1 christos # endif
1897 1.1 christos # if !defined(KFREE)
1898 1.2 christos # define KFREE(x) free((x), _M_IPF)
1899 1.1 christos # endif
1900 1.2 christos # if !defined(KFREES)
1901 1.2 christos # define KFREES(x,s) free((x), _M_IPF)
1902 1.1 christos # endif
1903 1.2 christos # define UIOMOVE(a,b,c,d) uiomove((void *)a,b,d)
1904 1.1 christos # define SLEEP(id, n) tsleep((id), PPAUSE|PCATCH, n, 0)
1905 1.1 christos # define WAKEUP(id,x) wakeup(id+x)
1906 1.1 christos # if !defined(POLLWAKEUP)
1907 1.1 christos # define POLLWAKEUP(x) selwakeup(softc->ipf_selwait+x)
1908 1.1 christos # endif
1909 1.1 christos # define GETIFP(n, v) ifunit(n)
1910 1.1 christos # define GETIFMTU_4(x) ((struct ifnet *)x)->if_mtu
1911 1.1 christos # define GETIFMTU_6(x) ((struct ifnet *)x)->if_mtu
1912 1.1 christos # endif /* (Free)BSD */
1913 1.1 christos
1914 1.1 christos # if !defined(USE_MUTEXES) && !defined(SPL_NET)
1915 1.1 christos # if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199407)) || \
1916 1.1 christos OPENBSD_GE_REV(200006)
1917 1.1 christos # define SPL_NET(x) x = splsoftnet()
1918 1.1 christos # else
1919 1.1 christos # define SPL_IMP(x) x = splimp()
1920 1.1 christos # define SPL_NET(x) x = splnet()
1921 1.1 christos # endif /* NetBSD && (NetBSD <= 1991011) && (NetBSD >= 199407) */
1922 1.1 christos # if !defined(SPL_SCHED)
1923 1.1 christos # define SPL_SCHED(x) x = splsched()
1924 1.1 christos # endif
1925 1.1 christos # define SPL_X(x) (void) splx(x)
1926 1.1 christos # endif /* !USE_MUTEXES */
1927 1.1 christos
1928 1.1 christos # ifndef FREE_MB_T
1929 1.1 christos # define FREE_MB_T(m) m_freem(m)
1930 1.1 christos # endif
1931 1.1 christos # ifndef ALLOC_MB_T
1932 1.1 christos # ifdef MGETHDR
1933 1.1 christos # define ALLOC_MB_T(m,l) do { \
1934 1.1 christos MGETHDR((m), M_DONTWAIT, MT_HEADER); \
1935 1.1 christos if ((m) != NULL) { \
1936 1.1 christos (m)->m_len = (l); \
1937 1.1 christos (m)->m_pkthdr.len = (l); \
1938 1.1 christos } \
1939 1.1 christos } while (0)
1940 1.1 christos # else
1941 1.1 christos # define ALLOC_MB_T(m,l) do { \
1942 1.1 christos MGET((m), M_DONTWAIT, MT_HEADER); \
1943 1.1 christos if ((m) != NULL) { \
1944 1.1 christos (m)->m_len = (l); \
1945 1.1 christos (m)->m_pkthdr.len = (l); \
1946 1.1 christos } \
1947 1.1 christos } while (0)
1948 1.1 christos # endif
1949 1.1 christos # endif
1950 1.1 christos # ifndef PREP_MB_T
1951 1.1 christos # define PREP_MB_T(f, m) do { \
1952 1.1 christos mb_t *_o = *(f)->fin_mp; \
1953 1.1 christos (m)->m_next = _o; \
1954 1.1 christos *(fin)->fin_mp = (m); \
1955 1.1 christos if (_o->m_flags & M_PKTHDR) { \
1956 1.1 christos (m)->m_pkthdr.len += \
1957 1.1 christos _o->m_pkthdr.len; \
1958 1.1 christos (m)->m_pkthdr.rcvif = \
1959 1.1 christos _o->m_pkthdr.rcvif; \
1960 1.1 christos } \
1961 1.1 christos } while (0)
1962 1.1 christos # endif
1963 1.1 christos # ifndef M_DUP
1964 1.1 christos # ifdef M_COPYALL
1965 1.1 christos # define M_DUP(m) m_dup(m, 0, M_COPYALL, 0)
1966 1.1 christos # else
1967 1.1 christos # define M_DUP(m) m_dup(m)
1968 1.1 christos # endif
1969 1.1 christos # endif
1970 1.1 christos
1971 1.1 christos # ifndef MTOD
1972 1.1 christos # define MTOD(m,t) mtod(m,t)
1973 1.1 christos # endif
1974 1.1 christos
1975 1.1 christos # ifndef COPYIN
1976 1.1 christos # define COPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
1977 1.1 christos # define COPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
1978 1.1 christos # endif
1979 1.1 christos
1980 1.1 christos # ifndef KMALLOC
1981 1.1 christos # define KMALLOC(a,b) (a) = (b)new_kmem_alloc(sizeof(*(a)), \
1982 1.1 christos KMEM_NOSLEEP)
1983 1.1 christos # define KMALLOCS(a,b,c) (a) = (b)new_kmem_alloc((c), KMEM_NOSLEEP)
1984 1.1 christos # endif
1985 1.1 christos
1986 1.1 christos # ifndef GET_MINOR
1987 1.1 christos # define GET_MINOR(x) minor(x)
1988 1.1 christos # endif
1989 1.1 christos # define PANIC(x,y) if (x) panic y
1990 1.1 christos #endif /* _KERNEL */
1991 1.1 christos
1992 1.1 christos #if !defined(IFNAME) && !defined(_KERNEL)
1993 1.1 christos # define IFNAME(x) get_ifname((struct ifnet *)x)
1994 1.1 christos #endif
1995 1.1 christos #ifndef COPYIFNAME
1996 1.1 christos # define NEED_FRGETIFNAME
1997 1.2 christos extern char *ipf_getifname(struct ifnet *, char *);
1998 1.1 christos # define COPYIFNAME(v, x, b) \
1999 1.1 christos ipf_getifname((struct ifnet *)x, b)
2000 1.1 christos #endif
2001 1.1 christos
2002 1.1 christos #ifndef ASSERT
2003 1.1 christos # ifdef _KERNEL
2004 1.1 christos # define ASSERT(x)
2005 1.1 christos # else
2006 1.1 christos # define ASSERT(x) do { if (!(x)) abort(); } while (0)
2007 1.1 christos # endif
2008 1.1 christos #endif
2009 1.1 christos
2010 1.1 christos #ifndef BCOPYIN
2011 1.1 christos # define BCOPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
2012 1.1 christos # define BCOPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
2013 1.1 christos #endif
2014 1.1 christos
2015 1.1 christos /*
2016 1.1 christos * Because the ctype(3) posix definition, if used "safely" in code everywhere,
2017 1.1 christos * would mean all normal code that walks through strings needed casts. Yuck.
2018 1.1 christos */
2019 1.1 christos #define ISALNUM(x) isalnum((u_char)(x))
2020 1.1 christos #define ISALPHA(x) isalpha((u_char)(x))
2021 1.1 christos #define ISDIGIT(x) isdigit((u_char)(x))
2022 1.1 christos #define ISSPACE(x) isspace((u_char)(x))
2023 1.1 christos #define ISUPPER(x) isupper((u_char)(x))
2024 1.1 christos #define ISXDIGIT(x) isxdigit((u_char)(x))
2025 1.1 christos #define ISLOWER(x) islower((u_char)(x))
2026 1.1 christos #define TOUPPER(x) toupper((u_char)(x))
2027 1.1 christos #define TOLOWER(x) tolower((u_char)(x))
2028 1.1 christos
2029 1.1 christos /*
2030 1.1 christos * If mutexes aren't being used, turn all the mutex functions into null-ops.
2031 1.1 christos */
2032 1.1 christos #if !defined(USE_MUTEXES)
2033 1.1 christos # define USE_SPL 1
2034 1.1 christos # undef RW_DESTROY
2035 1.1 christos # undef MUTEX_INIT
2036 1.1 christos # undef MUTEX_NUKE
2037 1.1 christos # undef MUTEX_DESTROY
2038 1.1 christos # define MUTEX_ENTER(x) ;
2039 1.1 christos # define READ_ENTER(x) ;
2040 1.1 christos # define WRITE_ENTER(x) ;
2041 1.1 christos # define MUTEX_DOWNGRADE(x) ;
2042 1.1 christos # define RWLOCK_INIT(x, y) ;
2043 1.1 christos # define RWLOCK_EXIT(x) ;
2044 1.1 christos # define RW_DESTROY(x) ;
2045 1.1 christos # define MUTEX_EXIT(x) ;
2046 1.1 christos # define MUTEX_INIT(x,y) ;
2047 1.1 christos # define MUTEX_DESTROY(x) ;
2048 1.1 christos # define MUTEX_NUKE(x) ;
2049 1.1 christos #endif /* !USE_MUTEXES */
2050 1.1 christos #ifndef ATOMIC_INC
2051 1.1 christos # define ATOMIC_INC(x) (x)++
2052 1.1 christos # define ATOMIC_DEC(x) (x)--
2053 1.1 christos #endif
2054 1.1 christos
2055 1.1 christos #if defined(USE_SPL) && defined(_KERNEL)
2056 1.1 christos # define SPL_INT(x) int x
2057 1.1 christos #else
2058 1.1 christos # define SPL_INT(x)
2059 1.1 christos #endif
2060 1.1 christos
2061 1.1 christos /*
2062 1.1 christos * If there are no atomic operations for bit sizes defined, define them to all
2063 1.1 christos * use a generic one that works for all sizes.
2064 1.1 christos */
2065 1.1 christos #ifndef ATOMIC_INCL
2066 1.1 christos # define ATOMIC_INCL ATOMIC_INC
2067 1.1 christos # define ATOMIC_INC64 ATOMIC_INC
2068 1.1 christos # define ATOMIC_INC32 ATOMIC_INC
2069 1.1 christos # define ATOMIC_DECL ATOMIC_DEC
2070 1.1 christos # define ATOMIC_DEC64 ATOMIC_DEC
2071 1.1 christos # define ATOMIC_DEC32 ATOMIC_DEC
2072 1.1 christos #endif
2073 1.1 christos
2074 1.1 christos #ifndef HDR_T_PRIVATE
2075 1.1 christos typedef struct tcphdr tcphdr_t;
2076 1.1 christos typedef struct udphdr udphdr_t;
2077 1.1 christos #endif
2078 1.1 christos typedef struct icmp icmphdr_t;
2079 1.1 christos typedef struct ip ip_t;
2080 1.1 christos typedef struct ether_header ether_header_t;
2081 1.1 christos typedef struct tcpiphdr tcpiphdr_t;
2082 1.1 christos
2083 1.1 christos #ifndef FR_GROUPLEN
2084 1.1 christos # define FR_GROUPLEN 16
2085 1.1 christos #endif
2086 1.1 christos
2087 1.1 christos #ifndef offsetof
2088 1.1 christos # define offsetof(t,m) (size_t)((&((t *)0L)->m))
2089 1.1 christos #endif
2090 1.1 christos #ifndef stsizeof
2091 1.1 christos # define stsizeof(t,m) sizeof(((t *)0L)->m)
2092 1.1 christos #endif
2093 1.1 christos
2094 1.1 christos /*
2095 1.1 christos * This set of macros has been brought about because on Tru64 it is not
2096 1.1 christos * possible to easily assign or examine values in a structure that are
2097 1.1 christos * bit fields.
2098 1.1 christos */
2099 1.1 christos #ifndef IP_V
2100 1.1 christos # define IP_V(x) (x)->ip_v
2101 1.1 christos #endif
2102 1.1 christos #ifndef IP_V_A
2103 1.1 christos # define IP_V_A(x,y) (x)->ip_v = (y)
2104 1.1 christos #endif
2105 1.1 christos #ifndef IP_HL
2106 1.1 christos # define IP_HL(x) (x)->ip_hl
2107 1.1 christos #endif
2108 1.1 christos #ifndef IP_HL_A
2109 1.1 christos # define IP_HL_A(x,y) (x)->ip_hl = ((y) & 0xf)
2110 1.1 christos #endif
2111 1.1 christos #ifndef TCP_X2
2112 1.1 christos # define TCP_X2(x) (x)->th_x2
2113 1.1 christos #endif
2114 1.1 christos #ifndef TCP_X2_A
2115 1.1 christos # define TCP_X2_A(x,y) (x)->th_x2 = (y)
2116 1.1 christos #endif
2117 1.1 christos #ifndef TCP_OFF
2118 1.1 christos # define TCP_OFF(x) (x)->th_off
2119 1.1 christos #endif
2120 1.1 christos #ifndef TCP_OFF_A
2121 1.1 christos # define TCP_OFF_A(x,y) (x)->th_off = (y)
2122 1.1 christos #endif
2123 1.1 christos #define IPMINLEN(i, h) ((i)->ip_len >= (IP_HL(i) * 4 + sizeof(struct h)))
2124 1.1 christos
2125 1.1 christos
2126 1.1 christos /*
2127 1.1 christos * XXX - This is one of those *awful* hacks which nobody likes
2128 1.1 christos */
2129 1.1 christos #ifdef ultrix
2130 1.1 christos #define A_A
2131 1.1 christos #else
2132 1.1 christos #define A_A &
2133 1.1 christos #endif
2134 1.1 christos
2135 1.1 christos #define TCPF_ALL (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|\
2136 1.1 christos TH_ECN|TH_CWR)
2137 1.1 christos
2138 1.1 christos #if BSD_GE_YEAR(199306) && !defined(m_act)
2139 1.1 christos # define m_act m_nextpkt
2140 1.1 christos #endif
2141 1.1 christos
2142 1.1 christos /*
2143 1.1 christos * Security Options for Intenet Protocol (IPSO) as defined in RFC 1108.
2144 1.1 christos *
2145 1.1 christos * Basic Option
2146 1.1 christos *
2147 1.1 christos * 00000001 - (Reserved 4)
2148 1.1 christos * 00111101 - Top Secret
2149 1.1 christos * 01011010 - Secret
2150 1.1 christos * 10010110 - Confidential
2151 1.1 christos * 01100110 - (Reserved 3)
2152 1.1 christos * 11001100 - (Reserved 2)
2153 1.1 christos * 10101011 - Unclassified
2154 1.1 christos * 11110001 - (Reserved 1)
2155 1.1 christos */
2156 1.1 christos #define IPSO_CLASS_RES4 0x01
2157 1.1 christos #define IPSO_CLASS_TOPS 0x3d
2158 1.1 christos #define IPSO_CLASS_SECR 0x5a
2159 1.1 christos #define IPSO_CLASS_CONF 0x96
2160 1.1 christos #define IPSO_CLASS_RES3 0x66
2161 1.1 christos #define IPSO_CLASS_RES2 0xcc
2162 1.1 christos #define IPSO_CLASS_UNCL 0xab
2163 1.1 christos #define IPSO_CLASS_RES1 0xf1
2164 1.1 christos
2165 1.1 christos #define IPSO_AUTH_GENSER 0x80
2166 1.1 christos #define IPSO_AUTH_ESI 0x40
2167 1.1 christos #define IPSO_AUTH_SCI 0x20
2168 1.1 christos #define IPSO_AUTH_NSA 0x10
2169 1.1 christos #define IPSO_AUTH_DOE 0x08
2170 1.1 christos #define IPSO_AUTH_UN 0x06
2171 1.1 christos #define IPSO_AUTH_FTE 0x01
2172 1.1 christos
2173 1.1 christos /*
2174 1.1 christos * IP option #defines
2175 1.1 christos */
2176 1.1 christos #undef IPOPT_RR
2177 1.1 christos #define IPOPT_RR 7
2178 1.1 christos #undef IPOPT_ZSU
2179 1.1 christos #define IPOPT_ZSU 10 /* ZSU */
2180 1.1 christos #undef IPOPT_MTUP
2181 1.1 christos #define IPOPT_MTUP 11 /* MTUP */
2182 1.1 christos #undef IPOPT_MTUR
2183 1.1 christos #define IPOPT_MTUR 12 /* MTUR */
2184 1.1 christos #undef IPOPT_ENCODE
2185 1.1 christos #define IPOPT_ENCODE 15 /* ENCODE */
2186 1.1 christos #undef IPOPT_TS
2187 1.1 christos #define IPOPT_TS 68
2188 1.1 christos #undef IPOPT_TR
2189 1.1 christos #define IPOPT_TR 82 /* TR */
2190 1.1 christos #undef IPOPT_SECURITY
2191 1.1 christos #define IPOPT_SECURITY 130
2192 1.1 christos #undef IPOPT_LSRR
2193 1.1 christos #define IPOPT_LSRR 131
2194 1.1 christos #undef IPOPT_E_SEC
2195 1.1 christos #define IPOPT_E_SEC 133 /* E-SEC */
2196 1.1 christos #undef IPOPT_CIPSO
2197 1.1 christos #define IPOPT_CIPSO 134 /* CIPSO */
2198 1.1 christos #undef IPOPT_SATID
2199 1.1 christos #define IPOPT_SATID 136
2200 1.1 christos #ifndef IPOPT_SID
2201 1.1 christos # define IPOPT_SID IPOPT_SATID
2202 1.1 christos #endif
2203 1.1 christos #undef IPOPT_SSRR
2204 1.1 christos #define IPOPT_SSRR 137
2205 1.1 christos #undef IPOPT_ADDEXT
2206 1.1 christos #define IPOPT_ADDEXT 147 /* ADDEXT */
2207 1.1 christos #undef IPOPT_VISA
2208 1.1 christos #define IPOPT_VISA 142 /* VISA */
2209 1.1 christos #undef IPOPT_IMITD
2210 1.1 christos #define IPOPT_IMITD 144 /* IMITD */
2211 1.1 christos #undef IPOPT_EIP
2212 1.1 christos #define IPOPT_EIP 145 /* EIP */
2213 1.1 christos #undef IPOPT_RTRALRT
2214 1.1 christos #define IPOPT_RTRALRT 148 /* RTRALRT */
2215 1.1 christos #undef IPOPT_SDB
2216 1.1 christos #define IPOPT_SDB 149
2217 1.1 christos #undef IPOPT_NSAPA
2218 1.1 christos #define IPOPT_NSAPA 150
2219 1.1 christos #undef IPOPT_DPS
2220 1.1 christos #define IPOPT_DPS 151
2221 1.1 christos #undef IPOPT_UMP
2222 1.1 christos #define IPOPT_UMP 152
2223 1.1 christos #undef IPOPT_FINN
2224 1.1 christos #define IPOPT_FINN 205 /* FINN */
2225 1.1 christos #undef IPOPT_AH
2226 1.1 christos #define IPOPT_AH 256+IPPROTO_AH
2227 1.1 christos
2228 1.1 christos #ifndef TCPOPT_EOL
2229 1.1 christos # define TCPOPT_EOL 0
2230 1.1 christos #endif
2231 1.1 christos #ifndef TCPOPT_NOP
2232 1.1 christos # define TCPOPT_NOP 1
2233 1.1 christos #endif
2234 1.1 christos #ifndef TCPOPT_MAXSEG
2235 1.1 christos # define TCPOPT_MAXSEG 2
2236 1.1 christos #endif
2237 1.1 christos #ifndef TCPOLEN_MAXSEG
2238 1.1 christos # define TCPOLEN_MAXSEG 4
2239 1.1 christos #endif
2240 1.1 christos #ifndef TCPOPT_WINDOW
2241 1.1 christos # define TCPOPT_WINDOW 3
2242 1.1 christos #endif
2243 1.1 christos #ifndef TCPOLEN_WINDOW
2244 1.1 christos # define TCPOLEN_WINDOW 3
2245 1.1 christos #endif
2246 1.1 christos #ifndef TCPOPT_SACK_PERMITTED
2247 1.1 christos # define TCPOPT_SACK_PERMITTED 4
2248 1.1 christos #endif
2249 1.1 christos #ifndef TCPOLEN_SACK_PERMITTED
2250 1.1 christos # define TCPOLEN_SACK_PERMITTED 2
2251 1.1 christos #endif
2252 1.1 christos #ifndef TCPOPT_SACK
2253 1.1 christos # define TCPOPT_SACK 5
2254 1.1 christos #endif
2255 1.1 christos #ifndef TCPOPT_TIMESTAMP
2256 1.1 christos # define TCPOPT_TIMESTAMP 8
2257 1.1 christos #endif
2258 1.1 christos
2259 1.1 christos #ifndef ICMP_MINLEN
2260 1.1 christos # define ICMP_MINLEN 8
2261 1.1 christos #endif
2262 1.1 christos #ifndef ICMP_ECHOREPLY
2263 1.1 christos # define ICMP_ECHOREPLY 0
2264 1.1 christos #endif
2265 1.1 christos #ifndef ICMP_UNREACH
2266 1.1 christos # define ICMP_UNREACH 3
2267 1.1 christos #endif
2268 1.1 christos #ifndef ICMP_UNREACH_NET
2269 1.1 christos # define ICMP_UNREACH_NET 0
2270 1.1 christos #endif
2271 1.1 christos #ifndef ICMP_UNREACH_HOST
2272 1.1 christos # define ICMP_UNREACH_HOST 1
2273 1.1 christos #endif
2274 1.1 christos #ifndef ICMP_UNREACH_PROTOCOL
2275 1.1 christos # define ICMP_UNREACH_PROTOCOL 2
2276 1.1 christos #endif
2277 1.1 christos #ifndef ICMP_UNREACH_PORT
2278 1.1 christos # define ICMP_UNREACH_PORT 3
2279 1.1 christos #endif
2280 1.1 christos #ifndef ICMP_UNREACH_NEEDFRAG
2281 1.1 christos # define ICMP_UNREACH_NEEDFRAG 4
2282 1.1 christos #endif
2283 1.1 christos #ifndef ICMP_UNREACH_SRCFAIL
2284 1.1 christos # define ICMP_UNREACH_SRCFAIL 5
2285 1.1 christos #endif
2286 1.1 christos #ifndef ICMP_UNREACH_NET_UNKNOWN
2287 1.1 christos # define ICMP_UNREACH_NET_UNKNOWN 6
2288 1.1 christos #endif
2289 1.1 christos #ifndef ICMP_UNREACH_HOST_UNKNOWN
2290 1.1 christos # define ICMP_UNREACH_HOST_UNKNOWN 7
2291 1.1 christos #endif
2292 1.1 christos #ifndef ICMP_UNREACH_ISOLATED
2293 1.1 christos # define ICMP_UNREACH_ISOLATED 8
2294 1.1 christos #endif
2295 1.1 christos #ifndef ICMP_UNREACH_NET_PROHIB
2296 1.1 christos # define ICMP_UNREACH_NET_PROHIB 9
2297 1.1 christos #endif
2298 1.1 christos #ifndef ICMP_UNREACH_HOST_PROHIB
2299 1.1 christos # define ICMP_UNREACH_HOST_PROHIB 10
2300 1.1 christos #endif
2301 1.1 christos #ifndef ICMP_UNREACH_TOSNET
2302 1.1 christos # define ICMP_UNREACH_TOSNET 11
2303 1.1 christos #endif
2304 1.1 christos #ifndef ICMP_UNREACH_TOSHOST
2305 1.1 christos # define ICMP_UNREACH_TOSHOST 12
2306 1.1 christos #endif
2307 1.1 christos #ifndef ICMP_UNREACH_ADMIN_PROHIBIT
2308 1.1 christos # define ICMP_UNREACH_ADMIN_PROHIBIT 13
2309 1.1 christos #endif
2310 1.1 christos #ifndef ICMP_UNREACH_FILTER
2311 1.1 christos # define ICMP_UNREACH_FILTER 13
2312 1.1 christos #endif
2313 1.1 christos #ifndef ICMP_UNREACH_HOST_PRECEDENCE
2314 1.1 christos # define ICMP_UNREACH_HOST_PRECEDENCE 14
2315 1.1 christos #endif
2316 1.1 christos #ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF
2317 1.1 christos # define ICMP_UNREACH_PRECEDENCE_CUTOFF 15
2318 1.1 christos #endif
2319 1.1 christos #ifndef ICMP_SOURCEQUENCH
2320 1.1 christos # define ICMP_SOURCEQUENCH 4
2321 1.1 christos #endif
2322 1.1 christos #ifndef ICMP_REDIRECT_NET
2323 1.1 christos # define ICMP_REDIRECT_NET 0
2324 1.1 christos #endif
2325 1.1 christos #ifndef ICMP_REDIRECT_HOST
2326 1.1 christos # define ICMP_REDIRECT_HOST 1
2327 1.1 christos #endif
2328 1.1 christos #ifndef ICMP_REDIRECT_TOSNET
2329 1.1 christos # define ICMP_REDIRECT_TOSNET 2
2330 1.1 christos #endif
2331 1.1 christos #ifndef ICMP_REDIRECT_TOSHOST
2332 1.1 christos # define ICMP_REDIRECT_TOSHOST 3
2333 1.1 christos #endif
2334 1.1 christos #ifndef ICMP_ALTHOSTADDR
2335 1.1 christos # define ICMP_ALTHOSTADDR 6
2336 1.1 christos #endif
2337 1.1 christos #ifndef ICMP_TIMXCEED
2338 1.1 christos # define ICMP_TIMXCEED 11
2339 1.1 christos #endif
2340 1.1 christos #ifndef ICMP_TIMXCEED_INTRANS
2341 1.1 christos # define ICMP_TIMXCEED_INTRANS 0
2342 1.1 christos #endif
2343 1.1 christos #ifndef ICMP_TIMXCEED_REASS
2344 1.1 christos # define ICMP_TIMXCEED_REASS 1
2345 1.1 christos #endif
2346 1.1 christos #ifndef ICMP_PARAMPROB
2347 1.1 christos # define ICMP_PARAMPROB 12
2348 1.1 christos #endif
2349 1.1 christos #ifndef ICMP_PARAMPROB_ERRATPTR
2350 1.1 christos # define ICMP_PARAMPROB_ERRATPTR 0
2351 1.1 christos #endif
2352 1.1 christos #ifndef ICMP_PARAMPROB_OPTABSENT
2353 1.1 christos # define ICMP_PARAMPROB_OPTABSENT 1
2354 1.1 christos #endif
2355 1.1 christos #ifndef ICMP_PARAMPROB_LENGTH
2356 1.1 christos # define ICMP_PARAMPROB_LENGTH 2
2357 1.1 christos #endif
2358 1.1 christos #ifndef ICMP_TSTAMP
2359 1.1 christos # define ICMP_TSTAMP 13
2360 1.1 christos #endif
2361 1.1 christos #ifndef ICMP_TSTAMPREPLY
2362 1.1 christos # define ICMP_TSTAMPREPLY 14
2363 1.1 christos #endif
2364 1.1 christos #ifndef ICMP_IREQ
2365 1.1 christos # define ICMP_IREQ 15
2366 1.1 christos #endif
2367 1.1 christos #ifndef ICMP_IREQREPLY
2368 1.1 christos # define ICMP_IREQREPLY 16
2369 1.1 christos #endif
2370 1.1 christos #ifndef ICMP_MASKREQ
2371 1.1 christos # define ICMP_MASKREQ 17
2372 1.1 christos #endif
2373 1.1 christos #ifndef ICMP_MASKREPLY
2374 1.1 christos # define ICMP_MASKREPLY 18
2375 1.1 christos #endif
2376 1.1 christos #ifndef ICMP_TRACEROUTE
2377 1.1 christos # define ICMP_TRACEROUTE 30
2378 1.1 christos #endif
2379 1.1 christos #ifndef ICMP_DATACONVERR
2380 1.1 christos # define ICMP_DATACONVERR 31
2381 1.1 christos #endif
2382 1.1 christos #ifndef ICMP_MOBILE_REDIRECT
2383 1.1 christos # define ICMP_MOBILE_REDIRECT 32
2384 1.1 christos #endif
2385 1.1 christos #ifndef ICMP_IPV6_WHEREAREYOU
2386 1.1 christos # define ICMP_IPV6_WHEREAREYOU 33
2387 1.1 christos #endif
2388 1.1 christos #ifndef ICMP_IPV6_IAMHERE
2389 1.1 christos # define ICMP_IPV6_IAMHERE 34
2390 1.1 christos #endif
2391 1.1 christos #ifndef ICMP_MOBILE_REGREQUEST
2392 1.1 christos # define ICMP_MOBILE_REGREQUEST 35
2393 1.1 christos #endif
2394 1.1 christos #ifndef ICMP_MOBILE_REGREPLY
2395 1.1 christos # define ICMP_MOBILE_REGREPLY 36
2396 1.1 christos #endif
2397 1.1 christos #ifndef ICMP_SKIP
2398 1.1 christos # define ICMP_SKIP 39
2399 1.1 christos #endif
2400 1.1 christos #ifndef ICMP_PHOTURIS
2401 1.1 christos # define ICMP_PHOTURIS 40
2402 1.1 christos #endif
2403 1.1 christos #ifndef ICMP_PHOTURIS_UNKNOWN_INDEX
2404 1.1 christos # define ICMP_PHOTURIS_UNKNOWN_INDEX 1
2405 1.1 christos #endif
2406 1.1 christos #ifndef ICMP_PHOTURIS_AUTH_FAILED
2407 1.1 christos # define ICMP_PHOTURIS_AUTH_FAILED 2
2408 1.1 christos #endif
2409 1.1 christos #ifndef ICMP_PHOTURIS_DECRYPT_FAILED
2410 1.1 christos # define ICMP_PHOTURIS_DECRYPT_FAILED 3
2411 1.1 christos #endif
2412 1.1 christos #ifndef IPVERSION
2413 1.1 christos # define IPVERSION 4
2414 1.1 christos #endif
2415 1.1 christos #ifndef IPOPT_MINOFF
2416 1.1 christos # define IPOPT_MINOFF 4
2417 1.1 christos #endif
2418 1.1 christos #ifndef IPOPT_COPIED
2419 1.1 christos # define IPOPT_COPIED(x) ((x)&0x80)
2420 1.1 christos #endif
2421 1.1 christos #ifndef IPOPT_EOL
2422 1.1 christos # define IPOPT_EOL 0
2423 1.1 christos #endif
2424 1.1 christos #ifndef IPOPT_NOP
2425 1.1 christos # define IPOPT_NOP 1
2426 1.1 christos #endif
2427 1.1 christos #ifndef IP_MF
2428 1.1 christos # define IP_MF ((u_short)0x2000)
2429 1.1 christos #endif
2430 1.1 christos #ifndef ETHERTYPE_IP
2431 1.1 christos # define ETHERTYPE_IP ((u_short)0x0800)
2432 1.1 christos #endif
2433 1.1 christos #ifndef TH_FIN
2434 1.1 christos # define TH_FIN 0x01
2435 1.1 christos #endif
2436 1.1 christos #ifndef TH_SYN
2437 1.1 christos # define TH_SYN 0x02
2438 1.1 christos #endif
2439 1.1 christos #ifndef TH_RST
2440 1.1 christos # define TH_RST 0x04
2441 1.1 christos #endif
2442 1.1 christos #ifndef TH_PUSH
2443 1.1 christos # define TH_PUSH 0x08
2444 1.1 christos #endif
2445 1.1 christos #ifndef TH_ACK
2446 1.1 christos # define TH_ACK 0x10
2447 1.1 christos #endif
2448 1.1 christos #ifndef TH_URG
2449 1.1 christos # define TH_URG 0x20
2450 1.1 christos #endif
2451 1.1 christos #undef TH_ACKMASK
2452 1.1 christos #define TH_ACKMASK (TH_FIN|TH_SYN|TH_RST|TH_ACK)
2453 1.1 christos
2454 1.1 christos #ifndef IPOPT_EOL
2455 1.1 christos # define IPOPT_EOL 0
2456 1.1 christos #endif
2457 1.1 christos #ifndef IPOPT_NOP
2458 1.1 christos # define IPOPT_NOP 1
2459 1.1 christos #endif
2460 1.1 christos #ifndef IPOPT_RR
2461 1.1 christos # define IPOPT_RR 7
2462 1.1 christos #endif
2463 1.1 christos #ifndef IPOPT_TS
2464 1.1 christos # define IPOPT_TS 68
2465 1.1 christos #endif
2466 1.1 christos #ifndef IPOPT_SECURITY
2467 1.1 christos # define IPOPT_SECURITY 130
2468 1.1 christos #endif
2469 1.1 christos #ifndef IPOPT_LSRR
2470 1.1 christos # define IPOPT_LSRR 131
2471 1.1 christos #endif
2472 1.1 christos #ifndef IPOPT_SATID
2473 1.1 christos # define IPOPT_SATID 136
2474 1.1 christos #endif
2475 1.1 christos #ifndef IPOPT_SSRR
2476 1.1 christos # define IPOPT_SSRR 137
2477 1.1 christos #endif
2478 1.1 christos #ifndef IPOPT_SECUR_UNCLASS
2479 1.1 christos # define IPOPT_SECUR_UNCLASS ((u_short)0x0000)
2480 1.1 christos #endif
2481 1.1 christos #ifndef IPOPT_SECUR_CONFID
2482 1.1 christos # define IPOPT_SECUR_CONFID ((u_short)0xf135)
2483 1.1 christos #endif
2484 1.1 christos #ifndef IPOPT_SECUR_EFTO
2485 1.1 christos # define IPOPT_SECUR_EFTO ((u_short)0x789a)
2486 1.1 christos #endif
2487 1.1 christos #ifndef IPOPT_SECUR_MMMM
2488 1.1 christos # define IPOPT_SECUR_MMMM ((u_short)0xbc4d)
2489 1.1 christos #endif
2490 1.1 christos #ifndef IPOPT_SECUR_RESTR
2491 1.1 christos # define IPOPT_SECUR_RESTR ((u_short)0xaf13)
2492 1.1 christos #endif
2493 1.1 christos #ifndef IPOPT_SECUR_SECRET
2494 1.1 christos # define IPOPT_SECUR_SECRET ((u_short)0xd788)
2495 1.1 christos #endif
2496 1.1 christos #ifndef IPOPT_SECUR_TOPSECRET
2497 1.1 christos # define IPOPT_SECUR_TOPSECRET ((u_short)0x6bc5)
2498 1.1 christos #endif
2499 1.1 christos #ifndef IPOPT_OLEN
2500 1.1 christos # define IPOPT_OLEN 1
2501 1.1 christos #endif
2502 1.1 christos #ifndef IPPROTO_HOPOPTS
2503 1.1 christos # define IPPROTO_HOPOPTS 0
2504 1.1 christos #endif
2505 1.1 christos #ifndef IPPROTO_IPIP
2506 1.1 christos # define IPPROTO_IPIP 4
2507 1.1 christos #endif
2508 1.1 christos #ifndef IPPROTO_ENCAP
2509 1.1 christos # define IPPROTO_ENCAP 98
2510 1.1 christos #endif
2511 1.1 christos #ifndef IPPROTO_IPV6
2512 1.1 christos # define IPPROTO_IPV6 41
2513 1.1 christos #endif
2514 1.1 christos #ifndef IPPROTO_ROUTING
2515 1.1 christos # define IPPROTO_ROUTING 43
2516 1.1 christos #endif
2517 1.1 christos #ifndef IPPROTO_FRAGMENT
2518 1.1 christos # define IPPROTO_FRAGMENT 44
2519 1.1 christos #endif
2520 1.1 christos #ifndef IPPROTO_GRE
2521 1.1 christos # define IPPROTO_GRE 47 /* GRE encaps RFC 1701 */
2522 1.1 christos #endif
2523 1.1 christos #ifndef IPPROTO_ESP
2524 1.1 christos # define IPPROTO_ESP 50
2525 1.1 christos #endif
2526 1.1 christos #ifndef IPPROTO_AH
2527 1.1 christos # define IPPROTO_AH 51
2528 1.1 christos #endif
2529 1.1 christos #ifndef IPPROTO_ICMPV6
2530 1.1 christos # define IPPROTO_ICMPV6 58
2531 1.1 christos #endif
2532 1.1 christos #ifndef IPPROTO_NONE
2533 1.1 christos # define IPPROTO_NONE 59
2534 1.1 christos #endif
2535 1.1 christos #ifndef IPPROTO_DSTOPTS
2536 1.1 christos # define IPPROTO_DSTOPTS 60
2537 1.1 christos #endif
2538 1.1 christos #ifndef IPPROTO_MOBILITY
2539 1.1 christos # define IPPROTO_MOBILITY 135
2540 1.1 christos #endif
2541 1.1 christos
2542 1.1 christos #ifndef ICMP_ROUTERADVERT
2543 1.1 christos # define ICMP_ROUTERADVERT 9
2544 1.1 christos #endif
2545 1.1 christos #ifndef ICMP_ROUTERSOLICIT
2546 1.1 christos # define ICMP_ROUTERSOLICIT 10
2547 1.1 christos #endif
2548 1.1 christos #ifndef ICMP6_DST_UNREACH
2549 1.1 christos # define ICMP6_DST_UNREACH 1
2550 1.1 christos #endif
2551 1.1 christos #ifndef ICMP6_PACKET_TOO_BIG
2552 1.1 christos # define ICMP6_PACKET_TOO_BIG 2
2553 1.1 christos #endif
2554 1.1 christos #ifndef ICMP6_TIME_EXCEEDED
2555 1.1 christos # define ICMP6_TIME_EXCEEDED 3
2556 1.1 christos #endif
2557 1.1 christos #ifndef ICMP6_PARAM_PROB
2558 1.1 christos # define ICMP6_PARAM_PROB 4
2559 1.1 christos #endif
2560 1.1 christos
2561 1.1 christos #ifndef ICMP6_ECHO_REQUEST
2562 1.1 christos # define ICMP6_ECHO_REQUEST 128
2563 1.1 christos #endif
2564 1.1 christos #ifndef ICMP6_ECHO_REPLY
2565 1.1 christos # define ICMP6_ECHO_REPLY 129
2566 1.1 christos #endif
2567 1.1 christos #ifndef ICMP6_MEMBERSHIP_QUERY
2568 1.1 christos # define ICMP6_MEMBERSHIP_QUERY 130
2569 1.1 christos #endif
2570 1.1 christos #ifndef MLD6_LISTENER_QUERY
2571 1.1 christos # define MLD6_LISTENER_QUERY 130
2572 1.1 christos #endif
2573 1.1 christos #ifndef ICMP6_MEMBERSHIP_REPORT
2574 1.1 christos # define ICMP6_MEMBERSHIP_REPORT 131
2575 1.1 christos #endif
2576 1.1 christos #ifndef MLD6_LISTENER_REPORT
2577 1.1 christos # define MLD6_LISTENER_REPORT 131
2578 1.1 christos #endif
2579 1.1 christos #ifndef ICMP6_MEMBERSHIP_REDUCTION
2580 1.1 christos # define ICMP6_MEMBERSHIP_REDUCTION 132
2581 1.1 christos #endif
2582 1.1 christos #ifndef MLD6_LISTENER_DONE
2583 1.1 christos # define MLD6_LISTENER_DONE 132
2584 1.1 christos #endif
2585 1.1 christos #ifndef ND_ROUTER_SOLICIT
2586 1.1 christos # define ND_ROUTER_SOLICIT 133
2587 1.1 christos #endif
2588 1.1 christos #ifndef ND_ROUTER_ADVERT
2589 1.1 christos # define ND_ROUTER_ADVERT 134
2590 1.1 christos #endif
2591 1.1 christos #ifndef ND_NEIGHBOR_SOLICIT
2592 1.1 christos # define ND_NEIGHBOR_SOLICIT 135
2593 1.1 christos #endif
2594 1.1 christos #ifndef ND_NEIGHBOR_ADVERT
2595 1.1 christos # define ND_NEIGHBOR_ADVERT 136
2596 1.1 christos #endif
2597 1.1 christos #ifndef ND_REDIRECT
2598 1.1 christos # define ND_REDIRECT 137
2599 1.1 christos #endif
2600 1.1 christos #ifndef ICMP6_ROUTER_RENUMBERING
2601 1.1 christos # define ICMP6_ROUTER_RENUMBERING 138
2602 1.1 christos #endif
2603 1.1 christos #ifndef ICMP6_WRUREQUEST
2604 1.1 christos # define ICMP6_WRUREQUEST 139
2605 1.1 christos #endif
2606 1.1 christos #ifndef ICMP6_WRUREPLY
2607 1.1 christos # define ICMP6_WRUREPLY 140
2608 1.1 christos #endif
2609 1.1 christos #ifndef ICMP6_FQDN_QUERY
2610 1.1 christos # define ICMP6_FQDN_QUERY 139
2611 1.1 christos #endif
2612 1.1 christos #ifndef ICMP6_FQDN_REPLY
2613 1.1 christos # define ICMP6_FQDN_REPLY 140
2614 1.1 christos #endif
2615 1.1 christos #ifndef ICMP6_NI_QUERY
2616 1.1 christos # define ICMP6_NI_QUERY 139
2617 1.1 christos #endif
2618 1.1 christos #ifndef ICMP6_NI_REPLY
2619 1.1 christos # define ICMP6_NI_REPLY 140
2620 1.1 christos #endif
2621 1.1 christos #ifndef MLD6_MTRACE_RESP
2622 1.1 christos # define MLD6_MTRACE_RESP 200
2623 1.1 christos #endif
2624 1.1 christos #ifndef MLD6_MTRACE
2625 1.1 christos # define MLD6_MTRACE 201
2626 1.1 christos #endif
2627 1.1 christos #ifndef ICMP6_HADISCOV_REQUEST
2628 1.1 christos # define ICMP6_HADISCOV_REQUEST 202
2629 1.1 christos #endif
2630 1.1 christos #ifndef ICMP6_HADISCOV_REPLY
2631 1.1 christos # define ICMP6_HADISCOV_REPLY 203
2632 1.1 christos #endif
2633 1.1 christos #ifndef ICMP6_MOBILEPREFIX_SOLICIT
2634 1.1 christos # define ICMP6_MOBILEPREFIX_SOLICIT 204
2635 1.1 christos #endif
2636 1.1 christos #ifndef ICMP6_MOBILEPREFIX_ADVERT
2637 1.1 christos # define ICMP6_MOBILEPREFIX_ADVERT 205
2638 1.1 christos #endif
2639 1.1 christos #ifndef ICMP6_MAXTYPE
2640 1.1 christos # define ICMP6_MAXTYPE 205
2641 1.1 christos #endif
2642 1.1 christos
2643 1.1 christos #ifndef ICMP6_DST_UNREACH_NOROUTE
2644 1.1 christos # define ICMP6_DST_UNREACH_NOROUTE 0
2645 1.1 christos #endif
2646 1.1 christos #ifndef ICMP6_DST_UNREACH_ADMIN
2647 1.1 christos # define ICMP6_DST_UNREACH_ADMIN 1
2648 1.1 christos #endif
2649 1.1 christos #ifndef ICMP6_DST_UNREACH_NOTNEIGHBOR
2650 1.1 christos # define ICMP6_DST_UNREACH_NOTNEIGHBOR 2
2651 1.1 christos #endif
2652 1.1 christos #ifndef ICMP6_DST_UNREACH_BEYONDSCOPE
2653 1.1 christos # define ICMP6_DST_UNREACH_BEYONDSCOPE 2
2654 1.1 christos #endif
2655 1.1 christos #ifndef ICMP6_DST_UNREACH_ADDR
2656 1.1 christos # define ICMP6_DST_UNREACH_ADDR 3
2657 1.1 christos #endif
2658 1.1 christos #ifndef ICMP6_DST_UNREACH_NOPORT
2659 1.1 christos # define ICMP6_DST_UNREACH_NOPORT 4
2660 1.1 christos #endif
2661 1.1 christos #ifndef ICMP6_TIME_EXCEED_TRANSIT
2662 1.1 christos # define ICMP6_TIME_EXCEED_TRANSIT 0
2663 1.1 christos #endif
2664 1.1 christos #ifndef ICMP6_TIME_EXCEED_REASSEMBLY
2665 1.1 christos # define ICMP6_TIME_EXCEED_REASSEMBLY 1
2666 1.1 christos #endif
2667 1.1 christos
2668 1.1 christos #ifndef ICMP6_NI_SUCCESS
2669 1.1 christos # define ICMP6_NI_SUCCESS 0
2670 1.1 christos #endif
2671 1.1 christos #ifndef ICMP6_NI_REFUSED
2672 1.1 christos # define ICMP6_NI_REFUSED 1
2673 1.1 christos #endif
2674 1.1 christos #ifndef ICMP6_NI_UNKNOWN
2675 1.1 christos # define ICMP6_NI_UNKNOWN 2
2676 1.1 christos #endif
2677 1.1 christos
2678 1.1 christos #ifndef ICMP6_ROUTER_RENUMBERING_COMMAND
2679 1.1 christos # define ICMP6_ROUTER_RENUMBERING_COMMAND 0
2680 1.1 christos #endif
2681 1.1 christos #ifndef ICMP6_ROUTER_RENUMBERING_RESULT
2682 1.1 christos # define ICMP6_ROUTER_RENUMBERING_RESULT 1
2683 1.1 christos #endif
2684 1.1 christos #ifndef ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET
2685 1.1 christos # define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255
2686 1.1 christos #endif
2687 1.1 christos
2688 1.1 christos #ifndef ICMP6_PARAMPROB_HEADER
2689 1.1 christos # define ICMP6_PARAMPROB_HEADER 0
2690 1.1 christos #endif
2691 1.1 christos #ifndef ICMP6_PARAMPROB_NEXTHEADER
2692 1.1 christos # define ICMP6_PARAMPROB_NEXTHEADER 1
2693 1.1 christos #endif
2694 1.1 christos #ifndef ICMP6_PARAMPROB_OPTION
2695 1.1 christos # define ICMP6_PARAMPROB_OPTION 2
2696 1.1 christos #endif
2697 1.1 christos
2698 1.1 christos #ifndef ICMP6_NI_SUBJ_IPV6
2699 1.1 christos # define ICMP6_NI_SUBJ_IPV6 0
2700 1.1 christos #endif
2701 1.1 christos #ifndef ICMP6_NI_SUBJ_FQDN
2702 1.1 christos # define ICMP6_NI_SUBJ_FQDN 1
2703 1.1 christos #endif
2704 1.1 christos #ifndef ICMP6_NI_SUBJ_IPV4
2705 1.1 christos # define ICMP6_NI_SUBJ_IPV4 2
2706 1.1 christos #endif
2707 1.1 christos
2708 1.1 christos #ifndef MLD_MTRACE_RESP
2709 1.1 christos # define MLD_MTRACE_RESP 200
2710 1.1 christos #endif
2711 1.1 christos #ifndef MLD_MTRACE
2712 1.1 christos # define MLD_MTRACE 201
2713 1.1 christos #endif
2714 1.1 christos #ifndef MLD6_MTRACE_RESP
2715 1.1 christos # define MLD6_MTRACE_RESP MLD_MTRACE_RESP
2716 1.1 christos #endif
2717 1.1 christos #ifndef MLD6_MTRACE
2718 1.1 christos # define MLD6_MTRACE MLD_MTRACE
2719 1.1 christos #endif
2720 1.1 christos
2721 1.1 christos #if !defined(IPV6_FLOWINFO_MASK)
2722 1.1 christos # if (BYTE_ORDER == BIG_ENDIAN) || defined(_BIG_ENDIAN)
2723 1.1 christos # define IPV6_FLOWINFO_MASK 0x0fffffff /* flow info (28 bits) */
2724 1.1 christos # else
2725 1.1 christos # if(BYTE_ORDER == LITTLE_ENDIAN) || !defined(_BIG_ENDIAN)
2726 1.1 christos # define IPV6_FLOWINFO_MASK 0xffffff0f /* flow info (28 bits) */
2727 1.1 christos # endif /* LITTLE_ENDIAN */
2728 1.1 christos # endif
2729 1.1 christos #endif
2730 1.1 christos #if !defined(IPV6_FLOWLABEL_MASK)
2731 1.1 christos # if (BYTE_ORDER == BIG_ENDIAN) || defined(_BIG_ENDIAN)
2732 1.1 christos # define IPV6_FLOWLABEL_MASK 0x000fffff /* flow label (20 bits) */
2733 1.1 christos # else
2734 1.1 christos # if (BYTE_ORDER == LITTLE_ENDIAN) || !defined(_BIG_ENDIAN)
2735 1.1 christos # define IPV6_FLOWLABEL_MASK 0xffff0f00 /* flow label (20 bits) */
2736 1.1 christos # endif /* LITTLE_ENDIAN */
2737 1.1 christos # endif
2738 1.1 christos #endif
2739 1.1 christos
2740 1.1 christos /*
2741 1.1 christos * ECN is a new addition to TCP - RFC 2481
2742 1.1 christos */
2743 1.1 christos #ifndef TH_ECN
2744 1.1 christos # define TH_ECN 0x40
2745 1.1 christos #endif
2746 1.1 christos #ifndef TH_CWR
2747 1.1 christos # define TH_CWR 0x80
2748 1.1 christos #endif
2749 1.1 christos #define TH_ECNALL (TH_ECN|TH_CWR)
2750 1.1 christos
2751 1.1 christos /*
2752 1.1 christos * TCP States
2753 1.1 christos */
2754 1.1 christos #define IPF_TCPS_LISTEN 0 /* listening for connection */
2755 1.1 christos #define IPF_TCPS_SYN_SENT 1 /* active, have sent syn */
2756 1.1 christos #define IPF_TCPS_SYN_RECEIVED 2 /* have send and received syn */
2757 1.1 christos #define IPF_TCPS_HALF_ESTAB 3 /* for connections not fully "up" */
2758 1.1 christos /* states < IPF_TCPS_ESTABLISHED are those where connections not established */
2759 1.1 christos #define IPF_TCPS_ESTABLISHED 4 /* established */
2760 1.1 christos #define IPF_TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */
2761 1.1 christos /* states > IPF_TCPS_CLOSE_WAIT are those where user has closed */
2762 1.1 christos #define IPF_TCPS_FIN_WAIT_1 6 /* have closed, sent fin */
2763 1.1 christos #define IPF_TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */
2764 1.1 christos #define IPF_TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */
2765 1.1 christos /* states > IPF_TCPS_CLOSE_WAIT && < IPF_TCPS_FIN_WAIT_2 await ACK of FIN */
2766 1.1 christos #define IPF_TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */
2767 1.1 christos #define IPF_TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */
2768 1.1 christos #define IPF_TCPS_CLOSED 11 /* closed */
2769 1.1 christos #define IPF_TCP_NSTATES 12
2770 1.1 christos
2771 1.1 christos #define TCP_MSL 120
2772 1.1 christos
2773 1.1 christos #undef ICMP_MAX_UNREACH
2774 1.1 christos #define ICMP_MAX_UNREACH 14
2775 1.1 christos #undef ICMP_MAXTYPE
2776 1.1 christos #define ICMP_MAXTYPE 18
2777 1.1 christos
2778 1.1 christos #ifndef IFNAMSIZ
2779 1.1 christos #define IFNAMSIZ 16
2780 1.1 christos #endif
2781 1.1 christos
2782 1.1 christos #ifndef LOG_FTP
2783 1.1 christos # define LOG_FTP (11<<3)
2784 1.1 christos #endif
2785 1.1 christos #ifndef LOG_AUTHPRIV
2786 1.1 christos # define LOG_AUTHPRIV (10<<3)
2787 1.1 christos #endif
2788 1.1 christos #ifndef LOG_AUDIT
2789 1.1 christos # define LOG_AUDIT (13<<3)
2790 1.1 christos #endif
2791 1.1 christos #ifndef LOG_NTP
2792 1.1 christos # define LOG_NTP (12<<3)
2793 1.1 christos #endif
2794 1.1 christos #ifndef LOG_SECURITY
2795 1.1 christos # define LOG_SECURITY (13<<3)
2796 1.1 christos #endif
2797 1.1 christos #ifndef LOG_LFMT
2798 1.1 christos # define LOG_LFMT (14<<3)
2799 1.1 christos #endif
2800 1.1 christos #ifndef LOG_CONSOLE
2801 1.1 christos # define LOG_CONSOLE (14<<3)
2802 1.1 christos #endif
2803 1.1 christos
2804 1.1 christos /*
2805 1.1 christos * ICMP error replies have an IP header (20 bytes), 8 bytes of ICMP data,
2806 1.1 christos * another IP header and then 64 bits of data, totalling 56. Of course,
2807 1.1 christos * the last 64 bits is dependent on that being available.
2808 1.1 christos */
2809 1.1 christos #define ICMPERR_ICMPHLEN 8
2810 1.1 christos #define ICMPERR_IPICMPHLEN (20 + 8)
2811 1.1 christos #define ICMPERR_MINPKTLEN (20 + 8 + 20)
2812 1.1 christos #define ICMPERR_MAXPKTLEN (20 + 8 + 20 + 8)
2813 1.1 christos #define ICMP6ERR_MINPKTLEN (40 + 8)
2814 1.1 christos #define ICMP6ERR_IPICMPHLEN (40 + 8 + 40)
2815 1.1 christos
2816 1.1 christos #ifndef MIN
2817 1.1 christos # define MIN(a,b) (((a)<(b))?(a):(b))
2818 1.1 christos #endif
2819 1.1 christos
2820 1.1 christos #ifdef RESCUE
2821 1.1 christos # undef IPFILTER_BPF
2822 1.1 christos #endif
2823 1.1 christos
2824 1.1 christos #ifdef IPF_DEBUG
2825 1.1 christos # define DPRINT(x) printf x
2826 1.1 christos #else
2827 1.1 christos # define DPRINT(x)
2828 1.1 christos #endif
2829 1.1 christos
2830 1.1 christos #ifndef AF_INET6
2831 1.1 christos # define AF_INET6 26
2832 1.1 christos #endif
2833 1.1 christos
2834 1.1 christos #ifdef DTRACE_PROBE
2835 1.1 christos # ifdef _KERNEL
2836 1.1 christos # define DT(_n) DTRACE_PROBE(_n)
2837 1.1 christos # define DT1(_n,_a,_b) DTRACE_PROBE1(_n,_a,_b)
2838 1.1 christos # define DT2(_n,_a,_b,_c,_d) DTRACE_PROBE2(_n,_a,_b,_c,_d)
2839 1.1 christos # define DT3(_n,_a,_b,_c,_d,_e,_f) \
2840 1.1 christos DTRACE_PROBE3(_n,_a,_b,_c,_d,_e,_f)
2841 1.1 christos # define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h) \
2842 1.1 christos DTRACE_PROBE4(_n,_a,_b,_c,_d,_e,_f,_g,_h)
2843 1.1 christos # else
2844 1.1 christos # define DT(_n)
2845 1.1 christos # define DT1(_n,_a,_b)
2846 1.1 christos # define DT2(_n,_a,_b,_c,_d)
2847 1.1 christos # define DT3(_n,_a,_b,_c,_d,_e,_f)
2848 1.1 christos # define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h)
2849 1.1 christos # endif
2850 1.1 christos #else
2851 1.1 christos # define DT(_n)
2852 1.1 christos # define DT1(_n,_a,_b)
2853 1.1 christos # define DT2(_n,_a,_b,_c,_d)
2854 1.1 christos # define DT3(_n,_a,_b,_c,_d,_e,_f)
2855 1.1 christos # define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h)
2856 1.1 christos #endif
2857 1.1 christos
2858 1.1 christos struct ip6_routing {
2859 1.1 christos u_char ip6r_nxt; /* next header */
2860 1.1 christos u_char ip6r_len; /* length in units of 8 octets */
2861 1.1 christos u_char ip6r_type; /* always zero */
2862 1.1 christos u_char ip6r_segleft; /* segments left */
2863 1.1 christos u_32_t ip6r_reserved; /* reserved field */
2864 1.1 christos };
2865 1.1 christos
2866 1.1 christos #endif /* __IP_COMPAT_H__ */
2867