ip_compat.h revision 255754
153642Sguido/* 2255332Scy * Copyright (C) 2012 by Darren Reed. 353642Sguido * 480482Sdarrenr * See the IPFILTER.LICENCE file for details on licencing. 553642Sguido * 653642Sguido * @(#)ip_compat.h 1.8 1/14/96 757126Sguido * $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_compat.h 255754 2013-09-21 03:57:56Z cy $ 8172776Sdarrenr * Id: ip_compat.h,v 2.142.2.57 2007/10/10 09:51:42 darrenr Exp $ 953642Sguido */ 1053642Sguido 1153642Sguido#ifndef __IP_COMPAT_H__ 1253642Sguido#define __IP_COMPAT_H__ 1353642Sguido 1453642Sguido#ifndef __P 1553642Sguido# ifdef __STDC__ 1653642Sguido# define __P(x) x 1753642Sguido# else 1853642Sguido# define __P(x) () 1953642Sguido# endif 2053642Sguido#endif 2153642Sguido#ifndef __STDC__ 2253642Sguido# undef const 2353642Sguido# define const 2453642Sguido#endif 2553642Sguido 2653642Sguido#if defined(_KERNEL) || defined(KERNEL) || defined(__KERNEL__) 2753642Sguido# undef KERNEL 2853642Sguido# undef _KERNEL 2953642Sguido# undef __KERNEL__ 3053642Sguido# define KERNEL 3153642Sguido# define _KERNEL 3253642Sguido# define __KERNEL__ 3353642Sguido#endif 3453642Sguido 35145522Sdarrenr#define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4))) 36145522Sdarrenr#if defined(__FreeBSD_version) && (__FreeBSD_version >= 400000) && \ 37145522Sdarrenr !defined(_KERNEL) && !defined(USE_INET6) && !defined(NOINET6) 38145522Sdarrenr# define USE_INET6 39145522Sdarrenr#endif 40145522Sdarrenr 41145522Sdarrenr 4253642Sguido#if defined(__SVR4) || defined(__svr4__) || defined(__sgi) 43145522Sdarrenr# define index strchr 44145522Sdarrenr# if !defined(_KERNEL) 4553642Sguido# define bzero(a,b) memset(a,0,b) 4653642Sguido# define bcmp memcmp 4753642Sguido# define bcopy(a,b,c) memmove(b,a,c) 4853642Sguido# endif 4953642Sguido#endif 5053642Sguido 51145522Sdarrenr#ifndef LIFNAMSIZ 52145522Sdarrenr# ifdef IF_NAMESIZE 5392685Sdarrenr# define LIFNAMSIZ IF_NAMESIZE 5492685Sdarrenr# else 5592685Sdarrenr# ifdef IFNAMSIZ 5692685Sdarrenr# define LIFNAMSIZ IFNAMSIZ 5792685Sdarrenr# else 5892685Sdarrenr# define LIFNAMSIZ 16 5992685Sdarrenr# endif 6092685Sdarrenr# endif 6192685Sdarrenr#endif 6292685Sdarrenr 63145522Sdarrenr#if defined(__sgi) || defined(bsdi) || defined(__hpux) || defined(hpux) 64145522Sdarrenrstruct ether_addr { 65145522Sdarrenr u_char ether_addr_octet[6]; 66145522Sdarrenr}; 67145522Sdarrenr#endif 68145522Sdarrenr 6953642Sguido# ifdef __STDC__ 7053642Sguido# define IPL_EXTERN(ep) ipl##ep 7153642Sguido# else 7253642Sguido# define IPL_EXTERN(ep) ipl/**/ep 7353642Sguido# endif 7453642Sguido 7592685Sdarrenr/* 7692685Sdarrenr * This is a workaround for <sys/uio.h> troubles on FreeBSD and OpenBSD. 7792685Sdarrenr */ 78145522Sdarrenr# ifndef _KERNEL 79145522Sdarrenr# define ADD_KERNEL 80145522Sdarrenr# define _KERNEL 81145522Sdarrenr# define KERNEL 82145522Sdarrenr# endif 83145522Sdarrenr# include <sys/uio.h> 84145522Sdarrenr# ifdef ADD_KERNEL 85145522Sdarrenr# undef _KERNEL 86145522Sdarrenr# undef KERNEL 87145522Sdarrenr# endif 8892685Sdarrenr 89255332Scy#define NETBSD_GE_REV(x) (defined(__NetBSD_Version__) && \ 90255332Scy (__NetBSD_Version__ >= (x))) 91255332Scy#define NETBSD_GT_REV(x) (defined(__NetBSD_Version__) && \ 92255332Scy (__NetBSD_Version__ > (x))) 93255332Scy#define NETBSD_LT_REV(x) (defined(__NetBSD_Version__) && \ 94255332Scy (__NetBSD_Version__ < (x))) 95255332Scy#define FREEBSD_GE_REV(x) (defined(__FreeBSD_version) && \ 96255332Scy (__FreeBSD_version >= (x))) 97255332Scy#define FREEBSD_GT_REV(x) (defined(__FreeBSD_version) && \ 98255332Scy (__FreeBSD_version > (x))) 99255332Scy#define FREEBSD_LT_REV(x) (defined(__FreeBSD_version) && \ 100255332Scy (__FreeBSD_version < (x))) 101255332Scy#define BSDOS_GE_REV(x) (defined(_BSDI_VERSION) && \ 102255332Scy (_BSDI_VERSION >= (x))) 103255332Scy#define BSDOS_GT_REV(x) (defined(_BSDI_VERSION) && \ 104255332Scy (_BSDI_VERSION > (x))) 105255332Scy#define BSDOS_LT_REV(x) (defined(_BSDI_VERSION) && \ 106255332Scy (_BSDI_VERSION < (x))) 107255332Scy#define OPENBSD_GE_REV(x) (defined(OpenBSD) && (OpenBSD >= (x))) 108255332Scy#define OPENBSD_GT_REV(x) (defined(OpenBSD) && (OpenBSD > (x))) 109255332Scy#define OPENBSD_LT_REV(x) (defined(OpenBSD) && (OpenBSD < (x))) 110255332Scy#define BSD_GE_YEAR(x) (defined(BSD) && (BSD >= (x))) 111255332Scy#define BSD_GT_YEAR(x) (defined(BSD) && (BSD > (x))) 112255332Scy#define BSD_LT_YEAR(x) (defined(BSD) && (BSD < (x))) 113145522Sdarrenr 114145522Sdarrenr 115145522Sdarrenr/* ----------------------------------------------------------------------- */ 116145522Sdarrenr/* F R E E B S D */ 117145522Sdarrenr/* ----------------------------------------------------------------------- */ 118255332Scy# define HAS_SYS_MD5_H 1 119146229Sdarrenr# if defined(_KERNEL) 120145522Sdarrenr# include "opt_bpf.h" 12160857Sdarrenr# include "opt_inet6.h" 122145522Sdarrenr# if defined(INET6) && !defined(USE_INET6) 12360857Sdarrenr# define USE_INET6 12460857Sdarrenr# endif 12560857Sdarrenr# endif 126145522Sdarrenr 127145522Sdarrenr# if defined(_KERNEL) 128255332Scy# include <netinet/ip_var.h> 129255332Scy# define p_cred td_ucred 130255332Scy# define p_uid td_ucred->cr_ruid 131255332Scy 13253642Sguido/* 133145522Sdarrenr * When #define'd, the 5.2.1 kernel panics when used with the ftp proxy. 134145522Sdarrenr * There may be other, safe, kernels but this is not extensively tested yet. 13553642Sguido */ 136145522Sdarrenr# define HAVE_M_PULLDOWN 137145522Sdarrenr# if !defined(IPFILTER_LKM) && (__FreeBSD_version >= 300000) 138145522Sdarrenr# include "opt_ipfilter.h" 139145522Sdarrenr# endif 140145522Sdarrenr# define COPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c)) 141145522Sdarrenr# define COPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c)) 142145522Sdarrenr 143145522Sdarrenr# define NETBSD_PF 144255332Scy# else 145255332Scy# include <inttypes.h> 146145522Sdarrenr# endif /* _KERNEL */ 147145522Sdarrenr 148255332Scy# include <sys/selinfo.h> 149145522Sdarrenr# include <sys/mutex.h> 150255332Scy# define KRWLOCK_FILL_SZ 56 151255332Scy# define KMUTEX_FILL_SZ 56 152172776Sdarrenr# include <sys/rwlock.h> 153255332Scy# define KMUTEX_T struct mtx 154255332Scy# define KRWLOCK_T struct rwlock 155255332Scy# ifdef _KERNEL 156255332Scy# define READ_ENTER(x) rw_rlock(&(x)->ipf_lk) 157255332Scy# define WRITE_ENTER(x) rw_wlock(&(x)->ipf_lk) 158255332Scy# define MUTEX_DOWNGRADE(x) rw_downgrade(&(x)->ipf_lk) 159255332Scy# define RWLOCK_INIT(x,y) rw_init(&(x)->ipf_lk, (y)) 160255332Scy# define RW_DESTROY(x) rw_destroy(&(x)->ipf_lk) 161255332Scy# define RWLOCK_EXIT(x) do { \ 162172776Sdarrenr if (rw_wowned(&(x)->ipf_lk)) \ 163255332Scy rw_wunlock(&(x)->ipf_lk); \ 164255332Scy else \ 165172776Sdarrenr rw_runlock(&(x)->ipf_lk); \ 166172776Sdarrenr } while (0) 167172776Sdarrenr# endif 16853642Sguido 169145522Sdarrenr# include <net/if_var.h> 170145522Sdarrenr# define IFNAME(x) ((struct ifnet *)x)->if_xname 171172776Sdarrenr# define COPYIFNAME(v, x, b) \ 172145522Sdarrenr (void) strncpy(b, \ 173145522Sdarrenr ((struct ifnet *)x)->if_xname, \ 174145522Sdarrenr LIFNAMSIZ) 175145522Sdarrenr 176145522Sdarrenr# ifdef _KERNEL 177145522Sdarrenr# define GETKTIME(x) microtime((struct timeval *)x) 178145522Sdarrenr 179145522Sdarrenr# include <netinet/in_systm.h> 180145522Sdarrenr# include <netinet/ip.h> 181145522Sdarrenr# include <machine/in_cksum.h> 182145522Sdarrenr 183145522Sdarrenr# define USE_MUTEXES 184145522Sdarrenr# define MUTEX_ENTER(x) mtx_lock(&(x)->ipf_lk) 185145522Sdarrenr# define MUTEX_EXIT(x) mtx_unlock(&(x)->ipf_lk) 186145522Sdarrenr# define MUTEX_INIT(x,y) mtx_init(&(x)->ipf_lk, (y), NULL,\ 187145522Sdarrenr MTX_DEF) 188145522Sdarrenr# define MUTEX_DESTROY(x) mtx_destroy(&(x)->ipf_lk) 189145522Sdarrenr# define MUTEX_NUKE(x) bzero((x), sizeof(*(x))) 190255332Scy/* 191255332Scy * Whilst the sx(9) locks on FreeBSD have the right semantics and interface 192255332Scy * for what we want to use them for, despite testing showing they work - 193255332Scy * with a WITNESS kernel, it generates LOR messages. 194255332Scy */ 195145522Sdarrenr# include <machine/atomic.h> 196255332Scy# define ATOMIC_INC(x) { mtx_lock(&softc->ipf_rw.ipf_lk); (x)++; \ 197255332Scy mtx_unlock(&softc->ipf_rw.ipf_lk); } 198255332Scy# define ATOMIC_DEC(x) { mtx_lock(&softc->ipf_rw.ipf_lk); (x)--; \ 199255332Scy mtx_unlock(&softc->ipf_rw.ipf_lk); } 200145522Sdarrenr# define ATOMIC_INCL(x) atomic_add_long(&(x), 1) 201145522Sdarrenr# define ATOMIC_INC64(x) ATOMIC_INC(x) 202170268Sdarrenr# define ATOMIC_INC32(x) atomic_add_32((u_int *)&(x), 1) 203145522Sdarrenr# define ATOMIC_DECL(x) atomic_add_long(&(x), -1) 204145522Sdarrenr# define ATOMIC_DEC64(x) ATOMIC_DEC(x) 205170268Sdarrenr# define ATOMIC_DEC32(x) atomic_add_32((u_int *)&(x), -1) 206145522Sdarrenr# define SPL_X(x) ; 207145522Sdarrenr# define SPL_NET(x) ; 208145522Sdarrenr# define SPL_IMP(x) ; 209170268Sdarrenr# define SPL_SCHED(x) ; 210255332Scy# define GET_MINOR dev2unit 211255332Scy# define MSGDSIZE(m) mbufchainlen(m) 212255332Scy# define M_LEN(m) (m)->m_len 213255332Scy# define M_ADJ(m,x) m_adj(m, x) 214255332Scy# define M_COPY(x) m_copy((x), 0, M_COPYALL) 215255332Scy# define M_DUP(m) m_dup(m, M_NOWAIT) 216145522Sdarrenr# define IPF_PANIC(x,y) if (x) { printf y; panic("ipf_panic"); } 217145522Sdarrenrtypedef struct mbuf mb_t; 218145522Sdarrenr# endif /* _KERNEL */ 219145522Sdarrenr 220145522Sdarrenr 221145522Sdarrenrtypedef u_long ioctlcmd_t; 222145522Sdarrenrtypedef struct uio uio_t; 223145522Sdarrenrtypedef int minor_t; 224145522Sdarrenrtypedef u_int32_t u_32_t; 225145522Sdarrenr# define U_32_T 1 226145522Sdarrenr 227145522Sdarrenr 228145522Sdarrenr/* ----------------------------------------------------------------------- */ 229145522Sdarrenr/* G E N E R I C */ 230145522Sdarrenr/* ----------------------------------------------------------------------- */ 231145522Sdarrenr 232145522Sdarrenr/* 233145522Sdarrenr * For BSD kernels, if bpf is in the kernel, enable ipfilter to use bpf in 234145522Sdarrenr * filter rules. 235145522Sdarrenr */ 236153876Sguido#if !defined(IPFILTER_BPF) 237153876Sguido# if (defined(NBPF) && (NBPF > 0)) || (defined(DEV_BPF) && (DEV_BPF > 0)) || \ 238153876Sguido (defined(NBPFILTER) && (NBPFILTER > 0)) 239153876Sguido# define IPFILTER_BPF 240153876Sguido# endif 241145522Sdarrenr#endif 242145522Sdarrenr 243145522Sdarrenr/* 244145522Sdarrenr * Userland locking primitives 245145522Sdarrenr */ 246255332Scy#ifndef _KERNEL 247255332Scy#if !defined(KMUTEX_FILL_SZ) 248255332Scy# define KMUTEX_FILL_SZ 1 249255332Scy#endif 250255332Scy#if !defined(KRWLOCK_FILL_SZ) 251255332Scy# define KRWLOCK_FILL_SZ 1 252255332Scy#endif 253255332Scy#endif 254255332Scy 255145522Sdarrenrtypedef struct { 256145522Sdarrenr char *eMm_owner; 257145522Sdarrenr char *eMm_heldin; 258145522Sdarrenr u_int eMm_magic; 259145522Sdarrenr int eMm_held; 260145522Sdarrenr int eMm_heldat; 261145522Sdarrenr} eMmutex_t; 262145522Sdarrenr 263145522Sdarrenrtypedef struct { 264145522Sdarrenr char *eMrw_owner; 265145522Sdarrenr char *eMrw_heldin; 266145522Sdarrenr u_int eMrw_magic; 267145522Sdarrenr short eMrw_read; 268145522Sdarrenr short eMrw_write; 269145522Sdarrenr int eMrw_heldat; 270145522Sdarrenr} eMrwlock_t; 271145522Sdarrenr 272145522Sdarrenrtypedef union { 273255332Scy char _fill[KMUTEX_FILL_SZ]; 274145522Sdarrenr#ifdef KMUTEX_T 275145522Sdarrenr struct { 276145522Sdarrenr KMUTEX_T ipf_slk; 277255332Scy const char *ipf_lname; 278145522Sdarrenr } ipf_lkun_s; 279145522Sdarrenr#endif 280145522Sdarrenr eMmutex_t ipf_emu; 281145522Sdarrenr} ipfmutex_t; 282145522Sdarrenr 283145522Sdarrenrtypedef union { 284255332Scy char _fill[KRWLOCK_FILL_SZ]; 285145522Sdarrenr#ifdef KRWLOCK_T 286145522Sdarrenr struct { 287145522Sdarrenr KRWLOCK_T ipf_slk; 288255332Scy const char *ipf_lname; 289145522Sdarrenr int ipf_sr; 290145522Sdarrenr int ipf_sw; 291145522Sdarrenr u_int ipf_magic; 292145522Sdarrenr } ipf_lkun_s; 293145522Sdarrenr#endif 294145522Sdarrenr eMrwlock_t ipf_emu; 295145522Sdarrenr} ipfrwlock_t; 296145522Sdarrenr 297145522Sdarrenr#define ipf_lk ipf_lkun_s.ipf_slk 298145522Sdarrenr#define ipf_lname ipf_lkun_s.ipf_lname 299145522Sdarrenr#define ipf_isr ipf_lkun_s.ipf_sr 300145522Sdarrenr#define ipf_isw ipf_lkun_s.ipf_sw 301145522Sdarrenr#define ipf_magic ipf_lkun_s.ipf_magic 302145522Sdarrenr 303145522Sdarrenr#if !defined(__GNUC__) || \ 304145522Sdarrenr (defined(__FreeBSD_version) && (__FreeBSD_version >= 503000)) 305145522Sdarrenr# ifndef INLINE 306145522Sdarrenr# define INLINE 307145522Sdarrenr# endif 308145522Sdarrenr#else 309145522Sdarrenr# define INLINE __inline__ 310145522Sdarrenr#endif 311145522Sdarrenr 312255332Scy#if defined(__FreeBSD_version) && defined(_KERNEL) 313255332Scy CTASSERT(sizeof(ipfrwlock_t) == KRWLOCK_FILL_SZ); 314255332Scy CTASSERT(sizeof(ipfmutex_t) == KMUTEX_FILL_SZ); 315145522Sdarrenr#endif 316145522Sdarrenr 317255332Scy 318145522Sdarrenr/* 319145522Sdarrenr * In a non-kernel environment, there are a lot of macros that need to be 320145522Sdarrenr * filled in to be null-ops or to point to some compatibility function, 321145522Sdarrenr * somewhere in userland. 322145522Sdarrenr */ 323145522Sdarrenr#ifndef _KERNEL 324145522Sdarrenrtypedef struct mb_s { 325145522Sdarrenr struct mb_s *mb_next; 326255332Scy char *mb_data; 327255332Scy void *mb_ifp; 328145522Sdarrenr int mb_len; 329255332Scy int mb_flags; 330145522Sdarrenr u_long mb_buf[2048]; 331145522Sdarrenr} mb_t; 332145522Sdarrenr# undef m_next 333145522Sdarrenr# define m_next mb_next 334255332Scy# undef m_len 335255332Scy# define m_len mb_len 336255332Scy# undef m_flags 337255332Scy# define m_flags mb_flags 338255332Scy# undef m_data 339255332Scy# define m_data mb_data 340255332Scy# undef M_MCAST 341255332Scy# define M_MCAST 0x01 342255332Scy# undef M_BCAST 343255332Scy# define M_BCAST 0x02 344255332Scy# undef M_MBCAST 345255332Scy# define M_MBCAST 0x04 346255332Scy# define MSGDSIZE(m) msgdsize(m) 347255332Scy# define M_LEN(m) (m)->mb_len 348255332Scy# define M_ADJ(m,x) (m)->mb_len += x 349255332Scy# define M_COPY(m) dupmbt(m) 350255332Scy# define M_DUP(m) dupmbt(m) 351145522Sdarrenr# define GETKTIME(x) gettimeofday((struct timeval *)(x), NULL) 352255332Scy# define MTOD(m, t) ((t)(m)->mb_data) 353255332Scy# define FREE_MB_T(m) freembt(m) 354255332Scy# define ALLOC_MB_T(m,l) (m) = allocmbt(l) 355255332Scy# define PREP_MB_T(f, m) do { \ 356255332Scy (m)->mb_next = *(f)->fin_mp; \ 357255332Scy *(fin)->fin_mp = (m); \ 358255332Scy (f)->fin_m = (m); \ 359255332Scy } while (0) 360145522Sdarrenr# define SLEEP(x,y) 1; 361145522Sdarrenr# define WAKEUP(x,y) ; 362161356Sguido# define POLLWAKEUP(y) ; 363145522Sdarrenr# define IPF_PANIC(x,y) ; 364145522Sdarrenr# define PANIC(x,y) ; 365170268Sdarrenr# define SPL_SCHED(x) ; 366145522Sdarrenr# define SPL_NET(x) ; 367145522Sdarrenr# define SPL_IMP(x) ; 368145522Sdarrenr# define SPL_X(x) ; 369145522Sdarrenr# define KMALLOC(a,b) (a) = (b)malloc(sizeof(*a)) 370145522Sdarrenr# define KMALLOCS(a,b,c) (a) = (b)malloc(c) 371145522Sdarrenr# define KFREE(x) free(x) 372145522Sdarrenr# define KFREES(x,s) free(x) 373145522Sdarrenr# define GETIFP(x, v) get_unit(x,v) 374255332Scy# define GETIFMTU_4(x) 2048 375255332Scy# define GETIFMTU_6(x) 2048 376153876Sguido# define COPYIN(a,b,c) bcopywrap((a), (b), (c)) 377153876Sguido# define COPYOUT(a,b,c) bcopywrap((a), (b), (c)) 378145522Sdarrenr# define COPYDATA(m, o, l, b) bcopy(MTOD((mb_t *)m, char *) + (o), \ 379145522Sdarrenr (b), (l)) 380145522Sdarrenr# define COPYBACK(m, o, l, b) bcopy((b), \ 381145522Sdarrenr MTOD((mb_t *)m, char *) + (o), \ 382145522Sdarrenr (l)) 383172776Sdarrenr# define UIOMOVE(a,b,c,d) ipfuiomove((caddr_t)a,b,c,d) 384145522Sdarrenrextern void m_copydata __P((mb_t *, int, int, caddr_t)); 385145522Sdarrenrextern int ipfuiomove __P((caddr_t, int, int, struct uio *)); 386153882Sguidoextern int bcopywrap __P((void *, void *, size_t)); 387255332Scyextern mb_t *allocmbt __P((size_t)); 388255332Scyextern mb_t *dupmbt __P((mb_t *)); 389255332Scyextern void freembt __P((mb_t *)); 390145522Sdarrenr 391255332Scy# define MUTEX_DESTROY(x) eMmutex_destroy(&(x)->ipf_emu, \ 392255332Scy __FILE__, __LINE__) 393145522Sdarrenr# define MUTEX_ENTER(x) eMmutex_enter(&(x)->ipf_emu, \ 394145522Sdarrenr __FILE__, __LINE__) 395255332Scy# define MUTEX_EXIT(x) eMmutex_exit(&(x)->ipf_emu, \ 396255332Scy __FILE__, __LINE__) 397255332Scy# define MUTEX_INIT(x,y) eMmutex_init(&(x)->ipf_emu, y, \ 398255332Scy __FILE__, __LINE__) 399145522Sdarrenr# define MUTEX_NUKE(x) bzero((x), sizeof(*(x))) 400145522Sdarrenr 401145522Sdarrenr# define MUTEX_DOWNGRADE(x) eMrwlock_downgrade(&(x)->ipf_emu, \ 402145522Sdarrenr __FILE__, __LINE__) 403145522Sdarrenr# define READ_ENTER(x) eMrwlock_read_enter(&(x)->ipf_emu, \ 404145522Sdarrenr __FILE__, __LINE__) 405145522Sdarrenr# define RWLOCK_INIT(x, y) eMrwlock_init(&(x)->ipf_emu, y) 406145522Sdarrenr# define RWLOCK_EXIT(x) eMrwlock_exit(&(x)->ipf_emu) 407145522Sdarrenr# define RW_DESTROY(x) eMrwlock_destroy(&(x)->ipf_emu) 408145522Sdarrenr# define WRITE_ENTER(x) eMrwlock_write_enter(&(x)->ipf_emu, \ 409145522Sdarrenr __FILE__, \ 410145522Sdarrenr __LINE__) 411145522Sdarrenr 412145522Sdarrenr# define USE_MUTEXES 1 413145522Sdarrenr 414255332Scyextern void eMmutex_destroy __P((eMmutex_t *, char *, int)); 415145522Sdarrenrextern void eMmutex_enter __P((eMmutex_t *, char *, int)); 416255332Scyextern void eMmutex_exit __P((eMmutex_t *, char *, int)); 417255332Scyextern void eMmutex_init __P((eMmutex_t *, char *, char *, int)); 418145522Sdarrenrextern void eMrwlock_destroy __P((eMrwlock_t *)); 419145522Sdarrenrextern void eMrwlock_exit __P((eMrwlock_t *)); 420145522Sdarrenrextern void eMrwlock_init __P((eMrwlock_t *, char *)); 421145522Sdarrenrextern void eMrwlock_read_enter __P((eMrwlock_t *, char *, int)); 422145522Sdarrenrextern void eMrwlock_write_enter __P((eMrwlock_t *, char *, int)); 423145522Sdarrenrextern void eMrwlock_downgrade __P((eMrwlock_t *, char *, int)); 424145522Sdarrenr 425145522Sdarrenr#endif 426145522Sdarrenr 427255332Scyextern mb_t *allocmbt(size_t); 428255332Scy 429145522Sdarrenr#define MAX_IPV4HDR ((0xf << 2) + sizeof(struct icmp) + sizeof(ip_t) + 8) 430145522Sdarrenr 431145522Sdarrenr#ifndef IP_OFFMASK 432145522Sdarrenr# define IP_OFFMASK 0x1fff 433145522Sdarrenr#endif 434145522Sdarrenr 435145522Sdarrenr 436145522Sdarrenr/* 437145522Sdarrenr * On BSD's use quad_t as a guarantee for getting at least a 64bit sized 438145522Sdarrenr * object. 439145522Sdarrenr */ 440255332Scy#if !defined(__amd64__) && BSD_GT_YEAR(199306) 441145522Sdarrenr# define USE_QUAD_T 442145640Sdarrenr# define U_QUAD_T unsigned long long 443145640Sdarrenr# define QUAD_T long long 444145522Sdarrenr#else /* BSD > 199306 */ 445255332Scy# if !defined(U_QUAD_T) 446255332Scy# define U_QUAD_T u_long 447255332Scy# define QUAD_T long 448255332Scy# endif 449145522Sdarrenr#endif /* BSD > 199306 */ 450145522Sdarrenr 451145522Sdarrenr 45260857Sdarrenr#ifdef USE_INET6 453145522Sdarrenr# if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || \ 454145522Sdarrenr defined(__osf__) || defined(linux) 45560857Sdarrenr# include <netinet/ip6.h> 456145522Sdarrenr# include <netinet/icmp6.h> 457145522Sdarrenr# if defined(_KERNEL) && !defined(__osf__) 458145522Sdarrenr# include <netinet6/ip6_var.h> 459145522Sdarrenr# endif 46060857Sdarrenrtypedef struct ip6_hdr ip6_t; 46160857Sdarrenr# endif 46260857Sdarrenr#endif 46360857Sdarrenr 46453642Sguido#ifndef MAX 465145522Sdarrenr# define MAX(a,b) (((a) > (b)) ? (a) : (b)) 46653642Sguido#endif 46753642Sguido 468145522Sdarrenr#if defined(_KERNEL) 469255332Scy# if defined(MENTAT) && !defined(INSTANCES) 470145522Sdarrenr# define COPYDATA mb_copydata 471145522Sdarrenr# define COPYBACK mb_copyback 472145522Sdarrenr# else 473145522Sdarrenr# define COPYDATA m_copydata 474145522Sdarrenr# define COPYBACK m_copyback 475145522Sdarrenr# endif 476145522Sdarrenr# if (defined(__NetBSD_Version__) && (__NetBSD_Version__ < 105180000)) || \ 477145522Sdarrenr defined(__FreeBSD__) || (defined(OpenBSD) && (OpenBSD < 200206)) || \ 478145522Sdarrenr defined(_BSDI_VERSION) 479145522Sdarrenr# include <vm/vm.h> 480145522Sdarrenr# endif 481255332Scy# if !defined(__FreeBSD__) || FREEBSD_GE_REV(300000) 482255332Scy# if NETBSD_GE_REV(105180000) || OPENBSD_GE_REV(200111) 483145522Sdarrenr# include <uvm/uvm_extern.h> 484145522Sdarrenr# else 485145522Sdarrenr# include <vm/vm_extern.h> 486145522Sdarrenrextern vm_map_t kmem_map; 487145522Sdarrenr# endif 488145522Sdarrenr# include <sys/proc.h> 489145522Sdarrenr# else /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD_version >= 300000) */ 490145522Sdarrenr# include <vm/vm_kern.h> 491145522Sdarrenr# endif /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD_version >= 300000) */ 492145522Sdarrenr 493145522Sdarrenr# ifdef IPFILTER_M_IPFILTER 494145522Sdarrenr# include <sys/malloc.h> 495145522SdarrenrMALLOC_DECLARE(M_IPFILTER); 496145522Sdarrenr# define _M_IPF M_IPFILTER 497145522Sdarrenr# else /* IPFILTER_M_IPFILTER */ 498145522Sdarrenr# ifdef M_PFIL 499145522Sdarrenr# define _M_IPF M_PFIL 500145522Sdarrenr# else 501145522Sdarrenr# ifdef M_IPFILTER 502145522Sdarrenr# define _M_IPF M_IPFILTER 503145522Sdarrenr# else 504145522Sdarrenr# define _M_IPF M_TEMP 505145522Sdarrenr# endif /* M_IPFILTER */ 506145522Sdarrenr# endif /* M_PFIL */ 507145522Sdarrenr# endif /* IPFILTER_M_IPFILTER */ 508255332Scy# if !defined(KMALLOC) 509184205Sdes# define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), _M_IPF, M_NOWAIT) 510255332Scy# endif 511255332Scy# if !defined(KMALLOCS) 512255332Scy# define KMALLOCS(a, b, c) MALLOC((a), b, (c), _M_IPF, M_NOWAIT) 513255332Scy# endif 514255332Scy# if !defined(KFREE) 515184205Sdes# define KFREE(x) FREE((x), _M_IPF) 516170268Sdarrenr# endif 517255332Scy# if !defined(KFREES) 518255332Scy# define KFREES(x,s) FREE((x), _M_IPF) 519255332Scy# endif 520172776Sdarrenr# define UIOMOVE(a,b,c,d) uiomove((caddr_t)a,b,d) 521145522Sdarrenr# define SLEEP(id, n) tsleep((id), PPAUSE|PCATCH, n, 0) 522145522Sdarrenr# define WAKEUP(id,x) wakeup(id+x) 523255332Scy# if !defined(POLLWAKEUP) 524255332Scy# define POLLWAKEUP(x) selwakeup(softc->ipf_selwait+x) 525255332Scy# endif 526145522Sdarrenr# define GETIFP(n, v) ifunit(n) 527255332Scy# define GETIFMTU_4(x) ((struct ifnet *)x)->if_mtu 528255332Scy# define GETIFMTU_6(x) ((struct ifnet *)x)->if_mtu 529145522Sdarrenr 530145522Sdarrenr# if !defined(USE_MUTEXES) && !defined(SPL_NET) 531255754Scy# define SPL_IMP(x) x = splimp() 532255754Scy# define SPL_NET(x) x = splnet() 533172776Sdarrenr# if !defined(SPL_SCHED) 534172776Sdarrenr# define SPL_SCHED(x) x = splsched() 535172776Sdarrenr# endif 536145522Sdarrenr# define SPL_X(x) (void) splx(x) 537145522Sdarrenr# endif /* !USE_MUTEXES */ 538145522Sdarrenr 539145522Sdarrenr# ifndef FREE_MB_T 540145522Sdarrenr# define FREE_MB_T(m) m_freem(m) 541145522Sdarrenr# endif 542255332Scy# ifndef ALLOC_MB_T 543255332Scy# ifdef MGETHDR 544255332Scy# define ALLOC_MB_T(m,l) do { \ 545255332Scy MGETHDR((m), M_DONTWAIT, MT_HEADER); \ 546255332Scy if ((m) != NULL) { \ 547255332Scy (m)->m_len = (l); \ 548255332Scy (m)->m_pkthdr.len = (l); \ 549255332Scy } \ 550255332Scy } while (0) 551255332Scy# else 552255332Scy# define ALLOC_MB_T(m,l) do { \ 553255332Scy MGET((m), M_DONTWAIT, MT_HEADER); \ 554255332Scy if ((m) != NULL) { \ 555255332Scy (m)->m_len = (l); \ 556255332Scy (m)->m_pkthdr.len = (l); \ 557255332Scy } \ 558255332Scy } while (0) 559255332Scy# endif 560255332Scy# endif 561255332Scy# ifndef PREP_MB_T 562255332Scy# define PREP_MB_T(f, m) do { \ 563255332Scy mb_t *_o = *(f)->fin_mp; \ 564255332Scy (m)->m_next = _o; \ 565255332Scy *(fin)->fin_mp = (m); \ 566255332Scy if (_o->m_flags & M_PKTHDR) { \ 567255332Scy (m)->m_pkthdr.len += \ 568255332Scy _o->m_pkthdr.len; \ 569255332Scy (m)->m_pkthdr.rcvif = \ 570255332Scy _o->m_pkthdr.rcvif; \ 571255332Scy } \ 572255332Scy } while (0) 573255332Scy# endif 574255332Scy# ifndef M_DUP 575255332Scy# ifdef M_COPYALL 576255332Scy# define M_DUP(m) m_dup(m, 0, M_COPYALL, 0) 577255332Scy# else 578255332Scy# define M_DUP(m) m_dup(m) 579255332Scy# endif 580255332Scy# endif 581145522Sdarrenr 582145522Sdarrenr# ifndef MTOD 583145522Sdarrenr# define MTOD(m,t) mtod(m,t) 584145522Sdarrenr# endif 585145522Sdarrenr 586145522Sdarrenr# ifndef COPYIN 587145522Sdarrenr# define COPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) 588145522Sdarrenr# define COPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) 589145522Sdarrenr# endif 590145522Sdarrenr 591145522Sdarrenr# ifndef KMALLOC 592145522Sdarrenr# define KMALLOC(a,b) (a) = (b)new_kmem_alloc(sizeof(*(a)), \ 593145522Sdarrenr KMEM_NOSLEEP) 594145522Sdarrenr# define KMALLOCS(a,b,c) (a) = (b)new_kmem_alloc((c), KMEM_NOSLEEP) 595145522Sdarrenr# endif 596145522Sdarrenr 597145522Sdarrenr# ifndef GET_MINOR 598183397Sed# define GET_MINOR(x) dev2unit(x) 599145522Sdarrenr# endif 600145522Sdarrenr# define PANIC(x,y) if (x) panic y 601145522Sdarrenr#endif /* _KERNEL */ 602145522Sdarrenr 603172776Sdarrenr#if !defined(IFNAME) && !defined(_KERNEL) 604255332Scy# define IFNAME(x) get_ifname((struct ifnet *)x) 605145522Sdarrenr#endif 606145522Sdarrenr#ifndef COPYIFNAME 607145522Sdarrenr# define NEED_FRGETIFNAME 608255332Scyextern char *ipf_getifname __P((struct ifnet *, char *)); 609172776Sdarrenr# define COPYIFNAME(v, x, b) \ 610255332Scy ipf_getifname((struct ifnet *)x, b) 611145522Sdarrenr#endif 612145522Sdarrenr 613145522Sdarrenr#ifndef ASSERT 614172776Sdarrenr# ifdef _KERNEL 615172776Sdarrenr# define ASSERT(x) 616172776Sdarrenr# else 617172776Sdarrenr# define ASSERT(x) do { if (!(x)) abort(); } while (0) 618172776Sdarrenr# endif 619145522Sdarrenr#endif 620145522Sdarrenr 621170268Sdarrenr#ifndef BCOPYIN 622170268Sdarrenr# define BCOPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) 623170268Sdarrenr# define BCOPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) 624170268Sdarrenr#endif 625170268Sdarrenr 62653642Sguido/* 627145522Sdarrenr * Because the ctype(3) posix definition, if used "safely" in code everywhere, 628145522Sdarrenr * would mean all normal code that walks through strings needed casts. Yuck. 629145522Sdarrenr */ 630145522Sdarrenr#define ISALNUM(x) isalnum((u_char)(x)) 631145522Sdarrenr#define ISALPHA(x) isalpha((u_char)(x)) 632145522Sdarrenr#define ISDIGIT(x) isdigit((u_char)(x)) 633145522Sdarrenr#define ISSPACE(x) isspace((u_char)(x)) 634145522Sdarrenr#define ISUPPER(x) isupper((u_char)(x)) 635145522Sdarrenr#define ISXDIGIT(x) isxdigit((u_char)(x)) 636145522Sdarrenr#define ISLOWER(x) islower((u_char)(x)) 637145522Sdarrenr#define TOUPPER(x) toupper((u_char)(x)) 638145522Sdarrenr#define TOLOWER(x) tolower((u_char)(x)) 639145522Sdarrenr 640145522Sdarrenr/* 641145522Sdarrenr * If mutexes aren't being used, turn all the mutex functions into null-ops. 642145522Sdarrenr */ 643145522Sdarrenr#if !defined(USE_MUTEXES) 644145522Sdarrenr# define USE_SPL 1 645145522Sdarrenr# undef RW_DESTROY 646145522Sdarrenr# undef MUTEX_INIT 647145522Sdarrenr# undef MUTEX_NUKE 648145522Sdarrenr# undef MUTEX_DESTROY 649145522Sdarrenr# define MUTEX_ENTER(x) ; 650145522Sdarrenr# define READ_ENTER(x) ; 651145522Sdarrenr# define WRITE_ENTER(x) ; 652145522Sdarrenr# define MUTEX_DOWNGRADE(x) ; 653145522Sdarrenr# define RWLOCK_INIT(x, y) ; 654145522Sdarrenr# define RWLOCK_EXIT(x) ; 655145522Sdarrenr# define RW_DESTROY(x) ; 656145522Sdarrenr# define MUTEX_EXIT(x) ; 657145522Sdarrenr# define MUTEX_INIT(x,y) ; 658145522Sdarrenr# define MUTEX_DESTROY(x) ; 659145522Sdarrenr# define MUTEX_NUKE(x) ; 660145522Sdarrenr#endif /* !USE_MUTEXES */ 661145522Sdarrenr#ifndef ATOMIC_INC 662145522Sdarrenr# define ATOMIC_INC(x) (x)++ 663145522Sdarrenr# define ATOMIC_DEC(x) (x)-- 664145522Sdarrenr#endif 665145522Sdarrenr 666153876Sguido#if defined(USE_SPL) && defined(_KERNEL) 667153876Sguido# define SPL_INT(x) int x 668153876Sguido#else 669153876Sguido# define SPL_INT(x) 670153876Sguido#endif 671153876Sguido 672145522Sdarrenr/* 673145522Sdarrenr * If there are no atomic operations for bit sizes defined, define them to all 674145522Sdarrenr * use a generic one that works for all sizes. 675145522Sdarrenr */ 676145522Sdarrenr#ifndef ATOMIC_INCL 677145522Sdarrenr# define ATOMIC_INCL ATOMIC_INC 678145522Sdarrenr# define ATOMIC_INC64 ATOMIC_INC 679145522Sdarrenr# define ATOMIC_INC32 ATOMIC_INC 680145522Sdarrenr# define ATOMIC_DECL ATOMIC_DEC 681145522Sdarrenr# define ATOMIC_DEC64 ATOMIC_DEC 682145522Sdarrenr# define ATOMIC_DEC32 ATOMIC_DEC 683145522Sdarrenr#endif 684145522Sdarrenr 685145522Sdarrenr#ifndef HDR_T_PRIVATE 686145522Sdarrenrtypedef struct tcphdr tcphdr_t; 687145522Sdarrenrtypedef struct udphdr udphdr_t; 688145522Sdarrenr#endif 689145522Sdarrenrtypedef struct icmp icmphdr_t; 690145522Sdarrenrtypedef struct ip ip_t; 691145522Sdarrenrtypedef struct ether_header ether_header_t; 692145522Sdarrenrtypedef struct tcpiphdr tcpiphdr_t; 693145522Sdarrenr 694145522Sdarrenr#ifndef FR_GROUPLEN 695145522Sdarrenr# define FR_GROUPLEN 16 696145522Sdarrenr#endif 697145522Sdarrenr 698145522Sdarrenr#ifndef offsetof 699255332Scy# define offsetof(t,m) (size_t)((&((t *)0L)->m)) 700145522Sdarrenr#endif 701255332Scy#ifndef stsizeof 702255332Scy# define stsizeof(t,m) sizeof(((t *)0L)->m) 703255332Scy#endif 704145522Sdarrenr 705145522Sdarrenr/* 706145522Sdarrenr * This set of macros has been brought about because on Tru64 it is not 707145522Sdarrenr * possible to easily assign or examine values in a structure that are 708145522Sdarrenr * bit fields. 709145522Sdarrenr */ 710145522Sdarrenr#ifndef IP_V 711145522Sdarrenr# define IP_V(x) (x)->ip_v 712145522Sdarrenr#endif 713145522Sdarrenr#ifndef IP_V_A 714145522Sdarrenr# define IP_V_A(x,y) (x)->ip_v = (y) 715145522Sdarrenr#endif 716145522Sdarrenr#ifndef IP_HL 717145522Sdarrenr# define IP_HL(x) (x)->ip_hl 718145522Sdarrenr#endif 719145522Sdarrenr#ifndef IP_HL_A 720170268Sdarrenr# define IP_HL_A(x,y) (x)->ip_hl = ((y) & 0xf) 721145522Sdarrenr#endif 722145522Sdarrenr#ifndef TCP_X2 723145522Sdarrenr# define TCP_X2(x) (x)->th_x2 724145522Sdarrenr#endif 725145522Sdarrenr#ifndef TCP_X2_A 726145522Sdarrenr# define TCP_X2_A(x,y) (x)->th_x2 = (y) 727145522Sdarrenr#endif 728145522Sdarrenr#ifndef TCP_OFF 729145522Sdarrenr# define TCP_OFF(x) (x)->th_off 730145522Sdarrenr#endif 731145522Sdarrenr#ifndef TCP_OFF_A 732145522Sdarrenr# define TCP_OFF_A(x,y) (x)->th_off = (y) 733145522Sdarrenr#endif 734145522Sdarrenr#define IPMINLEN(i, h) ((i)->ip_len >= (IP_HL(i) * 4 + sizeof(struct h))) 735145522Sdarrenr 736145522Sdarrenr 737145522Sdarrenr/* 738145522Sdarrenr * XXX - This is one of those *awful* hacks which nobody likes 739145522Sdarrenr */ 740145522Sdarrenr#ifdef ultrix 741145522Sdarrenr#define A_A 742145522Sdarrenr#else 743145522Sdarrenr#define A_A & 744145522Sdarrenr#endif 745145522Sdarrenr 746145522Sdarrenr#define TCPF_ALL (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|\ 747145522Sdarrenr TH_ECN|TH_CWR) 748145522Sdarrenr 749255332Scy#if BSD_GE_YEAR(199306) && !defined(m_act) 750145522Sdarrenr# define m_act m_nextpkt 751255332Scy#endif 752145522Sdarrenr 753145522Sdarrenr/* 75453642Sguido * Security Options for Intenet Protocol (IPSO) as defined in RFC 1108. 75553642Sguido * 75653642Sguido * Basic Option 75753642Sguido * 75853642Sguido * 00000001 - (Reserved 4) 75953642Sguido * 00111101 - Top Secret 76053642Sguido * 01011010 - Secret 76153642Sguido * 10010110 - Confidential 76253642Sguido * 01100110 - (Reserved 3) 76353642Sguido * 11001100 - (Reserved 2) 76453642Sguido * 10101011 - Unclassified 76553642Sguido * 11110001 - (Reserved 1) 76653642Sguido */ 76753642Sguido#define IPSO_CLASS_RES4 0x01 76853642Sguido#define IPSO_CLASS_TOPS 0x3d 76953642Sguido#define IPSO_CLASS_SECR 0x5a 77053642Sguido#define IPSO_CLASS_CONF 0x96 77153642Sguido#define IPSO_CLASS_RES3 0x66 77253642Sguido#define IPSO_CLASS_RES2 0xcc 77353642Sguido#define IPSO_CLASS_UNCL 0xab 77453642Sguido#define IPSO_CLASS_RES1 0xf1 77553642Sguido 77653642Sguido#define IPSO_AUTH_GENSER 0x80 77753642Sguido#define IPSO_AUTH_ESI 0x40 77853642Sguido#define IPSO_AUTH_SCI 0x20 77953642Sguido#define IPSO_AUTH_NSA 0x10 78053642Sguido#define IPSO_AUTH_DOE 0x08 78153642Sguido#define IPSO_AUTH_UN 0x06 78253642Sguido#define IPSO_AUTH_FTE 0x01 78353642Sguido 78453642Sguido/* 78553642Sguido * IP option #defines 78653642Sguido */ 787145522Sdarrenr#undef IPOPT_RR 788255332Scy#define IPOPT_RR 7 789145522Sdarrenr#undef IPOPT_ZSU 79053642Sguido#define IPOPT_ZSU 10 /* ZSU */ 791145522Sdarrenr#undef IPOPT_MTUP 79253642Sguido#define IPOPT_MTUP 11 /* MTUP */ 793145522Sdarrenr#undef IPOPT_MTUR 79453642Sguido#define IPOPT_MTUR 12 /* MTUR */ 795145522Sdarrenr#undef IPOPT_ENCODE 79653642Sguido#define IPOPT_ENCODE 15 /* ENCODE */ 797145522Sdarrenr#undef IPOPT_TS 798145522Sdarrenr#define IPOPT_TS 68 799145522Sdarrenr#undef IPOPT_TR 80053642Sguido#define IPOPT_TR 82 /* TR */ 801145522Sdarrenr#undef IPOPT_SECURITY 802145522Sdarrenr#define IPOPT_SECURITY 130 803145522Sdarrenr#undef IPOPT_LSRR 804145522Sdarrenr#define IPOPT_LSRR 131 805145522Sdarrenr#undef IPOPT_E_SEC 80653642Sguido#define IPOPT_E_SEC 133 /* E-SEC */ 807145522Sdarrenr#undef IPOPT_CIPSO 80853642Sguido#define IPOPT_CIPSO 134 /* CIPSO */ 809145522Sdarrenr#undef IPOPT_SATID 810145522Sdarrenr#define IPOPT_SATID 136 81153642Sguido#ifndef IPOPT_SID 81253642Sguido# define IPOPT_SID IPOPT_SATID 81353642Sguido#endif 814145522Sdarrenr#undef IPOPT_SSRR 815145522Sdarrenr#define IPOPT_SSRR 137 816145522Sdarrenr#undef IPOPT_ADDEXT 81753642Sguido#define IPOPT_ADDEXT 147 /* ADDEXT */ 818145522Sdarrenr#undef IPOPT_VISA 81953642Sguido#define IPOPT_VISA 142 /* VISA */ 820145522Sdarrenr#undef IPOPT_IMITD 82153642Sguido#define IPOPT_IMITD 144 /* IMITD */ 822145522Sdarrenr#undef IPOPT_EIP 82353642Sguido#define IPOPT_EIP 145 /* EIP */ 824145522Sdarrenr#undef IPOPT_RTRALRT 825145522Sdarrenr#define IPOPT_RTRALRT 148 /* RTRALRT */ 826145522Sdarrenr#undef IPOPT_SDB 827145522Sdarrenr#define IPOPT_SDB 149 828145522Sdarrenr#undef IPOPT_NSAPA 829145522Sdarrenr#define IPOPT_NSAPA 150 830145522Sdarrenr#undef IPOPT_DPS 831145522Sdarrenr#define IPOPT_DPS 151 832145522Sdarrenr#undef IPOPT_UMP 833145522Sdarrenr#define IPOPT_UMP 152 834145522Sdarrenr#undef IPOPT_FINN 83553642Sguido#define IPOPT_FINN 205 /* FINN */ 836255332Scy#undef IPOPT_AH 837255332Scy#define IPOPT_AH 256+IPPROTO_AH 83853642Sguido 839145522Sdarrenr#ifndef TCPOPT_EOL 840145522Sdarrenr# define TCPOPT_EOL 0 84195418Sdarrenr#endif 842145522Sdarrenr#ifndef TCPOPT_NOP 843145522Sdarrenr# define TCPOPT_NOP 1 84460857Sdarrenr#endif 845145522Sdarrenr#ifndef TCPOPT_MAXSEG 846145522Sdarrenr# define TCPOPT_MAXSEG 2 84767614Sdarrenr#endif 848145522Sdarrenr#ifndef TCPOLEN_MAXSEG 849145522Sdarrenr# define TCPOLEN_MAXSEG 4 850139255Sdarrenr#endif 851145522Sdarrenr#ifndef TCPOPT_WINDOW 852145522Sdarrenr# define TCPOPT_WINDOW 3 853145522Sdarrenr#endif 854145522Sdarrenr#ifndef TCPOLEN_WINDOW 855145522Sdarrenr# define TCPOLEN_WINDOW 3 856145522Sdarrenr#endif 857145522Sdarrenr#ifndef TCPOPT_SACK_PERMITTED 858145522Sdarrenr# define TCPOPT_SACK_PERMITTED 4 859145522Sdarrenr#endif 860145522Sdarrenr#ifndef TCPOLEN_SACK_PERMITTED 861145522Sdarrenr# define TCPOLEN_SACK_PERMITTED 2 862145522Sdarrenr#endif 863145522Sdarrenr#ifndef TCPOPT_SACK 864145522Sdarrenr# define TCPOPT_SACK 5 865145522Sdarrenr#endif 866145522Sdarrenr#ifndef TCPOPT_TIMESTAMP 867145522Sdarrenr# define TCPOPT_TIMESTAMP 8 868145522Sdarrenr#endif 86953642Sguido 87053642Sguido#ifndef ICMP_MINLEN 87153642Sguido# define ICMP_MINLEN 8 87253642Sguido#endif 87392685Sdarrenr#ifndef ICMP_ECHOREPLY 87492685Sdarrenr# define ICMP_ECHOREPLY 0 87592685Sdarrenr#endif 87653642Sguido#ifndef ICMP_UNREACH 87792685Sdarrenr# define ICMP_UNREACH 3 87853642Sguido#endif 87992685Sdarrenr#ifndef ICMP_UNREACH_NET 88092685Sdarrenr# define ICMP_UNREACH_NET 0 88192685Sdarrenr#endif 88292685Sdarrenr#ifndef ICMP_UNREACH_HOST 88392685Sdarrenr# define ICMP_UNREACH_HOST 1 88492685Sdarrenr#endif 88592685Sdarrenr#ifndef ICMP_UNREACH_PROTOCOL 88692685Sdarrenr# define ICMP_UNREACH_PROTOCOL 2 88792685Sdarrenr#endif 88892685Sdarrenr#ifndef ICMP_UNREACH_PORT 88992685Sdarrenr# define ICMP_UNREACH_PORT 3 89092685Sdarrenr#endif 89192685Sdarrenr#ifndef ICMP_UNREACH_NEEDFRAG 89292685Sdarrenr# define ICMP_UNREACH_NEEDFRAG 4 89392685Sdarrenr#endif 89492685Sdarrenr#ifndef ICMP_UNREACH_SRCFAIL 89592685Sdarrenr# define ICMP_UNREACH_SRCFAIL 5 89692685Sdarrenr#endif 89792685Sdarrenr#ifndef ICMP_UNREACH_NET_UNKNOWN 89892685Sdarrenr# define ICMP_UNREACH_NET_UNKNOWN 6 89992685Sdarrenr#endif 90092685Sdarrenr#ifndef ICMP_UNREACH_HOST_UNKNOWN 90192685Sdarrenr# define ICMP_UNREACH_HOST_UNKNOWN 7 90292685Sdarrenr#endif 90392685Sdarrenr#ifndef ICMP_UNREACH_ISOLATED 90492685Sdarrenr# define ICMP_UNREACH_ISOLATED 8 90592685Sdarrenr#endif 90692685Sdarrenr#ifndef ICMP_UNREACH_NET_PROHIB 90792685Sdarrenr# define ICMP_UNREACH_NET_PROHIB 9 90892685Sdarrenr#endif 90992685Sdarrenr#ifndef ICMP_UNREACH_HOST_PROHIB 91092685Sdarrenr# define ICMP_UNREACH_HOST_PROHIB 10 91192685Sdarrenr#endif 91292685Sdarrenr#ifndef ICMP_UNREACH_TOSNET 91392685Sdarrenr# define ICMP_UNREACH_TOSNET 11 91492685Sdarrenr#endif 91592685Sdarrenr#ifndef ICMP_UNREACH_TOSHOST 91692685Sdarrenr# define ICMP_UNREACH_TOSHOST 12 91792685Sdarrenr#endif 91892685Sdarrenr#ifndef ICMP_UNREACH_ADMIN_PROHIBIT 91992685Sdarrenr# define ICMP_UNREACH_ADMIN_PROHIBIT 13 92092685Sdarrenr#endif 921145522Sdarrenr#ifndef ICMP_UNREACH_FILTER 922145522Sdarrenr# define ICMP_UNREACH_FILTER 13 923145522Sdarrenr#endif 92492685Sdarrenr#ifndef ICMP_UNREACH_HOST_PRECEDENCE 92592685Sdarrenr# define ICMP_UNREACH_HOST_PRECEDENCE 14 92692685Sdarrenr#endif 92792685Sdarrenr#ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF 92892685Sdarrenr# define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 92992685Sdarrenr#endif 93053642Sguido#ifndef ICMP_SOURCEQUENCH 93192685Sdarrenr# define ICMP_SOURCEQUENCH 4 93253642Sguido#endif 93392685Sdarrenr#ifndef ICMP_REDIRECT_NET 93492685Sdarrenr# define ICMP_REDIRECT_NET 0 93592685Sdarrenr#endif 93692685Sdarrenr#ifndef ICMP_REDIRECT_HOST 93792685Sdarrenr# define ICMP_REDIRECT_HOST 1 93892685Sdarrenr#endif 93992685Sdarrenr#ifndef ICMP_REDIRECT_TOSNET 94092685Sdarrenr# define ICMP_REDIRECT_TOSNET 2 94192685Sdarrenr#endif 94292685Sdarrenr#ifndef ICMP_REDIRECT_TOSHOST 94392685Sdarrenr# define ICMP_REDIRECT_TOSHOST 3 94492685Sdarrenr#endif 94592685Sdarrenr#ifndef ICMP_ALTHOSTADDR 94692685Sdarrenr# define ICMP_ALTHOSTADDR 6 94792685Sdarrenr#endif 94853642Sguido#ifndef ICMP_TIMXCEED 94992685Sdarrenr# define ICMP_TIMXCEED 11 95053642Sguido#endif 95192685Sdarrenr#ifndef ICMP_TIMXCEED_INTRANS 95292685Sdarrenr# define ICMP_TIMXCEED_INTRANS 0 95392685Sdarrenr#endif 95492685Sdarrenr#ifndef ICMP_TIMXCEED_REASS 95592685Sdarrenr# define ICMP_TIMXCEED_REASS 1 95692685Sdarrenr#endif 95753642Sguido#ifndef ICMP_PARAMPROB 95892685Sdarrenr# define ICMP_PARAMPROB 12 95953642Sguido#endif 96092685Sdarrenr#ifndef ICMP_PARAMPROB_ERRATPTR 96192685Sdarrenr# define ICMP_PARAMPROB_ERRATPTR 0 96292685Sdarrenr#endif 96392685Sdarrenr#ifndef ICMP_PARAMPROB_OPTABSENT 96492685Sdarrenr# define ICMP_PARAMPROB_OPTABSENT 1 96592685Sdarrenr#endif 96692685Sdarrenr#ifndef ICMP_PARAMPROB_LENGTH 96792685Sdarrenr# define ICMP_PARAMPROB_LENGTH 2 96892685Sdarrenr#endif 96953642Sguido#ifndef ICMP_TSTAMP 97092685Sdarrenr# define ICMP_TSTAMP 13 97153642Sguido#endif 97253642Sguido#ifndef ICMP_TSTAMPREPLY 97392685Sdarrenr# define ICMP_TSTAMPREPLY 14 97453642Sguido#endif 97553642Sguido#ifndef ICMP_IREQ 97692685Sdarrenr# define ICMP_IREQ 15 97753642Sguido#endif 97853642Sguido#ifndef ICMP_IREQREPLY 97992685Sdarrenr# define ICMP_IREQREPLY 16 98053642Sguido#endif 98153642Sguido#ifndef ICMP_MASKREQ 98292685Sdarrenr# define ICMP_MASKREQ 17 98353642Sguido#endif 98453642Sguido#ifndef ICMP_MASKREPLY 98592685Sdarrenr# define ICMP_MASKREPLY 18 98653642Sguido#endif 98792685Sdarrenr#ifndef ICMP_TRACEROUTE 98892685Sdarrenr# define ICMP_TRACEROUTE 30 98980482Sdarrenr#endif 99092685Sdarrenr#ifndef ICMP_DATACONVERR 99192685Sdarrenr# define ICMP_DATACONVERR 31 99292685Sdarrenr#endif 99392685Sdarrenr#ifndef ICMP_MOBILE_REDIRECT 99492685Sdarrenr# define ICMP_MOBILE_REDIRECT 32 99592685Sdarrenr#endif 99692685Sdarrenr#ifndef ICMP_IPV6_WHEREAREYOU 99792685Sdarrenr# define ICMP_IPV6_WHEREAREYOU 33 99892685Sdarrenr#endif 99992685Sdarrenr#ifndef ICMP_IPV6_IAMHERE 100092685Sdarrenr# define ICMP_IPV6_IAMHERE 34 100192685Sdarrenr#endif 100292685Sdarrenr#ifndef ICMP_MOBILE_REGREQUEST 100392685Sdarrenr# define ICMP_MOBILE_REGREQUEST 35 100492685Sdarrenr#endif 100592685Sdarrenr#ifndef ICMP_MOBILE_REGREPLY 100692685Sdarrenr# define ICMP_MOBILE_REGREPLY 36 100792685Sdarrenr#endif 100892685Sdarrenr#ifndef ICMP_SKIP 100992685Sdarrenr# define ICMP_SKIP 39 101092685Sdarrenr#endif 101192685Sdarrenr#ifndef ICMP_PHOTURIS 101292685Sdarrenr# define ICMP_PHOTURIS 40 101392685Sdarrenr#endif 101492685Sdarrenr#ifndef ICMP_PHOTURIS_UNKNOWN_INDEX 101592685Sdarrenr# define ICMP_PHOTURIS_UNKNOWN_INDEX 1 101692685Sdarrenr#endif 101792685Sdarrenr#ifndef ICMP_PHOTURIS_AUTH_FAILED 101892685Sdarrenr# define ICMP_PHOTURIS_AUTH_FAILED 2 101992685Sdarrenr#endif 102092685Sdarrenr#ifndef ICMP_PHOTURIS_DECRYPT_FAILED 102192685Sdarrenr# define ICMP_PHOTURIS_DECRYPT_FAILED 3 102292685Sdarrenr#endif 102353642Sguido#ifndef IPVERSION 102453642Sguido# define IPVERSION 4 102553642Sguido#endif 102653642Sguido#ifndef IPOPT_MINOFF 102753642Sguido# define IPOPT_MINOFF 4 102853642Sguido#endif 102953642Sguido#ifndef IPOPT_COPIED 103053642Sguido# define IPOPT_COPIED(x) ((x)&0x80) 103153642Sguido#endif 103253642Sguido#ifndef IPOPT_EOL 103353642Sguido# define IPOPT_EOL 0 103453642Sguido#endif 103553642Sguido#ifndef IPOPT_NOP 103653642Sguido# define IPOPT_NOP 1 103753642Sguido#endif 103853642Sguido#ifndef IP_MF 103953642Sguido# define IP_MF ((u_short)0x2000) 104053642Sguido#endif 104153642Sguido#ifndef ETHERTYPE_IP 104253642Sguido# define ETHERTYPE_IP ((u_short)0x0800) 104353642Sguido#endif 104453642Sguido#ifndef TH_FIN 104553642Sguido# define TH_FIN 0x01 104653642Sguido#endif 104753642Sguido#ifndef TH_SYN 104853642Sguido# define TH_SYN 0x02 104953642Sguido#endif 105053642Sguido#ifndef TH_RST 105153642Sguido# define TH_RST 0x04 105253642Sguido#endif 105353642Sguido#ifndef TH_PUSH 105453642Sguido# define TH_PUSH 0x08 105553642Sguido#endif 105653642Sguido#ifndef TH_ACK 105753642Sguido# define TH_ACK 0x10 105853642Sguido#endif 105953642Sguido#ifndef TH_URG 106053642Sguido# define TH_URG 0x20 106153642Sguido#endif 1062145522Sdarrenr#undef TH_ACKMASK 1063145522Sdarrenr#define TH_ACKMASK (TH_FIN|TH_SYN|TH_RST|TH_ACK) 1064145522Sdarrenr 106553642Sguido#ifndef IPOPT_EOL 106653642Sguido# define IPOPT_EOL 0 106753642Sguido#endif 106853642Sguido#ifndef IPOPT_NOP 106953642Sguido# define IPOPT_NOP 1 107053642Sguido#endif 107153642Sguido#ifndef IPOPT_RR 107253642Sguido# define IPOPT_RR 7 107353642Sguido#endif 107453642Sguido#ifndef IPOPT_TS 107553642Sguido# define IPOPT_TS 68 107653642Sguido#endif 107753642Sguido#ifndef IPOPT_SECURITY 107853642Sguido# define IPOPT_SECURITY 130 107953642Sguido#endif 108053642Sguido#ifndef IPOPT_LSRR 108153642Sguido# define IPOPT_LSRR 131 108253642Sguido#endif 108353642Sguido#ifndef IPOPT_SATID 108453642Sguido# define IPOPT_SATID 136 108553642Sguido#endif 108653642Sguido#ifndef IPOPT_SSRR 108753642Sguido# define IPOPT_SSRR 137 108853642Sguido#endif 108953642Sguido#ifndef IPOPT_SECUR_UNCLASS 109053642Sguido# define IPOPT_SECUR_UNCLASS ((u_short)0x0000) 109153642Sguido#endif 109253642Sguido#ifndef IPOPT_SECUR_CONFID 109353642Sguido# define IPOPT_SECUR_CONFID ((u_short)0xf135) 109453642Sguido#endif 109553642Sguido#ifndef IPOPT_SECUR_EFTO 109653642Sguido# define IPOPT_SECUR_EFTO ((u_short)0x789a) 109753642Sguido#endif 109853642Sguido#ifndef IPOPT_SECUR_MMMM 109953642Sguido# define IPOPT_SECUR_MMMM ((u_short)0xbc4d) 110053642Sguido#endif 110153642Sguido#ifndef IPOPT_SECUR_RESTR 110253642Sguido# define IPOPT_SECUR_RESTR ((u_short)0xaf13) 110353642Sguido#endif 110453642Sguido#ifndef IPOPT_SECUR_SECRET 110553642Sguido# define IPOPT_SECUR_SECRET ((u_short)0xd788) 110653642Sguido#endif 110753642Sguido#ifndef IPOPT_SECUR_TOPSECRET 110853642Sguido# define IPOPT_SECUR_TOPSECRET ((u_short)0x6bc5) 110953642Sguido#endif 111053642Sguido#ifndef IPOPT_OLEN 111153642Sguido# define IPOPT_OLEN 1 111253642Sguido#endif 1113145522Sdarrenr#ifndef IPPROTO_HOPOPTS 1114145522Sdarrenr# define IPPROTO_HOPOPTS 0 1115145522Sdarrenr#endif 1116255332Scy#ifndef IPPROTO_IPIP 1117255332Scy# define IPPROTO_IPIP 4 1118255332Scy#endif 1119145522Sdarrenr#ifndef IPPROTO_ENCAP 1120255332Scy# define IPPROTO_ENCAP 98 1121145522Sdarrenr#endif 1122145522Sdarrenr#ifndef IPPROTO_IPV6 1123145522Sdarrenr# define IPPROTO_IPV6 41 1124145522Sdarrenr#endif 1125145522Sdarrenr#ifndef IPPROTO_ROUTING 1126145522Sdarrenr# define IPPROTO_ROUTING 43 1127145522Sdarrenr#endif 1128145522Sdarrenr#ifndef IPPROTO_FRAGMENT 1129145522Sdarrenr# define IPPROTO_FRAGMENT 44 1130145522Sdarrenr#endif 113192685Sdarrenr#ifndef IPPROTO_GRE 113292685Sdarrenr# define IPPROTO_GRE 47 /* GRE encaps RFC 1701 */ 113392685Sdarrenr#endif 113492685Sdarrenr#ifndef IPPROTO_ESP 113592685Sdarrenr# define IPPROTO_ESP 50 113692685Sdarrenr#endif 1137145522Sdarrenr#ifndef IPPROTO_AH 1138145522Sdarrenr# define IPPROTO_AH 51 1139145522Sdarrenr#endif 114092685Sdarrenr#ifndef IPPROTO_ICMPV6 114192685Sdarrenr# define IPPROTO_ICMPV6 58 114292685Sdarrenr#endif 1143145522Sdarrenr#ifndef IPPROTO_NONE 1144145522Sdarrenr# define IPPROTO_NONE 59 114553642Sguido#endif 1146145522Sdarrenr#ifndef IPPROTO_DSTOPTS 1147145522Sdarrenr# define IPPROTO_DSTOPTS 60 114853642Sguido#endif 1149153876Sguido#ifndef IPPROTO_MOBILITY 1150153876Sguido# define IPPROTO_MOBILITY 135 115153642Sguido#endif 1152153876Sguido 115353642Sguido#ifndef ICMP_ROUTERADVERT 115453642Sguido# define ICMP_ROUTERADVERT 9 115553642Sguido#endif 115653642Sguido#ifndef ICMP_ROUTERSOLICIT 115753642Sguido# define ICMP_ROUTERSOLICIT 10 115853642Sguido#endif 115992685Sdarrenr#ifndef ICMP6_DST_UNREACH 116092685Sdarrenr# define ICMP6_DST_UNREACH 1 116192685Sdarrenr#endif 116292685Sdarrenr#ifndef ICMP6_PACKET_TOO_BIG 116392685Sdarrenr# define ICMP6_PACKET_TOO_BIG 2 116492685Sdarrenr#endif 116592685Sdarrenr#ifndef ICMP6_TIME_EXCEEDED 116692685Sdarrenr# define ICMP6_TIME_EXCEEDED 3 116792685Sdarrenr#endif 116892685Sdarrenr#ifndef ICMP6_PARAM_PROB 116992685Sdarrenr# define ICMP6_PARAM_PROB 4 117092685Sdarrenr#endif 117192685Sdarrenr 117292685Sdarrenr#ifndef ICMP6_ECHO_REQUEST 117392685Sdarrenr# define ICMP6_ECHO_REQUEST 128 117492685Sdarrenr#endif 117592685Sdarrenr#ifndef ICMP6_ECHO_REPLY 117692685Sdarrenr# define ICMP6_ECHO_REPLY 129 117792685Sdarrenr#endif 117892685Sdarrenr#ifndef ICMP6_MEMBERSHIP_QUERY 117992685Sdarrenr# define ICMP6_MEMBERSHIP_QUERY 130 118092685Sdarrenr#endif 118192685Sdarrenr#ifndef MLD6_LISTENER_QUERY 118292685Sdarrenr# define MLD6_LISTENER_QUERY 130 118392685Sdarrenr#endif 118492685Sdarrenr#ifndef ICMP6_MEMBERSHIP_REPORT 118592685Sdarrenr# define ICMP6_MEMBERSHIP_REPORT 131 118692685Sdarrenr#endif 118792685Sdarrenr#ifndef MLD6_LISTENER_REPORT 118892685Sdarrenr# define MLD6_LISTENER_REPORT 131 118992685Sdarrenr#endif 119092685Sdarrenr#ifndef ICMP6_MEMBERSHIP_REDUCTION 119192685Sdarrenr# define ICMP6_MEMBERSHIP_REDUCTION 132 119292685Sdarrenr#endif 119392685Sdarrenr#ifndef MLD6_LISTENER_DONE 119492685Sdarrenr# define MLD6_LISTENER_DONE 132 119592685Sdarrenr#endif 119692685Sdarrenr#ifndef ND_ROUTER_SOLICIT 119792685Sdarrenr# define ND_ROUTER_SOLICIT 133 119892685Sdarrenr#endif 119992685Sdarrenr#ifndef ND_ROUTER_ADVERT 120092685Sdarrenr# define ND_ROUTER_ADVERT 134 120192685Sdarrenr#endif 120292685Sdarrenr#ifndef ND_NEIGHBOR_SOLICIT 120392685Sdarrenr# define ND_NEIGHBOR_SOLICIT 135 120492685Sdarrenr#endif 120592685Sdarrenr#ifndef ND_NEIGHBOR_ADVERT 120692685Sdarrenr# define ND_NEIGHBOR_ADVERT 136 120792685Sdarrenr#endif 120892685Sdarrenr#ifndef ND_REDIRECT 120992685Sdarrenr# define ND_REDIRECT 137 121092685Sdarrenr#endif 121192685Sdarrenr#ifndef ICMP6_ROUTER_RENUMBERING 121292685Sdarrenr# define ICMP6_ROUTER_RENUMBERING 138 121392685Sdarrenr#endif 121492685Sdarrenr#ifndef ICMP6_WRUREQUEST 121592685Sdarrenr# define ICMP6_WRUREQUEST 139 121692685Sdarrenr#endif 121792685Sdarrenr#ifndef ICMP6_WRUREPLY 121892685Sdarrenr# define ICMP6_WRUREPLY 140 121992685Sdarrenr#endif 122092685Sdarrenr#ifndef ICMP6_FQDN_QUERY 122192685Sdarrenr# define ICMP6_FQDN_QUERY 139 122292685Sdarrenr#endif 122392685Sdarrenr#ifndef ICMP6_FQDN_REPLY 122492685Sdarrenr# define ICMP6_FQDN_REPLY 140 122592685Sdarrenr#endif 122692685Sdarrenr#ifndef ICMP6_NI_QUERY 122792685Sdarrenr# define ICMP6_NI_QUERY 139 122892685Sdarrenr#endif 122992685Sdarrenr#ifndef ICMP6_NI_REPLY 123092685Sdarrenr# define ICMP6_NI_REPLY 140 123192685Sdarrenr#endif 123292685Sdarrenr#ifndef MLD6_MTRACE_RESP 123392685Sdarrenr# define MLD6_MTRACE_RESP 200 123492685Sdarrenr#endif 123592685Sdarrenr#ifndef MLD6_MTRACE 123692685Sdarrenr# define MLD6_MTRACE 201 123792685Sdarrenr#endif 123892685Sdarrenr#ifndef ICMP6_HADISCOV_REQUEST 123992685Sdarrenr# define ICMP6_HADISCOV_REQUEST 202 124092685Sdarrenr#endif 124192685Sdarrenr#ifndef ICMP6_HADISCOV_REPLY 124292685Sdarrenr# define ICMP6_HADISCOV_REPLY 203 124392685Sdarrenr#endif 124492685Sdarrenr#ifndef ICMP6_MOBILEPREFIX_SOLICIT 124592685Sdarrenr# define ICMP6_MOBILEPREFIX_SOLICIT 204 124692685Sdarrenr#endif 124792685Sdarrenr#ifndef ICMP6_MOBILEPREFIX_ADVERT 124892685Sdarrenr# define ICMP6_MOBILEPREFIX_ADVERT 205 124992685Sdarrenr#endif 125092685Sdarrenr#ifndef ICMP6_MAXTYPE 125192685Sdarrenr# define ICMP6_MAXTYPE 205 125292685Sdarrenr#endif 125392685Sdarrenr 125492685Sdarrenr#ifndef ICMP6_DST_UNREACH_NOROUTE 125592685Sdarrenr# define ICMP6_DST_UNREACH_NOROUTE 0 125692685Sdarrenr#endif 125792685Sdarrenr#ifndef ICMP6_DST_UNREACH_ADMIN 125892685Sdarrenr# define ICMP6_DST_UNREACH_ADMIN 1 125992685Sdarrenr#endif 126092685Sdarrenr#ifndef ICMP6_DST_UNREACH_NOTNEIGHBOR 126192685Sdarrenr# define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 126292685Sdarrenr#endif 126392685Sdarrenr#ifndef ICMP6_DST_UNREACH_BEYONDSCOPE 126492685Sdarrenr# define ICMP6_DST_UNREACH_BEYONDSCOPE 2 126592685Sdarrenr#endif 126692685Sdarrenr#ifndef ICMP6_DST_UNREACH_ADDR 126792685Sdarrenr# define ICMP6_DST_UNREACH_ADDR 3 126892685Sdarrenr#endif 126992685Sdarrenr#ifndef ICMP6_DST_UNREACH_NOPORT 127092685Sdarrenr# define ICMP6_DST_UNREACH_NOPORT 4 127192685Sdarrenr#endif 127292685Sdarrenr#ifndef ICMP6_TIME_EXCEED_TRANSIT 127392685Sdarrenr# define ICMP6_TIME_EXCEED_TRANSIT 0 127492685Sdarrenr#endif 127592685Sdarrenr#ifndef ICMP6_TIME_EXCEED_REASSEMBLY 127692685Sdarrenr# define ICMP6_TIME_EXCEED_REASSEMBLY 1 127792685Sdarrenr#endif 127892685Sdarrenr 127992685Sdarrenr#ifndef ICMP6_NI_SUCCESS 128092685Sdarrenr# define ICMP6_NI_SUCCESS 0 128192685Sdarrenr#endif 128292685Sdarrenr#ifndef ICMP6_NI_REFUSED 128392685Sdarrenr# define ICMP6_NI_REFUSED 1 128492685Sdarrenr#endif 128592685Sdarrenr#ifndef ICMP6_NI_UNKNOWN 128692685Sdarrenr# define ICMP6_NI_UNKNOWN 2 128792685Sdarrenr#endif 128892685Sdarrenr 128992685Sdarrenr#ifndef ICMP6_ROUTER_RENUMBERING_COMMAND 129092685Sdarrenr# define ICMP6_ROUTER_RENUMBERING_COMMAND 0 129192685Sdarrenr#endif 129292685Sdarrenr#ifndef ICMP6_ROUTER_RENUMBERING_RESULT 129392685Sdarrenr# define ICMP6_ROUTER_RENUMBERING_RESULT 1 129492685Sdarrenr#endif 129592685Sdarrenr#ifndef ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 129692685Sdarrenr# define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 129792685Sdarrenr#endif 129892685Sdarrenr 129992685Sdarrenr#ifndef ICMP6_PARAMPROB_HEADER 130092685Sdarrenr# define ICMP6_PARAMPROB_HEADER 0 130192685Sdarrenr#endif 130292685Sdarrenr#ifndef ICMP6_PARAMPROB_NEXTHEADER 130392685Sdarrenr# define ICMP6_PARAMPROB_NEXTHEADER 1 130492685Sdarrenr#endif 130592685Sdarrenr#ifndef ICMP6_PARAMPROB_OPTION 130692685Sdarrenr# define ICMP6_PARAMPROB_OPTION 2 130792685Sdarrenr#endif 130892685Sdarrenr 130992685Sdarrenr#ifndef ICMP6_NI_SUBJ_IPV6 131092685Sdarrenr# define ICMP6_NI_SUBJ_IPV6 0 131192685Sdarrenr#endif 131292685Sdarrenr#ifndef ICMP6_NI_SUBJ_FQDN 131392685Sdarrenr# define ICMP6_NI_SUBJ_FQDN 1 131492685Sdarrenr#endif 131592685Sdarrenr#ifndef ICMP6_NI_SUBJ_IPV4 131692685Sdarrenr# define ICMP6_NI_SUBJ_IPV4 2 131792685Sdarrenr#endif 131892685Sdarrenr 1319255332Scy#ifndef MLD_MTRACE_RESP 1320255332Scy# define MLD_MTRACE_RESP 200 1321255332Scy#endif 1322255332Scy#ifndef MLD_MTRACE 1323255332Scy# define MLD_MTRACE 201 1324255332Scy#endif 1325255332Scy#ifndef MLD6_MTRACE_RESP 1326255332Scy# define MLD6_MTRACE_RESP MLD_MTRACE_RESP 1327255332Scy#endif 1328255332Scy#ifndef MLD6_MTRACE 1329255332Scy# define MLD6_MTRACE MLD_MTRACE 1330255332Scy#endif 1331255332Scy 1332255332Scy#if !defined(IPV6_FLOWINFO_MASK) 1333255332Scy# if (BYTE_ORDER == BIG_ENDIAN) || defined(_BIG_ENDIAN) 1334255332Scy# define IPV6_FLOWINFO_MASK 0x0fffffff /* flow info (28 bits) */ 1335255332Scy# else 1336255332Scy# if(BYTE_ORDER == LITTLE_ENDIAN) || !defined(_BIG_ENDIAN) 1337255332Scy# define IPV6_FLOWINFO_MASK 0xffffff0f /* flow info (28 bits) */ 1338255332Scy# endif /* LITTLE_ENDIAN */ 1339255332Scy# endif 1340255332Scy#endif 1341255332Scy#if !defined(IPV6_FLOWLABEL_MASK) 1342255332Scy# if (BYTE_ORDER == BIG_ENDIAN) || defined(_BIG_ENDIAN) 1343255332Scy# define IPV6_FLOWLABEL_MASK 0x000fffff /* flow label (20 bits) */ 1344255332Scy# else 1345255332Scy# if (BYTE_ORDER == LITTLE_ENDIAN) || !defined(_BIG_ENDIAN) 1346255332Scy# define IPV6_FLOWLABEL_MASK 0xffff0f00 /* flow label (20 bits) */ 1347255332Scy# endif /* LITTLE_ENDIAN */ 1348255332Scy# endif 1349255332Scy#endif 1350255332Scy 135172006Sdarrenr/* 135272006Sdarrenr * ECN is a new addition to TCP - RFC 2481 135372006Sdarrenr */ 135472006Sdarrenr#ifndef TH_ECN 135572006Sdarrenr# define TH_ECN 0x40 135672006Sdarrenr#endif 135772006Sdarrenr#ifndef TH_CWR 135872006Sdarrenr# define TH_CWR 0x80 135972006Sdarrenr#endif 136072006Sdarrenr#define TH_ECNALL (TH_ECN|TH_CWR) 136172006Sdarrenr 1362145522Sdarrenr/* 1363145522Sdarrenr * TCP States 1364145522Sdarrenr */ 1365170268Sdarrenr#define IPF_TCPS_LISTEN 0 /* listening for connection */ 1366170268Sdarrenr#define IPF_TCPS_SYN_SENT 1 /* active, have sent syn */ 1367170268Sdarrenr#define IPF_TCPS_SYN_RECEIVED 2 /* have send and received syn */ 1368170268Sdarrenr#define IPF_TCPS_HALF_ESTAB 3 /* for connections not fully "up" */ 1369145522Sdarrenr/* states < IPF_TCPS_ESTABLISHED are those where connections not established */ 1370170268Sdarrenr#define IPF_TCPS_ESTABLISHED 4 /* established */ 1371170268Sdarrenr#define IPF_TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */ 1372145522Sdarrenr/* states > IPF_TCPS_CLOSE_WAIT are those where user has closed */ 1373170268Sdarrenr#define IPF_TCPS_FIN_WAIT_1 6 /* have closed, sent fin */ 1374170268Sdarrenr#define IPF_TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */ 1375170268Sdarrenr#define IPF_TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */ 1376145522Sdarrenr/* states > IPF_TCPS_CLOSE_WAIT && < IPF_TCPS_FIN_WAIT_2 await ACK of FIN */ 1377170268Sdarrenr#define IPF_TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */ 1378170268Sdarrenr#define IPF_TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */ 1379170268Sdarrenr#define IPF_TCPS_CLOSED 11 /* closed */ 1380145522Sdarrenr#define IPF_TCP_NSTATES 12 138172006Sdarrenr 1382145522Sdarrenr#define TCP_MSL 120 1383145522Sdarrenr 1384145522Sdarrenr#undef ICMP_MAX_UNREACH 1385145522Sdarrenr#define ICMP_MAX_UNREACH 14 1386145522Sdarrenr#undef ICMP_MAXTYPE 1387145522Sdarrenr#define ICMP_MAXTYPE 18 1388145522Sdarrenr 1389145522Sdarrenr#ifndef IFNAMSIZ 1390145522Sdarrenr#define IFNAMSIZ 16 1391145522Sdarrenr#endif 1392145522Sdarrenr 1393145522Sdarrenr#ifndef LOG_FTP 1394145522Sdarrenr# define LOG_FTP (11<<3) 1395145522Sdarrenr#endif 1396145522Sdarrenr#ifndef LOG_AUTHPRIV 1397145522Sdarrenr# define LOG_AUTHPRIV (10<<3) 1398145522Sdarrenr#endif 1399145522Sdarrenr#ifndef LOG_AUDIT 1400145522Sdarrenr# define LOG_AUDIT (13<<3) 1401145522Sdarrenr#endif 1402145522Sdarrenr#ifndef LOG_NTP 1403145522Sdarrenr# define LOG_NTP (12<<3) 1404145522Sdarrenr#endif 1405145522Sdarrenr#ifndef LOG_SECURITY 1406145522Sdarrenr# define LOG_SECURITY (13<<3) 1407145522Sdarrenr#endif 1408145522Sdarrenr#ifndef LOG_LFMT 1409145522Sdarrenr# define LOG_LFMT (14<<3) 1410145522Sdarrenr#endif 1411145522Sdarrenr#ifndef LOG_CONSOLE 1412145522Sdarrenr# define LOG_CONSOLE (14<<3) 1413145522Sdarrenr#endif 1414145522Sdarrenr 1415145522Sdarrenr/* 1416145522Sdarrenr * ICMP error replies have an IP header (20 bytes), 8 bytes of ICMP data, 1417145522Sdarrenr * another IP header and then 64 bits of data, totalling 56. Of course, 1418153876Sguido * the last 64 bits is dependent on that being available. 1419145522Sdarrenr */ 1420145522Sdarrenr#define ICMPERR_ICMPHLEN 8 1421145522Sdarrenr#define ICMPERR_IPICMPHLEN (20 + 8) 1422145522Sdarrenr#define ICMPERR_MINPKTLEN (20 + 8 + 20) 1423145522Sdarrenr#define ICMPERR_MAXPKTLEN (20 + 8 + 20 + 8) 1424145522Sdarrenr#define ICMP6ERR_MINPKTLEN (40 + 8) 1425145522Sdarrenr#define ICMP6ERR_IPICMPHLEN (40 + 8 + 40) 1426145522Sdarrenr 1427145522Sdarrenr#ifndef MIN 1428145522Sdarrenr# define MIN(a,b) (((a)<(b))?(a):(b)) 1429145522Sdarrenr#endif 1430145522Sdarrenr 1431255332Scy#ifdef RESCUE 1432255332Scy# undef IPFILTER_BPF 1433255332Scy#endif 1434255332Scy 1435145522Sdarrenr#ifdef IPF_DEBUG 1436145522Sdarrenr# define DPRINT(x) printf x 1437145522Sdarrenr#else 1438145522Sdarrenr# define DPRINT(x) 1439145522Sdarrenr#endif 1440145522Sdarrenr 1441255332Scy#ifndef AF_INET6 1442255332Scy# define AF_INET6 26 1443146277Sdarrenr#endif 1444146277Sdarrenr 1445255332Scy#ifdef DTRACE_PROBE 1446255332Scy# ifdef _KERNEL 1447255332Scy# define DT(_n) DTRACE_PROBE(_n) 1448255332Scy# define DT1(_n,_a,_b) DTRACE_PROBE1(_n,_a,_b) 1449255332Scy# define DT2(_n,_a,_b,_c,_d) DTRACE_PROBE2(_n,_a,_b,_c,_d) 1450255332Scy# define DT3(_n,_a,_b,_c,_d,_e,_f) \ 1451255332Scy DTRACE_PROBE3(_n,_a,_b,_c,_d,_e,_f) 1452255332Scy# define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h) \ 1453255332Scy DTRACE_PROBE4(_n,_a,_b,_c,_d,_e,_f,_g,_h) 1454255332Scy# else 1455255332Scy# define DT(_n) 1456255332Scy# define DT1(_n,_a,_b) 1457255332Scy# define DT2(_n,_a,_b,_c,_d) 1458255332Scy# define DT3(_n,_a,_b,_c,_d,_e,_f) 1459255332Scy# define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h) 1460255332Scy# endif 1461255332Scy#else 1462255332Scy# define DT(_n) 1463255332Scy# define DT1(_n,_a,_b) 1464255332Scy# define DT2(_n,_a,_b,_c,_d) 1465255332Scy# define DT3(_n,_a,_b,_c,_d,_e,_f) 1466255332Scy# define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h) 1467255332Scy#endif 1468255332Scy 1469255332Scystruct ip6_routing { 1470255332Scy u_char ip6r_nxt; /* next header */ 1471255332Scy u_char ip6r_len; /* length in units of 8 octets */ 1472255332Scy u_char ip6r_type; /* always zero */ 1473255332Scy u_char ip6r_segleft; /* segments left */ 1474255332Scy u_32_t ip6r_reserved; /* reserved field */ 1475255332Scy}; 1476255332Scy 147753642Sguido#endif /* __IP_COMPAT_H__ */ 1478