Cleanup remaining tsleep priority issues.
[dragonfly.git] / sys / contrib / ipfilter / netinet / ip_compat.h
CommitLineData
984263bc
MD
1/*
2 * Copyright (C) 1993-2001 by Darren Reed.
3 *
4 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * @(#)ip_compat.h 1.8 1/14/96
7 * $Id: ip_compat.h,v 2.26.2.46 2002/06/27 14:39:40 darrenr Exp $
8 * $FreeBSD: src/sys/contrib/ipfilter/netinet/ip_compat.h,v 1.13.2.5 2003/03/01 03:55:54 darrenr Exp $
2f65cd66 9 * $DragonFly: src/sys/contrib/ipfilter/netinet/ip_compat.h,v 1.4 2003/08/01 17:46:14 dillon Exp $
984263bc
MD
10 */
11
12#ifndef __IP_COMPAT_H__
13#define __IP_COMPAT_H__
14
15#ifndef __P
16# ifdef __STDC__
17# define __P(x) x
18# else
19# define __P(x) ()
20# endif
21#endif
22#ifndef __STDC__
23# undef const
24# define const
25#endif
26
27#ifndef SOLARIS
28#define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
29#endif
30#if SOLARIS
31# if !defined(SOLARIS2)
32# define SOLARIS2 3 /* Pick an old version */
33# endif
34# if SOLARIS2 >= 8
35# ifndef USE_INET6
36# define USE_INET6
37# endif
38# else
39# undef USE_INET6
40# endif
41#endif
42#if defined(sun) && !(defined(__svr4__) || defined(__SVR4))
43# undef USE_INET6
44#endif
45
46#if defined(_KERNEL) || defined(KERNEL) || defined(__KERNEL__)
47# undef KERNEL
48# undef _KERNEL
49# undef __KERNEL__
50# define KERNEL
51# define _KERNEL
52# define __KERNEL__
53#endif
54
55#if defined(__SVR4) || defined(__svr4__) || defined(__sgi)
56#define index strchr
57# if !defined(KERNEL)
58# define bzero(a,b) memset(a,0,b)
59# define bcmp memcmp
60# define bcopy(a,b,c) memmove(b,a,c)
61# endif
62#endif
63
64#ifndef offsetof
65#define offsetof(t,m) (int)((&((t *)0L)->m))
66#endif
67
68#if defined(__sgi) || defined(bsdi)
69struct ether_addr {
70 u_char ether_addr_octet[6];
71};
72#endif
73
74#ifndef LIFNAMSIZ
75# ifdef IF_NAMESIZE
76# define LIFNAMSIZ IF_NAMESIZE
77# else
78# ifdef IFNAMSIZ
79# define LIFNAMSIZ IFNAMSIZ
80# else
81# define LIFNAMSIZ 16
82# endif
83# endif
84#endif
85
86#if defined(__sgi) && !defined(IPFILTER_LKM)
87# ifdef __STDC__
88# define IPL_EXTERN(ep) ipfilter##ep
89# else
90# define IPL_EXTERN(ep) ipfilter/**/ep
91# endif
92#else
93# ifdef __STDC__
94# define IPL_EXTERN(ep) ipl##ep
95# else
96# define IPL_EXTERN(ep) ipl/**/ep
97# endif
98#endif
99
100#ifdef __sgi
101# include <sys/debug.h>
102#endif
103
104#ifdef linux
105# include <sys/sysmacros.h>
106#endif
107
108/*
109 * This is a workaround for <sys/uio.h> troubles on FreeBSD and OpenBSD.
110 */
111#ifndef _KERNEL
112# define ADD_KERNEL
113# define _KERNEL
114# define KERNEL
115#endif
116#ifdef __OpenBSD__
117struct file;
118#endif
119#include <sys/uio.h>
120#ifdef ADD_KERNEL
121# undef _KERNEL
122# undef KERNEL
123#endif
124
125#if SOLARIS
126# define MTYPE(m) ((m)->b_datap->db_type)
127# if SOLARIS2 >= 4
128# include <sys/isa_defs.h>
129# endif
130# include <sys/ioccom.h>
131# include <sys/sysmacros.h>
132# include <sys/kmem.h>
133/*
134 * because Solaris 2 defines these in two places :-/
135 */
136# undef IPOPT_EOL
137# undef IPOPT_NOP
138# undef IPOPT_LSRR
139# undef IPOPT_RR
140# undef IPOPT_SSRR
141# ifndef KERNEL
142# define _KERNEL
143# undef RES_INIT
144# if SOLARIS2 >= 8
145# include <netinet/ip6.h>
146# endif
147# include <inet/common.h>
148# include <inet/ip.h>
149# include <inet/ip_ire.h>
150# undef _KERNEL
151# else /* _KERNEL */
152# if SOLARIS2 >= 8
153# include <netinet/ip6.h>
154# endif
155# include <inet/common.h>
156# include <inet/ip.h>
157# include <inet/ip_ire.h>
158# endif /* _KERNEL */
159# if SOLARIS2 >= 8
160# include <inet/ip_if.h>
161# include <netinet/ip6.h>
162# define ipif_local_addr ipif_lcl_addr
163/* Only defined in private include file */
164# ifndef V4_PART_OF_V6
165# define V4_PART_OF_V6(v6) v6.s6_addr32[3]
166# endif
167# endif
168
169typedef struct qif {
170 struct qif *qf_next;
171 ill_t *qf_ill;
172 kmutex_t qf_lock;
173 void *qf_iptr;
174 void *qf_optr;
175 queue_t *qf_in;
176 queue_t *qf_out;
177 struct qinit *qf_wqinfo;
178 struct qinit *qf_rqinfo;
179 struct qinit qf_wqinit;
180 struct qinit qf_rqinit;
181 mblk_t *qf_m; /* These three fields are for passing data up from */
182 queue_t *qf_q; /* fr_qin and fr_qout to the packet processing. */
183 size_t qf_off;
184 size_t qf_len; /* this field is used for in ipfr_fastroute */
185 char qf_name[LIFNAMSIZ];
186 /*
187 * in case the ILL has disappeared...
188 */
189 size_t qf_hl; /* header length */
190 int qf_sap;
191# if SOLARIS2 >= 8
192 int qf_tunoff; /* tunnel offset */
193#endif
194 size_t qf_incnt;
195 size_t qf_outcnt;
196} qif_t;
197#else /* SOLARIS */
198# if !defined(__sgi)
199typedef int minor_t;
200# endif
201#endif /* SOLARIS */
202#define IPMINLEN(i, h) ((i)->ip_len >= ((i)->ip_hl * 4 + sizeof(struct h)))
203
204#ifndef IP_OFFMASK
205#define IP_OFFMASK 0x1fff
206#endif
207
208#if BSD > 199306
209# define USE_QUAD_T
210# define U_QUAD_T u_quad_t
211# define QUAD_T quad_t
212#else /* BSD > 199306 */
213# define U_QUAD_T u_long
214# define QUAD_T long
215#endif /* BSD > 199306 */
216
217
218#if defined(__FreeBSD__) && (defined(KERNEL) || defined(_KERNEL))
219# include <sys/param.h>
220# ifndef __FreeBSD_version
221# ifdef IPFILTER_LKM
222# include <osreldate.h>
223# else
224# include <sys/osreldate.h>
225# endif
226# endif
227# ifdef IPFILTER_LKM
228# define ACTUALLY_LKM_NOT_KERNEL
229# endif
230# if defined(__FreeBSD_version) && (__FreeBSD_version < 300000)
231# include <machine/spl.h>
232# else
233# if (__FreeBSD_version >= 300000) && (__FreeBSD_version < 400000)
234# if defined(IPFILTER_LKM) && !defined(ACTUALLY_LKM_NOT_KERNEL)
235# define ACTUALLY_LKM_NOT_KERNEL
236# endif
237# endif
238# endif
239#endif /* __FreeBSD__ && KERNEL */
240
241#if defined(__FreeBSD_version) && (__FreeBSD_version >= 500000) && \
242 defined(_KERNEL)
243# include <machine/in_cksum.h>
244#endif
245
246/*
247 * These operating systems already take care of the problem for us.
248 */
249#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || \
250 defined(__sgi)
251typedef u_int32_t u_32_t;
252# if defined(_KERNEL) && !defined(IPFILTER_LKM)
253# if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 104110000)
254# include "opt_inet.h"
255# endif
256# if defined(__FreeBSD_version) && (__FreeBSD_version >= 400000) && \
257 !defined(KLD_MODULE)
258# include "opt_inet6.h"
259# endif
260# ifdef INET6
261# define USE_INET6
262# endif
263# endif
264# if !defined(_KERNEL) && !defined(IPFILTER_LKM) && !defined(USE_INET6)
265# if (defined(__FreeBSD_version) && (__FreeBSD_version >= 400000)) || \
266 (defined(OpenBSD) && (OpenBSD >= 200111)) || \
267 (defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 105000000))
268# define USE_INET6
269# endif
270# endif
271#else
272/*
273 * Really, any arch where sizeof(long) != sizeof(int).
274 */
275# if defined(__alpha__) || defined(__alpha) || defined(_LP64)
276typedef unsigned int u_32_t;
277# else
278# if SOLARIS2 >= 6
279typedef uint32_t u_32_t;
280# else
281typedef unsigned int u_32_t;
282# endif
283# endif
284#endif /* __NetBSD__ || __OpenBSD__ || __FreeBSD__ || __sgi */
285
286#ifdef USE_INET6
287# if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
288# include <netinet/ip6.h>
289# ifdef _KERNEL
290# include <netinet6/ip6_var.h>
291# endif
292typedef struct ip6_hdr ip6_t;
293# endif
294# include <netinet/icmp6.h>
295union i6addr {
296 u_32_t i6[4];
297 struct in_addr in4;
298 struct in6_addr in6;
299};
300#else
301union i6addr {
302 u_32_t i6[4];
303 struct in_addr in4;
304};
305#endif
306
307#define IP6CMP(a,b) bcmp((char *)&(a), (char *)&(b), sizeof(a))
308#define IP6EQ(a,b) (bcmp((char *)&(a), (char *)&(b), sizeof(a)) == 0)
309#define IP6NEQ(a,b) (bcmp((char *)&(a), (char *)&(b), sizeof(a)) != 0)
310#define IP6_ISZERO(a) ((((union i6addr *)(a))->i6[0] | \
311 ((union i6addr *)(a))->i6[1] | \
312 ((union i6addr *)(a))->i6[2] | \
313 ((union i6addr *)(a))->i6[3]) == 0)
314#define IP6_NOTZERO(a) ((((union i6addr *)(a))->i6[0] | \
315 ((union i6addr *)(a))->i6[1] | \
316 ((union i6addr *)(a))->i6[2] | \
317 ((union i6addr *)(a))->i6[3]) != 0)
318
319#ifndef MAX
320#define MAX(a,b) (((a) > (b)) ? (a) : (b))
321#endif
322
323/*
324 * Security Options for Intenet Protocol (IPSO) as defined in RFC 1108.
325 *
326 * Basic Option
327 *
328 * 00000001 - (Reserved 4)
329 * 00111101 - Top Secret
330 * 01011010 - Secret
331 * 10010110 - Confidential
332 * 01100110 - (Reserved 3)
333 * 11001100 - (Reserved 2)
334 * 10101011 - Unclassified
335 * 11110001 - (Reserved 1)
336 */
337#define IPSO_CLASS_RES4 0x01
338#define IPSO_CLASS_TOPS 0x3d
339#define IPSO_CLASS_SECR 0x5a
340#define IPSO_CLASS_CONF 0x96
341#define IPSO_CLASS_RES3 0x66
342#define IPSO_CLASS_RES2 0xcc
343#define IPSO_CLASS_UNCL 0xab
344#define IPSO_CLASS_RES1 0xf1
345
346#define IPSO_AUTH_GENSER 0x80
347#define IPSO_AUTH_ESI 0x40
348#define IPSO_AUTH_SCI 0x20
349#define IPSO_AUTH_NSA 0x10
350#define IPSO_AUTH_DOE 0x08
351#define IPSO_AUTH_UN 0x06
352#define IPSO_AUTH_FTE 0x01
353
354/*
355 * IP option #defines
356 */
357/*#define IPOPT_RR 7 */
358#define IPOPT_ZSU 10 /* ZSU */
359#define IPOPT_MTUP 11 /* MTUP */
360#define IPOPT_MTUR 12 /* MTUR */
361#define IPOPT_ENCODE 15 /* ENCODE */
362/*#define IPOPT_TS 68 */
363#define IPOPT_TR 82 /* TR */
364/*#define IPOPT_SECURITY 130 */
365/*#define IPOPT_LSRR 131 */
366#define IPOPT_E_SEC 133 /* E-SEC */
367#define IPOPT_CIPSO 134 /* CIPSO */
368/*#define IPOPT_SATID 136 */
369#ifndef IPOPT_SID
370# define IPOPT_SID IPOPT_SATID
371#endif
372/*#define IPOPT_SSRR 137 */
373#define IPOPT_ADDEXT 147 /* ADDEXT */
374#define IPOPT_VISA 142 /* VISA */
375#define IPOPT_IMITD 144 /* IMITD */
376#define IPOPT_EIP 145 /* EIP */
377#define IPOPT_FINN 205 /* FINN */
378
379#ifndef TCPOPT_WSCALE
380# define TCPOPT_WSCALE 3
381#endif
382
383/*
384 * Build some macros and #defines to enable the same code to compile anywhere
385 * Well, that's the idea, anyway :-)
386 */
387#if SOLARIS
388typedef mblk_t mb_t;
389# if SOLARIS2 >= 7
390# ifdef lint
391# define ALIGN32(ptr) (ptr ? 0L : 0L)
392# define ALIGN16(ptr) (ptr ? 0L : 0L)
393# else
394# define ALIGN32(ptr) (ptr)
395# define ALIGN16(ptr) (ptr)
396# endif
397# endif
398#else
399typedef struct mbuf mb_t;
400#endif /* SOLARIS */
401
402#if !SOLARIS || (SOLARIS2 < 6) || !defined(KERNEL)
403# define ATOMIC_INCL ATOMIC_INC
404# define ATOMIC_INC64 ATOMIC_INC
405# define ATOMIC_INC32 ATOMIC_INC
406# define ATOMIC_INC16 ATOMIC_INC
407# define ATOMIC_DECL ATOMIC_DEC
408# define ATOMIC_DEC64 ATOMIC_DEC
409# define ATOMIC_DEC32 ATOMIC_DEC
410# define ATOMIC_DEC16 ATOMIC_DEC
411#endif
412#ifdef __sgi
413# define hz HZ
414# include <sys/ksynch.h>
415# define IPF_LOCK_PL plhi
416# include <sys/sema.h>
417#undef kmutex_t
418typedef struct {
419 lock_t *l;
420 int pl;
421} kmutex_t;
422# undef MUTEX_INIT
423# undef MUTEX_DESTROY
424#endif
425#ifdef KERNEL
426# if SOLARIS
427# if SOLARIS2 >= 6
428# include <sys/atomic.h>
429# if SOLARIS2 == 6
430# define ATOMIC_INCL(x) atomic_add_long((uint32_t*)&(x), 1)
431# define ATOMIC_DECL(x) atomic_add_long((uint32_t*)&(x), -1)
432# else
433# define ATOMIC_INCL(x) atomic_add_long(&(x), 1)
434# define ATOMIC_DECL(x) atomic_add_long(&(x), -1)
435# endif
436# define ATOMIC_INC64(x) atomic_add_64((uint64_t*)&(x), 1)
437# define ATOMIC_INC32(x) atomic_add_32((uint32_t*)&(x), 1)
438# define ATOMIC_INC16(x) atomic_add_16((uint16_t*)&(x), 1)
439# define ATOMIC_DEC64(x) atomic_add_64((uint64_t*)&(x), -1)
440# define ATOMIC_DEC32(x) atomic_add_32((uint32_t*)&(x), -1)
441# define ATOMIC_DEC16(x) atomic_add_16((uint16_t*)&(x), -1)
442# else
443# define IRE_CACHE IRE_ROUTE
444# define ATOMIC_INC(x) { mutex_enter(&ipf_rw); (x)++; \
445 mutex_exit(&ipf_rw); }
446# define ATOMIC_DEC(x) { mutex_enter(&ipf_rw); (x)--; \
447 mutex_exit(&ipf_rw); }
448# endif
449# define MUTEX_ENTER(x) mutex_enter(x)
450# if 1
451# define KRWLOCK_T krwlock_t
452# define READ_ENTER(x) rw_enter(x, RW_READER)
453# define WRITE_ENTER(x) rw_enter(x, RW_WRITER)
454# define RW_UPGRADE(x) { if (rw_tryupgrade(x) == 0) { \
455 rw_exit(x); \
456 rw_enter(x, RW_WRITER); } \
457 }
458# define MUTEX_DOWNGRADE(x) rw_downgrade(x)
459# define RWLOCK_INIT(x, y, z) rw_init((x), (y), RW_DRIVER, (z))
460# define RWLOCK_EXIT(x) rw_exit(x)
461# define RW_DESTROY(x) rw_destroy(x)
462# else
463# define KRWLOCK_T kmutex_t
464# define READ_ENTER(x) mutex_enter(x)
465# define WRITE_ENTER(x) mutex_enter(x)
466# define MUTEX_DOWNGRADE(x) ;
467# define RWLOCK_INIT(x, y, z) mutex_init((x), (y), MUTEX_DRIVER, (z))
468# define RWLOCK_EXIT(x) mutex_exit(x)
469# define RW_DESTROY(x) mutex_destroy(x)
470# endif
471# define MUTEX_INIT(x, y, z) mutex_init((x), (y), MUTEX_DRIVER, (z))
472# define MUTEX_DESTROY(x) mutex_destroy(x)
473# define MUTEX_EXIT(x) mutex_exit(x)
474# define MTOD(m,t) (t)((m)->b_rptr)
475# define IRCOPY(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c))
476# define IWCOPY(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c))
477# define IRCOPYPTR ircopyptr
478# define IWCOPYPTR iwcopyptr
479# define FREE_MB_T(m) freemsg(m)
480# define SPL_NET(x) ;
481# define SPL_IMP(x) ;
482# undef SPL_X
483# define SPL_X(x) ;
484# ifdef sparc
485# define ntohs(x) (x)
486# define ntohl(x) (x)
487# define htons(x) (x)
488# define htonl(x) (x)
489# endif /* sparc */
490# define KMALLOC(a,b) (a) = (b)kmem_alloc(sizeof(*(a)), KM_NOSLEEP)
491# define KMALLOCS(a,b,c) (a) = (b)kmem_alloc((c), KM_NOSLEEP)
492# define GET_MINOR(x) getminor(x)
493extern ill_t *get_unit __P((char *, int));
494# define GETUNIT(n, v) get_unit(n, v)
495# define IFNAME(x) ((ill_t *)x)->ill_name
496# else /* SOLARIS */
497# if defined(__sgi)
498# define ATOMIC_INC(x) { MUTEX_ENTER(&ipf_rw); \
499 (x)++; MUTEX_EXIT(&ipf_rw); }
500# define ATOMIC_DEC(x) { MUTEX_ENTER(&ipf_rw); \
501 (x)--; MUTEX_EXIT(&ipf_rw); }
502# define MUTEX_ENTER(x) (x)->pl = LOCK((x)->l, IPF_LOCK_PL);
503# define KRWLOCK_T kmutex_t
504# define READ_ENTER(x) MUTEX_ENTER(x)
505# define WRITE_ENTER(x) MUTEX_ENTER(x)
506# define RW_UPGRADE(x) ;
507# define MUTEX_DOWNGRADE(x) ;
508# define RWLOCK_EXIT(x) MUTEX_EXIT(x)
509# define MUTEX_EXIT(x) UNLOCK((x)->l, (x)->pl);
510# define MUTEX_INIT(x,y,z) (x)->l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP)
511# define MUTEX_DESTROY(x) LOCK_DEALLOC((x)->l)
512# else /* __sgi */
513# define ATOMIC_INC(x) (x)++
514# define ATOMIC_DEC(x) (x)--
515# define MUTEX_ENTER(x) ;
516# define READ_ENTER(x) ;
517# define WRITE_ENTER(x) ;
518# define RW_UPGRADE(x) ;
519# define MUTEX_DOWNGRADE(x) ;
520# define RWLOCK_EXIT(x) ;
521# define MUTEX_EXIT(x) ;
522# define MUTEX_INIT(x,y,z) ;
523# define MUTEX_DESTROY(x) ;
524# endif /* __sgi */
525# ifndef linux
526# define FREE_MB_T(m) m_freem(m)
527# define MTOD(m,t) mtod(m,t)
528# define IRCOPY(a,b,c) (bcopy((a), (b), (c)), 0)
529# define IWCOPY(a,b,c) (bcopy((a), (b), (c)), 0)
530# define IRCOPYPTR ircopyptr
531# define IWCOPYPTR iwcopyptr
532# endif /* !linux */
533# endif /* SOLARIS */
534
535# ifdef sun
536# if !SOLARIS
537# include <sys/time.h>
538# include <sys/kmem_alloc.h>
539# define GETUNIT(n, v) ifunit(n, IFNAMSIZ)
540# define IFNAME(x) ((struct ifnet *)x)->if_name
541# endif
542# else
543# ifndef linux
544# define GETUNIT(n, v) ifunit(n)
545# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \
546 (defined(OpenBSD) && (OpenBSD >= 199603))
547# define IFNAME(x) ((struct ifnet *)x)->if_xname
548# else
549# define USE_GETIFNAME 1
550# define IFNAME(x) get_ifname((struct ifnet *)x)
551extern char *get_ifname __P((struct ifnet *));
552# endif
553# endif
554# endif /* sun */
555
556# if defined(sun) && !defined(linux) || defined(__sgi)
557# define UIOMOVE(a,b,c,d) uiomove((caddr_t)a,b,c,d)
2f65cd66 558# define SLEEP(id, n) sleep((id), 0)
984263bc
MD
559# define WAKEUP(id) wakeup(id)
560# define KFREE(x) kmem_free((char *)(x), sizeof(*(x)))
561# define KFREES(x,s) kmem_free((char *)(x), (s))
562# if !SOLARIS
563extern void m_copydata __P((struct mbuf *, int, int, caddr_t));
564extern void m_copyback __P((struct mbuf *, int, int, caddr_t));
565# endif
566# ifdef __sgi
567# include <sys/kmem.h>
568# include <sys/ddi.h>
569# define KMALLOC(a,b) (a) = (b)kmem_alloc(sizeof(*(a)), KM_NOSLEEP)
570# define KMALLOCS(a,b,c) (a) = (b)kmem_alloc((c), KM_NOSLEEP)
571# define GET_MINOR(x) getminor(x)
572# else
573# if !SOLARIS
574# define KMALLOC(a,b) (a) = (b)new_kmem_alloc(sizeof(*(a)), \
575 KMEM_NOSLEEP)
576# define KMALLOCS(a,b,c) (a) = (b)new_kmem_alloc((c), KMEM_NOSLEEP)
577# endif /* SOLARIS */
578# endif /* __sgi */
579# endif /* sun && !linux */
580# ifndef GET_MINOR
581# define GET_MINOR(x) minor(x)
582# endif
583# if (BSD >= 199306) || defined(__FreeBSD__)
584# if (defined(__NetBSD_Version__) && (__NetBSD_Version__ < 105180000)) || \
585 defined(__FreeBSD__) || (defined(OpenBSD) && (OpenBSD < 200206)) || \
586 defined(_BSDI_VERSION)
587# include <vm/vm.h>
588# endif
589# if !defined(__FreeBSD__) || (defined (__FreeBSD_version) && \
590 (__FreeBSD_version >= 300000))
591# if (defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 105180000)) || \
592 (defined(OpenBSD) && (OpenBSD >= 200111))
593# include <uvm/uvm_extern.h>
594# else
595# include <vm/vm_extern.h>
596extern vm_map_t kmem_map;
597# endif
598# include <sys/proc.h>
599# else /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD_version >= 300000) */
600# include <vm/vm_kern.h>
601# endif /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD_version >= 300000) */
602# ifdef M_PFIL
603# define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), M_PFIL, M_NOWAIT)
604# define KMALLOCS(a, b, c) MALLOC((a), b, (c), M_PFIL, M_NOWAIT)
605# define KFREE(x) FREE((x), M_PFIL)
606# define KFREES(x,s) FREE((x), M_PFIL)
607# else
608# define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), M_TEMP, M_NOWAIT)
609# define KMALLOCS(a, b, c) MALLOC((a), b, (c), M_TEMP, M_NOWAIT)
610# define KFREE(x) FREE((x), M_TEMP)
611# define KFREES(x,s) FREE((x), M_TEMP)
612# endif /* M_PFIL */
613# define UIOMOVE(a,b,c,d) uiomove(a,b,d)
377d4740 614# define SLEEP(id, n) tsleep((id), PCATCH, n, 0)
984263bc
MD
615# define WAKEUP(id) wakeup(id)
616# endif /* BSD */
617# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199407)) || \
618 (defined(OpenBSD) && (OpenBSD >= 200006))
619# define SPL_NET(x) x = splsoftnet()
620# define SPL_X(x) (void) splx(x)
621# else
622# if !SOLARIS && !defined(linux)
623# define SPL_IMP(x) x = splimp()
624# define SPL_NET(x) x = splnet()
625# define SPL_X(x) (void) splx(x)
626# endif
627# endif /* NetBSD && (NetBSD <= 1991011) && (NetBSD >= 199407) */
628# define PANIC(x,y) if (x) panic y
629#else /* KERNEL */
630# define SLEEP(x,y) 1
631# define WAKEUP(x) ;
632# define PANIC(x,y) ;
633# define ATOMIC_INC(x) (x)++
634# define ATOMIC_DEC(x) (x)--
635# define MUTEX_ENTER(x) ;
636# define READ_ENTER(x) ;
637# define MUTEX_INIT(x,y,z) ;
638# define MUTEX_DESTROY(x) ;
639# define WRITE_ENTER(x) ;
640# define RW_UPGRADE(x) ;
641# define MUTEX_DOWNGRADE(x) ;
642# define RWLOCK_EXIT(x) ;
643# define MUTEX_EXIT(x) ;
644# define SPL_NET(x) ;
645# define SPL_IMP(x) ;
646# undef SPL_X
647# define SPL_X(x) ;
648# define KMALLOC(a,b) (a) = (b)malloc(sizeof(*a))
649# define KMALLOCS(a,b,c) (a) = (b)malloc(c)
650# define KFREE(x) free(x)
651# define KFREES(x,s) free(x)
652# define FREE_MB_T(x) ;
653# define GETUNIT(x, v) get_unit(x,v)
654# define IRCOPY(a,b,c) (bcopy((a), (b), (c)), 0)
655# define IWCOPY(a,b,c) (bcopy((a), (b), (c)), 0)
656# define IRCOPYPTR ircopyptr
657# define IWCOPYPTR iwcopyptr
658# define IFNAME(x) get_ifname((struct ifnet *)x)
659# define UIOMOVE(a,b,c,d) ipfuiomove(a,b,c,d)
660# include <sys/time.h>
661extern void m_copydata __P((mb_t *, int, int, caddr_t));
662extern int ipfuiomove __P((caddr_t, int, int, struct uio *));
663#endif /* KERNEL */
664
665/*
666 * These #ifdef's are here mainly for linux, but who knows, they may
667 * not be in other places or maybe one day linux will grow up and some
668 * of these will turn up there too.
669 */
670#ifndef ICMP_MINLEN
671# define ICMP_MINLEN 8
672#endif
673#ifndef ICMP_ECHOREPLY
674# define ICMP_ECHOREPLY 0
675#endif
676#ifndef ICMP_UNREACH
677# define ICMP_UNREACH 3
678#endif
679#ifndef ICMP_UNREACH_NET
680# define ICMP_UNREACH_NET 0
681#endif
682#ifndef ICMP_UNREACH_HOST
683# define ICMP_UNREACH_HOST 1
684#endif
685#ifndef ICMP_UNREACH_PROTOCOL
686# define ICMP_UNREACH_PROTOCOL 2
687#endif
688#ifndef ICMP_UNREACH_PORT
689# define ICMP_UNREACH_PORT 3
690#endif
691#ifndef ICMP_UNREACH_NEEDFRAG
692# define ICMP_UNREACH_NEEDFRAG 4
693#endif
694#ifndef ICMP_UNREACH_SRCFAIL
695# define ICMP_UNREACH_SRCFAIL 5
696#endif
697#ifndef ICMP_UNREACH_NET_UNKNOWN
698# define ICMP_UNREACH_NET_UNKNOWN 6
699#endif
700#ifndef ICMP_UNREACH_HOST_UNKNOWN
701# define ICMP_UNREACH_HOST_UNKNOWN 7
702#endif
703#ifndef ICMP_UNREACH_ISOLATED
704# define ICMP_UNREACH_ISOLATED 8
705#endif
706#ifndef ICMP_UNREACH_NET_PROHIB
707# define ICMP_UNREACH_NET_PROHIB 9
708#endif
709#ifndef ICMP_UNREACH_HOST_PROHIB
710# define ICMP_UNREACH_HOST_PROHIB 10
711#endif
712#ifndef ICMP_UNREACH_TOSNET
713# define ICMP_UNREACH_TOSNET 11
714#endif
715#ifndef ICMP_UNREACH_TOSHOST
716# define ICMP_UNREACH_TOSHOST 12
717#endif
718#ifndef ICMP_UNREACH_ADMIN_PROHIBIT
719# define ICMP_UNREACH_ADMIN_PROHIBIT 13
720#endif
721#ifndef ICMP_UNREACH_HOST_PRECEDENCE
722# define ICMP_UNREACH_HOST_PRECEDENCE 14
723#endif
724#ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF
725# define ICMP_UNREACH_PRECEDENCE_CUTOFF 15
726#endif
727#ifndef ICMP_SOURCEQUENCH
728# define ICMP_SOURCEQUENCH 4
729#endif
730#ifndef ICMP_REDIRECT_NET
731# define ICMP_REDIRECT_NET 0
732#endif
733#ifndef ICMP_REDIRECT_HOST
734# define ICMP_REDIRECT_HOST 1
735#endif
736#ifndef ICMP_REDIRECT_TOSNET
737# define ICMP_REDIRECT_TOSNET 2
738#endif
739#ifndef ICMP_REDIRECT_TOSHOST
740# define ICMP_REDIRECT_TOSHOST 3
741#endif
742#ifndef ICMP_ALTHOSTADDR
743# define ICMP_ALTHOSTADDR 6
744#endif
745#ifndef ICMP_TIMXCEED
746# define ICMP_TIMXCEED 11
747#endif
748#ifndef ICMP_TIMXCEED_INTRANS
749# define ICMP_TIMXCEED_INTRANS 0
750#endif
751#ifndef ICMP_TIMXCEED_REASS
752# define ICMP_TIMXCEED_REASS 1
753#endif
754#ifndef ICMP_PARAMPROB
755# define ICMP_PARAMPROB 12
756#endif
757#ifndef ICMP_PARAMPROB_ERRATPTR
758# define ICMP_PARAMPROB_ERRATPTR 0
759#endif
760#ifndef ICMP_PARAMPROB_OPTABSENT
761# define ICMP_PARAMPROB_OPTABSENT 1
762#endif
763#ifndef ICMP_PARAMPROB_LENGTH
764# define ICMP_PARAMPROB_LENGTH 2
765#endif
766#ifndef ICMP_TSTAMP
767# define ICMP_TSTAMP 13
768#endif
769#ifndef ICMP_TSTAMPREPLY
770# define ICMP_TSTAMPREPLY 14
771#endif
772#ifndef ICMP_IREQ
773# define ICMP_IREQ 15
774#endif
775#ifndef ICMP_IREQREPLY
776# define ICMP_IREQREPLY 16
777#endif
778#ifndef ICMP_MASKREQ
779# define ICMP_MASKREQ 17
780#endif
781#ifndef ICMP_MASKREPLY
782# define ICMP_MASKREPLY 18
783#endif
784#ifndef ICMP_TRACEROUTE
785# define ICMP_TRACEROUTE 30
786#endif
787#ifndef ICMP_DATACONVERR
788# define ICMP_DATACONVERR 31
789#endif
790#ifndef ICMP_MOBILE_REDIRECT
791# define ICMP_MOBILE_REDIRECT 32
792#endif
793#ifndef ICMP_IPV6_WHEREAREYOU
794# define ICMP_IPV6_WHEREAREYOU 33
795#endif
796#ifndef ICMP_IPV6_IAMHERE
797# define ICMP_IPV6_IAMHERE 34
798#endif
799#ifndef ICMP_MOBILE_REGREQUEST
800# define ICMP_MOBILE_REGREQUEST 35
801#endif
802#ifndef ICMP_MOBILE_REGREPLY
803# define ICMP_MOBILE_REGREPLY 36
804#endif
805#ifndef ICMP_SKIP
806# define ICMP_SKIP 39
807#endif
808#ifndef ICMP_PHOTURIS
809# define ICMP_PHOTURIS 40
810#endif
811#ifndef ICMP_PHOTURIS_UNKNOWN_INDEX
812# define ICMP_PHOTURIS_UNKNOWN_INDEX 1
813#endif
814#ifndef ICMP_PHOTURIS_AUTH_FAILED
815# define ICMP_PHOTURIS_AUTH_FAILED 2
816#endif
817#ifndef ICMP_PHOTURIS_DECRYPT_FAILED
818# define ICMP_PHOTURIS_DECRYPT_FAILED 3
819#endif
820#ifndef IPVERSION
821# define IPVERSION 4
822#endif
823#ifndef IPOPT_MINOFF
824# define IPOPT_MINOFF 4
825#endif
826#ifndef IPOPT_COPIED
827# define IPOPT_COPIED(x) ((x)&0x80)
828#endif
829#ifndef IPOPT_EOL
830# define IPOPT_EOL 0
831#endif
832#ifndef IPOPT_NOP
833# define IPOPT_NOP 1
834#endif
835#ifndef IP_MF
836# define IP_MF ((u_short)0x2000)
837#endif
838#ifndef ETHERTYPE_IP
839# define ETHERTYPE_IP ((u_short)0x0800)
840#endif
841#ifndef TH_FIN
842# define TH_FIN 0x01
843#endif
844#ifndef TH_SYN
845# define TH_SYN 0x02
846#endif
847#ifndef TH_RST
848# define TH_RST 0x04
849#endif
850#ifndef TH_PUSH
851# define TH_PUSH 0x08
852#endif
853#ifndef TH_ACK
854# define TH_ACK 0x10
855#endif
856#ifndef TH_URG
857# define TH_URG 0x20
858#endif
859#ifndef IPOPT_EOL
860# define IPOPT_EOL 0
861#endif
862#ifndef IPOPT_NOP
863# define IPOPT_NOP 1
864#endif
865#ifndef IPOPT_RR
866# define IPOPT_RR 7
867#endif
868#ifndef IPOPT_TS
869# define IPOPT_TS 68
870#endif
871#ifndef IPOPT_SECURITY
872# define IPOPT_SECURITY 130
873#endif
874#ifndef IPOPT_LSRR
875# define IPOPT_LSRR 131
876#endif
877#ifndef IPOPT_SATID
878# define IPOPT_SATID 136
879#endif
880#ifndef IPOPT_SSRR
881# define IPOPT_SSRR 137
882#endif
883#ifndef IPOPT_SECUR_UNCLASS
884# define IPOPT_SECUR_UNCLASS ((u_short)0x0000)
885#endif
886#ifndef IPOPT_SECUR_CONFID
887# define IPOPT_SECUR_CONFID ((u_short)0xf135)
888#endif
889#ifndef IPOPT_SECUR_EFTO
890# define IPOPT_SECUR_EFTO ((u_short)0x789a)
891#endif
892#ifndef IPOPT_SECUR_MMMM
893# define IPOPT_SECUR_MMMM ((u_short)0xbc4d)
894#endif
895#ifndef IPOPT_SECUR_RESTR
896# define IPOPT_SECUR_RESTR ((u_short)0xaf13)
897#endif
898#ifndef IPOPT_SECUR_SECRET
899# define IPOPT_SECUR_SECRET ((u_short)0xd788)
900#endif
901#ifndef IPOPT_SECUR_TOPSECRET
902# define IPOPT_SECUR_TOPSECRET ((u_short)0x6bc5)
903#endif
904#ifndef IPOPT_OLEN
905# define IPOPT_OLEN 1
906#endif
907#ifndef IPPROTO_GRE
908# define IPPROTO_GRE 47 /* GRE encaps RFC 1701 */
909#endif
910#ifndef IPPROTO_ESP
911# define IPPROTO_ESP 50
912#endif
913#ifndef IPPROTO_ICMPV6
914# define IPPROTO_ICMPV6 58
915#endif
916
917#ifdef linux
918#include <linux/in_systm.h>
919/*
920 * TCP States
921 */
922#define TCPS_CLOSED 0 /* closed */
923#define TCPS_LISTEN 1 /* listening for connection */
924#define TCPS_SYN_SENT 2 /* active, have sent syn */
925#define TCPS_SYN_RECEIVED 3 /* have send and received syn */
926/* states < TCPS_ESTABLISHED are those where connections not established */
927#define TCPS_ESTABLISHED 4 /* established */
928#define TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */
929/* states > TCPS_CLOSE_WAIT are those where user has closed */
930#define TCPS_FIN_WAIT_1 6 /* have closed, sent fin */
931#define TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */
932#define TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */
933/* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */
934#define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */
935#define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */
936
937/*
938 * file flags.
939 */
940#ifdef WRITE
941#define FWRITE WRITE
942#define FREAD READ
943#else
944#define FWRITE _IOC_WRITE
945#define FREAD _IOC_READ
946#endif
947/*
948 * mbuf related problems.
949 */
950#define mtod(m,t) (t)((m)->data)
951#define m_len len
952#define m_next next
953
954#ifdef IP_DF
955#undef IP_DF
956#endif
957#define IP_DF 0x4000
958
959typedef struct {
960 __u16 th_sport;
961 __u16 th_dport;
962 __u32 th_seq;
963 __u32 th_ack;
964# if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\
965 defined(vax)
966 __u8 th_res:4;
967 __u8 th_off:4;
968#else
969 __u8 th_off:4;
970 __u8 th_res:4;
971#endif
972 __u8 th_flags;
973 __u16 th_win;
974 __u16 th_sum;
975 __u16 th_urp;
976} tcphdr_t;
977
978typedef struct {
979 __u16 uh_sport;
980 __u16 uh_dport;
981 __u16 uh_ulen;
982 __u16 uh_sum;
983} udphdr_t;
984
985typedef struct {
986# if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\
987 defined(vax)
988 __u8 ip_hl:4;
989 __u8 ip_v:4;
990# else
991 __u8 ip_v:4;
992 __u8 ip_hl:4;
993# endif
994 __u8 ip_tos;
995 __u16 ip_len;
996 __u16 ip_id;
997 __u16 ip_off;
998 __u8 ip_ttl;
999 __u8 ip_p;
1000 __u16 ip_sum;
1001 struct in_addr ip_src;
1002 struct in_addr ip_dst;
1003} ip_t;
1004
1005/*
1006 * Structure of an icmp header.
1007 */
1008typedef struct icmp {
1009 __u8 icmp_type; /* type of message, see below */
1010 __u8 icmp_code; /* type sub code */
1011 __u16 icmp_cksum; /* ones complement cksum of struct */
1012 union {
1013 __u8 ih_pptr; /* ICMP_PARAMPROB */
1014 struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
1015 struct ih_idseq {
1016 __u16 icd_id;
1017 __u16 icd_seq;
1018 } ih_idseq;
1019 int ih_void;
1020 } icmp_hun;
1021# define icmp_pptr icmp_hun.ih_pptr
1022# define icmp_gwaddr icmp_hun.ih_gwaddr
1023# define icmp_id icmp_hun.ih_idseq.icd_id
1024# define icmp_seq icmp_hun.ih_idseq.icd_seq
1025# define icmp_void icmp_hun.ih_void
1026 union {
1027 struct id_ts {
1028 n_time its_otime;
1029 n_time its_rtime;
1030 n_time its_ttime;
1031 } id_ts;
1032 struct id_ip {
1033 ip_t idi_ip;
1034 /* options and then 64 bits of data */
1035 } id_ip;
1036 u_long id_mask;
1037 char id_data[1];
1038 } icmp_dun;
1039# define icmp_otime icmp_dun.id_ts.its_otime
1040# define icmp_rtime icmp_dun.id_ts.its_rtime
1041# define icmp_ttime icmp_dun.id_ts.its_ttime
1042# define icmp_ip icmp_dun.id_ip.idi_ip
1043# define icmp_mask icmp_dun.id_mask
1044# define icmp_data icmp_dun.id_data
1045} icmphdr_t;
1046
1047# ifndef LINUX_IPOVLY
1048# define LINUX_IPOVLY
1049struct ipovly {
1050 caddr_t ih_next, ih_prev; /* for protocol sequence q's */
1051 u_char ih_x1; /* (unused) */
1052 u_char ih_pr; /* protocol */
1053 short ih_len; /* protocol length */
1054 struct in_addr ih_src; /* source internet address */
1055 struct in_addr ih_dst; /* destination internet address */
1056};
1057# endif
1058
1059typedef struct {
1060 __u8 ether_dhost[6];
1061 __u8 ether_shost[6];
1062 __u16 ether_type;
1063} ether_header_t;
1064
1065typedef struct uio {
1066 int uio_resid;
1067 int uio_rw;
1068 caddr_t uio_buf;
1069} uio_t;
1070
1071# define UIO_READ 0
1072# define UIO_WRITE 1
1073# define UIOMOVE(a, b, c, d) uiomove(a,b,c,d)
1074
1075/*
1076 * For masking struct ifnet onto struct device
1077 */
1078# define if_name name
1079
1080# ifdef KERNEL
1081# define GETUNIT(x, v) dev_get(x)
1082# define FREE_MB_T(m) kfree_skb(m, FREE_WRITE)
1083# define uniqtime do_gettimeofday
1084# undef INT_MAX
1085# undef UINT_MAX
1086# undef LONG_MAX
1087# undef ULONG_MAX
1088# include <linux/netdevice.h>
1089# define SPL_X(x)
1090# define SPL_NET(x)
1091# define SPL_IMP(x)
1092
1093# define bcmp(a,b,c) memcmp(a,b,c)
1094# define bcopy(a,b,c) memcpy(b,a,c)
1095# define bzero(a,c) memset(a,0,c)
1096
1097# define UNITNAME(n) dev_get((n))
1098
1099# define KMALLOC(a,b) (a) = (b)kmalloc(sizeof(*(a)), GFP_ATOMIC)
1100# define KMALLOCS(a,b,c) (a) = (b)kmalloc((c), GFP_ATOMIC)
1101# define KFREE(x) kfree_s((x), sizeof(*(x)))
1102# define KFREES(x,s) kfree_s((x), (s))
1103#define IRCOPY(const void *a, void *b, size_t c) { \
1104 int error; \
1105
1106 error = verify_area(VERIFY_READ, a ,c); \
1107 if (!error) \
1108 memcpy_fromfs(b, a, c); \
1109 return error; \
1110}
1111static inline int IWCOPY(const void *a, void *b, size_t c)
1112{
1113 int error;
1114
1115 error = verify_area(VERIFY_WRITE, b, c);
1116 if (!error)
1117 memcpy_tofs(b, a, c);
1118 return error;
1119}
1120static inline int IRCOPYPTR(const void *a, void *b, size_t c) {
1121 caddr_t ca;
1122 int error;
1123
1124 error = verify_area(VERIFY_READ, a ,sizeof(ca));
1125 if (!error) {
1126 memcpy_fromfs(ca, a, sizeof(ca));
1127 error = verify_area(VERIFY_READ, ca , c);
1128 if (!error)
1129 memcpy_fromfs(b, ca, c);
1130 }
1131 return error;
1132}
1133static inline int IWCOPYPTR(const void *a, void *b, size_t c) {
1134 caddr_t ca;
1135 int error;
1136
1137
1138 error = verify_area(VERIFY_READ, b ,sizeof(ca));
1139 if (!error) {
1140 memcpy_fromfs(ca, b, sizeof(ca));
1141 error = verify_area(VERIFY_WRITE, ca, c);
1142 if (!error)
1143 memcpy_tofs(ca, a, c);
1144 }
1145 return error;
1146}
1147# else
1148# define __KERNEL__
1149# undef INT_MAX
1150# undef UINT_MAX
1151# undef LONG_MAX
1152# undef ULONG_MAX
1153# define s8 __s8
1154# define u8 __u8
1155# define s16 __s16
1156# define u16 __u16
1157# define s32 __s32
1158# define u32 __u32
1159# include <linux/netdevice.h>
1160# undef __KERNEL__
1161# endif
1162# define ifnet device
1163#else
1164typedef struct tcphdr tcphdr_t;
1165typedef struct udphdr udphdr_t;
1166typedef struct icmp icmphdr_t;
1167typedef struct ip ip_t;
1168typedef struct ether_header ether_header_t;
1169#endif /* linux */
1170typedef struct tcpiphdr tcpiphdr_t;
1171
1172#if defined(hpux) || defined(linux)
1173struct ether_addr {
1174 char ether_addr_octet[6];
1175};
1176#endif
1177
1178/*
1179 * XXX - This is one of those *awful* hacks which nobody likes
1180 */
1181#ifdef ultrix
1182#define A_A
1183#else
1184#define A_A &
1185#endif
1186
1187#if (BSD >= 199306) && !defined(m_act)
1188# define m_act m_nextpkt
1189#endif
1190
1191#ifndef ICMP_ROUTERADVERT
1192# define ICMP_ROUTERADVERT 9
1193#endif
1194#ifndef ICMP_ROUTERSOLICIT
1195# define ICMP_ROUTERSOLICIT 10
1196#endif
1197#undef ICMP_MAX_UNREACH
1198#define ICMP_MAX_UNREACH 14
1199#undef ICMP_MAXTYPE
1200#define ICMP_MAXTYPE 18
1201/*
1202 * ICMP error replies have an IP header (20 bytes), 8 bytes of ICMP data,
1203 * another IP header and then 64 bits of data, totalling 56. Of course,
1204 * the last 64 bits is dependant on that being available.
1205 */
1206#define ICMPERR_ICMPHLEN 8
1207#define ICMPERR_IPICMPHLEN (20 + 8)
1208#define ICMPERR_MINPKTLEN (20 + 8 + 20)
1209#define ICMPERR_MAXPKTLEN (20 + 8 + 20 + 8)
1210#define ICMP6_MINLEN 8
1211#define ICMP6ERR_MINPKTLEN (40 + 8)
1212#define ICMP6ERR_IPICMPHLEN (40 + 8 + 40)
1213
1214#ifndef ICMP6_DST_UNREACH
1215# define ICMP6_DST_UNREACH 1
1216#endif
1217#ifndef ICMP6_PACKET_TOO_BIG
1218# define ICMP6_PACKET_TOO_BIG 2
1219#endif
1220#ifndef ICMP6_TIME_EXCEEDED
1221# define ICMP6_TIME_EXCEEDED 3
1222#endif
1223#ifndef ICMP6_PARAM_PROB
1224# define ICMP6_PARAM_PROB 4
1225#endif
1226
1227#ifndef ICMP6_ECHO_REQUEST
1228# define ICMP6_ECHO_REQUEST 128
1229#endif
1230#ifndef ICMP6_ECHO_REPLY
1231# define ICMP6_ECHO_REPLY 129
1232#endif
1233#ifndef ICMP6_MEMBERSHIP_QUERY
1234# define ICMP6_MEMBERSHIP_QUERY 130
1235#endif
1236#ifndef MLD6_LISTENER_QUERY
1237# define MLD6_LISTENER_QUERY 130
1238#endif
1239#ifndef ICMP6_MEMBERSHIP_REPORT
1240# define ICMP6_MEMBERSHIP_REPORT 131
1241#endif
1242#ifndef MLD6_LISTENER_REPORT
1243# define MLD6_LISTENER_REPORT 131
1244#endif
1245#ifndef ICMP6_MEMBERSHIP_REDUCTION
1246# define ICMP6_MEMBERSHIP_REDUCTION 132
1247#endif
1248#ifndef MLD6_LISTENER_DONE
1249# define MLD6_LISTENER_DONE 132
1250#endif
1251#ifndef ND_ROUTER_SOLICIT
1252# define ND_ROUTER_SOLICIT 133
1253#endif
1254#ifndef ND_ROUTER_ADVERT
1255# define ND_ROUTER_ADVERT 134
1256#endif
1257#ifndef ND_NEIGHBOR_SOLICIT
1258# define ND_NEIGHBOR_SOLICIT 135
1259#endif
1260#ifndef ND_NEIGHBOR_ADVERT
1261# define ND_NEIGHBOR_ADVERT 136
1262#endif
1263#ifndef ND_REDIRECT
1264# define ND_REDIRECT 137
1265#endif
1266#ifndef ICMP6_ROUTER_RENUMBERING
1267# define ICMP6_ROUTER_RENUMBERING 138
1268#endif
1269#ifndef ICMP6_WRUREQUEST
1270# define ICMP6_WRUREQUEST 139
1271#endif
1272#ifndef ICMP6_WRUREPLY
1273# define ICMP6_WRUREPLY 140
1274#endif
1275#ifndef ICMP6_FQDN_QUERY
1276# define ICMP6_FQDN_QUERY 139
1277#endif
1278#ifndef ICMP6_FQDN_REPLY
1279# define ICMP6_FQDN_REPLY 140
1280#endif
1281#ifndef ICMP6_NI_QUERY
1282# define ICMP6_NI_QUERY 139
1283#endif
1284#ifndef ICMP6_NI_REPLY
1285# define ICMP6_NI_REPLY 140
1286#endif
1287#ifndef MLD6_MTRACE_RESP
1288# define MLD6_MTRACE_RESP 200
1289#endif
1290#ifndef MLD6_MTRACE
1291# define MLD6_MTRACE 201
1292#endif
1293#ifndef ICMP6_HADISCOV_REQUEST
1294# define ICMP6_HADISCOV_REQUEST 202
1295#endif
1296#ifndef ICMP6_HADISCOV_REPLY
1297# define ICMP6_HADISCOV_REPLY 203
1298#endif
1299#ifndef ICMP6_MOBILEPREFIX_SOLICIT
1300# define ICMP6_MOBILEPREFIX_SOLICIT 204
1301#endif
1302#ifndef ICMP6_MOBILEPREFIX_ADVERT
1303# define ICMP6_MOBILEPREFIX_ADVERT 205
1304#endif
1305#ifndef ICMP6_MAXTYPE
1306# define ICMP6_MAXTYPE 205
1307#endif
1308
1309#ifndef ICMP6_DST_UNREACH_NOROUTE
1310# define ICMP6_DST_UNREACH_NOROUTE 0
1311#endif
1312#ifndef ICMP6_DST_UNREACH_ADMIN
1313# define ICMP6_DST_UNREACH_ADMIN 1
1314#endif
1315#ifndef ICMP6_DST_UNREACH_NOTNEIGHBOR
1316# define ICMP6_DST_UNREACH_NOTNEIGHBOR 2
1317#endif
1318#ifndef ICMP6_DST_UNREACH_BEYONDSCOPE
1319# define ICMP6_DST_UNREACH_BEYONDSCOPE 2
1320#endif
1321#ifndef ICMP6_DST_UNREACH_ADDR
1322# define ICMP6_DST_UNREACH_ADDR 3
1323#endif
1324#ifndef ICMP6_DST_UNREACH_NOPORT
1325# define ICMP6_DST_UNREACH_NOPORT 4
1326#endif
1327#ifndef ICMP6_TIME_EXCEED_TRANSIT
1328# define ICMP6_TIME_EXCEED_TRANSIT 0
1329#endif
1330#ifndef ICMP6_TIME_EXCEED_REASSEMBLY
1331# define ICMP6_TIME_EXCEED_REASSEMBLY 1
1332#endif
1333
1334#ifndef ICMP6_NI_SUCCESS
1335# define ICMP6_NI_SUCCESS 0
1336#endif
1337#ifndef ICMP6_NI_REFUSED
1338# define ICMP6_NI_REFUSED 1
1339#endif
1340#ifndef ICMP6_NI_UNKNOWN
1341# define ICMP6_NI_UNKNOWN 2
1342#endif
1343
1344#ifndef ICMP6_ROUTER_RENUMBERING_COMMAND
1345# define ICMP6_ROUTER_RENUMBERING_COMMAND 0
1346#endif
1347#ifndef ICMP6_ROUTER_RENUMBERING_RESULT
1348# define ICMP6_ROUTER_RENUMBERING_RESULT 1
1349#endif
1350#ifndef ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET
1351# define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255
1352#endif
1353
1354#ifndef ICMP6_PARAMPROB_HEADER
1355# define ICMP6_PARAMPROB_HEADER 0
1356#endif
1357#ifndef ICMP6_PARAMPROB_NEXTHEADER
1358# define ICMP6_PARAMPROB_NEXTHEADER 1
1359#endif
1360#ifndef ICMP6_PARAMPROB_OPTION
1361# define ICMP6_PARAMPROB_OPTION 2
1362#endif
1363
1364#ifndef ICMP6_NI_SUBJ_IPV6
1365# define ICMP6_NI_SUBJ_IPV6 0
1366#endif
1367#ifndef ICMP6_NI_SUBJ_FQDN
1368# define ICMP6_NI_SUBJ_FQDN 1
1369#endif
1370#ifndef ICMP6_NI_SUBJ_IPV4
1371# define ICMP6_NI_SUBJ_IPV4 2
1372#endif
1373
1374/*
1375 * ECN is a new addition to TCP - RFC 2481
1376 */
1377#ifndef TH_ECN
1378# define TH_ECN 0x40
1379#endif
1380#ifndef TH_CWR
1381# define TH_CWR 0x80
1382#endif
1383#define TH_ECNALL (TH_ECN|TH_CWR)
1384
1385#define TCPF_ALL (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|TH_ECN|TH_CWR)
1386
1387#endif /* __IP_COMPAT_H__ */