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: stable/10/sys/contrib/ipfilter/netinet/ip_compat.h 342607 2018-12-30 04:37:49Z 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 35305138Sdim#ifndef SOLARIS 36305138Sdim# if defined(sun) && (defined(__svr4__) || defined(__SVR4)) 37305138Sdim# define SOLARIS 1 38305138Sdim# else 39305138Sdim# define SOLARIS 0 40305138Sdim# endif 41305138Sdim#endif 42145522Sdarrenr 43145522Sdarrenr 4453642Sguido#if defined(__SVR4) || defined(__svr4__) || defined(__sgi) 45145522Sdarrenr# define index strchr 46145522Sdarrenr# if !defined(_KERNEL) 4753642Sguido# define bzero(a,b) memset(a,0,b) 4853642Sguido# define bcmp memcmp 4953642Sguido# define bcopy(a,b,c) memmove(b,a,c) 5053642Sguido# endif 5153642Sguido#endif 5253642Sguido 53145522Sdarrenr#ifndef LIFNAMSIZ 54145522Sdarrenr# ifdef IF_NAMESIZE 5592685Sdarrenr# define LIFNAMSIZ IF_NAMESIZE 5692685Sdarrenr# else 5792685Sdarrenr# ifdef IFNAMSIZ 5892685Sdarrenr# define LIFNAMSIZ IFNAMSIZ 5992685Sdarrenr# else 6092685Sdarrenr# define LIFNAMSIZ 16 6192685Sdarrenr# endif 6292685Sdarrenr# endif 6392685Sdarrenr#endif 6492685Sdarrenr 65145522Sdarrenr#if defined(__sgi) || defined(bsdi) || defined(__hpux) || defined(hpux) 66145522Sdarrenrstruct ether_addr { 67145522Sdarrenr u_char ether_addr_octet[6]; 68145522Sdarrenr}; 69145522Sdarrenr#endif 70145522Sdarrenr 7153642Sguido# ifdef __STDC__ 7253642Sguido# define IPL_EXTERN(ep) ipl##ep 7353642Sguido# else 7453642Sguido# define IPL_EXTERN(ep) ipl/**/ep 7553642Sguido# endif 7653642Sguido 7792685Sdarrenr/* 7892685Sdarrenr * This is a workaround for <sys/uio.h> troubles on FreeBSD and OpenBSD. 7992685Sdarrenr */ 80145522Sdarrenr# ifndef _KERNEL 81145522Sdarrenr# define ADD_KERNEL 82145522Sdarrenr# define _KERNEL 83145522Sdarrenr# define KERNEL 84145522Sdarrenr# endif 85145522Sdarrenr# include <sys/uio.h> 86145522Sdarrenr# ifdef ADD_KERNEL 87145522Sdarrenr# undef _KERNEL 88145522Sdarrenr# undef KERNEL 89145522Sdarrenr# endif 9092685Sdarrenr 91255332Scy#define NETBSD_GE_REV(x) (defined(__NetBSD_Version__) && \ 92255332Scy (__NetBSD_Version__ >= (x))) 93255332Scy#define NETBSD_GT_REV(x) (defined(__NetBSD_Version__) && \ 94255332Scy (__NetBSD_Version__ > (x))) 95255332Scy#define NETBSD_LT_REV(x) (defined(__NetBSD_Version__) && \ 96255332Scy (__NetBSD_Version__ < (x))) 97255332Scy#define FREEBSD_GE_REV(x) (defined(__FreeBSD_version) && \ 98255332Scy (__FreeBSD_version >= (x))) 99255332Scy#define FREEBSD_GT_REV(x) (defined(__FreeBSD_version) && \ 100255332Scy (__FreeBSD_version > (x))) 101255332Scy#define FREEBSD_LT_REV(x) (defined(__FreeBSD_version) && \ 102255332Scy (__FreeBSD_version < (x))) 103255332Scy#define BSDOS_GE_REV(x) (defined(_BSDI_VERSION) && \ 104255332Scy (_BSDI_VERSION >= (x))) 105255332Scy#define BSDOS_GT_REV(x) (defined(_BSDI_VERSION) && \ 106255332Scy (_BSDI_VERSION > (x))) 107255332Scy#define BSDOS_LT_REV(x) (defined(_BSDI_VERSION) && \ 108255332Scy (_BSDI_VERSION < (x))) 109255332Scy#define OPENBSD_GE_REV(x) (defined(OpenBSD) && (OpenBSD >= (x))) 110255332Scy#define OPENBSD_GT_REV(x) (defined(OpenBSD) && (OpenBSD > (x))) 111255332Scy#define OPENBSD_LT_REV(x) (defined(OpenBSD) && (OpenBSD < (x))) 112255332Scy#define BSD_GE_YEAR(x) (defined(BSD) && (BSD >= (x))) 113255332Scy#define BSD_GT_YEAR(x) (defined(BSD) && (BSD > (x))) 114255332Scy#define BSD_LT_YEAR(x) (defined(BSD) && (BSD < (x))) 115145522Sdarrenr 116145522Sdarrenr 117145522Sdarrenr/* ----------------------------------------------------------------------- */ 118145522Sdarrenr/* F R E E B S D */ 119145522Sdarrenr/* ----------------------------------------------------------------------- */ 120255332Scy# define HAS_SYS_MD5_H 1 121146229Sdarrenr# if defined(_KERNEL) 122145522Sdarrenr# include "opt_bpf.h" 12360857Sdarrenr# include "opt_inet6.h" 124145522Sdarrenr# if defined(INET6) && !defined(USE_INET6) 12560857Sdarrenr# define USE_INET6 12660857Sdarrenr# endif 127269696Scy# else 128269696Scy# if !defined(USE_INET6) && !defined(NOINET6) 129269696Scy# define USE_INET6 130269696Scy# endif 13160857Sdarrenr# endif 132145522Sdarrenr 133145522Sdarrenr# if defined(_KERNEL) 134255332Scy# include <netinet/ip_var.h> 135255332Scy# define p_cred td_ucred 136255332Scy# define p_uid td_ucred->cr_ruid 137255332Scy 13853642Sguido/* 139145522Sdarrenr * When #define'd, the 5.2.1 kernel panics when used with the ftp proxy. 140145522Sdarrenr * There may be other, safe, kernels but this is not extensively tested yet. 14153642Sguido */ 142145522Sdarrenr# define HAVE_M_PULLDOWN 143145522Sdarrenr# if !defined(IPFILTER_LKM) && (__FreeBSD_version >= 300000) 144145522Sdarrenr# include "opt_ipfilter.h" 145145522Sdarrenr# endif 146145522Sdarrenr# define COPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c)) 147145522Sdarrenr# define COPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c)) 148145522Sdarrenr 149255332Scy# else 150255332Scy# include <inttypes.h> 151145522Sdarrenr# endif /* _KERNEL */ 152145522Sdarrenr 153255332Scy# include <sys/selinfo.h> 154145522Sdarrenr# include <sys/mutex.h> 155255332Scy# define KRWLOCK_FILL_SZ 56 156255332Scy# define KMUTEX_FILL_SZ 56 157172776Sdarrenr# include <sys/rwlock.h> 158255332Scy# define KMUTEX_T struct mtx 159255332Scy# define KRWLOCK_T struct rwlock 160255332Scy# ifdef _KERNEL 161255332Scy# define READ_ENTER(x) rw_rlock(&(x)->ipf_lk) 162255332Scy# define WRITE_ENTER(x) rw_wlock(&(x)->ipf_lk) 163255332Scy# define MUTEX_DOWNGRADE(x) rw_downgrade(&(x)->ipf_lk) 164314251Scy# define MUTEX_TRY_UPGRADE(x) rw_try_upgrade(&(x)->ipf_lk) 165255332Scy# define RWLOCK_INIT(x,y) rw_init(&(x)->ipf_lk, (y)) 166255332Scy# define RW_DESTROY(x) rw_destroy(&(x)->ipf_lk) 167255332Scy# define RWLOCK_EXIT(x) do { \ 168172776Sdarrenr if (rw_wowned(&(x)->ipf_lk)) \ 169255332Scy rw_wunlock(&(x)->ipf_lk); \ 170255332Scy else \ 171172776Sdarrenr rw_runlock(&(x)->ipf_lk); \ 172172776Sdarrenr } while (0) 173172776Sdarrenr# endif 17453642Sguido 175145522Sdarrenr# include <net/if_var.h> 176145522Sdarrenr# define IFNAME(x) ((struct ifnet *)x)->if_xname 177172776Sdarrenr# define COPYIFNAME(v, x, b) \ 178145522Sdarrenr (void) strncpy(b, \ 179145522Sdarrenr ((struct ifnet *)x)->if_xname, \ 180145522Sdarrenr LIFNAMSIZ) 181145522Sdarrenr 182145522Sdarrenr# ifdef _KERNEL 183145522Sdarrenr# define GETKTIME(x) microtime((struct timeval *)x) 184145522Sdarrenr 185145522Sdarrenr# include <netinet/in_systm.h> 186145522Sdarrenr# include <netinet/ip.h> 187145522Sdarrenr# include <machine/in_cksum.h> 188145522Sdarrenr 189145522Sdarrenr# define USE_MUTEXES 190145522Sdarrenr# define MUTEX_ENTER(x) mtx_lock(&(x)->ipf_lk) 191145522Sdarrenr# define MUTEX_EXIT(x) mtx_unlock(&(x)->ipf_lk) 192145522Sdarrenr# define MUTEX_INIT(x,y) mtx_init(&(x)->ipf_lk, (y), NULL,\ 193145522Sdarrenr MTX_DEF) 194145522Sdarrenr# define MUTEX_DESTROY(x) mtx_destroy(&(x)->ipf_lk) 195145522Sdarrenr# define MUTEX_NUKE(x) bzero((x), sizeof(*(x))) 196255332Scy/* 197255332Scy * Whilst the sx(9) locks on FreeBSD have the right semantics and interface 198255332Scy * for what we want to use them for, despite testing showing they work - 199255332Scy * with a WITNESS kernel, it generates LOR messages. 200255332Scy */ 201145522Sdarrenr# include <machine/atomic.h> 202255332Scy# define ATOMIC_INC(x) { mtx_lock(&softc->ipf_rw.ipf_lk); (x)++; \ 203255332Scy mtx_unlock(&softc->ipf_rw.ipf_lk); } 204255332Scy# define ATOMIC_DEC(x) { mtx_lock(&softc->ipf_rw.ipf_lk); (x)--; \ 205255332Scy mtx_unlock(&softc->ipf_rw.ipf_lk); } 206145522Sdarrenr# define ATOMIC_INCL(x) atomic_add_long(&(x), 1) 207145522Sdarrenr# define ATOMIC_INC64(x) ATOMIC_INC(x) 208170268Sdarrenr# define ATOMIC_INC32(x) atomic_add_32((u_int *)&(x), 1) 209145522Sdarrenr# define ATOMIC_DECL(x) atomic_add_long(&(x), -1) 210145522Sdarrenr# define ATOMIC_DEC64(x) ATOMIC_DEC(x) 211170268Sdarrenr# define ATOMIC_DEC32(x) atomic_add_32((u_int *)&(x), -1) 212145522Sdarrenr# define SPL_X(x) ; 213145522Sdarrenr# define SPL_NET(x) ; 214145522Sdarrenr# define SPL_IMP(x) ; 215170268Sdarrenr# define SPL_SCHED(x) ; 216255332Scy# define GET_MINOR dev2unit 217255332Scy# define MSGDSIZE(m) mbufchainlen(m) 218255332Scy# define M_LEN(m) (m)->m_len 219255332Scy# define M_ADJ(m,x) m_adj(m, x) 220255332Scy# define M_COPY(x) m_copy((x), 0, M_COPYALL) 221255332Scy# define M_DUP(m) m_dup(m, M_NOWAIT) 222145522Sdarrenr# define IPF_PANIC(x,y) if (x) { printf y; panic("ipf_panic"); } 223145522Sdarrenrtypedef struct mbuf mb_t; 224145522Sdarrenr# endif /* _KERNEL */ 225145522Sdarrenr 226145522Sdarrenr 227145522Sdarrenrtypedef u_long ioctlcmd_t; 228145522Sdarrenrtypedef struct uio uio_t; 229145522Sdarrenrtypedef int minor_t; 230145522Sdarrenrtypedef u_int32_t u_32_t; 231145522Sdarrenr# define U_32_T 1 232145522Sdarrenr 233145522Sdarrenr 234145522Sdarrenr/* ----------------------------------------------------------------------- */ 235145522Sdarrenr/* G E N E R I C */ 236145522Sdarrenr/* ----------------------------------------------------------------------- */ 237145522Sdarrenr 238145522Sdarrenr/* 239145522Sdarrenr * For BSD kernels, if bpf is in the kernel, enable ipfilter to use bpf in 240145522Sdarrenr * filter rules. 241145522Sdarrenr */ 242153876Sguido#if !defined(IPFILTER_BPF) 243153876Sguido# if (defined(NBPF) && (NBPF > 0)) || (defined(DEV_BPF) && (DEV_BPF > 0)) || \ 244153876Sguido (defined(NBPFILTER) && (NBPFILTER > 0)) 245153876Sguido# define IPFILTER_BPF 246153876Sguido# endif 247145522Sdarrenr#endif 248145522Sdarrenr 249145522Sdarrenr/* 250145522Sdarrenr * Userland locking primitives 251145522Sdarrenr */ 252255332Scy#ifndef _KERNEL 253255332Scy#if !defined(KMUTEX_FILL_SZ) 254255332Scy# define KMUTEX_FILL_SZ 1 255255332Scy#endif 256255332Scy#if !defined(KRWLOCK_FILL_SZ) 257255332Scy# define KRWLOCK_FILL_SZ 1 258255332Scy#endif 259255332Scy#endif 260255332Scy 261145522Sdarrenrtypedef struct { 262145522Sdarrenr char *eMm_owner; 263145522Sdarrenr char *eMm_heldin; 264145522Sdarrenr u_int eMm_magic; 265145522Sdarrenr int eMm_held; 266145522Sdarrenr int eMm_heldat; 267145522Sdarrenr} eMmutex_t; 268145522Sdarrenr 269145522Sdarrenrtypedef struct { 270145522Sdarrenr char *eMrw_owner; 271145522Sdarrenr char *eMrw_heldin; 272145522Sdarrenr u_int eMrw_magic; 273145522Sdarrenr short eMrw_read; 274145522Sdarrenr short eMrw_write; 275145522Sdarrenr int eMrw_heldat; 276145522Sdarrenr} eMrwlock_t; 277145522Sdarrenr 278145522Sdarrenrtypedef union { 279255332Scy char _fill[KMUTEX_FILL_SZ]; 280145522Sdarrenr#ifdef KMUTEX_T 281145522Sdarrenr struct { 282145522Sdarrenr KMUTEX_T ipf_slk; 283255332Scy const char *ipf_lname; 284145522Sdarrenr } ipf_lkun_s; 285145522Sdarrenr#endif 286145522Sdarrenr eMmutex_t ipf_emu; 287145522Sdarrenr} ipfmutex_t; 288145522Sdarrenr 289145522Sdarrenrtypedef union { 290255332Scy char _fill[KRWLOCK_FILL_SZ]; 291145522Sdarrenr#ifdef KRWLOCK_T 292145522Sdarrenr struct { 293145522Sdarrenr KRWLOCK_T ipf_slk; 294255332Scy const char *ipf_lname; 295145522Sdarrenr int ipf_sr; 296145522Sdarrenr int ipf_sw; 297145522Sdarrenr u_int ipf_magic; 298145522Sdarrenr } ipf_lkun_s; 299145522Sdarrenr#endif 300145522Sdarrenr eMrwlock_t ipf_emu; 301145522Sdarrenr} ipfrwlock_t; 302145522Sdarrenr 303145522Sdarrenr#define ipf_lk ipf_lkun_s.ipf_slk 304145522Sdarrenr#define ipf_lname ipf_lkun_s.ipf_lname 305145522Sdarrenr#define ipf_isr ipf_lkun_s.ipf_sr 306145522Sdarrenr#define ipf_isw ipf_lkun_s.ipf_sw 307145522Sdarrenr#define ipf_magic ipf_lkun_s.ipf_magic 308145522Sdarrenr 309145522Sdarrenr#if !defined(__GNUC__) || \ 310145522Sdarrenr (defined(__FreeBSD_version) && (__FreeBSD_version >= 503000)) 311145522Sdarrenr# ifndef INLINE 312145522Sdarrenr# define INLINE 313145522Sdarrenr# endif 314145522Sdarrenr#else 315145522Sdarrenr# define INLINE __inline__ 316145522Sdarrenr#endif 317145522Sdarrenr 318255332Scy#if defined(__FreeBSD_version) && defined(_KERNEL) 319255332Scy CTASSERT(sizeof(ipfrwlock_t) == KRWLOCK_FILL_SZ); 320255332Scy CTASSERT(sizeof(ipfmutex_t) == KMUTEX_FILL_SZ); 321145522Sdarrenr#endif 322145522Sdarrenr 323255332Scy 324145522Sdarrenr/* 325145522Sdarrenr * In a non-kernel environment, there are a lot of macros that need to be 326145522Sdarrenr * filled in to be null-ops or to point to some compatibility function, 327145522Sdarrenr * somewhere in userland. 328145522Sdarrenr */ 329145522Sdarrenr#ifndef _KERNEL 330145522Sdarrenrtypedef struct mb_s { 331145522Sdarrenr struct mb_s *mb_next; 332255332Scy char *mb_data; 333255332Scy void *mb_ifp; 334145522Sdarrenr int mb_len; 335255332Scy int mb_flags; 336145522Sdarrenr u_long mb_buf[2048]; 337145522Sdarrenr} mb_t; 338145522Sdarrenr# undef m_next 339145522Sdarrenr# define m_next mb_next 340255332Scy# undef m_len 341255332Scy# define m_len mb_len 342255332Scy# undef m_flags 343255332Scy# define m_flags mb_flags 344255332Scy# undef m_data 345255332Scy# define m_data mb_data 346255332Scy# undef M_MCAST 347255332Scy# define M_MCAST 0x01 348255332Scy# undef M_BCAST 349255332Scy# define M_BCAST 0x02 350255332Scy# undef M_MBCAST 351255332Scy# define M_MBCAST 0x04 352255332Scy# define MSGDSIZE(m) msgdsize(m) 353255332Scy# define M_LEN(m) (m)->mb_len 354255332Scy# define M_ADJ(m,x) (m)->mb_len += x 355255332Scy# define M_COPY(m) dupmbt(m) 356255332Scy# define M_DUP(m) dupmbt(m) 357145522Sdarrenr# define GETKTIME(x) gettimeofday((struct timeval *)(x), NULL) 358255332Scy# define MTOD(m, t) ((t)(m)->mb_data) 359255332Scy# define FREE_MB_T(m) freembt(m) 360255332Scy# define ALLOC_MB_T(m,l) (m) = allocmbt(l) 361255332Scy# define PREP_MB_T(f, m) do { \ 362255332Scy (m)->mb_next = *(f)->fin_mp; \ 363255332Scy *(fin)->fin_mp = (m); \ 364255332Scy (f)->fin_m = (m); \ 365255332Scy } while (0) 366145522Sdarrenr# define SLEEP(x,y) 1; 367145522Sdarrenr# define WAKEUP(x,y) ; 368161356Sguido# define POLLWAKEUP(y) ; 369145522Sdarrenr# define IPF_PANIC(x,y) ; 370145522Sdarrenr# define PANIC(x,y) ; 371170268Sdarrenr# define SPL_SCHED(x) ; 372145522Sdarrenr# define SPL_NET(x) ; 373145522Sdarrenr# define SPL_IMP(x) ; 374145522Sdarrenr# define SPL_X(x) ; 375145522Sdarrenr# define KMALLOC(a,b) (a) = (b)malloc(sizeof(*a)) 376145522Sdarrenr# define KMALLOCS(a,b,c) (a) = (b)malloc(c) 377145522Sdarrenr# define KFREE(x) free(x) 378145522Sdarrenr# define KFREES(x,s) free(x) 379145522Sdarrenr# define GETIFP(x, v) get_unit(x,v) 380255332Scy# define GETIFMTU_4(x) 2048 381255332Scy# define GETIFMTU_6(x) 2048 382153876Sguido# define COPYIN(a,b,c) bcopywrap((a), (b), (c)) 383153876Sguido# define COPYOUT(a,b,c) bcopywrap((a), (b), (c)) 384145522Sdarrenr# define COPYDATA(m, o, l, b) bcopy(MTOD((mb_t *)m, char *) + (o), \ 385145522Sdarrenr (b), (l)) 386145522Sdarrenr# define COPYBACK(m, o, l, b) bcopy((b), \ 387145522Sdarrenr MTOD((mb_t *)m, char *) + (o), \ 388145522Sdarrenr (l)) 389172776Sdarrenr# define UIOMOVE(a,b,c,d) ipfuiomove((caddr_t)a,b,c,d) 390145522Sdarrenrextern void m_copydata __P((mb_t *, int, int, caddr_t)); 391145522Sdarrenrextern int ipfuiomove __P((caddr_t, int, int, struct uio *)); 392153882Sguidoextern int bcopywrap __P((void *, void *, size_t)); 393255332Scyextern mb_t *allocmbt __P((size_t)); 394255332Scyextern mb_t *dupmbt __P((mb_t *)); 395255332Scyextern void freembt __P((mb_t *)); 396145522Sdarrenr 397255332Scy# define MUTEX_DESTROY(x) eMmutex_destroy(&(x)->ipf_emu, \ 398255332Scy __FILE__, __LINE__) 399145522Sdarrenr# define MUTEX_ENTER(x) eMmutex_enter(&(x)->ipf_emu, \ 400145522Sdarrenr __FILE__, __LINE__) 401255332Scy# define MUTEX_EXIT(x) eMmutex_exit(&(x)->ipf_emu, \ 402255332Scy __FILE__, __LINE__) 403255332Scy# define MUTEX_INIT(x,y) eMmutex_init(&(x)->ipf_emu, y, \ 404255332Scy __FILE__, __LINE__) 405145522Sdarrenr# define MUTEX_NUKE(x) bzero((x), sizeof(*(x))) 406145522Sdarrenr 407145522Sdarrenr# define MUTEX_DOWNGRADE(x) eMrwlock_downgrade(&(x)->ipf_emu, \ 408145522Sdarrenr __FILE__, __LINE__) 409314251Scy# define MUTEX_TRY_UPGRADE(x) eMrwlock_try_upgrade(&(x)->ipf_emu, \ 410314251Scy __FILE__, __LINE__) 411145522Sdarrenr# define READ_ENTER(x) eMrwlock_read_enter(&(x)->ipf_emu, \ 412145522Sdarrenr __FILE__, __LINE__) 413145522Sdarrenr# define RWLOCK_INIT(x, y) eMrwlock_init(&(x)->ipf_emu, y) 414145522Sdarrenr# define RWLOCK_EXIT(x) eMrwlock_exit(&(x)->ipf_emu) 415145522Sdarrenr# define RW_DESTROY(x) eMrwlock_destroy(&(x)->ipf_emu) 416145522Sdarrenr# define WRITE_ENTER(x) eMrwlock_write_enter(&(x)->ipf_emu, \ 417145522Sdarrenr __FILE__, \ 418145522Sdarrenr __LINE__) 419145522Sdarrenr 420145522Sdarrenr# define USE_MUTEXES 1 421145522Sdarrenr 422255332Scyextern void eMmutex_destroy __P((eMmutex_t *, char *, int)); 423145522Sdarrenrextern void eMmutex_enter __P((eMmutex_t *, char *, int)); 424255332Scyextern void eMmutex_exit __P((eMmutex_t *, char *, int)); 425255332Scyextern void eMmutex_init __P((eMmutex_t *, char *, char *, int)); 426145522Sdarrenrextern void eMrwlock_destroy __P((eMrwlock_t *)); 427145522Sdarrenrextern void eMrwlock_exit __P((eMrwlock_t *)); 428145522Sdarrenrextern void eMrwlock_init __P((eMrwlock_t *, char *)); 429145522Sdarrenrextern void eMrwlock_read_enter __P((eMrwlock_t *, char *, int)); 430145522Sdarrenrextern void eMrwlock_write_enter __P((eMrwlock_t *, char *, int)); 431145522Sdarrenrextern void eMrwlock_downgrade __P((eMrwlock_t *, char *, int)); 432145522Sdarrenr 433145522Sdarrenr#endif 434145522Sdarrenr 435255332Scyextern mb_t *allocmbt(size_t); 436255332Scy 437145522Sdarrenr#define MAX_IPV4HDR ((0xf << 2) + sizeof(struct icmp) + sizeof(ip_t) + 8) 438145522Sdarrenr 439145522Sdarrenr#ifndef IP_OFFMASK 440145522Sdarrenr# define IP_OFFMASK 0x1fff 441145522Sdarrenr#endif 442145522Sdarrenr 443145522Sdarrenr 444145522Sdarrenr/* 445145522Sdarrenr * On BSD's use quad_t as a guarantee for getting at least a 64bit sized 446145522Sdarrenr * object. 447145522Sdarrenr */ 448255332Scy#if !defined(__amd64__) && BSD_GT_YEAR(199306) 449145522Sdarrenr# define USE_QUAD_T 450145640Sdarrenr# define U_QUAD_T unsigned long long 451145640Sdarrenr# define QUAD_T long long 452145522Sdarrenr#else /* BSD > 199306 */ 453255332Scy# if !defined(U_QUAD_T) 454255332Scy# define U_QUAD_T u_long 455255332Scy# define QUAD_T long 456255332Scy# endif 457145522Sdarrenr#endif /* BSD > 199306 */ 458145522Sdarrenr 459145522Sdarrenr 46060857Sdarrenr#ifdef USE_INET6 461145522Sdarrenr# if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || \ 462145522Sdarrenr defined(__osf__) || defined(linux) 46360857Sdarrenr# include <netinet/ip6.h> 464145522Sdarrenr# include <netinet/icmp6.h> 465145522Sdarrenr# if defined(_KERNEL) && !defined(__osf__) 466145522Sdarrenr# include <netinet6/ip6_var.h> 467145522Sdarrenr# endif 46860857Sdarrenrtypedef struct ip6_hdr ip6_t; 46960857Sdarrenr# endif 47060857Sdarrenr#endif 47160857Sdarrenr 47253642Sguido#ifndef MAX 473145522Sdarrenr# define MAX(a,b) (((a) > (b)) ? (a) : (b)) 47453642Sguido#endif 47553642Sguido 476145522Sdarrenr#if defined(_KERNEL) 477255332Scy# if defined(MENTAT) && !defined(INSTANCES) 478145522Sdarrenr# define COPYDATA mb_copydata 479145522Sdarrenr# define COPYBACK mb_copyback 480145522Sdarrenr# else 481145522Sdarrenr# define COPYDATA m_copydata 482145522Sdarrenr# define COPYBACK m_copyback 483145522Sdarrenr# endif 484145522Sdarrenr# if (defined(__NetBSD_Version__) && (__NetBSD_Version__ < 105180000)) || \ 485145522Sdarrenr defined(__FreeBSD__) || (defined(OpenBSD) && (OpenBSD < 200206)) || \ 486145522Sdarrenr defined(_BSDI_VERSION) 487145522Sdarrenr# include <vm/vm.h> 488145522Sdarrenr# endif 489255332Scy# if !defined(__FreeBSD__) || FREEBSD_GE_REV(300000) 490255332Scy# if NETBSD_GE_REV(105180000) || OPENBSD_GE_REV(200111) 491145522Sdarrenr# include <uvm/uvm_extern.h> 492145522Sdarrenr# else 493145522Sdarrenr# include <vm/vm_extern.h> 494145522Sdarrenrextern vm_map_t kmem_map; 495145522Sdarrenr# endif 496145522Sdarrenr# include <sys/proc.h> 497145522Sdarrenr# else /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD_version >= 300000) */ 498145522Sdarrenr# include <vm/vm_kern.h> 499145522Sdarrenr# endif /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD_version >= 300000) */ 500145522Sdarrenr 501145522Sdarrenr# ifdef IPFILTER_M_IPFILTER 502145522Sdarrenr# include <sys/malloc.h> 503145522SdarrenrMALLOC_DECLARE(M_IPFILTER); 504145522Sdarrenr# define _M_IPF M_IPFILTER 505145522Sdarrenr# else /* IPFILTER_M_IPFILTER */ 506145522Sdarrenr# ifdef M_PFIL 507145522Sdarrenr# define _M_IPF M_PFIL 508145522Sdarrenr# else 509145522Sdarrenr# ifdef M_IPFILTER 510145522Sdarrenr# define _M_IPF M_IPFILTER 511145522Sdarrenr# else 512145522Sdarrenr# define _M_IPF M_TEMP 513145522Sdarrenr# endif /* M_IPFILTER */ 514145522Sdarrenr# endif /* M_PFIL */ 515145522Sdarrenr# endif /* IPFILTER_M_IPFILTER */ 516255332Scy# if !defined(KMALLOC) 517184205Sdes# define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), _M_IPF, M_NOWAIT) 518255332Scy# endif 519255332Scy# if !defined(KMALLOCS) 520255332Scy# define KMALLOCS(a, b, c) MALLOC((a), b, (c), _M_IPF, M_NOWAIT) 521255332Scy# endif 522255332Scy# if !defined(KFREE) 523184205Sdes# define KFREE(x) FREE((x), _M_IPF) 524170268Sdarrenr# endif 525255332Scy# if !defined(KFREES) 526255332Scy# define KFREES(x,s) FREE((x), _M_IPF) 527255332Scy# endif 528172776Sdarrenr# define UIOMOVE(a,b,c,d) uiomove((caddr_t)a,b,d) 529145522Sdarrenr# define SLEEP(id, n) tsleep((id), PPAUSE|PCATCH, n, 0) 530145522Sdarrenr# define WAKEUP(id,x) wakeup(id+x) 531255332Scy# if !defined(POLLWAKEUP) 532255332Scy# define POLLWAKEUP(x) selwakeup(softc->ipf_selwait+x) 533255332Scy# endif 534145522Sdarrenr# define GETIFP(n, v) ifunit(n) 535255332Scy# define GETIFMTU_4(x) ((struct ifnet *)x)->if_mtu 536255332Scy# define GETIFMTU_6(x) ((struct ifnet *)x)->if_mtu 537145522Sdarrenr 538145522Sdarrenr# if !defined(USE_MUTEXES) && !defined(SPL_NET) 539255754Scy# define SPL_IMP(x) x = splimp() 540255754Scy# define SPL_NET(x) x = splnet() 541172776Sdarrenr# if !defined(SPL_SCHED) 542172776Sdarrenr# define SPL_SCHED(x) x = splsched() 543172776Sdarrenr# endif 544145522Sdarrenr# define SPL_X(x) (void) splx(x) 545145522Sdarrenr# endif /* !USE_MUTEXES */ 546145522Sdarrenr 547145522Sdarrenr# ifndef FREE_MB_T 548145522Sdarrenr# define FREE_MB_T(m) m_freem(m) 549145522Sdarrenr# endif 550255332Scy# ifndef ALLOC_MB_T 551255332Scy# ifdef MGETHDR 552255332Scy# define ALLOC_MB_T(m,l) do { \ 553255332Scy MGETHDR((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# else 560255332Scy# define ALLOC_MB_T(m,l) do { \ 561255332Scy MGET((m), M_DONTWAIT, MT_HEADER); \ 562255332Scy if ((m) != NULL) { \ 563255332Scy (m)->m_len = (l); \ 564255332Scy (m)->m_pkthdr.len = (l); \ 565255332Scy } \ 566255332Scy } while (0) 567255332Scy# endif 568255332Scy# endif 569255332Scy# ifndef PREP_MB_T 570255332Scy# define PREP_MB_T(f, m) do { \ 571255332Scy mb_t *_o = *(f)->fin_mp; \ 572255332Scy (m)->m_next = _o; \ 573255332Scy *(fin)->fin_mp = (m); \ 574255332Scy if (_o->m_flags & M_PKTHDR) { \ 575255332Scy (m)->m_pkthdr.len += \ 576255332Scy _o->m_pkthdr.len; \ 577255332Scy (m)->m_pkthdr.rcvif = \ 578255332Scy _o->m_pkthdr.rcvif; \ 579255332Scy } \ 580255332Scy } while (0) 581255332Scy# endif 582255332Scy# ifndef M_DUP 583255332Scy# ifdef M_COPYALL 584255332Scy# define M_DUP(m) m_dup(m, 0, M_COPYALL, 0) 585255332Scy# else 586255332Scy# define M_DUP(m) m_dup(m) 587255332Scy# endif 588255332Scy# endif 589145522Sdarrenr 590145522Sdarrenr# ifndef MTOD 591145522Sdarrenr# define MTOD(m,t) mtod(m,t) 592145522Sdarrenr# endif 593145522Sdarrenr 594145522Sdarrenr# ifndef COPYIN 595145522Sdarrenr# define COPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) 596145522Sdarrenr# define COPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) 597145522Sdarrenr# endif 598145522Sdarrenr 599145522Sdarrenr# ifndef KMALLOC 600145522Sdarrenr# define KMALLOC(a,b) (a) = (b)new_kmem_alloc(sizeof(*(a)), \ 601145522Sdarrenr KMEM_NOSLEEP) 602145522Sdarrenr# define KMALLOCS(a,b,c) (a) = (b)new_kmem_alloc((c), KMEM_NOSLEEP) 603145522Sdarrenr# endif 604145522Sdarrenr 605145522Sdarrenr# ifndef GET_MINOR 606183397Sed# define GET_MINOR(x) dev2unit(x) 607145522Sdarrenr# endif 608145522Sdarrenr# define PANIC(x,y) if (x) panic y 609145522Sdarrenr#endif /* _KERNEL */ 610145522Sdarrenr 611172776Sdarrenr#if !defined(IFNAME) && !defined(_KERNEL) 612255332Scy# define IFNAME(x) get_ifname((struct ifnet *)x) 613145522Sdarrenr#endif 614145522Sdarrenr#ifndef COPYIFNAME 615145522Sdarrenr# define NEED_FRGETIFNAME 616255332Scyextern char *ipf_getifname __P((struct ifnet *, char *)); 617172776Sdarrenr# define COPYIFNAME(v, x, b) \ 618255332Scy ipf_getifname((struct ifnet *)x, b) 619145522Sdarrenr#endif 620145522Sdarrenr 621145522Sdarrenr#ifndef ASSERT 622172776Sdarrenr# ifdef _KERNEL 623172776Sdarrenr# define ASSERT(x) 624172776Sdarrenr# else 625172776Sdarrenr# define ASSERT(x) do { if (!(x)) abort(); } while (0) 626172776Sdarrenr# endif 627145522Sdarrenr#endif 628145522Sdarrenr 629170268Sdarrenr#ifndef BCOPYIN 630170268Sdarrenr# define BCOPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) 631170268Sdarrenr# define BCOPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) 632170268Sdarrenr#endif 633170268Sdarrenr 63453642Sguido/* 635145522Sdarrenr * Because the ctype(3) posix definition, if used "safely" in code everywhere, 636145522Sdarrenr * would mean all normal code that walks through strings needed casts. Yuck. 637145522Sdarrenr */ 638145522Sdarrenr#define ISALNUM(x) isalnum((u_char)(x)) 639145522Sdarrenr#define ISALPHA(x) isalpha((u_char)(x)) 640145522Sdarrenr#define ISDIGIT(x) isdigit((u_char)(x)) 641145522Sdarrenr#define ISSPACE(x) isspace((u_char)(x)) 642145522Sdarrenr#define ISUPPER(x) isupper((u_char)(x)) 643145522Sdarrenr#define ISXDIGIT(x) isxdigit((u_char)(x)) 644145522Sdarrenr#define ISLOWER(x) islower((u_char)(x)) 645145522Sdarrenr#define TOUPPER(x) toupper((u_char)(x)) 646145522Sdarrenr#define TOLOWER(x) tolower((u_char)(x)) 647145522Sdarrenr 648145522Sdarrenr/* 649145522Sdarrenr * If mutexes aren't being used, turn all the mutex functions into null-ops. 650145522Sdarrenr */ 651145522Sdarrenr#if !defined(USE_MUTEXES) 652145522Sdarrenr# define USE_SPL 1 653145522Sdarrenr# undef RW_DESTROY 654145522Sdarrenr# undef MUTEX_INIT 655145522Sdarrenr# undef MUTEX_NUKE 656145522Sdarrenr# undef MUTEX_DESTROY 657145522Sdarrenr# define MUTEX_ENTER(x) ; 658145522Sdarrenr# define READ_ENTER(x) ; 659145522Sdarrenr# define WRITE_ENTER(x) ; 660145522Sdarrenr# define MUTEX_DOWNGRADE(x) ; 661314251Scy# define MUTEX_TRY_UPGRADE(x) ; 662145522Sdarrenr# define RWLOCK_INIT(x, y) ; 663145522Sdarrenr# define RWLOCK_EXIT(x) ; 664145522Sdarrenr# define RW_DESTROY(x) ; 665145522Sdarrenr# define MUTEX_EXIT(x) ; 666145522Sdarrenr# define MUTEX_INIT(x,y) ; 667145522Sdarrenr# define MUTEX_DESTROY(x) ; 668145522Sdarrenr# define MUTEX_NUKE(x) ; 669145522Sdarrenr#endif /* !USE_MUTEXES */ 670145522Sdarrenr#ifndef ATOMIC_INC 671145522Sdarrenr# define ATOMIC_INC(x) (x)++ 672145522Sdarrenr# define ATOMIC_DEC(x) (x)-- 673145522Sdarrenr#endif 674145522Sdarrenr 675153876Sguido#if defined(USE_SPL) && defined(_KERNEL) 676153876Sguido# define SPL_INT(x) int x 677153876Sguido#else 678153876Sguido# define SPL_INT(x) 679153876Sguido#endif 680153876Sguido 681145522Sdarrenr/* 682145522Sdarrenr * If there are no atomic operations for bit sizes defined, define them to all 683145522Sdarrenr * use a generic one that works for all sizes. 684145522Sdarrenr */ 685145522Sdarrenr#ifndef ATOMIC_INCL 686145522Sdarrenr# define ATOMIC_INCL ATOMIC_INC 687145522Sdarrenr# define ATOMIC_INC64 ATOMIC_INC 688145522Sdarrenr# define ATOMIC_INC32 ATOMIC_INC 689145522Sdarrenr# define ATOMIC_DECL ATOMIC_DEC 690145522Sdarrenr# define ATOMIC_DEC64 ATOMIC_DEC 691145522Sdarrenr# define ATOMIC_DEC32 ATOMIC_DEC 692145522Sdarrenr#endif 693145522Sdarrenr 694145522Sdarrenr#ifndef HDR_T_PRIVATE 695145522Sdarrenrtypedef struct tcphdr tcphdr_t; 696145522Sdarrenrtypedef struct udphdr udphdr_t; 697145522Sdarrenr#endif 698145522Sdarrenrtypedef struct icmp icmphdr_t; 699145522Sdarrenrtypedef struct ip ip_t; 700145522Sdarrenrtypedef struct ether_header ether_header_t; 701145522Sdarrenrtypedef struct tcpiphdr tcpiphdr_t; 702145522Sdarrenr 703145522Sdarrenr#ifndef FR_GROUPLEN 704145522Sdarrenr# define FR_GROUPLEN 16 705145522Sdarrenr#endif 706145522Sdarrenr 707145522Sdarrenr#ifndef offsetof 708255332Scy# define offsetof(t,m) (size_t)((&((t *)0L)->m)) 709145522Sdarrenr#endif 710255332Scy#ifndef stsizeof 711255332Scy# define stsizeof(t,m) sizeof(((t *)0L)->m) 712255332Scy#endif 713145522Sdarrenr 714145522Sdarrenr/* 715145522Sdarrenr * This set of macros has been brought about because on Tru64 it is not 716145522Sdarrenr * possible to easily assign or examine values in a structure that are 717145522Sdarrenr * bit fields. 718145522Sdarrenr */ 719145522Sdarrenr#ifndef IP_V 720145522Sdarrenr# define IP_V(x) (x)->ip_v 721145522Sdarrenr#endif 722145522Sdarrenr#ifndef IP_V_A 723145522Sdarrenr# define IP_V_A(x,y) (x)->ip_v = (y) 724145522Sdarrenr#endif 725145522Sdarrenr#ifndef IP_HL 726145522Sdarrenr# define IP_HL(x) (x)->ip_hl 727145522Sdarrenr#endif 728145522Sdarrenr#ifndef IP_HL_A 729170268Sdarrenr# define IP_HL_A(x,y) (x)->ip_hl = ((y) & 0xf) 730145522Sdarrenr#endif 731145522Sdarrenr#ifndef TCP_X2 732145522Sdarrenr# define TCP_X2(x) (x)->th_x2 733145522Sdarrenr#endif 734145522Sdarrenr#ifndef TCP_X2_A 735145522Sdarrenr# define TCP_X2_A(x,y) (x)->th_x2 = (y) 736145522Sdarrenr#endif 737145522Sdarrenr#ifndef TCP_OFF 738145522Sdarrenr# define TCP_OFF(x) (x)->th_off 739145522Sdarrenr#endif 740145522Sdarrenr#ifndef TCP_OFF_A 741145522Sdarrenr# define TCP_OFF_A(x,y) (x)->th_off = (y) 742145522Sdarrenr#endif 743145522Sdarrenr#define IPMINLEN(i, h) ((i)->ip_len >= (IP_HL(i) * 4 + sizeof(struct h))) 744145522Sdarrenr 745145522Sdarrenr#define TCPF_ALL (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|\ 746145522Sdarrenr TH_ECN|TH_CWR) 747145522Sdarrenr 748255332Scy#if BSD_GE_YEAR(199306) && !defined(m_act) 749145522Sdarrenr# define m_act m_nextpkt 750255332Scy#endif 751145522Sdarrenr 752145522Sdarrenr/* 75353642Sguido * Security Options for Intenet Protocol (IPSO) as defined in RFC 1108. 75453642Sguido * 75553642Sguido * Basic Option 75653642Sguido * 75753642Sguido * 00000001 - (Reserved 4) 75853642Sguido * 00111101 - Top Secret 75953642Sguido * 01011010 - Secret 76053642Sguido * 10010110 - Confidential 76153642Sguido * 01100110 - (Reserved 3) 76253642Sguido * 11001100 - (Reserved 2) 76353642Sguido * 10101011 - Unclassified 76453642Sguido * 11110001 - (Reserved 1) 76553642Sguido */ 76653642Sguido#define IPSO_CLASS_RES4 0x01 76753642Sguido#define IPSO_CLASS_TOPS 0x3d 76853642Sguido#define IPSO_CLASS_SECR 0x5a 76953642Sguido#define IPSO_CLASS_CONF 0x96 77053642Sguido#define IPSO_CLASS_RES3 0x66 77153642Sguido#define IPSO_CLASS_RES2 0xcc 77253642Sguido#define IPSO_CLASS_UNCL 0xab 77353642Sguido#define IPSO_CLASS_RES1 0xf1 77453642Sguido 77553642Sguido#define IPSO_AUTH_GENSER 0x80 77653642Sguido#define IPSO_AUTH_ESI 0x40 77753642Sguido#define IPSO_AUTH_SCI 0x20 77853642Sguido#define IPSO_AUTH_NSA 0x10 77953642Sguido#define IPSO_AUTH_DOE 0x08 78053642Sguido#define IPSO_AUTH_UN 0x06 78153642Sguido#define IPSO_AUTH_FTE 0x01 78253642Sguido 78353642Sguido/* 78453642Sguido * IP option #defines 78553642Sguido */ 786145522Sdarrenr#undef IPOPT_RR 787255332Scy#define IPOPT_RR 7 788145522Sdarrenr#undef IPOPT_ZSU 78953642Sguido#define IPOPT_ZSU 10 /* ZSU */ 790145522Sdarrenr#undef IPOPT_MTUP 79153642Sguido#define IPOPT_MTUP 11 /* MTUP */ 792145522Sdarrenr#undef IPOPT_MTUR 79353642Sguido#define IPOPT_MTUR 12 /* MTUR */ 794145522Sdarrenr#undef IPOPT_ENCODE 79553642Sguido#define IPOPT_ENCODE 15 /* ENCODE */ 796145522Sdarrenr#undef IPOPT_TS 797145522Sdarrenr#define IPOPT_TS 68 798145522Sdarrenr#undef IPOPT_TR 79953642Sguido#define IPOPT_TR 82 /* TR */ 800145522Sdarrenr#undef IPOPT_SECURITY 801145522Sdarrenr#define IPOPT_SECURITY 130 802145522Sdarrenr#undef IPOPT_LSRR 803145522Sdarrenr#define IPOPT_LSRR 131 804145522Sdarrenr#undef IPOPT_E_SEC 80553642Sguido#define IPOPT_E_SEC 133 /* E-SEC */ 806145522Sdarrenr#undef IPOPT_CIPSO 80753642Sguido#define IPOPT_CIPSO 134 /* CIPSO */ 808145522Sdarrenr#undef IPOPT_SATID 809145522Sdarrenr#define IPOPT_SATID 136 81053642Sguido#ifndef IPOPT_SID 81153642Sguido# define IPOPT_SID IPOPT_SATID 81253642Sguido#endif 813145522Sdarrenr#undef IPOPT_SSRR 814145522Sdarrenr#define IPOPT_SSRR 137 815145522Sdarrenr#undef IPOPT_ADDEXT 81653642Sguido#define IPOPT_ADDEXT 147 /* ADDEXT */ 817145522Sdarrenr#undef IPOPT_VISA 81853642Sguido#define IPOPT_VISA 142 /* VISA */ 819145522Sdarrenr#undef IPOPT_IMITD 82053642Sguido#define IPOPT_IMITD 144 /* IMITD */ 821145522Sdarrenr#undef IPOPT_EIP 82253642Sguido#define IPOPT_EIP 145 /* EIP */ 823145522Sdarrenr#undef IPOPT_RTRALRT 824145522Sdarrenr#define IPOPT_RTRALRT 148 /* RTRALRT */ 825145522Sdarrenr#undef IPOPT_SDB 826145522Sdarrenr#define IPOPT_SDB 149 827145522Sdarrenr#undef IPOPT_NSAPA 828145522Sdarrenr#define IPOPT_NSAPA 150 829145522Sdarrenr#undef IPOPT_DPS 830145522Sdarrenr#define IPOPT_DPS 151 831145522Sdarrenr#undef IPOPT_UMP 832145522Sdarrenr#define IPOPT_UMP 152 833145522Sdarrenr#undef IPOPT_FINN 83453642Sguido#define IPOPT_FINN 205 /* FINN */ 835255332Scy#undef IPOPT_AH 836255332Scy#define IPOPT_AH 256+IPPROTO_AH 83753642Sguido 838145522Sdarrenr#ifndef TCPOPT_EOL 839145522Sdarrenr# define TCPOPT_EOL 0 84095418Sdarrenr#endif 841145522Sdarrenr#ifndef TCPOPT_NOP 842145522Sdarrenr# define TCPOPT_NOP 1 84360857Sdarrenr#endif 844145522Sdarrenr#ifndef TCPOPT_MAXSEG 845145522Sdarrenr# define TCPOPT_MAXSEG 2 84667614Sdarrenr#endif 847145522Sdarrenr#ifndef TCPOLEN_MAXSEG 848145522Sdarrenr# define TCPOLEN_MAXSEG 4 849139255Sdarrenr#endif 850145522Sdarrenr#ifndef TCPOPT_WINDOW 851145522Sdarrenr# define TCPOPT_WINDOW 3 852145522Sdarrenr#endif 853145522Sdarrenr#ifndef TCPOLEN_WINDOW 854145522Sdarrenr# define TCPOLEN_WINDOW 3 855145522Sdarrenr#endif 856145522Sdarrenr#ifndef TCPOPT_SACK_PERMITTED 857145522Sdarrenr# define TCPOPT_SACK_PERMITTED 4 858145522Sdarrenr#endif 859145522Sdarrenr#ifndef TCPOLEN_SACK_PERMITTED 860145522Sdarrenr# define TCPOLEN_SACK_PERMITTED 2 861145522Sdarrenr#endif 862145522Sdarrenr#ifndef TCPOPT_SACK 863145522Sdarrenr# define TCPOPT_SACK 5 864145522Sdarrenr#endif 865145522Sdarrenr#ifndef TCPOPT_TIMESTAMP 866145522Sdarrenr# define TCPOPT_TIMESTAMP 8 867145522Sdarrenr#endif 86853642Sguido 86953642Sguido#ifndef ICMP_MINLEN 87053642Sguido# define ICMP_MINLEN 8 87153642Sguido#endif 87292685Sdarrenr#ifndef ICMP_ECHOREPLY 87392685Sdarrenr# define ICMP_ECHOREPLY 0 87492685Sdarrenr#endif 87553642Sguido#ifndef ICMP_UNREACH 87692685Sdarrenr# define ICMP_UNREACH 3 87753642Sguido#endif 87892685Sdarrenr#ifndef ICMP_UNREACH_NET 87992685Sdarrenr# define ICMP_UNREACH_NET 0 88092685Sdarrenr#endif 88192685Sdarrenr#ifndef ICMP_UNREACH_HOST 88292685Sdarrenr# define ICMP_UNREACH_HOST 1 88392685Sdarrenr#endif 88492685Sdarrenr#ifndef ICMP_UNREACH_PROTOCOL 88592685Sdarrenr# define ICMP_UNREACH_PROTOCOL 2 88692685Sdarrenr#endif 88792685Sdarrenr#ifndef ICMP_UNREACH_PORT 88892685Sdarrenr# define ICMP_UNREACH_PORT 3 88992685Sdarrenr#endif 89092685Sdarrenr#ifndef ICMP_UNREACH_NEEDFRAG 89192685Sdarrenr# define ICMP_UNREACH_NEEDFRAG 4 89292685Sdarrenr#endif 89392685Sdarrenr#ifndef ICMP_UNREACH_SRCFAIL 89492685Sdarrenr# define ICMP_UNREACH_SRCFAIL 5 89592685Sdarrenr#endif 89692685Sdarrenr#ifndef ICMP_UNREACH_NET_UNKNOWN 89792685Sdarrenr# define ICMP_UNREACH_NET_UNKNOWN 6 89892685Sdarrenr#endif 89992685Sdarrenr#ifndef ICMP_UNREACH_HOST_UNKNOWN 90092685Sdarrenr# define ICMP_UNREACH_HOST_UNKNOWN 7 90192685Sdarrenr#endif 90292685Sdarrenr#ifndef ICMP_UNREACH_ISOLATED 90392685Sdarrenr# define ICMP_UNREACH_ISOLATED 8 90492685Sdarrenr#endif 90592685Sdarrenr#ifndef ICMP_UNREACH_NET_PROHIB 90692685Sdarrenr# define ICMP_UNREACH_NET_PROHIB 9 90792685Sdarrenr#endif 90892685Sdarrenr#ifndef ICMP_UNREACH_HOST_PROHIB 90992685Sdarrenr# define ICMP_UNREACH_HOST_PROHIB 10 91092685Sdarrenr#endif 91192685Sdarrenr#ifndef ICMP_UNREACH_TOSNET 91292685Sdarrenr# define ICMP_UNREACH_TOSNET 11 91392685Sdarrenr#endif 91492685Sdarrenr#ifndef ICMP_UNREACH_TOSHOST 91592685Sdarrenr# define ICMP_UNREACH_TOSHOST 12 91692685Sdarrenr#endif 91792685Sdarrenr#ifndef ICMP_UNREACH_ADMIN_PROHIBIT 91892685Sdarrenr# define ICMP_UNREACH_ADMIN_PROHIBIT 13 91992685Sdarrenr#endif 920145522Sdarrenr#ifndef ICMP_UNREACH_FILTER 921145522Sdarrenr# define ICMP_UNREACH_FILTER 13 922145522Sdarrenr#endif 92392685Sdarrenr#ifndef ICMP_UNREACH_HOST_PRECEDENCE 92492685Sdarrenr# define ICMP_UNREACH_HOST_PRECEDENCE 14 92592685Sdarrenr#endif 92692685Sdarrenr#ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF 92792685Sdarrenr# define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 92892685Sdarrenr#endif 92953642Sguido#ifndef ICMP_SOURCEQUENCH 93092685Sdarrenr# define ICMP_SOURCEQUENCH 4 93153642Sguido#endif 93292685Sdarrenr#ifndef ICMP_REDIRECT_NET 93392685Sdarrenr# define ICMP_REDIRECT_NET 0 93492685Sdarrenr#endif 93592685Sdarrenr#ifndef ICMP_REDIRECT_HOST 93692685Sdarrenr# define ICMP_REDIRECT_HOST 1 93792685Sdarrenr#endif 93892685Sdarrenr#ifndef ICMP_REDIRECT_TOSNET 93992685Sdarrenr# define ICMP_REDIRECT_TOSNET 2 94092685Sdarrenr#endif 94192685Sdarrenr#ifndef ICMP_REDIRECT_TOSHOST 94292685Sdarrenr# define ICMP_REDIRECT_TOSHOST 3 94392685Sdarrenr#endif 94492685Sdarrenr#ifndef ICMP_ALTHOSTADDR 94592685Sdarrenr# define ICMP_ALTHOSTADDR 6 94692685Sdarrenr#endif 94753642Sguido#ifndef ICMP_TIMXCEED 94892685Sdarrenr# define ICMP_TIMXCEED 11 94953642Sguido#endif 95092685Sdarrenr#ifndef ICMP_TIMXCEED_INTRANS 95192685Sdarrenr# define ICMP_TIMXCEED_INTRANS 0 95292685Sdarrenr#endif 95392685Sdarrenr#ifndef ICMP_TIMXCEED_REASS 95492685Sdarrenr# define ICMP_TIMXCEED_REASS 1 95592685Sdarrenr#endif 95653642Sguido#ifndef ICMP_PARAMPROB 95792685Sdarrenr# define ICMP_PARAMPROB 12 95853642Sguido#endif 95992685Sdarrenr#ifndef ICMP_PARAMPROB_ERRATPTR 96092685Sdarrenr# define ICMP_PARAMPROB_ERRATPTR 0 96192685Sdarrenr#endif 96292685Sdarrenr#ifndef ICMP_PARAMPROB_OPTABSENT 96392685Sdarrenr# define ICMP_PARAMPROB_OPTABSENT 1 96492685Sdarrenr#endif 96592685Sdarrenr#ifndef ICMP_PARAMPROB_LENGTH 96692685Sdarrenr# define ICMP_PARAMPROB_LENGTH 2 96792685Sdarrenr#endif 96853642Sguido#ifndef ICMP_TSTAMP 96992685Sdarrenr# define ICMP_TSTAMP 13 97053642Sguido#endif 97153642Sguido#ifndef ICMP_TSTAMPREPLY 97292685Sdarrenr# define ICMP_TSTAMPREPLY 14 97353642Sguido#endif 97453642Sguido#ifndef ICMP_IREQ 97592685Sdarrenr# define ICMP_IREQ 15 97653642Sguido#endif 97753642Sguido#ifndef ICMP_IREQREPLY 97892685Sdarrenr# define ICMP_IREQREPLY 16 97953642Sguido#endif 98053642Sguido#ifndef ICMP_MASKREQ 98192685Sdarrenr# define ICMP_MASKREQ 17 98253642Sguido#endif 98353642Sguido#ifndef ICMP_MASKREPLY 98492685Sdarrenr# define ICMP_MASKREPLY 18 98553642Sguido#endif 98692685Sdarrenr#ifndef ICMP_TRACEROUTE 98792685Sdarrenr# define ICMP_TRACEROUTE 30 98880482Sdarrenr#endif 98992685Sdarrenr#ifndef ICMP_DATACONVERR 99092685Sdarrenr# define ICMP_DATACONVERR 31 99192685Sdarrenr#endif 99292685Sdarrenr#ifndef ICMP_MOBILE_REDIRECT 99392685Sdarrenr# define ICMP_MOBILE_REDIRECT 32 99492685Sdarrenr#endif 99592685Sdarrenr#ifndef ICMP_IPV6_WHEREAREYOU 99692685Sdarrenr# define ICMP_IPV6_WHEREAREYOU 33 99792685Sdarrenr#endif 99892685Sdarrenr#ifndef ICMP_IPV6_IAMHERE 99992685Sdarrenr# define ICMP_IPV6_IAMHERE 34 100092685Sdarrenr#endif 100192685Sdarrenr#ifndef ICMP_MOBILE_REGREQUEST 100292685Sdarrenr# define ICMP_MOBILE_REGREQUEST 35 100392685Sdarrenr#endif 100492685Sdarrenr#ifndef ICMP_MOBILE_REGREPLY 100592685Sdarrenr# define ICMP_MOBILE_REGREPLY 36 100692685Sdarrenr#endif 100792685Sdarrenr#ifndef ICMP_SKIP 100892685Sdarrenr# define ICMP_SKIP 39 100992685Sdarrenr#endif 101092685Sdarrenr#ifndef ICMP_PHOTURIS 101192685Sdarrenr# define ICMP_PHOTURIS 40 101292685Sdarrenr#endif 101392685Sdarrenr#ifndef ICMP_PHOTURIS_UNKNOWN_INDEX 101492685Sdarrenr# define ICMP_PHOTURIS_UNKNOWN_INDEX 1 101592685Sdarrenr#endif 101692685Sdarrenr#ifndef ICMP_PHOTURIS_AUTH_FAILED 101792685Sdarrenr# define ICMP_PHOTURIS_AUTH_FAILED 2 101892685Sdarrenr#endif 101992685Sdarrenr#ifndef ICMP_PHOTURIS_DECRYPT_FAILED 102092685Sdarrenr# define ICMP_PHOTURIS_DECRYPT_FAILED 3 102192685Sdarrenr#endif 102253642Sguido#ifndef IPVERSION 102353642Sguido# define IPVERSION 4 102453642Sguido#endif 102553642Sguido#ifndef IPOPT_MINOFF 102653642Sguido# define IPOPT_MINOFF 4 102753642Sguido#endif 102853642Sguido#ifndef IPOPT_COPIED 102953642Sguido# define IPOPT_COPIED(x) ((x)&0x80) 103053642Sguido#endif 103153642Sguido#ifndef IPOPT_EOL 103253642Sguido# define IPOPT_EOL 0 103353642Sguido#endif 103453642Sguido#ifndef IPOPT_NOP 103553642Sguido# define IPOPT_NOP 1 103653642Sguido#endif 103753642Sguido#ifndef IP_MF 103853642Sguido# define IP_MF ((u_short)0x2000) 103953642Sguido#endif 104053642Sguido#ifndef ETHERTYPE_IP 104153642Sguido# define ETHERTYPE_IP ((u_short)0x0800) 104253642Sguido#endif 104353642Sguido#ifndef TH_FIN 104453642Sguido# define TH_FIN 0x01 104553642Sguido#endif 104653642Sguido#ifndef TH_SYN 104753642Sguido# define TH_SYN 0x02 104853642Sguido#endif 104953642Sguido#ifndef TH_RST 105053642Sguido# define TH_RST 0x04 105153642Sguido#endif 105253642Sguido#ifndef TH_PUSH 105353642Sguido# define TH_PUSH 0x08 105453642Sguido#endif 105553642Sguido#ifndef TH_ACK 105653642Sguido# define TH_ACK 0x10 105753642Sguido#endif 105853642Sguido#ifndef TH_URG 105953642Sguido# define TH_URG 0x20 106053642Sguido#endif 1061145522Sdarrenr#undef TH_ACKMASK 1062145522Sdarrenr#define TH_ACKMASK (TH_FIN|TH_SYN|TH_RST|TH_ACK) 1063145522Sdarrenr 106453642Sguido#ifndef IPOPT_EOL 106553642Sguido# define IPOPT_EOL 0 106653642Sguido#endif 106753642Sguido#ifndef IPOPT_NOP 106853642Sguido# define IPOPT_NOP 1 106953642Sguido#endif 107053642Sguido#ifndef IPOPT_RR 107153642Sguido# define IPOPT_RR 7 107253642Sguido#endif 107353642Sguido#ifndef IPOPT_TS 107453642Sguido# define IPOPT_TS 68 107553642Sguido#endif 107653642Sguido#ifndef IPOPT_SECURITY 107753642Sguido# define IPOPT_SECURITY 130 107853642Sguido#endif 107953642Sguido#ifndef IPOPT_LSRR 108053642Sguido# define IPOPT_LSRR 131 108153642Sguido#endif 108253642Sguido#ifndef IPOPT_SATID 108353642Sguido# define IPOPT_SATID 136 108453642Sguido#endif 108553642Sguido#ifndef IPOPT_SSRR 108653642Sguido# define IPOPT_SSRR 137 108753642Sguido#endif 108853642Sguido#ifndef IPOPT_SECUR_UNCLASS 108953642Sguido# define IPOPT_SECUR_UNCLASS ((u_short)0x0000) 109053642Sguido#endif 109153642Sguido#ifndef IPOPT_SECUR_CONFID 109253642Sguido# define IPOPT_SECUR_CONFID ((u_short)0xf135) 109353642Sguido#endif 109453642Sguido#ifndef IPOPT_SECUR_EFTO 109553642Sguido# define IPOPT_SECUR_EFTO ((u_short)0x789a) 109653642Sguido#endif 109753642Sguido#ifndef IPOPT_SECUR_MMMM 109853642Sguido# define IPOPT_SECUR_MMMM ((u_short)0xbc4d) 109953642Sguido#endif 110053642Sguido#ifndef IPOPT_SECUR_RESTR 110153642Sguido# define IPOPT_SECUR_RESTR ((u_short)0xaf13) 110253642Sguido#endif 110353642Sguido#ifndef IPOPT_SECUR_SECRET 110453642Sguido# define IPOPT_SECUR_SECRET ((u_short)0xd788) 110553642Sguido#endif 110653642Sguido#ifndef IPOPT_SECUR_TOPSECRET 110753642Sguido# define IPOPT_SECUR_TOPSECRET ((u_short)0x6bc5) 110853642Sguido#endif 110953642Sguido#ifndef IPOPT_OLEN 111053642Sguido# define IPOPT_OLEN 1 111153642Sguido#endif 1112145522Sdarrenr#ifndef IPPROTO_HOPOPTS 1113145522Sdarrenr# define IPPROTO_HOPOPTS 0 1114145522Sdarrenr#endif 1115255332Scy#ifndef IPPROTO_IPIP 1116255332Scy# define IPPROTO_IPIP 4 1117255332Scy#endif 1118145522Sdarrenr#ifndef IPPROTO_ENCAP 1119255332Scy# define IPPROTO_ENCAP 98 1120145522Sdarrenr#endif 1121145522Sdarrenr#ifndef IPPROTO_IPV6 1122145522Sdarrenr# define IPPROTO_IPV6 41 1123145522Sdarrenr#endif 1124145522Sdarrenr#ifndef IPPROTO_ROUTING 1125145522Sdarrenr# define IPPROTO_ROUTING 43 1126145522Sdarrenr#endif 1127145522Sdarrenr#ifndef IPPROTO_FRAGMENT 1128145522Sdarrenr# define IPPROTO_FRAGMENT 44 1129145522Sdarrenr#endif 113092685Sdarrenr#ifndef IPPROTO_GRE 113192685Sdarrenr# define IPPROTO_GRE 47 /* GRE encaps RFC 1701 */ 113292685Sdarrenr#endif 113392685Sdarrenr#ifndef IPPROTO_ESP 113492685Sdarrenr# define IPPROTO_ESP 50 113592685Sdarrenr#endif 1136145522Sdarrenr#ifndef IPPROTO_AH 1137145522Sdarrenr# define IPPROTO_AH 51 1138145522Sdarrenr#endif 113992685Sdarrenr#ifndef IPPROTO_ICMPV6 114092685Sdarrenr# define IPPROTO_ICMPV6 58 114192685Sdarrenr#endif 1142145522Sdarrenr#ifndef IPPROTO_NONE 1143145522Sdarrenr# define IPPROTO_NONE 59 114453642Sguido#endif 1145145522Sdarrenr#ifndef IPPROTO_DSTOPTS 1146145522Sdarrenr# define IPPROTO_DSTOPTS 60 114753642Sguido#endif 1148153876Sguido#ifndef IPPROTO_MOBILITY 1149153876Sguido# define IPPROTO_MOBILITY 135 115053642Sguido#endif 1151153876Sguido 115253642Sguido#ifndef ICMP_ROUTERADVERT 115353642Sguido# define ICMP_ROUTERADVERT 9 115453642Sguido#endif 115553642Sguido#ifndef ICMP_ROUTERSOLICIT 115653642Sguido# define ICMP_ROUTERSOLICIT 10 115753642Sguido#endif 115892685Sdarrenr#ifndef ICMP6_DST_UNREACH 115992685Sdarrenr# define ICMP6_DST_UNREACH 1 116092685Sdarrenr#endif 116192685Sdarrenr#ifndef ICMP6_PACKET_TOO_BIG 116292685Sdarrenr# define ICMP6_PACKET_TOO_BIG 2 116392685Sdarrenr#endif 116492685Sdarrenr#ifndef ICMP6_TIME_EXCEEDED 116592685Sdarrenr# define ICMP6_TIME_EXCEEDED 3 116692685Sdarrenr#endif 116792685Sdarrenr#ifndef ICMP6_PARAM_PROB 116892685Sdarrenr# define ICMP6_PARAM_PROB 4 116992685Sdarrenr#endif 117092685Sdarrenr 117192685Sdarrenr#ifndef ICMP6_ECHO_REQUEST 117292685Sdarrenr# define ICMP6_ECHO_REQUEST 128 117392685Sdarrenr#endif 117492685Sdarrenr#ifndef ICMP6_ECHO_REPLY 117592685Sdarrenr# define ICMP6_ECHO_REPLY 129 117692685Sdarrenr#endif 117792685Sdarrenr#ifndef ICMP6_MEMBERSHIP_QUERY 117892685Sdarrenr# define ICMP6_MEMBERSHIP_QUERY 130 117992685Sdarrenr#endif 118092685Sdarrenr#ifndef MLD6_LISTENER_QUERY 118192685Sdarrenr# define MLD6_LISTENER_QUERY 130 118292685Sdarrenr#endif 118392685Sdarrenr#ifndef ICMP6_MEMBERSHIP_REPORT 118492685Sdarrenr# define ICMP6_MEMBERSHIP_REPORT 131 118592685Sdarrenr#endif 118692685Sdarrenr#ifndef MLD6_LISTENER_REPORT 118792685Sdarrenr# define MLD6_LISTENER_REPORT 131 118892685Sdarrenr#endif 118992685Sdarrenr#ifndef ICMP6_MEMBERSHIP_REDUCTION 119092685Sdarrenr# define ICMP6_MEMBERSHIP_REDUCTION 132 119192685Sdarrenr#endif 119292685Sdarrenr#ifndef MLD6_LISTENER_DONE 119392685Sdarrenr# define MLD6_LISTENER_DONE 132 119492685Sdarrenr#endif 119592685Sdarrenr#ifndef ND_ROUTER_SOLICIT 119692685Sdarrenr# define ND_ROUTER_SOLICIT 133 119792685Sdarrenr#endif 119892685Sdarrenr#ifndef ND_ROUTER_ADVERT 119992685Sdarrenr# define ND_ROUTER_ADVERT 134 120092685Sdarrenr#endif 120192685Sdarrenr#ifndef ND_NEIGHBOR_SOLICIT 120292685Sdarrenr# define ND_NEIGHBOR_SOLICIT 135 120392685Sdarrenr#endif 120492685Sdarrenr#ifndef ND_NEIGHBOR_ADVERT 120592685Sdarrenr# define ND_NEIGHBOR_ADVERT 136 120692685Sdarrenr#endif 120792685Sdarrenr#ifndef ND_REDIRECT 120892685Sdarrenr# define ND_REDIRECT 137 120992685Sdarrenr#endif 121092685Sdarrenr#ifndef ICMP6_ROUTER_RENUMBERING 121192685Sdarrenr# define ICMP6_ROUTER_RENUMBERING 138 121292685Sdarrenr#endif 121392685Sdarrenr#ifndef ICMP6_WRUREQUEST 121492685Sdarrenr# define ICMP6_WRUREQUEST 139 121592685Sdarrenr#endif 121692685Sdarrenr#ifndef ICMP6_WRUREPLY 121792685Sdarrenr# define ICMP6_WRUREPLY 140 121892685Sdarrenr#endif 121992685Sdarrenr#ifndef ICMP6_FQDN_QUERY 122092685Sdarrenr# define ICMP6_FQDN_QUERY 139 122192685Sdarrenr#endif 122292685Sdarrenr#ifndef ICMP6_FQDN_REPLY 122392685Sdarrenr# define ICMP6_FQDN_REPLY 140 122492685Sdarrenr#endif 122592685Sdarrenr#ifndef ICMP6_NI_QUERY 122692685Sdarrenr# define ICMP6_NI_QUERY 139 122792685Sdarrenr#endif 122892685Sdarrenr#ifndef ICMP6_NI_REPLY 122992685Sdarrenr# define ICMP6_NI_REPLY 140 123092685Sdarrenr#endif 123192685Sdarrenr#ifndef MLD6_MTRACE_RESP 123292685Sdarrenr# define MLD6_MTRACE_RESP 200 123392685Sdarrenr#endif 123492685Sdarrenr#ifndef MLD6_MTRACE 123592685Sdarrenr# define MLD6_MTRACE 201 123692685Sdarrenr#endif 123792685Sdarrenr#ifndef ICMP6_HADISCOV_REQUEST 123892685Sdarrenr# define ICMP6_HADISCOV_REQUEST 202 123992685Sdarrenr#endif 124092685Sdarrenr#ifndef ICMP6_HADISCOV_REPLY 124192685Sdarrenr# define ICMP6_HADISCOV_REPLY 203 124292685Sdarrenr#endif 124392685Sdarrenr#ifndef ICMP6_MOBILEPREFIX_SOLICIT 124492685Sdarrenr# define ICMP6_MOBILEPREFIX_SOLICIT 204 124592685Sdarrenr#endif 124692685Sdarrenr#ifndef ICMP6_MOBILEPREFIX_ADVERT 124792685Sdarrenr# define ICMP6_MOBILEPREFIX_ADVERT 205 124892685Sdarrenr#endif 124992685Sdarrenr#ifndef ICMP6_MAXTYPE 125092685Sdarrenr# define ICMP6_MAXTYPE 205 125192685Sdarrenr#endif 125292685Sdarrenr 125392685Sdarrenr#ifndef ICMP6_DST_UNREACH_NOROUTE 125492685Sdarrenr# define ICMP6_DST_UNREACH_NOROUTE 0 125592685Sdarrenr#endif 125692685Sdarrenr#ifndef ICMP6_DST_UNREACH_ADMIN 125792685Sdarrenr# define ICMP6_DST_UNREACH_ADMIN 1 125892685Sdarrenr#endif 125992685Sdarrenr#ifndef ICMP6_DST_UNREACH_NOTNEIGHBOR 126092685Sdarrenr# define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 126192685Sdarrenr#endif 126292685Sdarrenr#ifndef ICMP6_DST_UNREACH_BEYONDSCOPE 126392685Sdarrenr# define ICMP6_DST_UNREACH_BEYONDSCOPE 2 126492685Sdarrenr#endif 126592685Sdarrenr#ifndef ICMP6_DST_UNREACH_ADDR 126692685Sdarrenr# define ICMP6_DST_UNREACH_ADDR 3 126792685Sdarrenr#endif 126892685Sdarrenr#ifndef ICMP6_DST_UNREACH_NOPORT 126992685Sdarrenr# define ICMP6_DST_UNREACH_NOPORT 4 127092685Sdarrenr#endif 127192685Sdarrenr#ifndef ICMP6_TIME_EXCEED_TRANSIT 127292685Sdarrenr# define ICMP6_TIME_EXCEED_TRANSIT 0 127392685Sdarrenr#endif 127492685Sdarrenr#ifndef ICMP6_TIME_EXCEED_REASSEMBLY 127592685Sdarrenr# define ICMP6_TIME_EXCEED_REASSEMBLY 1 127692685Sdarrenr#endif 127792685Sdarrenr 127892685Sdarrenr#ifndef ICMP6_NI_SUCCESS 127992685Sdarrenr# define ICMP6_NI_SUCCESS 0 128092685Sdarrenr#endif 128192685Sdarrenr#ifndef ICMP6_NI_REFUSED 128292685Sdarrenr# define ICMP6_NI_REFUSED 1 128392685Sdarrenr#endif 128492685Sdarrenr#ifndef ICMP6_NI_UNKNOWN 128592685Sdarrenr# define ICMP6_NI_UNKNOWN 2 128692685Sdarrenr#endif 128792685Sdarrenr 128892685Sdarrenr#ifndef ICMP6_ROUTER_RENUMBERING_COMMAND 128992685Sdarrenr# define ICMP6_ROUTER_RENUMBERING_COMMAND 0 129092685Sdarrenr#endif 129192685Sdarrenr#ifndef ICMP6_ROUTER_RENUMBERING_RESULT 129292685Sdarrenr# define ICMP6_ROUTER_RENUMBERING_RESULT 1 129392685Sdarrenr#endif 129492685Sdarrenr#ifndef ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 129592685Sdarrenr# define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 129692685Sdarrenr#endif 129792685Sdarrenr 129892685Sdarrenr#ifndef ICMP6_PARAMPROB_HEADER 129992685Sdarrenr# define ICMP6_PARAMPROB_HEADER 0 130092685Sdarrenr#endif 130192685Sdarrenr#ifndef ICMP6_PARAMPROB_NEXTHEADER 130292685Sdarrenr# define ICMP6_PARAMPROB_NEXTHEADER 1 130392685Sdarrenr#endif 130492685Sdarrenr#ifndef ICMP6_PARAMPROB_OPTION 130592685Sdarrenr# define ICMP6_PARAMPROB_OPTION 2 130692685Sdarrenr#endif 130792685Sdarrenr 130892685Sdarrenr#ifndef ICMP6_NI_SUBJ_IPV6 130992685Sdarrenr# define ICMP6_NI_SUBJ_IPV6 0 131092685Sdarrenr#endif 131192685Sdarrenr#ifndef ICMP6_NI_SUBJ_FQDN 131292685Sdarrenr# define ICMP6_NI_SUBJ_FQDN 1 131392685Sdarrenr#endif 131492685Sdarrenr#ifndef ICMP6_NI_SUBJ_IPV4 131592685Sdarrenr# define ICMP6_NI_SUBJ_IPV4 2 131692685Sdarrenr#endif 131792685Sdarrenr 1318255332Scy#ifndef MLD_MTRACE_RESP 1319255332Scy# define MLD_MTRACE_RESP 200 1320255332Scy#endif 1321255332Scy#ifndef MLD_MTRACE 1322255332Scy# define MLD_MTRACE 201 1323255332Scy#endif 1324255332Scy#ifndef MLD6_MTRACE_RESP 1325255332Scy# define MLD6_MTRACE_RESP MLD_MTRACE_RESP 1326255332Scy#endif 1327255332Scy#ifndef MLD6_MTRACE 1328255332Scy# define MLD6_MTRACE MLD_MTRACE 1329255332Scy#endif 1330255332Scy 1331255332Scy#if !defined(IPV6_FLOWINFO_MASK) 1332255332Scy# if (BYTE_ORDER == BIG_ENDIAN) || defined(_BIG_ENDIAN) 1333255332Scy# define IPV6_FLOWINFO_MASK 0x0fffffff /* flow info (28 bits) */ 1334255332Scy# else 1335255332Scy# if(BYTE_ORDER == LITTLE_ENDIAN) || !defined(_BIG_ENDIAN) 1336255332Scy# define IPV6_FLOWINFO_MASK 0xffffff0f /* flow info (28 bits) */ 1337255332Scy# endif /* LITTLE_ENDIAN */ 1338255332Scy# endif 1339255332Scy#endif 1340255332Scy#if !defined(IPV6_FLOWLABEL_MASK) 1341255332Scy# if (BYTE_ORDER == BIG_ENDIAN) || defined(_BIG_ENDIAN) 1342255332Scy# define IPV6_FLOWLABEL_MASK 0x000fffff /* flow label (20 bits) */ 1343255332Scy# else 1344255332Scy# if (BYTE_ORDER == LITTLE_ENDIAN) || !defined(_BIG_ENDIAN) 1345255332Scy# define IPV6_FLOWLABEL_MASK 0xffff0f00 /* flow label (20 bits) */ 1346255332Scy# endif /* LITTLE_ENDIAN */ 1347255332Scy# endif 1348255332Scy#endif 1349255332Scy 135072006Sdarrenr/* 135172006Sdarrenr * ECN is a new addition to TCP - RFC 2481 135272006Sdarrenr */ 135372006Sdarrenr#ifndef TH_ECN 135472006Sdarrenr# define TH_ECN 0x40 135572006Sdarrenr#endif 135672006Sdarrenr#ifndef TH_CWR 135772006Sdarrenr# define TH_CWR 0x80 135872006Sdarrenr#endif 135972006Sdarrenr#define TH_ECNALL (TH_ECN|TH_CWR) 136072006Sdarrenr 1361145522Sdarrenr/* 1362145522Sdarrenr * TCP States 1363145522Sdarrenr */ 1364170268Sdarrenr#define IPF_TCPS_LISTEN 0 /* listening for connection */ 1365170268Sdarrenr#define IPF_TCPS_SYN_SENT 1 /* active, have sent syn */ 1366170268Sdarrenr#define IPF_TCPS_SYN_RECEIVED 2 /* have send and received syn */ 1367170268Sdarrenr#define IPF_TCPS_HALF_ESTAB 3 /* for connections not fully "up" */ 1368145522Sdarrenr/* states < IPF_TCPS_ESTABLISHED are those where connections not established */ 1369170268Sdarrenr#define IPF_TCPS_ESTABLISHED 4 /* established */ 1370170268Sdarrenr#define IPF_TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */ 1371145522Sdarrenr/* states > IPF_TCPS_CLOSE_WAIT are those where user has closed */ 1372170268Sdarrenr#define IPF_TCPS_FIN_WAIT_1 6 /* have closed, sent fin */ 1373170268Sdarrenr#define IPF_TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */ 1374170268Sdarrenr#define IPF_TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */ 1375145522Sdarrenr/* states > IPF_TCPS_CLOSE_WAIT && < IPF_TCPS_FIN_WAIT_2 await ACK of FIN */ 1376170268Sdarrenr#define IPF_TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */ 1377170268Sdarrenr#define IPF_TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */ 1378170268Sdarrenr#define IPF_TCPS_CLOSED 11 /* closed */ 1379145522Sdarrenr#define IPF_TCP_NSTATES 12 138072006Sdarrenr 1381145522Sdarrenr#define TCP_MSL 120 1382145522Sdarrenr 1383145522Sdarrenr#undef ICMP_MAX_UNREACH 1384145522Sdarrenr#define ICMP_MAX_UNREACH 14 1385145522Sdarrenr#undef ICMP_MAXTYPE 1386145522Sdarrenr#define ICMP_MAXTYPE 18 1387145522Sdarrenr 1388145522Sdarrenr#ifndef LOG_FTP 1389145522Sdarrenr# define LOG_FTP (11<<3) 1390145522Sdarrenr#endif 1391145522Sdarrenr#ifndef LOG_AUTHPRIV 1392145522Sdarrenr# define LOG_AUTHPRIV (10<<3) 1393145522Sdarrenr#endif 1394145522Sdarrenr#ifndef LOG_AUDIT 1395145522Sdarrenr# define LOG_AUDIT (13<<3) 1396145522Sdarrenr#endif 1397145522Sdarrenr#ifndef LOG_NTP 1398145522Sdarrenr# define LOG_NTP (12<<3) 1399145522Sdarrenr#endif 1400145522Sdarrenr#ifndef LOG_SECURITY 1401145522Sdarrenr# define LOG_SECURITY (13<<3) 1402145522Sdarrenr#endif 1403145522Sdarrenr#ifndef LOG_LFMT 1404145522Sdarrenr# define LOG_LFMT (14<<3) 1405145522Sdarrenr#endif 1406145522Sdarrenr#ifndef LOG_CONSOLE 1407145522Sdarrenr# define LOG_CONSOLE (14<<3) 1408145522Sdarrenr#endif 1409145522Sdarrenr 1410145522Sdarrenr/* 1411145522Sdarrenr * ICMP error replies have an IP header (20 bytes), 8 bytes of ICMP data, 1412145522Sdarrenr * another IP header and then 64 bits of data, totalling 56. Of course, 1413153876Sguido * the last 64 bits is dependent on that being available. 1414145522Sdarrenr */ 1415145522Sdarrenr#define ICMPERR_ICMPHLEN 8 1416145522Sdarrenr#define ICMPERR_IPICMPHLEN (20 + 8) 1417145522Sdarrenr#define ICMPERR_MINPKTLEN (20 + 8 + 20) 1418145522Sdarrenr#define ICMPERR_MAXPKTLEN (20 + 8 + 20 + 8) 1419145522Sdarrenr#define ICMP6ERR_MINPKTLEN (40 + 8) 1420145522Sdarrenr#define ICMP6ERR_IPICMPHLEN (40 + 8 + 40) 1421145522Sdarrenr 1422145522Sdarrenr#ifndef MIN 1423145522Sdarrenr# define MIN(a,b) (((a)<(b))?(a):(b)) 1424145522Sdarrenr#endif 1425145522Sdarrenr 1426255332Scy#ifdef RESCUE 1427255332Scy# undef IPFILTER_BPF 1428255332Scy#endif 1429255332Scy 1430145522Sdarrenr#ifdef IPF_DEBUG 1431145522Sdarrenr# define DPRINT(x) printf x 1432145522Sdarrenr#else 1433145522Sdarrenr# define DPRINT(x) 1434145522Sdarrenr#endif 1435145522Sdarrenr 1436255332Scy#ifdef DTRACE_PROBE 1437255332Scy# ifdef _KERNEL 1438255332Scy# define DT(_n) DTRACE_PROBE(_n) 1439255332Scy# define DT1(_n,_a,_b) DTRACE_PROBE1(_n,_a,_b) 1440255332Scy# define DT2(_n,_a,_b,_c,_d) DTRACE_PROBE2(_n,_a,_b,_c,_d) 1441255332Scy# define DT3(_n,_a,_b,_c,_d,_e,_f) \ 1442255332Scy DTRACE_PROBE3(_n,_a,_b,_c,_d,_e,_f) 1443255332Scy# define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h) \ 1444255332Scy DTRACE_PROBE4(_n,_a,_b,_c,_d,_e,_f,_g,_h) 1445255332Scy# else 1446255332Scy# define DT(_n) 1447255332Scy# define DT1(_n,_a,_b) 1448255332Scy# define DT2(_n,_a,_b,_c,_d) 1449255332Scy# define DT3(_n,_a,_b,_c,_d,_e,_f) 1450255332Scy# define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h) 1451255332Scy# endif 1452255332Scy#else 1453255332Scy# define DT(_n) 1454255332Scy# define DT1(_n,_a,_b) 1455255332Scy# define DT2(_n,_a,_b,_c,_d) 1456255332Scy# define DT3(_n,_a,_b,_c,_d,_e,_f) 1457255332Scy# define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h) 1458255332Scy#endif 1459255332Scy 1460255332Scystruct ip6_routing { 1461255332Scy u_char ip6r_nxt; /* next header */ 1462255332Scy u_char ip6r_len; /* length in units of 8 octets */ 1463255332Scy u_char ip6r_type; /* always zero */ 1464255332Scy u_char ip6r_segleft; /* segments left */ 1465255332Scy u_32_t ip6r_reserved; /* reserved field */ 1466255332Scy}; 1467255332Scy 146853642Sguido#endif /* __IP_COMPAT_H__ */ 1469