ip_compat.h revision 305138
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/11/sys/contrib/ipfilter/netinet/ip_compat.h 305138 2016-08-31 18:00:41Z dim $ 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 127269585Scy# else 128269585Scy# if !defined(USE_INET6) && !defined(NOINET6) 129269585Scy# define USE_INET6 130269585Scy# 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 149145522Sdarrenr# define NETBSD_PF 150255332Scy# else 151255332Scy# include <inttypes.h> 152145522Sdarrenr# endif /* _KERNEL */ 153145522Sdarrenr 154255332Scy# include <sys/selinfo.h> 155257218Sglebius# include <sys/lock.h> 156295126Sglebius# include <sys/malloc.h> 157145522Sdarrenr# include <sys/mutex.h> 158255332Scy# define KRWLOCK_FILL_SZ 56 159255332Scy# define KMUTEX_FILL_SZ 56 160172776Sdarrenr# include <sys/rwlock.h> 161255332Scy# define KMUTEX_T struct mtx 162255332Scy# define KRWLOCK_T struct rwlock 163281192Sglebius 164281192Sglebius#ifdef _KERNEL 165255332Scy# define READ_ENTER(x) rw_rlock(&(x)->ipf_lk) 166255332Scy# define WRITE_ENTER(x) rw_wlock(&(x)->ipf_lk) 167255332Scy# define MUTEX_DOWNGRADE(x) rw_downgrade(&(x)->ipf_lk) 168255332Scy# define RWLOCK_INIT(x,y) rw_init(&(x)->ipf_lk, (y)) 169255332Scy# define RW_DESTROY(x) rw_destroy(&(x)->ipf_lk) 170255332Scy# define RWLOCK_EXIT(x) do { \ 171172776Sdarrenr if (rw_wowned(&(x)->ipf_lk)) \ 172255332Scy rw_wunlock(&(x)->ipf_lk); \ 173255332Scy else \ 174172776Sdarrenr rw_runlock(&(x)->ipf_lk); \ 175172776Sdarrenr } while (0) 176145522Sdarrenr# include <net/if_var.h> 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 219281192Sglebius#else /* !_KERNEL */ 220281192Sglebius#ifndef _NET_IF_VAR_H_ 221281192Sglebius/* 222281192Sglebius * Userland emulation of struct ifnet. 223281192Sglebius */ 224281192Sglebiusstruct route; 225281192Sglebiusstruct mbuf; 226281192Sglebiusstruct ifnet { 227281192Sglebius char if_xname[IFNAMSIZ]; 228281192Sglebius TAILQ_HEAD(, ifaddr) if_addrlist; 229281192Sglebius int (*if_output)(struct ifnet *, struct mbuf *, 230281192Sglebius const struct sockaddr *, struct route *); 231281192Sglebius}; 232281192Sglebius#endif /* _NET_IF_VAR_H_ */ 233281192Sglebius#endif /* _KERNEL */ 234145522Sdarrenr 235281192Sglebius# define IFNAME(x) ((struct ifnet *)x)->if_xname 236281192Sglebius# define COPYIFNAME(v, x, b) \ 237281192Sglebius (void) strncpy(b, \ 238281192Sglebius ((struct ifnet *)x)->if_xname, \ 239281192Sglebius LIFNAMSIZ) 240281192Sglebius 241145522Sdarrenrtypedef u_long ioctlcmd_t; 242145522Sdarrenrtypedef struct uio uio_t; 243145522Sdarrenrtypedef int minor_t; 244145522Sdarrenrtypedef u_int32_t u_32_t; 245145522Sdarrenr# define U_32_T 1 246145522Sdarrenr 247145522Sdarrenr 248145522Sdarrenr/* ----------------------------------------------------------------------- */ 249145522Sdarrenr/* G E N E R I C */ 250145522Sdarrenr/* ----------------------------------------------------------------------- */ 251145522Sdarrenr 252145522Sdarrenr/* 253145522Sdarrenr * For BSD kernels, if bpf is in the kernel, enable ipfilter to use bpf in 254145522Sdarrenr * filter rules. 255145522Sdarrenr */ 256153876Sguido#if !defined(IPFILTER_BPF) 257153876Sguido# if (defined(NBPF) && (NBPF > 0)) || (defined(DEV_BPF) && (DEV_BPF > 0)) || \ 258153876Sguido (defined(NBPFILTER) && (NBPFILTER > 0)) 259153876Sguido# define IPFILTER_BPF 260153876Sguido# endif 261145522Sdarrenr#endif 262145522Sdarrenr 263145522Sdarrenr/* 264145522Sdarrenr * Userland locking primitives 265145522Sdarrenr */ 266255332Scy#ifndef _KERNEL 267255332Scy#if !defined(KMUTEX_FILL_SZ) 268255332Scy# define KMUTEX_FILL_SZ 1 269255332Scy#endif 270255332Scy#if !defined(KRWLOCK_FILL_SZ) 271255332Scy# define KRWLOCK_FILL_SZ 1 272255332Scy#endif 273255332Scy#endif 274255332Scy 275145522Sdarrenrtypedef struct { 276145522Sdarrenr char *eMm_owner; 277145522Sdarrenr char *eMm_heldin; 278145522Sdarrenr u_int eMm_magic; 279145522Sdarrenr int eMm_held; 280145522Sdarrenr int eMm_heldat; 281145522Sdarrenr} eMmutex_t; 282145522Sdarrenr 283145522Sdarrenrtypedef struct { 284145522Sdarrenr char *eMrw_owner; 285145522Sdarrenr char *eMrw_heldin; 286145522Sdarrenr u_int eMrw_magic; 287145522Sdarrenr short eMrw_read; 288145522Sdarrenr short eMrw_write; 289145522Sdarrenr int eMrw_heldat; 290145522Sdarrenr} eMrwlock_t; 291145522Sdarrenr 292145522Sdarrenrtypedef union { 293255332Scy char _fill[KMUTEX_FILL_SZ]; 294145522Sdarrenr#ifdef KMUTEX_T 295145522Sdarrenr struct { 296145522Sdarrenr KMUTEX_T ipf_slk; 297255332Scy const char *ipf_lname; 298145522Sdarrenr } ipf_lkun_s; 299145522Sdarrenr#endif 300145522Sdarrenr eMmutex_t ipf_emu; 301145522Sdarrenr} ipfmutex_t; 302145522Sdarrenr 303145522Sdarrenrtypedef union { 304255332Scy char _fill[KRWLOCK_FILL_SZ]; 305145522Sdarrenr#ifdef KRWLOCK_T 306145522Sdarrenr struct { 307145522Sdarrenr KRWLOCK_T ipf_slk; 308255332Scy const char *ipf_lname; 309145522Sdarrenr int ipf_sr; 310145522Sdarrenr int ipf_sw; 311145522Sdarrenr u_int ipf_magic; 312145522Sdarrenr } ipf_lkun_s; 313145522Sdarrenr#endif 314145522Sdarrenr eMrwlock_t ipf_emu; 315145522Sdarrenr} ipfrwlock_t; 316145522Sdarrenr 317145522Sdarrenr#define ipf_lk ipf_lkun_s.ipf_slk 318145522Sdarrenr#define ipf_lname ipf_lkun_s.ipf_lname 319145522Sdarrenr#define ipf_isr ipf_lkun_s.ipf_sr 320145522Sdarrenr#define ipf_isw ipf_lkun_s.ipf_sw 321145522Sdarrenr#define ipf_magic ipf_lkun_s.ipf_magic 322145522Sdarrenr 323145522Sdarrenr#if !defined(__GNUC__) || \ 324145522Sdarrenr (defined(__FreeBSD_version) && (__FreeBSD_version >= 503000)) 325145522Sdarrenr# ifndef INLINE 326145522Sdarrenr# define INLINE 327145522Sdarrenr# endif 328145522Sdarrenr#else 329145522Sdarrenr# define INLINE __inline__ 330145522Sdarrenr#endif 331145522Sdarrenr 332255332Scy#if defined(__FreeBSD_version) && defined(_KERNEL) 333255332Scy CTASSERT(sizeof(ipfrwlock_t) == KRWLOCK_FILL_SZ); 334255332Scy CTASSERT(sizeof(ipfmutex_t) == KMUTEX_FILL_SZ); 335145522Sdarrenr#endif 336145522Sdarrenr 337255332Scy 338145522Sdarrenr/* 339145522Sdarrenr * In a non-kernel environment, there are a lot of macros that need to be 340145522Sdarrenr * filled in to be null-ops or to point to some compatibility function, 341145522Sdarrenr * somewhere in userland. 342145522Sdarrenr */ 343145522Sdarrenr#ifndef _KERNEL 344145522Sdarrenrtypedef struct mb_s { 345145522Sdarrenr struct mb_s *mb_next; 346255332Scy char *mb_data; 347255332Scy void *mb_ifp; 348145522Sdarrenr int mb_len; 349255332Scy int mb_flags; 350145522Sdarrenr u_long mb_buf[2048]; 351145522Sdarrenr} mb_t; 352145522Sdarrenr# undef m_next 353145522Sdarrenr# define m_next mb_next 354255332Scy# undef m_len 355255332Scy# define m_len mb_len 356255332Scy# undef m_flags 357255332Scy# define m_flags mb_flags 358255332Scy# undef m_data 359255332Scy# define m_data mb_data 360255332Scy# undef M_MCAST 361255332Scy# define M_MCAST 0x01 362255332Scy# undef M_BCAST 363255332Scy# define M_BCAST 0x02 364255332Scy# undef M_MBCAST 365255332Scy# define M_MBCAST 0x04 366255332Scy# define MSGDSIZE(m) msgdsize(m) 367255332Scy# define M_LEN(m) (m)->mb_len 368255332Scy# define M_ADJ(m,x) (m)->mb_len += x 369255332Scy# define M_COPY(m) dupmbt(m) 370255332Scy# define M_DUP(m) dupmbt(m) 371145522Sdarrenr# define GETKTIME(x) gettimeofday((struct timeval *)(x), NULL) 372255332Scy# define MTOD(m, t) ((t)(m)->mb_data) 373255332Scy# define FREE_MB_T(m) freembt(m) 374255332Scy# define ALLOC_MB_T(m,l) (m) = allocmbt(l) 375255332Scy# define PREP_MB_T(f, m) do { \ 376255332Scy (m)->mb_next = *(f)->fin_mp; \ 377255332Scy *(fin)->fin_mp = (m); \ 378255332Scy (f)->fin_m = (m); \ 379255332Scy } while (0) 380145522Sdarrenr# define SLEEP(x,y) 1; 381145522Sdarrenr# define WAKEUP(x,y) ; 382161356Sguido# define POLLWAKEUP(y) ; 383145522Sdarrenr# define IPF_PANIC(x,y) ; 384145522Sdarrenr# define PANIC(x,y) ; 385170268Sdarrenr# define SPL_SCHED(x) ; 386145522Sdarrenr# define SPL_NET(x) ; 387145522Sdarrenr# define SPL_IMP(x) ; 388145522Sdarrenr# define SPL_X(x) ; 389145522Sdarrenr# define KMALLOC(a,b) (a) = (b)malloc(sizeof(*a)) 390145522Sdarrenr# define KMALLOCS(a,b,c) (a) = (b)malloc(c) 391145522Sdarrenr# define KFREE(x) free(x) 392145522Sdarrenr# define KFREES(x,s) free(x) 393145522Sdarrenr# define GETIFP(x, v) get_unit(x,v) 394255332Scy# define GETIFMTU_4(x) 2048 395255332Scy# define GETIFMTU_6(x) 2048 396153876Sguido# define COPYIN(a,b,c) bcopywrap((a), (b), (c)) 397153876Sguido# define COPYOUT(a,b,c) bcopywrap((a), (b), (c)) 398145522Sdarrenr# define COPYDATA(m, o, l, b) bcopy(MTOD((mb_t *)m, char *) + (o), \ 399145522Sdarrenr (b), (l)) 400145522Sdarrenr# define COPYBACK(m, o, l, b) bcopy((b), \ 401145522Sdarrenr MTOD((mb_t *)m, char *) + (o), \ 402145522Sdarrenr (l)) 403172776Sdarrenr# define UIOMOVE(a,b,c,d) ipfuiomove((caddr_t)a,b,c,d) 404145522Sdarrenrextern void m_copydata __P((mb_t *, int, int, caddr_t)); 405145522Sdarrenrextern int ipfuiomove __P((caddr_t, int, int, struct uio *)); 406153882Sguidoextern int bcopywrap __P((void *, void *, size_t)); 407255332Scyextern mb_t *allocmbt __P((size_t)); 408255332Scyextern mb_t *dupmbt __P((mb_t *)); 409255332Scyextern void freembt __P((mb_t *)); 410145522Sdarrenr 411255332Scy# define MUTEX_DESTROY(x) eMmutex_destroy(&(x)->ipf_emu, \ 412255332Scy __FILE__, __LINE__) 413145522Sdarrenr# define MUTEX_ENTER(x) eMmutex_enter(&(x)->ipf_emu, \ 414145522Sdarrenr __FILE__, __LINE__) 415255332Scy# define MUTEX_EXIT(x) eMmutex_exit(&(x)->ipf_emu, \ 416255332Scy __FILE__, __LINE__) 417255332Scy# define MUTEX_INIT(x,y) eMmutex_init(&(x)->ipf_emu, y, \ 418255332Scy __FILE__, __LINE__) 419145522Sdarrenr# define MUTEX_NUKE(x) bzero((x), sizeof(*(x))) 420145522Sdarrenr 421145522Sdarrenr# define MUTEX_DOWNGRADE(x) eMrwlock_downgrade(&(x)->ipf_emu, \ 422145522Sdarrenr __FILE__, __LINE__) 423145522Sdarrenr# define READ_ENTER(x) eMrwlock_read_enter(&(x)->ipf_emu, \ 424145522Sdarrenr __FILE__, __LINE__) 425145522Sdarrenr# define RWLOCK_INIT(x, y) eMrwlock_init(&(x)->ipf_emu, y) 426145522Sdarrenr# define RWLOCK_EXIT(x) eMrwlock_exit(&(x)->ipf_emu) 427145522Sdarrenr# define RW_DESTROY(x) eMrwlock_destroy(&(x)->ipf_emu) 428145522Sdarrenr# define WRITE_ENTER(x) eMrwlock_write_enter(&(x)->ipf_emu, \ 429145522Sdarrenr __FILE__, \ 430145522Sdarrenr __LINE__) 431145522Sdarrenr 432145522Sdarrenr# define USE_MUTEXES 1 433145522Sdarrenr 434255332Scyextern void eMmutex_destroy __P((eMmutex_t *, char *, int)); 435145522Sdarrenrextern void eMmutex_enter __P((eMmutex_t *, char *, int)); 436255332Scyextern void eMmutex_exit __P((eMmutex_t *, char *, int)); 437255332Scyextern void eMmutex_init __P((eMmutex_t *, char *, char *, int)); 438145522Sdarrenrextern void eMrwlock_destroy __P((eMrwlock_t *)); 439145522Sdarrenrextern void eMrwlock_exit __P((eMrwlock_t *)); 440145522Sdarrenrextern void eMrwlock_init __P((eMrwlock_t *, char *)); 441145522Sdarrenrextern void eMrwlock_read_enter __P((eMrwlock_t *, char *, int)); 442145522Sdarrenrextern void eMrwlock_write_enter __P((eMrwlock_t *, char *, int)); 443145522Sdarrenrextern void eMrwlock_downgrade __P((eMrwlock_t *, char *, int)); 444145522Sdarrenr 445145522Sdarrenr#endif 446145522Sdarrenr 447255332Scyextern mb_t *allocmbt(size_t); 448255332Scy 449145522Sdarrenr#define MAX_IPV4HDR ((0xf << 2) + sizeof(struct icmp) + sizeof(ip_t) + 8) 450145522Sdarrenr 451145522Sdarrenr#ifndef IP_OFFMASK 452145522Sdarrenr# define IP_OFFMASK 0x1fff 453145522Sdarrenr#endif 454145522Sdarrenr 455145522Sdarrenr 456145522Sdarrenr/* 457145522Sdarrenr * On BSD's use quad_t as a guarantee for getting at least a 64bit sized 458145522Sdarrenr * object. 459145522Sdarrenr */ 460255332Scy#if !defined(__amd64__) && BSD_GT_YEAR(199306) 461145522Sdarrenr# define USE_QUAD_T 462145640Sdarrenr# define U_QUAD_T unsigned long long 463145640Sdarrenr# define QUAD_T long long 464145522Sdarrenr#else /* BSD > 199306 */ 465255332Scy# if !defined(U_QUAD_T) 466255332Scy# define U_QUAD_T u_long 467255332Scy# define QUAD_T long 468255332Scy# endif 469145522Sdarrenr#endif /* BSD > 199306 */ 470145522Sdarrenr 471145522Sdarrenr 47260857Sdarrenr#ifdef USE_INET6 473145522Sdarrenr# if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || \ 474145522Sdarrenr defined(__osf__) || defined(linux) 47560857Sdarrenr# include <netinet/ip6.h> 476145522Sdarrenr# include <netinet/icmp6.h> 477145522Sdarrenr# if defined(_KERNEL) && !defined(__osf__) 478145522Sdarrenr# include <netinet6/ip6_var.h> 479145522Sdarrenr# endif 48060857Sdarrenrtypedef struct ip6_hdr ip6_t; 48160857Sdarrenr# endif 48260857Sdarrenr#endif 48360857Sdarrenr 48453642Sguido#ifndef MAX 485145522Sdarrenr# define MAX(a,b) (((a) > (b)) ? (a) : (b)) 48653642Sguido#endif 48753642Sguido 488145522Sdarrenr#if defined(_KERNEL) 489255332Scy# if defined(MENTAT) && !defined(INSTANCES) 490145522Sdarrenr# define COPYDATA mb_copydata 491145522Sdarrenr# define COPYBACK mb_copyback 492145522Sdarrenr# else 493145522Sdarrenr# define COPYDATA m_copydata 494145522Sdarrenr# define COPYBACK m_copyback 495145522Sdarrenr# endif 496145522Sdarrenr# if (defined(__NetBSD_Version__) && (__NetBSD_Version__ < 105180000)) || \ 497145522Sdarrenr defined(__FreeBSD__) || (defined(OpenBSD) && (OpenBSD < 200206)) || \ 498145522Sdarrenr defined(_BSDI_VERSION) 499145522Sdarrenr# include <vm/vm.h> 500145522Sdarrenr# endif 501255332Scy# if !defined(__FreeBSD__) || FREEBSD_GE_REV(300000) 502255332Scy# if NETBSD_GE_REV(105180000) || OPENBSD_GE_REV(200111) 503145522Sdarrenr# include <uvm/uvm_extern.h> 504145522Sdarrenr# else 505145522Sdarrenr# include <vm/vm_extern.h> 506145522Sdarrenrextern vm_map_t kmem_map; 507145522Sdarrenr# endif 508145522Sdarrenr# include <sys/proc.h> 509145522Sdarrenr# else /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD_version >= 300000) */ 510145522Sdarrenr# include <vm/vm_kern.h> 511145522Sdarrenr# endif /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD_version >= 300000) */ 512145522Sdarrenr 513145522Sdarrenr# ifdef IPFILTER_M_IPFILTER 514145522Sdarrenr# include <sys/malloc.h> 515145522SdarrenrMALLOC_DECLARE(M_IPFILTER); 516145522Sdarrenr# define _M_IPF M_IPFILTER 517145522Sdarrenr# else /* IPFILTER_M_IPFILTER */ 518145522Sdarrenr# ifdef M_PFIL 519145522Sdarrenr# define _M_IPF M_PFIL 520145522Sdarrenr# else 521145522Sdarrenr# ifdef M_IPFILTER 522145522Sdarrenr# define _M_IPF M_IPFILTER 523145522Sdarrenr# else 524145522Sdarrenr# define _M_IPF M_TEMP 525145522Sdarrenr# endif /* M_IPFILTER */ 526145522Sdarrenr# endif /* M_PFIL */ 527145522Sdarrenr# endif /* IPFILTER_M_IPFILTER */ 528255332Scy# if !defined(KMALLOC) 529184205Sdes# define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), _M_IPF, M_NOWAIT) 530255332Scy# endif 531255332Scy# if !defined(KMALLOCS) 532255332Scy# define KMALLOCS(a, b, c) MALLOC((a), b, (c), _M_IPF, M_NOWAIT) 533255332Scy# endif 534255332Scy# if !defined(KFREE) 535184205Sdes# define KFREE(x) FREE((x), _M_IPF) 536170268Sdarrenr# endif 537255332Scy# if !defined(KFREES) 538255332Scy# define KFREES(x,s) FREE((x), _M_IPF) 539255332Scy# endif 540172776Sdarrenr# define UIOMOVE(a,b,c,d) uiomove((caddr_t)a,b,d) 541145522Sdarrenr# define SLEEP(id, n) tsleep((id), PPAUSE|PCATCH, n, 0) 542145522Sdarrenr# define WAKEUP(id,x) wakeup(id+x) 543255332Scy# if !defined(POLLWAKEUP) 544255332Scy# define POLLWAKEUP(x) selwakeup(softc->ipf_selwait+x) 545255332Scy# endif 546145522Sdarrenr# define GETIFP(n, v) ifunit(n) 547255332Scy# define GETIFMTU_4(x) ((struct ifnet *)x)->if_mtu 548255332Scy# define GETIFMTU_6(x) ((struct ifnet *)x)->if_mtu 549145522Sdarrenr 550145522Sdarrenr# if !defined(USE_MUTEXES) && !defined(SPL_NET) 551255754Scy# define SPL_IMP(x) x = splimp() 552255754Scy# define SPL_NET(x) x = splnet() 553172776Sdarrenr# if !defined(SPL_SCHED) 554172776Sdarrenr# define SPL_SCHED(x) x = splsched() 555172776Sdarrenr# endif 556145522Sdarrenr# define SPL_X(x) (void) splx(x) 557145522Sdarrenr# endif /* !USE_MUTEXES */ 558145522Sdarrenr 559145522Sdarrenr# ifndef FREE_MB_T 560145522Sdarrenr# define FREE_MB_T(m) m_freem(m) 561145522Sdarrenr# endif 562255332Scy# ifndef ALLOC_MB_T 563255332Scy# ifdef MGETHDR 564255332Scy# define ALLOC_MB_T(m,l) do { \ 565260715Sglebius MGETHDR((m), M_NOWAIT, MT_HEADER); \ 566255332Scy if ((m) != NULL) { \ 567255332Scy (m)->m_len = (l); \ 568255332Scy (m)->m_pkthdr.len = (l); \ 569255332Scy } \ 570255332Scy } while (0) 571255332Scy# else 572255332Scy# define ALLOC_MB_T(m,l) do { \ 573260715Sglebius MGET((m), M_NOWAIT, MT_HEADER); \ 574255332Scy if ((m) != NULL) { \ 575255332Scy (m)->m_len = (l); \ 576255332Scy (m)->m_pkthdr.len = (l); \ 577255332Scy } \ 578255332Scy } while (0) 579255332Scy# endif 580255332Scy# endif 581255332Scy# ifndef PREP_MB_T 582255332Scy# define PREP_MB_T(f, m) do { \ 583255332Scy mb_t *_o = *(f)->fin_mp; \ 584255332Scy (m)->m_next = _o; \ 585255332Scy *(fin)->fin_mp = (m); \ 586255332Scy if (_o->m_flags & M_PKTHDR) { \ 587255332Scy (m)->m_pkthdr.len += \ 588255332Scy _o->m_pkthdr.len; \ 589255332Scy (m)->m_pkthdr.rcvif = \ 590255332Scy _o->m_pkthdr.rcvif; \ 591255332Scy } \ 592255332Scy } while (0) 593255332Scy# endif 594255332Scy# ifndef M_DUP 595255332Scy# ifdef M_COPYALL 596255332Scy# define M_DUP(m) m_dup(m, 0, M_COPYALL, 0) 597255332Scy# else 598255332Scy# define M_DUP(m) m_dup(m) 599255332Scy# endif 600255332Scy# endif 601145522Sdarrenr 602145522Sdarrenr# ifndef MTOD 603145522Sdarrenr# define MTOD(m,t) mtod(m,t) 604145522Sdarrenr# endif 605145522Sdarrenr 606145522Sdarrenr# ifndef COPYIN 607145522Sdarrenr# define COPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) 608145522Sdarrenr# define COPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) 609145522Sdarrenr# endif 610145522Sdarrenr 611145522Sdarrenr# ifndef KMALLOC 612145522Sdarrenr# define KMALLOC(a,b) (a) = (b)new_kmem_alloc(sizeof(*(a)), \ 613145522Sdarrenr KMEM_NOSLEEP) 614145522Sdarrenr# define KMALLOCS(a,b,c) (a) = (b)new_kmem_alloc((c), KMEM_NOSLEEP) 615145522Sdarrenr# endif 616145522Sdarrenr 617145522Sdarrenr# ifndef GET_MINOR 618183397Sed# define GET_MINOR(x) dev2unit(x) 619145522Sdarrenr# endif 620145522Sdarrenr# define PANIC(x,y) if (x) panic y 621145522Sdarrenr#endif /* _KERNEL */ 622145522Sdarrenr 623172776Sdarrenr#if !defined(IFNAME) && !defined(_KERNEL) 624255332Scy# define IFNAME(x) get_ifname((struct ifnet *)x) 625145522Sdarrenr#endif 626145522Sdarrenr#ifndef COPYIFNAME 627145522Sdarrenr# define NEED_FRGETIFNAME 628255332Scyextern char *ipf_getifname __P((struct ifnet *, char *)); 629172776Sdarrenr# define COPYIFNAME(v, x, b) \ 630255332Scy ipf_getifname((struct ifnet *)x, b) 631145522Sdarrenr#endif 632145522Sdarrenr 633145522Sdarrenr#ifndef ASSERT 634172776Sdarrenr# ifdef _KERNEL 635172776Sdarrenr# define ASSERT(x) 636172776Sdarrenr# else 637172776Sdarrenr# define ASSERT(x) do { if (!(x)) abort(); } while (0) 638172776Sdarrenr# endif 639145522Sdarrenr#endif 640145522Sdarrenr 641170268Sdarrenr#ifndef BCOPYIN 642170268Sdarrenr# define BCOPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) 643170268Sdarrenr# define BCOPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0) 644170268Sdarrenr#endif 645170268Sdarrenr 64653642Sguido/* 647145522Sdarrenr * Because the ctype(3) posix definition, if used "safely" in code everywhere, 648145522Sdarrenr * would mean all normal code that walks through strings needed casts. Yuck. 649145522Sdarrenr */ 650145522Sdarrenr#define ISALNUM(x) isalnum((u_char)(x)) 651145522Sdarrenr#define ISALPHA(x) isalpha((u_char)(x)) 652145522Sdarrenr#define ISDIGIT(x) isdigit((u_char)(x)) 653145522Sdarrenr#define ISSPACE(x) isspace((u_char)(x)) 654145522Sdarrenr#define ISUPPER(x) isupper((u_char)(x)) 655145522Sdarrenr#define ISXDIGIT(x) isxdigit((u_char)(x)) 656145522Sdarrenr#define ISLOWER(x) islower((u_char)(x)) 657145522Sdarrenr#define TOUPPER(x) toupper((u_char)(x)) 658145522Sdarrenr#define TOLOWER(x) tolower((u_char)(x)) 659145522Sdarrenr 660145522Sdarrenr/* 661145522Sdarrenr * If mutexes aren't being used, turn all the mutex functions into null-ops. 662145522Sdarrenr */ 663145522Sdarrenr#if !defined(USE_MUTEXES) 664145522Sdarrenr# define USE_SPL 1 665145522Sdarrenr# undef RW_DESTROY 666145522Sdarrenr# undef MUTEX_INIT 667145522Sdarrenr# undef MUTEX_NUKE 668145522Sdarrenr# undef MUTEX_DESTROY 669145522Sdarrenr# define MUTEX_ENTER(x) ; 670145522Sdarrenr# define READ_ENTER(x) ; 671145522Sdarrenr# define WRITE_ENTER(x) ; 672145522Sdarrenr# define MUTEX_DOWNGRADE(x) ; 673145522Sdarrenr# define RWLOCK_INIT(x, y) ; 674145522Sdarrenr# define RWLOCK_EXIT(x) ; 675145522Sdarrenr# define RW_DESTROY(x) ; 676145522Sdarrenr# define MUTEX_EXIT(x) ; 677145522Sdarrenr# define MUTEX_INIT(x,y) ; 678145522Sdarrenr# define MUTEX_DESTROY(x) ; 679145522Sdarrenr# define MUTEX_NUKE(x) ; 680145522Sdarrenr#endif /* !USE_MUTEXES */ 681145522Sdarrenr#ifndef ATOMIC_INC 682145522Sdarrenr# define ATOMIC_INC(x) (x)++ 683145522Sdarrenr# define ATOMIC_DEC(x) (x)-- 684145522Sdarrenr#endif 685145522Sdarrenr 686153876Sguido#if defined(USE_SPL) && defined(_KERNEL) 687153876Sguido# define SPL_INT(x) int x 688153876Sguido#else 689153876Sguido# define SPL_INT(x) 690153876Sguido#endif 691153876Sguido 692145522Sdarrenr/* 693145522Sdarrenr * If there are no atomic operations for bit sizes defined, define them to all 694145522Sdarrenr * use a generic one that works for all sizes. 695145522Sdarrenr */ 696145522Sdarrenr#ifndef ATOMIC_INCL 697145522Sdarrenr# define ATOMIC_INCL ATOMIC_INC 698145522Sdarrenr# define ATOMIC_INC64 ATOMIC_INC 699145522Sdarrenr# define ATOMIC_INC32 ATOMIC_INC 700145522Sdarrenr# define ATOMIC_DECL ATOMIC_DEC 701145522Sdarrenr# define ATOMIC_DEC64 ATOMIC_DEC 702145522Sdarrenr# define ATOMIC_DEC32 ATOMIC_DEC 703145522Sdarrenr#endif 704145522Sdarrenr 705145522Sdarrenr#ifndef HDR_T_PRIVATE 706145522Sdarrenrtypedef struct tcphdr tcphdr_t; 707145522Sdarrenrtypedef struct udphdr udphdr_t; 708145522Sdarrenr#endif 709145522Sdarrenrtypedef struct icmp icmphdr_t; 710145522Sdarrenrtypedef struct ip ip_t; 711145522Sdarrenrtypedef struct ether_header ether_header_t; 712145522Sdarrenrtypedef struct tcpiphdr tcpiphdr_t; 713145522Sdarrenr 714145522Sdarrenr#ifndef FR_GROUPLEN 715145522Sdarrenr# define FR_GROUPLEN 16 716145522Sdarrenr#endif 717145522Sdarrenr 718145522Sdarrenr#ifndef offsetof 719255332Scy# define offsetof(t,m) (size_t)((&((t *)0L)->m)) 720145522Sdarrenr#endif 721255332Scy#ifndef stsizeof 722255332Scy# define stsizeof(t,m) sizeof(((t *)0L)->m) 723255332Scy#endif 724145522Sdarrenr 725145522Sdarrenr/* 726145522Sdarrenr * This set of macros has been brought about because on Tru64 it is not 727145522Sdarrenr * possible to easily assign or examine values in a structure that are 728145522Sdarrenr * bit fields. 729145522Sdarrenr */ 730145522Sdarrenr#ifndef IP_V 731145522Sdarrenr# define IP_V(x) (x)->ip_v 732145522Sdarrenr#endif 733145522Sdarrenr#ifndef IP_V_A 734145522Sdarrenr# define IP_V_A(x,y) (x)->ip_v = (y) 735145522Sdarrenr#endif 736145522Sdarrenr#ifndef IP_HL 737145522Sdarrenr# define IP_HL(x) (x)->ip_hl 738145522Sdarrenr#endif 739145522Sdarrenr#ifndef IP_HL_A 740170268Sdarrenr# define IP_HL_A(x,y) (x)->ip_hl = ((y) & 0xf) 741145522Sdarrenr#endif 742145522Sdarrenr#ifndef TCP_X2 743145522Sdarrenr# define TCP_X2(x) (x)->th_x2 744145522Sdarrenr#endif 745145522Sdarrenr#ifndef TCP_X2_A 746145522Sdarrenr# define TCP_X2_A(x,y) (x)->th_x2 = (y) 747145522Sdarrenr#endif 748145522Sdarrenr#ifndef TCP_OFF 749145522Sdarrenr# define TCP_OFF(x) (x)->th_off 750145522Sdarrenr#endif 751145522Sdarrenr#ifndef TCP_OFF_A 752145522Sdarrenr# define TCP_OFF_A(x,y) (x)->th_off = (y) 753145522Sdarrenr#endif 754145522Sdarrenr#define IPMINLEN(i, h) ((i)->ip_len >= (IP_HL(i) * 4 + sizeof(struct h))) 755145522Sdarrenr 756145522Sdarrenr 757145522Sdarrenr/* 758145522Sdarrenr * XXX - This is one of those *awful* hacks which nobody likes 759145522Sdarrenr */ 760145522Sdarrenr#ifdef ultrix 761145522Sdarrenr#define A_A 762145522Sdarrenr#else 763145522Sdarrenr#define A_A & 764145522Sdarrenr#endif 765145522Sdarrenr 766145522Sdarrenr#define TCPF_ALL (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|\ 767145522Sdarrenr TH_ECN|TH_CWR) 768145522Sdarrenr 769255332Scy#if BSD_GE_YEAR(199306) && !defined(m_act) 770145522Sdarrenr# define m_act m_nextpkt 771255332Scy#endif 772145522Sdarrenr 773145522Sdarrenr/* 77453642Sguido * Security Options for Intenet Protocol (IPSO) as defined in RFC 1108. 77553642Sguido * 77653642Sguido * Basic Option 77753642Sguido * 77853642Sguido * 00000001 - (Reserved 4) 77953642Sguido * 00111101 - Top Secret 78053642Sguido * 01011010 - Secret 78153642Sguido * 10010110 - Confidential 78253642Sguido * 01100110 - (Reserved 3) 78353642Sguido * 11001100 - (Reserved 2) 78453642Sguido * 10101011 - Unclassified 78553642Sguido * 11110001 - (Reserved 1) 78653642Sguido */ 78753642Sguido#define IPSO_CLASS_RES4 0x01 78853642Sguido#define IPSO_CLASS_TOPS 0x3d 78953642Sguido#define IPSO_CLASS_SECR 0x5a 79053642Sguido#define IPSO_CLASS_CONF 0x96 79153642Sguido#define IPSO_CLASS_RES3 0x66 79253642Sguido#define IPSO_CLASS_RES2 0xcc 79353642Sguido#define IPSO_CLASS_UNCL 0xab 79453642Sguido#define IPSO_CLASS_RES1 0xf1 79553642Sguido 79653642Sguido#define IPSO_AUTH_GENSER 0x80 79753642Sguido#define IPSO_AUTH_ESI 0x40 79853642Sguido#define IPSO_AUTH_SCI 0x20 79953642Sguido#define IPSO_AUTH_NSA 0x10 80053642Sguido#define IPSO_AUTH_DOE 0x08 80153642Sguido#define IPSO_AUTH_UN 0x06 80253642Sguido#define IPSO_AUTH_FTE 0x01 80353642Sguido 80453642Sguido/* 80553642Sguido * IP option #defines 80653642Sguido */ 807145522Sdarrenr#undef IPOPT_RR 808255332Scy#define IPOPT_RR 7 809145522Sdarrenr#undef IPOPT_ZSU 81053642Sguido#define IPOPT_ZSU 10 /* ZSU */ 811145522Sdarrenr#undef IPOPT_MTUP 81253642Sguido#define IPOPT_MTUP 11 /* MTUP */ 813145522Sdarrenr#undef IPOPT_MTUR 81453642Sguido#define IPOPT_MTUR 12 /* MTUR */ 815145522Sdarrenr#undef IPOPT_ENCODE 81653642Sguido#define IPOPT_ENCODE 15 /* ENCODE */ 817145522Sdarrenr#undef IPOPT_TS 818145522Sdarrenr#define IPOPT_TS 68 819145522Sdarrenr#undef IPOPT_TR 82053642Sguido#define IPOPT_TR 82 /* TR */ 821145522Sdarrenr#undef IPOPT_SECURITY 822145522Sdarrenr#define IPOPT_SECURITY 130 823145522Sdarrenr#undef IPOPT_LSRR 824145522Sdarrenr#define IPOPT_LSRR 131 825145522Sdarrenr#undef IPOPT_E_SEC 82653642Sguido#define IPOPT_E_SEC 133 /* E-SEC */ 827145522Sdarrenr#undef IPOPT_CIPSO 82853642Sguido#define IPOPT_CIPSO 134 /* CIPSO */ 829145522Sdarrenr#undef IPOPT_SATID 830145522Sdarrenr#define IPOPT_SATID 136 83153642Sguido#ifndef IPOPT_SID 83253642Sguido# define IPOPT_SID IPOPT_SATID 83353642Sguido#endif 834145522Sdarrenr#undef IPOPT_SSRR 835145522Sdarrenr#define IPOPT_SSRR 137 836145522Sdarrenr#undef IPOPT_ADDEXT 83753642Sguido#define IPOPT_ADDEXT 147 /* ADDEXT */ 838145522Sdarrenr#undef IPOPT_VISA 83953642Sguido#define IPOPT_VISA 142 /* VISA */ 840145522Sdarrenr#undef IPOPT_IMITD 84153642Sguido#define IPOPT_IMITD 144 /* IMITD */ 842145522Sdarrenr#undef IPOPT_EIP 84353642Sguido#define IPOPT_EIP 145 /* EIP */ 844145522Sdarrenr#undef IPOPT_RTRALRT 845145522Sdarrenr#define IPOPT_RTRALRT 148 /* RTRALRT */ 846145522Sdarrenr#undef IPOPT_SDB 847145522Sdarrenr#define IPOPT_SDB 149 848145522Sdarrenr#undef IPOPT_NSAPA 849145522Sdarrenr#define IPOPT_NSAPA 150 850145522Sdarrenr#undef IPOPT_DPS 851145522Sdarrenr#define IPOPT_DPS 151 852145522Sdarrenr#undef IPOPT_UMP 853145522Sdarrenr#define IPOPT_UMP 152 854145522Sdarrenr#undef IPOPT_FINN 85553642Sguido#define IPOPT_FINN 205 /* FINN */ 856255332Scy#undef IPOPT_AH 857255332Scy#define IPOPT_AH 256+IPPROTO_AH 85853642Sguido 859145522Sdarrenr#ifndef TCPOPT_EOL 860145522Sdarrenr# define TCPOPT_EOL 0 86195418Sdarrenr#endif 862145522Sdarrenr#ifndef TCPOPT_NOP 863145522Sdarrenr# define TCPOPT_NOP 1 86460857Sdarrenr#endif 865145522Sdarrenr#ifndef TCPOPT_MAXSEG 866145522Sdarrenr# define TCPOPT_MAXSEG 2 86767614Sdarrenr#endif 868145522Sdarrenr#ifndef TCPOLEN_MAXSEG 869145522Sdarrenr# define TCPOLEN_MAXSEG 4 870139255Sdarrenr#endif 871145522Sdarrenr#ifndef TCPOPT_WINDOW 872145522Sdarrenr# define TCPOPT_WINDOW 3 873145522Sdarrenr#endif 874145522Sdarrenr#ifndef TCPOLEN_WINDOW 875145522Sdarrenr# define TCPOLEN_WINDOW 3 876145522Sdarrenr#endif 877145522Sdarrenr#ifndef TCPOPT_SACK_PERMITTED 878145522Sdarrenr# define TCPOPT_SACK_PERMITTED 4 879145522Sdarrenr#endif 880145522Sdarrenr#ifndef TCPOLEN_SACK_PERMITTED 881145522Sdarrenr# define TCPOLEN_SACK_PERMITTED 2 882145522Sdarrenr#endif 883145522Sdarrenr#ifndef TCPOPT_SACK 884145522Sdarrenr# define TCPOPT_SACK 5 885145522Sdarrenr#endif 886145522Sdarrenr#ifndef TCPOPT_TIMESTAMP 887145522Sdarrenr# define TCPOPT_TIMESTAMP 8 888145522Sdarrenr#endif 88953642Sguido 89053642Sguido#ifndef ICMP_MINLEN 89153642Sguido# define ICMP_MINLEN 8 89253642Sguido#endif 89392685Sdarrenr#ifndef ICMP_ECHOREPLY 89492685Sdarrenr# define ICMP_ECHOREPLY 0 89592685Sdarrenr#endif 89653642Sguido#ifndef ICMP_UNREACH 89792685Sdarrenr# define ICMP_UNREACH 3 89853642Sguido#endif 89992685Sdarrenr#ifndef ICMP_UNREACH_NET 90092685Sdarrenr# define ICMP_UNREACH_NET 0 90192685Sdarrenr#endif 90292685Sdarrenr#ifndef ICMP_UNREACH_HOST 90392685Sdarrenr# define ICMP_UNREACH_HOST 1 90492685Sdarrenr#endif 90592685Sdarrenr#ifndef ICMP_UNREACH_PROTOCOL 90692685Sdarrenr# define ICMP_UNREACH_PROTOCOL 2 90792685Sdarrenr#endif 90892685Sdarrenr#ifndef ICMP_UNREACH_PORT 90992685Sdarrenr# define ICMP_UNREACH_PORT 3 91092685Sdarrenr#endif 91192685Sdarrenr#ifndef ICMP_UNREACH_NEEDFRAG 91292685Sdarrenr# define ICMP_UNREACH_NEEDFRAG 4 91392685Sdarrenr#endif 91492685Sdarrenr#ifndef ICMP_UNREACH_SRCFAIL 91592685Sdarrenr# define ICMP_UNREACH_SRCFAIL 5 91692685Sdarrenr#endif 91792685Sdarrenr#ifndef ICMP_UNREACH_NET_UNKNOWN 91892685Sdarrenr# define ICMP_UNREACH_NET_UNKNOWN 6 91992685Sdarrenr#endif 92092685Sdarrenr#ifndef ICMP_UNREACH_HOST_UNKNOWN 92192685Sdarrenr# define ICMP_UNREACH_HOST_UNKNOWN 7 92292685Sdarrenr#endif 92392685Sdarrenr#ifndef ICMP_UNREACH_ISOLATED 92492685Sdarrenr# define ICMP_UNREACH_ISOLATED 8 92592685Sdarrenr#endif 92692685Sdarrenr#ifndef ICMP_UNREACH_NET_PROHIB 92792685Sdarrenr# define ICMP_UNREACH_NET_PROHIB 9 92892685Sdarrenr#endif 92992685Sdarrenr#ifndef ICMP_UNREACH_HOST_PROHIB 93092685Sdarrenr# define ICMP_UNREACH_HOST_PROHIB 10 93192685Sdarrenr#endif 93292685Sdarrenr#ifndef ICMP_UNREACH_TOSNET 93392685Sdarrenr# define ICMP_UNREACH_TOSNET 11 93492685Sdarrenr#endif 93592685Sdarrenr#ifndef ICMP_UNREACH_TOSHOST 93692685Sdarrenr# define ICMP_UNREACH_TOSHOST 12 93792685Sdarrenr#endif 93892685Sdarrenr#ifndef ICMP_UNREACH_ADMIN_PROHIBIT 93992685Sdarrenr# define ICMP_UNREACH_ADMIN_PROHIBIT 13 94092685Sdarrenr#endif 941145522Sdarrenr#ifndef ICMP_UNREACH_FILTER 942145522Sdarrenr# define ICMP_UNREACH_FILTER 13 943145522Sdarrenr#endif 94492685Sdarrenr#ifndef ICMP_UNREACH_HOST_PRECEDENCE 94592685Sdarrenr# define ICMP_UNREACH_HOST_PRECEDENCE 14 94692685Sdarrenr#endif 94792685Sdarrenr#ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF 94892685Sdarrenr# define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 94992685Sdarrenr#endif 95053642Sguido#ifndef ICMP_SOURCEQUENCH 95192685Sdarrenr# define ICMP_SOURCEQUENCH 4 95253642Sguido#endif 95392685Sdarrenr#ifndef ICMP_REDIRECT_NET 95492685Sdarrenr# define ICMP_REDIRECT_NET 0 95592685Sdarrenr#endif 95692685Sdarrenr#ifndef ICMP_REDIRECT_HOST 95792685Sdarrenr# define ICMP_REDIRECT_HOST 1 95892685Sdarrenr#endif 95992685Sdarrenr#ifndef ICMP_REDIRECT_TOSNET 96092685Sdarrenr# define ICMP_REDIRECT_TOSNET 2 96192685Sdarrenr#endif 96292685Sdarrenr#ifndef ICMP_REDIRECT_TOSHOST 96392685Sdarrenr# define ICMP_REDIRECT_TOSHOST 3 96492685Sdarrenr#endif 96592685Sdarrenr#ifndef ICMP_ALTHOSTADDR 96692685Sdarrenr# define ICMP_ALTHOSTADDR 6 96792685Sdarrenr#endif 96853642Sguido#ifndef ICMP_TIMXCEED 96992685Sdarrenr# define ICMP_TIMXCEED 11 97053642Sguido#endif 97192685Sdarrenr#ifndef ICMP_TIMXCEED_INTRANS 97292685Sdarrenr# define ICMP_TIMXCEED_INTRANS 0 97392685Sdarrenr#endif 97492685Sdarrenr#ifndef ICMP_TIMXCEED_REASS 97592685Sdarrenr# define ICMP_TIMXCEED_REASS 1 97692685Sdarrenr#endif 97753642Sguido#ifndef ICMP_PARAMPROB 97892685Sdarrenr# define ICMP_PARAMPROB 12 97953642Sguido#endif 98092685Sdarrenr#ifndef ICMP_PARAMPROB_ERRATPTR 98192685Sdarrenr# define ICMP_PARAMPROB_ERRATPTR 0 98292685Sdarrenr#endif 98392685Sdarrenr#ifndef ICMP_PARAMPROB_OPTABSENT 98492685Sdarrenr# define ICMP_PARAMPROB_OPTABSENT 1 98592685Sdarrenr#endif 98692685Sdarrenr#ifndef ICMP_PARAMPROB_LENGTH 98792685Sdarrenr# define ICMP_PARAMPROB_LENGTH 2 98892685Sdarrenr#endif 98953642Sguido#ifndef ICMP_TSTAMP 99092685Sdarrenr# define ICMP_TSTAMP 13 99153642Sguido#endif 99253642Sguido#ifndef ICMP_TSTAMPREPLY 99392685Sdarrenr# define ICMP_TSTAMPREPLY 14 99453642Sguido#endif 99553642Sguido#ifndef ICMP_IREQ 99692685Sdarrenr# define ICMP_IREQ 15 99753642Sguido#endif 99853642Sguido#ifndef ICMP_IREQREPLY 99992685Sdarrenr# define ICMP_IREQREPLY 16 100053642Sguido#endif 100153642Sguido#ifndef ICMP_MASKREQ 100292685Sdarrenr# define ICMP_MASKREQ 17 100353642Sguido#endif 100453642Sguido#ifndef ICMP_MASKREPLY 100592685Sdarrenr# define ICMP_MASKREPLY 18 100653642Sguido#endif 100792685Sdarrenr#ifndef ICMP_TRACEROUTE 100892685Sdarrenr# define ICMP_TRACEROUTE 30 100980482Sdarrenr#endif 101092685Sdarrenr#ifndef ICMP_DATACONVERR 101192685Sdarrenr# define ICMP_DATACONVERR 31 101292685Sdarrenr#endif 101392685Sdarrenr#ifndef ICMP_MOBILE_REDIRECT 101492685Sdarrenr# define ICMP_MOBILE_REDIRECT 32 101592685Sdarrenr#endif 101692685Sdarrenr#ifndef ICMP_IPV6_WHEREAREYOU 101792685Sdarrenr# define ICMP_IPV6_WHEREAREYOU 33 101892685Sdarrenr#endif 101992685Sdarrenr#ifndef ICMP_IPV6_IAMHERE 102092685Sdarrenr# define ICMP_IPV6_IAMHERE 34 102192685Sdarrenr#endif 102292685Sdarrenr#ifndef ICMP_MOBILE_REGREQUEST 102392685Sdarrenr# define ICMP_MOBILE_REGREQUEST 35 102492685Sdarrenr#endif 102592685Sdarrenr#ifndef ICMP_MOBILE_REGREPLY 102692685Sdarrenr# define ICMP_MOBILE_REGREPLY 36 102792685Sdarrenr#endif 102892685Sdarrenr#ifndef ICMP_SKIP 102992685Sdarrenr# define ICMP_SKIP 39 103092685Sdarrenr#endif 103192685Sdarrenr#ifndef ICMP_PHOTURIS 103292685Sdarrenr# define ICMP_PHOTURIS 40 103392685Sdarrenr#endif 103492685Sdarrenr#ifndef ICMP_PHOTURIS_UNKNOWN_INDEX 103592685Sdarrenr# define ICMP_PHOTURIS_UNKNOWN_INDEX 1 103692685Sdarrenr#endif 103792685Sdarrenr#ifndef ICMP_PHOTURIS_AUTH_FAILED 103892685Sdarrenr# define ICMP_PHOTURIS_AUTH_FAILED 2 103992685Sdarrenr#endif 104092685Sdarrenr#ifndef ICMP_PHOTURIS_DECRYPT_FAILED 104192685Sdarrenr# define ICMP_PHOTURIS_DECRYPT_FAILED 3 104292685Sdarrenr#endif 104353642Sguido#ifndef IPVERSION 104453642Sguido# define IPVERSION 4 104553642Sguido#endif 104653642Sguido#ifndef IPOPT_MINOFF 104753642Sguido# define IPOPT_MINOFF 4 104853642Sguido#endif 104953642Sguido#ifndef IPOPT_COPIED 105053642Sguido# define IPOPT_COPIED(x) ((x)&0x80) 105153642Sguido#endif 105253642Sguido#ifndef IPOPT_EOL 105353642Sguido# define IPOPT_EOL 0 105453642Sguido#endif 105553642Sguido#ifndef IPOPT_NOP 105653642Sguido# define IPOPT_NOP 1 105753642Sguido#endif 105853642Sguido#ifndef IP_MF 105953642Sguido# define IP_MF ((u_short)0x2000) 106053642Sguido#endif 106153642Sguido#ifndef ETHERTYPE_IP 106253642Sguido# define ETHERTYPE_IP ((u_short)0x0800) 106353642Sguido#endif 106453642Sguido#ifndef TH_FIN 106553642Sguido# define TH_FIN 0x01 106653642Sguido#endif 106753642Sguido#ifndef TH_SYN 106853642Sguido# define TH_SYN 0x02 106953642Sguido#endif 107053642Sguido#ifndef TH_RST 107153642Sguido# define TH_RST 0x04 107253642Sguido#endif 107353642Sguido#ifndef TH_PUSH 107453642Sguido# define TH_PUSH 0x08 107553642Sguido#endif 107653642Sguido#ifndef TH_ACK 107753642Sguido# define TH_ACK 0x10 107853642Sguido#endif 107953642Sguido#ifndef TH_URG 108053642Sguido# define TH_URG 0x20 108153642Sguido#endif 1082145522Sdarrenr#undef TH_ACKMASK 1083145522Sdarrenr#define TH_ACKMASK (TH_FIN|TH_SYN|TH_RST|TH_ACK) 1084145522Sdarrenr 108553642Sguido#ifndef IPOPT_EOL 108653642Sguido# define IPOPT_EOL 0 108753642Sguido#endif 108853642Sguido#ifndef IPOPT_NOP 108953642Sguido# define IPOPT_NOP 1 109053642Sguido#endif 109153642Sguido#ifndef IPOPT_RR 109253642Sguido# define IPOPT_RR 7 109353642Sguido#endif 109453642Sguido#ifndef IPOPT_TS 109553642Sguido# define IPOPT_TS 68 109653642Sguido#endif 109753642Sguido#ifndef IPOPT_SECURITY 109853642Sguido# define IPOPT_SECURITY 130 109953642Sguido#endif 110053642Sguido#ifndef IPOPT_LSRR 110153642Sguido# define IPOPT_LSRR 131 110253642Sguido#endif 110353642Sguido#ifndef IPOPT_SATID 110453642Sguido# define IPOPT_SATID 136 110553642Sguido#endif 110653642Sguido#ifndef IPOPT_SSRR 110753642Sguido# define IPOPT_SSRR 137 110853642Sguido#endif 110953642Sguido#ifndef IPOPT_SECUR_UNCLASS 111053642Sguido# define IPOPT_SECUR_UNCLASS ((u_short)0x0000) 111153642Sguido#endif 111253642Sguido#ifndef IPOPT_SECUR_CONFID 111353642Sguido# define IPOPT_SECUR_CONFID ((u_short)0xf135) 111453642Sguido#endif 111553642Sguido#ifndef IPOPT_SECUR_EFTO 111653642Sguido# define IPOPT_SECUR_EFTO ((u_short)0x789a) 111753642Sguido#endif 111853642Sguido#ifndef IPOPT_SECUR_MMMM 111953642Sguido# define IPOPT_SECUR_MMMM ((u_short)0xbc4d) 112053642Sguido#endif 112153642Sguido#ifndef IPOPT_SECUR_RESTR 112253642Sguido# define IPOPT_SECUR_RESTR ((u_short)0xaf13) 112353642Sguido#endif 112453642Sguido#ifndef IPOPT_SECUR_SECRET 112553642Sguido# define IPOPT_SECUR_SECRET ((u_short)0xd788) 112653642Sguido#endif 112753642Sguido#ifndef IPOPT_SECUR_TOPSECRET 112853642Sguido# define IPOPT_SECUR_TOPSECRET ((u_short)0x6bc5) 112953642Sguido#endif 113053642Sguido#ifndef IPOPT_OLEN 113153642Sguido# define IPOPT_OLEN 1 113253642Sguido#endif 1133145522Sdarrenr#ifndef IPPROTO_HOPOPTS 1134145522Sdarrenr# define IPPROTO_HOPOPTS 0 1135145522Sdarrenr#endif 1136255332Scy#ifndef IPPROTO_IPIP 1137255332Scy# define IPPROTO_IPIP 4 1138255332Scy#endif 1139145522Sdarrenr#ifndef IPPROTO_ENCAP 1140255332Scy# define IPPROTO_ENCAP 98 1141145522Sdarrenr#endif 1142145522Sdarrenr#ifndef IPPROTO_IPV6 1143145522Sdarrenr# define IPPROTO_IPV6 41 1144145522Sdarrenr#endif 1145145522Sdarrenr#ifndef IPPROTO_ROUTING 1146145522Sdarrenr# define IPPROTO_ROUTING 43 1147145522Sdarrenr#endif 1148145522Sdarrenr#ifndef IPPROTO_FRAGMENT 1149145522Sdarrenr# define IPPROTO_FRAGMENT 44 1150145522Sdarrenr#endif 115192685Sdarrenr#ifndef IPPROTO_GRE 115292685Sdarrenr# define IPPROTO_GRE 47 /* GRE encaps RFC 1701 */ 115392685Sdarrenr#endif 115492685Sdarrenr#ifndef IPPROTO_ESP 115592685Sdarrenr# define IPPROTO_ESP 50 115692685Sdarrenr#endif 1157145522Sdarrenr#ifndef IPPROTO_AH 1158145522Sdarrenr# define IPPROTO_AH 51 1159145522Sdarrenr#endif 116092685Sdarrenr#ifndef IPPROTO_ICMPV6 116192685Sdarrenr# define IPPROTO_ICMPV6 58 116292685Sdarrenr#endif 1163145522Sdarrenr#ifndef IPPROTO_NONE 1164145522Sdarrenr# define IPPROTO_NONE 59 116553642Sguido#endif 1166145522Sdarrenr#ifndef IPPROTO_DSTOPTS 1167145522Sdarrenr# define IPPROTO_DSTOPTS 60 116853642Sguido#endif 1169153876Sguido#ifndef IPPROTO_MOBILITY 1170153876Sguido# define IPPROTO_MOBILITY 135 117153642Sguido#endif 1172153876Sguido 117353642Sguido#ifndef ICMP_ROUTERADVERT 117453642Sguido# define ICMP_ROUTERADVERT 9 117553642Sguido#endif 117653642Sguido#ifndef ICMP_ROUTERSOLICIT 117753642Sguido# define ICMP_ROUTERSOLICIT 10 117853642Sguido#endif 117992685Sdarrenr#ifndef ICMP6_DST_UNREACH 118092685Sdarrenr# define ICMP6_DST_UNREACH 1 118192685Sdarrenr#endif 118292685Sdarrenr#ifndef ICMP6_PACKET_TOO_BIG 118392685Sdarrenr# define ICMP6_PACKET_TOO_BIG 2 118492685Sdarrenr#endif 118592685Sdarrenr#ifndef ICMP6_TIME_EXCEEDED 118692685Sdarrenr# define ICMP6_TIME_EXCEEDED 3 118792685Sdarrenr#endif 118892685Sdarrenr#ifndef ICMP6_PARAM_PROB 118992685Sdarrenr# define ICMP6_PARAM_PROB 4 119092685Sdarrenr#endif 119192685Sdarrenr 119292685Sdarrenr#ifndef ICMP6_ECHO_REQUEST 119392685Sdarrenr# define ICMP6_ECHO_REQUEST 128 119492685Sdarrenr#endif 119592685Sdarrenr#ifndef ICMP6_ECHO_REPLY 119692685Sdarrenr# define ICMP6_ECHO_REPLY 129 119792685Sdarrenr#endif 119892685Sdarrenr#ifndef ICMP6_MEMBERSHIP_QUERY 119992685Sdarrenr# define ICMP6_MEMBERSHIP_QUERY 130 120092685Sdarrenr#endif 120192685Sdarrenr#ifndef MLD6_LISTENER_QUERY 120292685Sdarrenr# define MLD6_LISTENER_QUERY 130 120392685Sdarrenr#endif 120492685Sdarrenr#ifndef ICMP6_MEMBERSHIP_REPORT 120592685Sdarrenr# define ICMP6_MEMBERSHIP_REPORT 131 120692685Sdarrenr#endif 120792685Sdarrenr#ifndef MLD6_LISTENER_REPORT 120892685Sdarrenr# define MLD6_LISTENER_REPORT 131 120992685Sdarrenr#endif 121092685Sdarrenr#ifndef ICMP6_MEMBERSHIP_REDUCTION 121192685Sdarrenr# define ICMP6_MEMBERSHIP_REDUCTION 132 121292685Sdarrenr#endif 121392685Sdarrenr#ifndef MLD6_LISTENER_DONE 121492685Sdarrenr# define MLD6_LISTENER_DONE 132 121592685Sdarrenr#endif 121692685Sdarrenr#ifndef ND_ROUTER_SOLICIT 121792685Sdarrenr# define ND_ROUTER_SOLICIT 133 121892685Sdarrenr#endif 121992685Sdarrenr#ifndef ND_ROUTER_ADVERT 122092685Sdarrenr# define ND_ROUTER_ADVERT 134 122192685Sdarrenr#endif 122292685Sdarrenr#ifndef ND_NEIGHBOR_SOLICIT 122392685Sdarrenr# define ND_NEIGHBOR_SOLICIT 135 122492685Sdarrenr#endif 122592685Sdarrenr#ifndef ND_NEIGHBOR_ADVERT 122692685Sdarrenr# define ND_NEIGHBOR_ADVERT 136 122792685Sdarrenr#endif 122892685Sdarrenr#ifndef ND_REDIRECT 122992685Sdarrenr# define ND_REDIRECT 137 123092685Sdarrenr#endif 123192685Sdarrenr#ifndef ICMP6_ROUTER_RENUMBERING 123292685Sdarrenr# define ICMP6_ROUTER_RENUMBERING 138 123392685Sdarrenr#endif 123492685Sdarrenr#ifndef ICMP6_WRUREQUEST 123592685Sdarrenr# define ICMP6_WRUREQUEST 139 123692685Sdarrenr#endif 123792685Sdarrenr#ifndef ICMP6_WRUREPLY 123892685Sdarrenr# define ICMP6_WRUREPLY 140 123992685Sdarrenr#endif 124092685Sdarrenr#ifndef ICMP6_FQDN_QUERY 124192685Sdarrenr# define ICMP6_FQDN_QUERY 139 124292685Sdarrenr#endif 124392685Sdarrenr#ifndef ICMP6_FQDN_REPLY 124492685Sdarrenr# define ICMP6_FQDN_REPLY 140 124592685Sdarrenr#endif 124692685Sdarrenr#ifndef ICMP6_NI_QUERY 124792685Sdarrenr# define ICMP6_NI_QUERY 139 124892685Sdarrenr#endif 124992685Sdarrenr#ifndef ICMP6_NI_REPLY 125092685Sdarrenr# define ICMP6_NI_REPLY 140 125192685Sdarrenr#endif 125292685Sdarrenr#ifndef MLD6_MTRACE_RESP 125392685Sdarrenr# define MLD6_MTRACE_RESP 200 125492685Sdarrenr#endif 125592685Sdarrenr#ifndef MLD6_MTRACE 125692685Sdarrenr# define MLD6_MTRACE 201 125792685Sdarrenr#endif 125892685Sdarrenr#ifndef ICMP6_HADISCOV_REQUEST 125992685Sdarrenr# define ICMP6_HADISCOV_REQUEST 202 126092685Sdarrenr#endif 126192685Sdarrenr#ifndef ICMP6_HADISCOV_REPLY 126292685Sdarrenr# define ICMP6_HADISCOV_REPLY 203 126392685Sdarrenr#endif 126492685Sdarrenr#ifndef ICMP6_MOBILEPREFIX_SOLICIT 126592685Sdarrenr# define ICMP6_MOBILEPREFIX_SOLICIT 204 126692685Sdarrenr#endif 126792685Sdarrenr#ifndef ICMP6_MOBILEPREFIX_ADVERT 126892685Sdarrenr# define ICMP6_MOBILEPREFIX_ADVERT 205 126992685Sdarrenr#endif 127092685Sdarrenr#ifndef ICMP6_MAXTYPE 127192685Sdarrenr# define ICMP6_MAXTYPE 205 127292685Sdarrenr#endif 127392685Sdarrenr 127492685Sdarrenr#ifndef ICMP6_DST_UNREACH_NOROUTE 127592685Sdarrenr# define ICMP6_DST_UNREACH_NOROUTE 0 127692685Sdarrenr#endif 127792685Sdarrenr#ifndef ICMP6_DST_UNREACH_ADMIN 127892685Sdarrenr# define ICMP6_DST_UNREACH_ADMIN 1 127992685Sdarrenr#endif 128092685Sdarrenr#ifndef ICMP6_DST_UNREACH_NOTNEIGHBOR 128192685Sdarrenr# define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 128292685Sdarrenr#endif 128392685Sdarrenr#ifndef ICMP6_DST_UNREACH_BEYONDSCOPE 128492685Sdarrenr# define ICMP6_DST_UNREACH_BEYONDSCOPE 2 128592685Sdarrenr#endif 128692685Sdarrenr#ifndef ICMP6_DST_UNREACH_ADDR 128792685Sdarrenr# define ICMP6_DST_UNREACH_ADDR 3 128892685Sdarrenr#endif 128992685Sdarrenr#ifndef ICMP6_DST_UNREACH_NOPORT 129092685Sdarrenr# define ICMP6_DST_UNREACH_NOPORT 4 129192685Sdarrenr#endif 129292685Sdarrenr#ifndef ICMP6_TIME_EXCEED_TRANSIT 129392685Sdarrenr# define ICMP6_TIME_EXCEED_TRANSIT 0 129492685Sdarrenr#endif 129592685Sdarrenr#ifndef ICMP6_TIME_EXCEED_REASSEMBLY 129692685Sdarrenr# define ICMP6_TIME_EXCEED_REASSEMBLY 1 129792685Sdarrenr#endif 129892685Sdarrenr 129992685Sdarrenr#ifndef ICMP6_NI_SUCCESS 130092685Sdarrenr# define ICMP6_NI_SUCCESS 0 130192685Sdarrenr#endif 130292685Sdarrenr#ifndef ICMP6_NI_REFUSED 130392685Sdarrenr# define ICMP6_NI_REFUSED 1 130492685Sdarrenr#endif 130592685Sdarrenr#ifndef ICMP6_NI_UNKNOWN 130692685Sdarrenr# define ICMP6_NI_UNKNOWN 2 130792685Sdarrenr#endif 130892685Sdarrenr 130992685Sdarrenr#ifndef ICMP6_ROUTER_RENUMBERING_COMMAND 131092685Sdarrenr# define ICMP6_ROUTER_RENUMBERING_COMMAND 0 131192685Sdarrenr#endif 131292685Sdarrenr#ifndef ICMP6_ROUTER_RENUMBERING_RESULT 131392685Sdarrenr# define ICMP6_ROUTER_RENUMBERING_RESULT 1 131492685Sdarrenr#endif 131592685Sdarrenr#ifndef ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 131692685Sdarrenr# define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 131792685Sdarrenr#endif 131892685Sdarrenr 131992685Sdarrenr#ifndef ICMP6_PARAMPROB_HEADER 132092685Sdarrenr# define ICMP6_PARAMPROB_HEADER 0 132192685Sdarrenr#endif 132292685Sdarrenr#ifndef ICMP6_PARAMPROB_NEXTHEADER 132392685Sdarrenr# define ICMP6_PARAMPROB_NEXTHEADER 1 132492685Sdarrenr#endif 132592685Sdarrenr#ifndef ICMP6_PARAMPROB_OPTION 132692685Sdarrenr# define ICMP6_PARAMPROB_OPTION 2 132792685Sdarrenr#endif 132892685Sdarrenr 132992685Sdarrenr#ifndef ICMP6_NI_SUBJ_IPV6 133092685Sdarrenr# define ICMP6_NI_SUBJ_IPV6 0 133192685Sdarrenr#endif 133292685Sdarrenr#ifndef ICMP6_NI_SUBJ_FQDN 133392685Sdarrenr# define ICMP6_NI_SUBJ_FQDN 1 133492685Sdarrenr#endif 133592685Sdarrenr#ifndef ICMP6_NI_SUBJ_IPV4 133692685Sdarrenr# define ICMP6_NI_SUBJ_IPV4 2 133792685Sdarrenr#endif 133892685Sdarrenr 1339255332Scy#ifndef MLD_MTRACE_RESP 1340255332Scy# define MLD_MTRACE_RESP 200 1341255332Scy#endif 1342255332Scy#ifndef MLD_MTRACE 1343255332Scy# define MLD_MTRACE 201 1344255332Scy#endif 1345255332Scy#ifndef MLD6_MTRACE_RESP 1346255332Scy# define MLD6_MTRACE_RESP MLD_MTRACE_RESP 1347255332Scy#endif 1348255332Scy#ifndef MLD6_MTRACE 1349255332Scy# define MLD6_MTRACE MLD_MTRACE 1350255332Scy#endif 1351255332Scy 1352255332Scy#if !defined(IPV6_FLOWINFO_MASK) 1353255332Scy# if (BYTE_ORDER == BIG_ENDIAN) || defined(_BIG_ENDIAN) 1354255332Scy# define IPV6_FLOWINFO_MASK 0x0fffffff /* flow info (28 bits) */ 1355255332Scy# else 1356255332Scy# if(BYTE_ORDER == LITTLE_ENDIAN) || !defined(_BIG_ENDIAN) 1357255332Scy# define IPV6_FLOWINFO_MASK 0xffffff0f /* flow info (28 bits) */ 1358255332Scy# endif /* LITTLE_ENDIAN */ 1359255332Scy# endif 1360255332Scy#endif 1361255332Scy#if !defined(IPV6_FLOWLABEL_MASK) 1362255332Scy# if (BYTE_ORDER == BIG_ENDIAN) || defined(_BIG_ENDIAN) 1363255332Scy# define IPV6_FLOWLABEL_MASK 0x000fffff /* flow label (20 bits) */ 1364255332Scy# else 1365255332Scy# if (BYTE_ORDER == LITTLE_ENDIAN) || !defined(_BIG_ENDIAN) 1366255332Scy# define IPV6_FLOWLABEL_MASK 0xffff0f00 /* flow label (20 bits) */ 1367255332Scy# endif /* LITTLE_ENDIAN */ 1368255332Scy# endif 1369255332Scy#endif 1370255332Scy 137172006Sdarrenr/* 137272006Sdarrenr * ECN is a new addition to TCP - RFC 2481 137372006Sdarrenr */ 137472006Sdarrenr#ifndef TH_ECN 137572006Sdarrenr# define TH_ECN 0x40 137672006Sdarrenr#endif 137772006Sdarrenr#ifndef TH_CWR 137872006Sdarrenr# define TH_CWR 0x80 137972006Sdarrenr#endif 138072006Sdarrenr#define TH_ECNALL (TH_ECN|TH_CWR) 138172006Sdarrenr 1382145522Sdarrenr/* 1383145522Sdarrenr * TCP States 1384145522Sdarrenr */ 1385170268Sdarrenr#define IPF_TCPS_LISTEN 0 /* listening for connection */ 1386170268Sdarrenr#define IPF_TCPS_SYN_SENT 1 /* active, have sent syn */ 1387170268Sdarrenr#define IPF_TCPS_SYN_RECEIVED 2 /* have send and received syn */ 1388170268Sdarrenr#define IPF_TCPS_HALF_ESTAB 3 /* for connections not fully "up" */ 1389145522Sdarrenr/* states < IPF_TCPS_ESTABLISHED are those where connections not established */ 1390170268Sdarrenr#define IPF_TCPS_ESTABLISHED 4 /* established */ 1391170268Sdarrenr#define IPF_TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */ 1392145522Sdarrenr/* states > IPF_TCPS_CLOSE_WAIT are those where user has closed */ 1393170268Sdarrenr#define IPF_TCPS_FIN_WAIT_1 6 /* have closed, sent fin */ 1394170268Sdarrenr#define IPF_TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */ 1395170268Sdarrenr#define IPF_TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */ 1396145522Sdarrenr/* states > IPF_TCPS_CLOSE_WAIT && < IPF_TCPS_FIN_WAIT_2 await ACK of FIN */ 1397170268Sdarrenr#define IPF_TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */ 1398170268Sdarrenr#define IPF_TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */ 1399170268Sdarrenr#define IPF_TCPS_CLOSED 11 /* closed */ 1400145522Sdarrenr#define IPF_TCP_NSTATES 12 140172006Sdarrenr 1402145522Sdarrenr#define TCP_MSL 120 1403145522Sdarrenr 1404145522Sdarrenr#undef ICMP_MAX_UNREACH 1405145522Sdarrenr#define ICMP_MAX_UNREACH 14 1406145522Sdarrenr#undef ICMP_MAXTYPE 1407145522Sdarrenr#define ICMP_MAXTYPE 18 1408145522Sdarrenr 1409145522Sdarrenr#ifndef IFNAMSIZ 1410145522Sdarrenr#define IFNAMSIZ 16 1411145522Sdarrenr#endif 1412145522Sdarrenr 1413145522Sdarrenr#ifndef LOG_FTP 1414145522Sdarrenr# define LOG_FTP (11<<3) 1415145522Sdarrenr#endif 1416145522Sdarrenr#ifndef LOG_AUTHPRIV 1417145522Sdarrenr# define LOG_AUTHPRIV (10<<3) 1418145522Sdarrenr#endif 1419145522Sdarrenr#ifndef LOG_AUDIT 1420145522Sdarrenr# define LOG_AUDIT (13<<3) 1421145522Sdarrenr#endif 1422145522Sdarrenr#ifndef LOG_NTP 1423145522Sdarrenr# define LOG_NTP (12<<3) 1424145522Sdarrenr#endif 1425145522Sdarrenr#ifndef LOG_SECURITY 1426145522Sdarrenr# define LOG_SECURITY (13<<3) 1427145522Sdarrenr#endif 1428145522Sdarrenr#ifndef LOG_LFMT 1429145522Sdarrenr# define LOG_LFMT (14<<3) 1430145522Sdarrenr#endif 1431145522Sdarrenr#ifndef LOG_CONSOLE 1432145522Sdarrenr# define LOG_CONSOLE (14<<3) 1433145522Sdarrenr#endif 1434145522Sdarrenr 1435145522Sdarrenr/* 1436145522Sdarrenr * ICMP error replies have an IP header (20 bytes), 8 bytes of ICMP data, 1437145522Sdarrenr * another IP header and then 64 bits of data, totalling 56. Of course, 1438153876Sguido * the last 64 bits is dependent on that being available. 1439145522Sdarrenr */ 1440145522Sdarrenr#define ICMPERR_ICMPHLEN 8 1441145522Sdarrenr#define ICMPERR_IPICMPHLEN (20 + 8) 1442145522Sdarrenr#define ICMPERR_MINPKTLEN (20 + 8 + 20) 1443145522Sdarrenr#define ICMPERR_MAXPKTLEN (20 + 8 + 20 + 8) 1444145522Sdarrenr#define ICMP6ERR_MINPKTLEN (40 + 8) 1445145522Sdarrenr#define ICMP6ERR_IPICMPHLEN (40 + 8 + 40) 1446145522Sdarrenr 1447145522Sdarrenr#ifndef MIN 1448145522Sdarrenr# define MIN(a,b) (((a)<(b))?(a):(b)) 1449145522Sdarrenr#endif 1450145522Sdarrenr 1451255332Scy#ifdef RESCUE 1452255332Scy# undef IPFILTER_BPF 1453255332Scy#endif 1454255332Scy 1455145522Sdarrenr#ifdef IPF_DEBUG 1456145522Sdarrenr# define DPRINT(x) printf x 1457145522Sdarrenr#else 1458145522Sdarrenr# define DPRINT(x) 1459145522Sdarrenr#endif 1460145522Sdarrenr 1461255332Scy#ifndef AF_INET6 1462255332Scy# define AF_INET6 26 1463146277Sdarrenr#endif 1464146277Sdarrenr 1465255332Scy#ifdef DTRACE_PROBE 1466255332Scy# ifdef _KERNEL 1467255332Scy# define DT(_n) DTRACE_PROBE(_n) 1468255332Scy# define DT1(_n,_a,_b) DTRACE_PROBE1(_n,_a,_b) 1469255332Scy# define DT2(_n,_a,_b,_c,_d) DTRACE_PROBE2(_n,_a,_b,_c,_d) 1470255332Scy# define DT3(_n,_a,_b,_c,_d,_e,_f) \ 1471255332Scy DTRACE_PROBE3(_n,_a,_b,_c,_d,_e,_f) 1472255332Scy# define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h) \ 1473255332Scy DTRACE_PROBE4(_n,_a,_b,_c,_d,_e,_f,_g,_h) 1474255332Scy# else 1475255332Scy# define DT(_n) 1476255332Scy# define DT1(_n,_a,_b) 1477255332Scy# define DT2(_n,_a,_b,_c,_d) 1478255332Scy# define DT3(_n,_a,_b,_c,_d,_e,_f) 1479255332Scy# define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h) 1480255332Scy# endif 1481255332Scy#else 1482255332Scy# define DT(_n) 1483255332Scy# define DT1(_n,_a,_b) 1484255332Scy# define DT2(_n,_a,_b,_c,_d) 1485255332Scy# define DT3(_n,_a,_b,_c,_d,_e,_f) 1486255332Scy# define DT4(_n,_a,_b,_c,_d,_e,_f,_g,_h) 1487255332Scy#endif 1488255332Scy 1489255332Scystruct ip6_routing { 1490255332Scy u_char ip6r_nxt; /* next header */ 1491255332Scy u_char ip6r_len; /* length in units of 8 octets */ 1492255332Scy u_char ip6r_type; /* always zero */ 1493255332Scy u_char ip6r_segleft; /* segments left */ 1494255332Scy u_32_t ip6r_reserved; /* reserved field */ 1495255332Scy}; 1496255332Scy 149753642Sguido#endif /* __IP_COMPAT_H__ */ 1498