ip_compat.h revision 92685
153642Sguido/* 280482Sdarrenr * Copyright (C) 1993-2001 by Darren Reed. 353642Sguido * 480482Sdarrenr * See the IPFILTER.LICENCE file for details on licencing. 553642Sguido * 653642Sguido * @(#)ip_compat.h 1.8 1/14/96 772006Sdarrenr * $Id: ip_compat.h,v 2.26.2.9 2001/01/14 14:58:01 darrenr Exp $ 857126Sguido * $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_compat.h 92685 2002-03-19 11:44:16Z darrenr $ 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#ifndef SOLARIS 2753642Sguido#define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4))) 2853642Sguido#endif 2992685Sdarrenr#if SOLARIS 3092685Sdarrenr# if !defined(SOLARIS2) 3192685Sdarrenr# define SOLARIS2 3 /* Pick an old version */ 3260857Sdarrenr# endif 3392685Sdarrenr# if SOLARIS2 >= 8 3492685Sdarrenr# ifndef USE_INET6 3592685Sdarrenr# define USE_INET6 3692685Sdarrenr# endif 3792685Sdarrenr# else 3892685Sdarrenr# undef USE_INET6 3992685Sdarrenr# endif 4060857Sdarrenr#endif 4192685Sdarrenr#if defined(sun) && !(defined(__svr4__) || defined(__SVR4)) 4292685Sdarrenr# undef USE_INET6 4392685Sdarrenr#endif 4453642Sguido 4553642Sguido#if defined(_KERNEL) || defined(KERNEL) || defined(__KERNEL__) 4653642Sguido# undef KERNEL 4753642Sguido# undef _KERNEL 4853642Sguido# undef __KERNEL__ 4953642Sguido# define KERNEL 5053642Sguido# define _KERNEL 5153642Sguido# define __KERNEL__ 5253642Sguido#endif 5353642Sguido 5453642Sguido#if defined(__SVR4) || defined(__svr4__) || defined(__sgi) 5553642Sguido#define index strchr 5653642Sguido# if !defined(KERNEL) 5753642Sguido# define bzero(a,b) memset(a,0,b) 5853642Sguido# define bcmp memcmp 5953642Sguido# define bcopy(a,b,c) memmove(b,a,c) 6053642Sguido# endif 6153642Sguido#endif 6253642Sguido 6353642Sguido#ifndef offsetof 6453642Sguido#define offsetof(t,m) (int)((&((t *)0L)->m)) 6553642Sguido#endif 6653642Sguido 6753642Sguido#if defined(__sgi) || defined(bsdi) 6853642Sguidostruct ether_addr { 6953642Sguido u_char ether_addr_octet[6]; 7053642Sguido}; 7153642Sguido#endif 7253642Sguido 7392685Sdarrenr#ifndef LIFNAMSIZ 7492685Sdarrenr# ifdef IF_NAMESIZE 7592685Sdarrenr# define LIFNAMSIZ IF_NAMESIZE 7692685Sdarrenr# else 7792685Sdarrenr# ifdef IFNAMSIZ 7892685Sdarrenr# define LIFNAMSIZ IFNAMSIZ 7992685Sdarrenr# else 8092685Sdarrenr# define LIFNAMSIZ 16 8192685Sdarrenr# endif 8292685Sdarrenr# endif 8392685Sdarrenr#endif 8492685Sdarrenr 8553642Sguido#if defined(__sgi) && !defined(IPFILTER_LKM) 8653642Sguido# ifdef __STDC__ 8753642Sguido# define IPL_EXTERN(ep) ipfilter##ep 8853642Sguido# else 8953642Sguido# define IPL_EXTERN(ep) ipfilter/**/ep 9053642Sguido# endif 9153642Sguido#else 9253642Sguido# ifdef __STDC__ 9353642Sguido# define IPL_EXTERN(ep) ipl##ep 9453642Sguido# else 9553642Sguido# define IPL_EXTERN(ep) ipl/**/ep 9653642Sguido# endif 9753642Sguido#endif 9853642Sguido 9992685Sdarrenr#ifdef __sgi 10092685Sdarrenr# include <sys/debug.h> 10192685Sdarrenr#endif 10292685Sdarrenr 10353642Sguido#ifdef linux 10453642Sguido# include <sys/sysmacros.h> 10553642Sguido#endif 10692685Sdarrenr 10792685Sdarrenr 10892685Sdarrenr/* 10992685Sdarrenr * This is a workaround for <sys/uio.h> troubles on FreeBSD and OpenBSD. 11092685Sdarrenr */ 11192685Sdarrenr#ifndef _KERNEL 11292685Sdarrenr# define ADD_KERNEL 11392685Sdarrenr# define _KERNEL 11492685Sdarrenr# define KERNEL 11592685Sdarrenr#endif 11692685Sdarrenr#ifdef __OpenBSD__ 11792685Sdarrenrstruct file; 11892685Sdarrenr#endif 11992685Sdarrenr#include <sys/uio.h> 12092685Sdarrenr#ifdef ADD_KERNEL 12192685Sdarrenr# undef _KERNEL 12292685Sdarrenr# undef KERNEL 12392685Sdarrenr#endif 12492685Sdarrenr 12553642Sguido#if SOLARIS 12653642Sguido# define MTYPE(m) ((m)->b_datap->db_type) 12792685Sdarrenr# if SOLARIS2 >= 4 12892685Sdarrenr# include <sys/isa_defs.h> 12992685Sdarrenr# endif 13053642Sguido# include <sys/ioccom.h> 13153642Sguido# include <sys/sysmacros.h> 13253642Sguido# include <sys/kmem.h> 13353642Sguido/* 13453642Sguido * because Solaris 2 defines these in two places :-/ 13553642Sguido */ 13653642Sguido# undef IPOPT_EOL 13753642Sguido# undef IPOPT_NOP 13853642Sguido# undef IPOPT_LSRR 13953642Sguido# undef IPOPT_RR 14053642Sguido# undef IPOPT_SSRR 14153642Sguido# ifndef KERNEL 14253642Sguido# define _KERNEL 14353642Sguido# undef RES_INIT 14460857Sdarrenr# if SOLARIS2 >= 8 14560857Sdarrenr# include <netinet/ip6.h> 14660857Sdarrenr# endif 14753642Sguido# include <inet/common.h> 14853642Sguido# include <inet/ip.h> 14953642Sguido# include <inet/ip_ire.h> 15053642Sguido# undef _KERNEL 15153642Sguido# else /* _KERNEL */ 15260857Sdarrenr# if SOLARIS2 >= 8 15360857Sdarrenr# include <netinet/ip6.h> 15460857Sdarrenr# endif 15553642Sguido# include <inet/common.h> 15653642Sguido# include <inet/ip.h> 15753642Sguido# include <inet/ip_ire.h> 15853642Sguido# endif /* _KERNEL */ 15955929Sguido# if SOLARIS2 >= 8 16060857Sdarrenr# include <inet/ip_if.h> 16155929Sguido# include <netinet/ip6.h> 16255929Sguido# define ipif_local_addr ipif_lcl_addr 16360857Sdarrenr/* Only defined in private include file */ 16460857Sdarrenr# ifndef V4_PART_OF_V6 16560857Sdarrenr# define V4_PART_OF_V6(v6) v6.s6_addr32[3] 16660857Sdarrenr# endif 16755929Sguido# endif 16880482Sdarrenr 16980482Sdarrenrtypedef struct qif { 17080482Sdarrenr struct qif *qf_next; 17180482Sdarrenr ill_t *qf_ill; 17280482Sdarrenr kmutex_t qf_lock; 17380482Sdarrenr void *qf_iptr; 17480482Sdarrenr void *qf_optr; 17580482Sdarrenr queue_t *qf_in; 17680482Sdarrenr queue_t *qf_out; 17780482Sdarrenr struct qinit *qf_wqinfo; 17880482Sdarrenr struct qinit *qf_rqinfo; 17980482Sdarrenr struct qinit qf_wqinit; 18080482Sdarrenr struct qinit qf_rqinit; 18180482Sdarrenr mblk_t *qf_m; /* These three fields are for passing data up from */ 18280482Sdarrenr queue_t *qf_q; /* fr_qin and fr_qout to the packet processing. */ 18380482Sdarrenr size_t qf_off; 18480482Sdarrenr size_t qf_len; /* this field is used for in ipfr_fastroute */ 18592685Sdarrenr char qf_name[LIFNAMSIZ]; 18680482Sdarrenr /* 18780482Sdarrenr * in case the ILL has disappeared... 18880482Sdarrenr */ 18980482Sdarrenr size_t qf_hl; /* header length */ 19080482Sdarrenr int qf_sap; 19192685Sdarrenr size_t qf_incnt; 19292685Sdarrenr size_t qf_outcnt; 19380482Sdarrenr} qif_t; 19480482Sdarrenr#else /* SOLARIS */ 19553642Sguido# if !defined(__sgi) 19653642Sguidotypedef int minor_t; 19780482Sdarrenr# endif 19853642Sguido#endif /* SOLARIS */ 19953642Sguido#define IPMINLEN(i, h) ((i)->ip_len >= ((i)->ip_hl * 4 + sizeof(struct h))) 20053642Sguido 20164580Sdarrenr#if defined(__FreeBSD__) && (__FreeBSD__ >= 5) && defined(_KERNEL) 20264580Sdarrenr# include <machine/in_cksum.h> 20364580Sdarrenr#endif 20464580Sdarrenr 20553642Sguido#ifndef IP_OFFMASK 20653642Sguido#define IP_OFFMASK 0x1fff 20753642Sguido#endif 20853642Sguido 20953642Sguido#if BSD > 199306 21053642Sguido# define USE_QUAD_T 21153642Sguido# define U_QUAD_T u_quad_t 21253642Sguido# define QUAD_T quad_t 21353642Sguido#else /* BSD > 199306 */ 21453642Sguido# define U_QUAD_T u_long 21553642Sguido# define QUAD_T long 21653642Sguido#endif /* BSD > 199306 */ 21753642Sguido 21860857Sdarrenr 21953642Sguido/* 22053642Sguido * These operating systems already take care of the problem for us. 22153642Sguido */ 22253642Sguido#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || \ 22353642Sguido defined(__sgi) 22453642Sguidotypedef u_int32_t u_32_t; 22560857Sdarrenr# if defined(_KERNEL) && !defined(IPFILTER_LKM) 22660857Sdarrenr# if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 104110000) 22760857Sdarrenr# include "opt_inet.h" 22860857Sdarrenr# endif 22960857Sdarrenr# if defined(__FreeBSD_version) && (__FreeBSD_version >= 400000) && \ 23060857Sdarrenr !defined(KLD_MODULE) 23160857Sdarrenr# include "opt_inet6.h" 23260857Sdarrenr# endif 23360857Sdarrenr# ifdef INET6 23460857Sdarrenr# define USE_INET6 23560857Sdarrenr# endif 23660857Sdarrenr# endif 23753642Sguido#else 23853642Sguido/* 23953642Sguido * Really, any arch where sizeof(long) != sizeof(int). 24053642Sguido */ 24153642Sguido# if defined(__alpha__) || defined(__alpha) || defined(_LP64) 24253642Sguidotypedef unsigned int u_32_t; 24353642Sguido# else 24460857Sdarrenr# if SOLARIS2 >= 6 24560857Sdarrenrtypedef uint32_t u_32_t; 24660857Sdarrenr# else 24760857Sdarrenrtypedef unsigned int u_32_t; 24860857Sdarrenr# endif 24953642Sguido# endif 25053642Sguido#endif /* __NetBSD__ || __OpenBSD__ || __FreeBSD__ || __sgi */ 25153642Sguido 25260857Sdarrenr#ifdef USE_INET6 25360857Sdarrenr# if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) 25460857Sdarrenr# include <netinet/ip6.h> 25560857Sdarrenr# ifdef _KERNEL 25660857Sdarrenr# include <netinet6/ip6_var.h> 25760857Sdarrenr# endif 25860857Sdarrenrtypedef struct ip6_hdr ip6_t; 25960857Sdarrenr# endif 26092685Sdarrenr# include <netinet/icmp6.h> 26160857Sdarrenrunion i6addr { 26260857Sdarrenr u_32_t i6[4]; 26360857Sdarrenr struct in_addr in4; 26460857Sdarrenr struct in6_addr in6; 26560857Sdarrenr}; 26660857Sdarrenr#else 26760857Sdarrenrunion i6addr { 26860857Sdarrenr u_32_t i6[4]; 26960857Sdarrenr struct in_addr in4; 27060857Sdarrenr}; 27160857Sdarrenr#endif 27260857Sdarrenr 27360857Sdarrenr#define IP6CMP(a,b) bcmp((char *)&(a), (char *)&(b), sizeof(a)) 27460857Sdarrenr#define IP6EQ(a,b) (bcmp((char *)&(a), (char *)&(b), sizeof(a)) == 0) 27560857Sdarrenr#define IP6NEQ(a,b) (bcmp((char *)&(a), (char *)&(b), sizeof(a)) != 0) 27692685Sdarrenr#define IP6_ISZERO(a) ((((union i6addr *)(a))->i6[0] | \ 27792685Sdarrenr ((union i6addr *)(a))->i6[1] | \ 27892685Sdarrenr ((union i6addr *)(a))->i6[2] | \ 27992685Sdarrenr ((union i6addr *)(a))->i6[3]) == 0) 28092685Sdarrenr#define IP6_NOTZERO(a) ((((union i6addr *)(a))->i6[0] | \ 28192685Sdarrenr ((union i6addr *)(a))->i6[1] | \ 28292685Sdarrenr ((union i6addr *)(a))->i6[2] | \ 28392685Sdarrenr ((union i6addr *)(a))->i6[3]) != 0) 28460857Sdarrenr 28553642Sguido#ifndef MAX 28653642Sguido#define MAX(a,b) (((a) > (b)) ? (a) : (b)) 28753642Sguido#endif 28853642Sguido 28953642Sguido/* 29053642Sguido * Security Options for Intenet Protocol (IPSO) as defined in RFC 1108. 29153642Sguido * 29253642Sguido * Basic Option 29353642Sguido * 29453642Sguido * 00000001 - (Reserved 4) 29553642Sguido * 00111101 - Top Secret 29653642Sguido * 01011010 - Secret 29753642Sguido * 10010110 - Confidential 29853642Sguido * 01100110 - (Reserved 3) 29953642Sguido * 11001100 - (Reserved 2) 30053642Sguido * 10101011 - Unclassified 30153642Sguido * 11110001 - (Reserved 1) 30253642Sguido */ 30353642Sguido#define IPSO_CLASS_RES4 0x01 30453642Sguido#define IPSO_CLASS_TOPS 0x3d 30553642Sguido#define IPSO_CLASS_SECR 0x5a 30653642Sguido#define IPSO_CLASS_CONF 0x96 30753642Sguido#define IPSO_CLASS_RES3 0x66 30853642Sguido#define IPSO_CLASS_RES2 0xcc 30953642Sguido#define IPSO_CLASS_UNCL 0xab 31053642Sguido#define IPSO_CLASS_RES1 0xf1 31153642Sguido 31253642Sguido#define IPSO_AUTH_GENSER 0x80 31353642Sguido#define IPSO_AUTH_ESI 0x40 31453642Sguido#define IPSO_AUTH_SCI 0x20 31553642Sguido#define IPSO_AUTH_NSA 0x10 31653642Sguido#define IPSO_AUTH_DOE 0x08 31753642Sguido#define IPSO_AUTH_UN 0x06 31853642Sguido#define IPSO_AUTH_FTE 0x01 31953642Sguido 32053642Sguido/* 32153642Sguido * IP option #defines 32253642Sguido */ 32353642Sguido/*#define IPOPT_RR 7 */ 32453642Sguido#define IPOPT_ZSU 10 /* ZSU */ 32553642Sguido#define IPOPT_MTUP 11 /* MTUP */ 32653642Sguido#define IPOPT_MTUR 12 /* MTUR */ 32753642Sguido#define IPOPT_ENCODE 15 /* ENCODE */ 32853642Sguido/*#define IPOPT_TS 68 */ 32953642Sguido#define IPOPT_TR 82 /* TR */ 33053642Sguido/*#define IPOPT_SECURITY 130 */ 33153642Sguido/*#define IPOPT_LSRR 131 */ 33253642Sguido#define IPOPT_E_SEC 133 /* E-SEC */ 33353642Sguido#define IPOPT_CIPSO 134 /* CIPSO */ 33453642Sguido/*#define IPOPT_SATID 136 */ 33553642Sguido#ifndef IPOPT_SID 33653642Sguido# define IPOPT_SID IPOPT_SATID 33753642Sguido#endif 33853642Sguido/*#define IPOPT_SSRR 137 */ 33953642Sguido#define IPOPT_ADDEXT 147 /* ADDEXT */ 34053642Sguido#define IPOPT_VISA 142 /* VISA */ 34153642Sguido#define IPOPT_IMITD 144 /* IMITD */ 34253642Sguido#define IPOPT_EIP 145 /* EIP */ 34353642Sguido#define IPOPT_FINN 205 /* FINN */ 34453642Sguido 34553642Sguido 34660857Sdarrenr#if defined(__FreeBSD__) && (defined(KERNEL) || defined(_KERNEL)) 34767614Sdarrenr# ifdef IPFILTER_LKM 34880482Sdarrenr# ifndef __FreeBSD_cc_version 34980482Sdarrenr# include <osreldate.h> 35080482Sdarrenr# else 35180482Sdarrenr# if __FreeBSD_cc_version < 430000 35280482Sdarrenr# include <osreldate.h> 35380482Sdarrenr# else 35480482Sdarrenr# include <sys/param.h> 35580482Sdarrenr# endif 35680482Sdarrenr# endif 35767614Sdarrenr# define ACTUALLY_LKM_NOT_KERNEL 35867614Sdarrenr# else 35980482Sdarrenr# ifndef __FreeBSD_cc_version 36080482Sdarrenr# include <sys/osreldate.h> 36180482Sdarrenr# else 36280482Sdarrenr# if __FreeBSD_cc_version < 430000 36380482Sdarrenr# include <sys/osreldate.h> 36480482Sdarrenr# else 36580482Sdarrenr# include <sys/param.h> 36680482Sdarrenr# endif 36780482Sdarrenr# endif 36867614Sdarrenr# endif 36953642Sguido# if __FreeBSD__ < 3 37053642Sguido# include <machine/spl.h> 37160857Sdarrenr# else 37260857Sdarrenr# if __FreeBSD__ == 3 37360857Sdarrenr# if defined(IPFILTER_LKM) && !defined(ACTUALLY_LKM_NOT_KERNEL) 37460857Sdarrenr# define ACTUALLY_LKM_NOT_KERNEL 37560857Sdarrenr# endif 37660857Sdarrenr# endif 37753642Sguido# endif 37853642Sguido#endif /* __FreeBSD__ && KERNEL */ 37953642Sguido 38053642Sguido/* 38153642Sguido * Build some macros and #defines to enable the same code to compile anywhere 38253642Sguido * Well, that's the idea, anyway :-) 38353642Sguido */ 38492685Sdarrenr#if SOLARIS 38592685Sdarrenrtypedef mblk_t mb_t; 38692685Sdarrenr# if SOLARIS2 >= 7 38792685Sdarrenr# ifdef lint 38892685Sdarrenr# define ALIGN32(ptr) (ptr ? 0L : 0L) 38992685Sdarrenr# define ALIGN16(ptr) (ptr ? 0L : 0L) 39092685Sdarrenr# else 39192685Sdarrenr# define ALIGN32(ptr) (ptr) 39292685Sdarrenr# define ALIGN16(ptr) (ptr) 39392685Sdarrenr# endif 39492685Sdarrenr# endif 39592685Sdarrenr#else 39692685Sdarrenrtypedef struct mbuf mb_t; 39792685Sdarrenr#endif /* SOLARIS */ 39892685Sdarrenr 39960857Sdarrenr#if !SOLARIS || (SOLARIS2 < 6) || !defined(KERNEL) 40060857Sdarrenr# define ATOMIC_INCL ATOMIC_INC 40160857Sdarrenr# define ATOMIC_INC64 ATOMIC_INC 40260857Sdarrenr# define ATOMIC_INC32 ATOMIC_INC 40360857Sdarrenr# define ATOMIC_INC16 ATOMIC_INC 40460857Sdarrenr# define ATOMIC_DECL ATOMIC_DEC 40560857Sdarrenr# define ATOMIC_DEC64 ATOMIC_DEC 40660857Sdarrenr# define ATOMIC_DEC32 ATOMIC_DEC 40760857Sdarrenr# define ATOMIC_DEC16 ATOMIC_DEC 40860857Sdarrenr#endif 40967614Sdarrenr#ifdef __sgi 41067614Sdarrenr# define hz HZ 41167614Sdarrenr# include <sys/ksynch.h> 41267614Sdarrenr# define IPF_LOCK_PL plhi 41367614Sdarrenr# include <sys/sema.h> 41467614Sdarrenr#undef kmutex_t 41567614Sdarrenrtypedef struct { 41667614Sdarrenr lock_t *l; 41767614Sdarrenr int pl; 41867614Sdarrenr} kmutex_t; 41967614Sdarrenr# undef MUTEX_INIT 42067614Sdarrenr# undef MUTEX_DESTROY 42167614Sdarrenr#endif 42253642Sguido#ifdef KERNEL 42353642Sguido# if SOLARIS 42460857Sdarrenr# if SOLARIS2 >= 6 42560857Sdarrenr# include <sys/atomic.h> 42660857Sdarrenr# if SOLARIS2 == 6 42760857Sdarrenr# define ATOMIC_INCL(x) atomic_add_long((uint32_t*)&(x), 1) 42860857Sdarrenr# define ATOMIC_DECL(x) atomic_add_long((uint32_t*)&(x), -1) 42960857Sdarrenr# else 43060857Sdarrenr# define ATOMIC_INCL(x) atomic_add_long(&(x), 1) 43160857Sdarrenr# define ATOMIC_DECL(x) atomic_add_long(&(x), -1) 43260857Sdarrenr# endif 43360857Sdarrenr# define ATOMIC_INC64(x) atomic_add_64((uint64_t*)&(x), 1) 43460857Sdarrenr# define ATOMIC_INC32(x) atomic_add_32((uint32_t*)&(x), 1) 43560857Sdarrenr# define ATOMIC_INC16(x) atomic_add_16((uint16_t*)&(x), 1) 43660857Sdarrenr# define ATOMIC_DEC64(x) atomic_add_64((uint64_t*)&(x), -1) 43760857Sdarrenr# define ATOMIC_DEC32(x) atomic_add_32((uint32_t*)&(x), -1) 43860857Sdarrenr# define ATOMIC_DEC16(x) atomic_add_16((uint16_t*)&(x), -1) 43960857Sdarrenr# else 44080482Sdarrenr# define IRE_CACHE IRE_ROUTE 44160857Sdarrenr# define ATOMIC_INC(x) { mutex_enter(&ipf_rw); (x)++; \ 44253642Sguido mutex_exit(&ipf_rw); } 44360857Sdarrenr# define ATOMIC_DEC(x) { mutex_enter(&ipf_rw); (x)--; \ 44453642Sguido mutex_exit(&ipf_rw); } 44560857Sdarrenr# endif 44653642Sguido# define MUTEX_ENTER(x) mutex_enter(x) 44753642Sguido# if 1 44853642Sguido# define KRWLOCK_T krwlock_t 44953642Sguido# define READ_ENTER(x) rw_enter(x, RW_READER) 45053642Sguido# define WRITE_ENTER(x) rw_enter(x, RW_WRITER) 45153642Sguido# define RW_UPGRADE(x) { if (rw_tryupgrade(x) == 0) { \ 45253642Sguido rw_exit(x); \ 45353642Sguido rw_enter(x, RW_WRITER); } \ 45453642Sguido } 45553642Sguido# define MUTEX_DOWNGRADE(x) rw_downgrade(x) 45653642Sguido# define RWLOCK_INIT(x, y, z) rw_init((x), (y), RW_DRIVER, (z)) 45753642Sguido# define RWLOCK_EXIT(x) rw_exit(x) 45853642Sguido# define RW_DESTROY(x) rw_destroy(x) 45953642Sguido# else 46053642Sguido# define KRWLOCK_T kmutex_t 46153642Sguido# define READ_ENTER(x) mutex_enter(x) 46253642Sguido# define WRITE_ENTER(x) mutex_enter(x) 46353642Sguido# define MUTEX_DOWNGRADE(x) ; 46453642Sguido# define RWLOCK_INIT(x, y, z) mutex_init((x), (y), MUTEX_DRIVER, (z)) 46553642Sguido# define RWLOCK_EXIT(x) mutex_exit(x) 46653642Sguido# define RW_DESTROY(x) mutex_destroy(x) 46753642Sguido# endif 46860857Sdarrenr# define MUTEX_INIT(x, y, z) mutex_init((x), (y), MUTEX_DRIVER, (z)) 46960857Sdarrenr# define MUTEX_DESTROY(x) mutex_destroy(x) 47053642Sguido# define MUTEX_EXIT(x) mutex_exit(x) 47153642Sguido# define MTOD(m,t) (t)((m)->b_rptr) 47267614Sdarrenr# define IRCOPY(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c)) 47367614Sdarrenr# define IWCOPY(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c)) 47460857Sdarrenr# define IRCOPYPTR ircopyptr 47560857Sdarrenr# define IWCOPYPTR iwcopyptr 47653642Sguido# define FREE_MB_T(m) freemsg(m) 47753642Sguido# define SPL_NET(x) ; 47853642Sguido# define SPL_IMP(x) ; 47953642Sguido# undef SPL_X 48053642Sguido# define SPL_X(x) ; 48153642Sguido# ifdef sparc 48253642Sguido# define ntohs(x) (x) 48353642Sguido# define ntohl(x) (x) 48453642Sguido# define htons(x) (x) 48553642Sguido# define htonl(x) (x) 48653642Sguido# endif /* sparc */ 48753642Sguido# define KMALLOC(a,b) (a) = (b)kmem_alloc(sizeof(*(a)), KM_NOSLEEP) 48853642Sguido# define KMALLOCS(a,b,c) (a) = (b)kmem_alloc((c), KM_NOSLEEP) 48953642Sguido# define GET_MINOR(x) getminor(x) 49060857Sdarrenrextern ill_t *get_unit __P((char *, int)); 49160857Sdarrenr# define GETUNIT(n, v) get_unit(n, v) 49260857Sdarrenr# define IFNAME(x) ((ill_t *)x)->ill_name 49353642Sguido# else /* SOLARIS */ 49453642Sguido# if defined(__sgi) 49553642Sguido# define ATOMIC_INC(x) { MUTEX_ENTER(&ipf_rw); \ 49653642Sguido (x)++; MUTEX_EXIT(&ipf_rw); } 49753642Sguido# define ATOMIC_DEC(x) { MUTEX_ENTER(&ipf_rw); \ 49853642Sguido (x)--; MUTEX_EXIT(&ipf_rw); } 49953642Sguido# define MUTEX_ENTER(x) (x)->pl = LOCK((x)->l, IPF_LOCK_PL); 50053642Sguido# define KRWLOCK_T kmutex_t 50153642Sguido# define READ_ENTER(x) MUTEX_ENTER(x) 50253642Sguido# define WRITE_ENTER(x) MUTEX_ENTER(x) 50353642Sguido# define RW_UPGRADE(x) ; 50453642Sguido# define MUTEX_DOWNGRADE(x) ; 50560857Sdarrenr# define RWLOCK_EXIT(x) MUTEX_EXIT(x) 50660857Sdarrenr# define MUTEX_EXIT(x) UNLOCK((x)->l, (x)->pl); 50767614Sdarrenr# define MUTEX_INIT(x,y,z) (x)->l = LOCK_ALLOC((uchar_t)-1, IPF_LOCK_PL, (lkinfo_t *)-1, KM_NOSLEEP) 50867614Sdarrenr# define MUTEX_DESTROY(x) LOCK_DEALLOC((x)->l) 50953642Sguido# else /* __sgi */ 51053642Sguido# define ATOMIC_INC(x) (x)++ 51153642Sguido# define ATOMIC_DEC(x) (x)-- 51253642Sguido# define MUTEX_ENTER(x) ; 51360857Sdarrenr# define READ_ENTER(x) ; 51460857Sdarrenr# define WRITE_ENTER(x) ; 51560857Sdarrenr# define RW_UPGRADE(x) ; 51653642Sguido# define MUTEX_DOWNGRADE(x) ; 51760857Sdarrenr# define RWLOCK_EXIT(x) ; 51860857Sdarrenr# define MUTEX_EXIT(x) ; 51960857Sdarrenr# define MUTEX_INIT(x,y,z) ; 52060857Sdarrenr# define MUTEX_DESTROY(x) ; 52153642Sguido# endif /* __sgi */ 52253642Sguido# ifndef linux 52353642Sguido# define FREE_MB_T(m) m_freem(m) 52453642Sguido# define MTOD(m,t) mtod(m,t) 52560857Sdarrenr# define IRCOPY(a,b,c) (bcopy((a), (b), (c)), 0) 52660857Sdarrenr# define IWCOPY(a,b,c) (bcopy((a), (b), (c)), 0) 52760857Sdarrenr# define IRCOPYPTR ircopyptr 52860857Sdarrenr# define IWCOPYPTR iwcopyptr 52953642Sguido# endif /* !linux */ 53053642Sguido# endif /* SOLARIS */ 53153642Sguido 53253642Sguido# ifdef sun 53353642Sguido# if !SOLARIS 53453642Sguido# include <sys/kmem_alloc.h> 53560857Sdarrenr# define GETUNIT(n, v) ifunit(n, IFNAMSIZ) 53660857Sdarrenr# define IFNAME(x) ((struct ifnet *)x)->if_name 53753642Sguido# endif 53853642Sguido# else 53953642Sguido# ifndef linux 54060857Sdarrenr# define GETUNIT(n, v) ifunit(n) 54160857Sdarrenr# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \ 54260857Sdarrenr (defined(OpenBSD) && (OpenBSD >= 199603)) 54360857Sdarrenr# define IFNAME(x) ((struct ifnet *)x)->if_xname 54460857Sdarrenr# else 54580482Sdarrenr# define USE_GETIFNAME 1 54680482Sdarrenr# define IFNAME(x) get_ifname((struct ifnet *)x) 54780482Sdarrenrextern char *get_ifname __P((struct ifnet *)); 54860857Sdarrenr# endif 54953642Sguido# endif 55053642Sguido# endif /* sun */ 55153642Sguido 55253642Sguido# if defined(sun) && !defined(linux) || defined(__sgi) 55353642Sguido# define UIOMOVE(a,b,c,d) uiomove((caddr_t)a,b,c,d) 55453642Sguido# define SLEEP(id, n) sleep((id), PZERO+1) 55553642Sguido# define WAKEUP(id) wakeup(id) 55653642Sguido# define KFREE(x) kmem_free((char *)(x), sizeof(*(x))) 55753642Sguido# define KFREES(x,s) kmem_free((char *)(x), (s)) 55853642Sguido# if !SOLARIS 55953642Sguidoextern void m_copydata __P((struct mbuf *, int, int, caddr_t)); 56053642Sguidoextern void m_copyback __P((struct mbuf *, int, int, caddr_t)); 56153642Sguido# endif 56253642Sguido# ifdef __sgi 56353642Sguido# include <sys/kmem.h> 56453642Sguido# include <sys/ddi.h> 56553642Sguido# define KMALLOC(a,b) (a) = (b)kmem_alloc(sizeof(*(a)), KM_NOSLEEP) 56653642Sguido# define KMALLOCS(a,b,c) (a) = (b)kmem_alloc((c), KM_NOSLEEP) 56753642Sguido# define GET_MINOR(x) getminor(x) 56853642Sguido# else 56953642Sguido# if !SOLARIS 57053642Sguido# define KMALLOC(a,b) (a) = (b)new_kmem_alloc(sizeof(*(a)), \ 57153642Sguido KMEM_NOSLEEP) 57253642Sguido# define KMALLOCS(a,b,c) (a) = (b)new_kmem_alloc((c), KMEM_NOSLEEP) 57353642Sguido# endif /* SOLARIS */ 57453642Sguido# endif /* __sgi */ 57553642Sguido# endif /* sun && !linux */ 57653642Sguido# ifndef GET_MINOR 57753642Sguido# define GET_MINOR(x) minor(x) 57853642Sguido# endif 57953642Sguido# if (BSD >= 199306) || defined(__FreeBSD__) 58092685Sdarrenr# if (defined(__NetBSD_Version__) && (__NetBSD_Version__ < 105180000)) || \ 58192685Sdarrenr defined(__FreeBSD__) || defined(__OpenBSD__) || defined(_BSDI_VERSION) 58292685Sdarrenr# include <vm/vm.h> 58392685Sdarrenr# endif 58453642Sguido# if !defined(__FreeBSD__) || (defined (__FreeBSD__) && __FreeBSD__>=3) 58592685Sdarrenr# if (defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 105180000)) || \ 58692685Sdarrenr (defined(OpenBSD) && (OpenBSD >= 200111)) 58792685Sdarrenr# include <uvm/uvm_extern.h> 58892685Sdarrenr# else 58992685Sdarrenr# include <vm/vm_extern.h> 59092685Sdarrenrextern vm_map_t kmem_map; 59192685Sdarrenr# endif 59253642Sguido# include <sys/proc.h> 59353642Sguido# else /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD__>=3) */ 59453642Sguido# include <vm/vm_kern.h> 59553642Sguido# endif /* !__FreeBSD__ || (__FreeBSD__ && __FreeBSD__>=3) */ 59653642Sguido# ifdef M_PFIL 59753642Sguido# define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), M_PFIL, M_NOWAIT) 59853642Sguido# define KMALLOCS(a, b, c) MALLOC((a), b, (c), M_PFIL, M_NOWAIT) 59953642Sguido# define KFREE(x) FREE((x), M_PFIL) 60053642Sguido# define KFREES(x,s) FREE((x), M_PFIL) 60153642Sguido# else 60253642Sguido# define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), M_TEMP, M_NOWAIT) 60353642Sguido# define KMALLOCS(a, b, c) MALLOC((a), b, (c), M_TEMP, M_NOWAIT) 60453642Sguido# define KFREE(x) FREE((x), M_TEMP) 60553642Sguido# define KFREES(x,s) FREE((x), M_TEMP) 60653642Sguido# endif /* M_PFIL */ 60753642Sguido# define UIOMOVE(a,b,c,d) uiomove(a,b,d) 60853642Sguido# define SLEEP(id, n) tsleep((id), PPAUSE|PCATCH, n, 0) 60953642Sguido# define WAKEUP(id) wakeup(id) 61053642Sguido# endif /* BSD */ 61180482Sdarrenr# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199407)) || \ 61280482Sdarrenr (defined(OpenBSD) && (OpenBSD >= 200006)) 61353642Sguido# define SPL_NET(x) x = splsoftnet() 61453642Sguido# define SPL_X(x) (void) splx(x) 61553642Sguido# else 61653642Sguido# if !SOLARIS && !defined(linux) 61753642Sguido# define SPL_IMP(x) x = splimp() 61853642Sguido# define SPL_NET(x) x = splnet() 61953642Sguido# define SPL_X(x) (void) splx(x) 62053642Sguido# endif 62180482Sdarrenr# endif /* NetBSD && (NetBSD <= 1991011) && (NetBSD >= 199407) */ 62253642Sguido# define PANIC(x,y) if (x) panic y 62353642Sguido#else /* KERNEL */ 62492685Sdarrenr# define SLEEP(x,y) 1 62553642Sguido# define WAKEUP(x) ; 62653642Sguido# define PANIC(x,y) ; 62753642Sguido# define ATOMIC_INC(x) (x)++ 62853642Sguido# define ATOMIC_DEC(x) (x)-- 62953642Sguido# define MUTEX_ENTER(x) ; 63053642Sguido# define READ_ENTER(x) ; 63160857Sdarrenr# define MUTEX_INIT(x,y,z) ; 63260857Sdarrenr# define MUTEX_DESTROY(x) ; 63353642Sguido# define WRITE_ENTER(x) ; 63453642Sguido# define RW_UPGRADE(x) ; 63553642Sguido# define MUTEX_DOWNGRADE(x) ; 63653642Sguido# define RWLOCK_EXIT(x) ; 63753642Sguido# define MUTEX_EXIT(x) ; 63853642Sguido# define SPL_NET(x) ; 63953642Sguido# define SPL_IMP(x) ; 64053642Sguido# undef SPL_X 64153642Sguido# define SPL_X(x) ; 64253642Sguido# define KMALLOC(a,b) (a) = (b)malloc(sizeof(*a)) 64353642Sguido# define KMALLOCS(a,b,c) (a) = (b)malloc(c) 64453642Sguido# define KFREE(x) free(x) 64553642Sguido# define KFREES(x,s) free(x) 64692685Sdarrenr# define FREE_MB_T(x) ; 64760857Sdarrenr# define GETUNIT(x, v) get_unit(x,v) 64860857Sdarrenr# define IRCOPY(a,b,c) (bcopy((a), (b), (c)), 0) 64960857Sdarrenr# define IWCOPY(a,b,c) (bcopy((a), (b), (c)), 0) 65060857Sdarrenr# define IRCOPYPTR ircopyptr 65160857Sdarrenr# define IWCOPYPTR iwcopyptr 65292685Sdarrenr# define IFNAME(x) get_ifname((struct ifnet *)x) 65392685Sdarrenr# define UIOMOVE(a,b,c,d) ipfuiomove(a,b,c,d) 65492685Sdarrenrextern void m_copydata __P((mb_t *, int, int, caddr_t)); 65592685Sdarrenrextern int ipfuiomove __P((caddr_t, int, int, struct uio *)); 65653642Sguido#endif /* KERNEL */ 65753642Sguido 65853642Sguido/* 65953642Sguido * These #ifdef's are here mainly for linux, but who knows, they may 66053642Sguido * not be in other places or maybe one day linux will grow up and some 66153642Sguido * of these will turn up there too. 66253642Sguido */ 66353642Sguido#ifndef ICMP_MINLEN 66453642Sguido# define ICMP_MINLEN 8 66553642Sguido#endif 66692685Sdarrenr#ifndef ICMP_ECHOREPLY 66792685Sdarrenr# define ICMP_ECHOREPLY 0 66892685Sdarrenr#endif 66953642Sguido#ifndef ICMP_UNREACH 67092685Sdarrenr# define ICMP_UNREACH 3 67153642Sguido#endif 67292685Sdarrenr#ifndef ICMP_UNREACH_NET 67392685Sdarrenr# define ICMP_UNREACH_NET 0 67492685Sdarrenr#endif 67592685Sdarrenr#ifndef ICMP_UNREACH_HOST 67692685Sdarrenr# define ICMP_UNREACH_HOST 1 67792685Sdarrenr#endif 67892685Sdarrenr#ifndef ICMP_UNREACH_PROTOCOL 67992685Sdarrenr# define ICMP_UNREACH_PROTOCOL 2 68092685Sdarrenr#endif 68192685Sdarrenr#ifndef ICMP_UNREACH_PORT 68292685Sdarrenr# define ICMP_UNREACH_PORT 3 68392685Sdarrenr#endif 68492685Sdarrenr#ifndef ICMP_UNREACH_NEEDFRAG 68592685Sdarrenr# define ICMP_UNREACH_NEEDFRAG 4 68692685Sdarrenr#endif 68792685Sdarrenr#ifndef ICMP_UNREACH_SRCFAIL 68892685Sdarrenr# define ICMP_UNREACH_SRCFAIL 5 68992685Sdarrenr#endif 69092685Sdarrenr#ifndef ICMP_UNREACH_NET_UNKNOWN 69192685Sdarrenr# define ICMP_UNREACH_NET_UNKNOWN 6 69292685Sdarrenr#endif 69392685Sdarrenr#ifndef ICMP_UNREACH_HOST_UNKNOWN 69492685Sdarrenr# define ICMP_UNREACH_HOST_UNKNOWN 7 69592685Sdarrenr#endif 69692685Sdarrenr#ifndef ICMP_UNREACH_ISOLATED 69792685Sdarrenr# define ICMP_UNREACH_ISOLATED 8 69892685Sdarrenr#endif 69992685Sdarrenr#ifndef ICMP_UNREACH_NET_PROHIB 70092685Sdarrenr# define ICMP_UNREACH_NET_PROHIB 9 70192685Sdarrenr#endif 70292685Sdarrenr#ifndef ICMP_UNREACH_HOST_PROHIB 70392685Sdarrenr# define ICMP_UNREACH_HOST_PROHIB 10 70492685Sdarrenr#endif 70592685Sdarrenr#ifndef ICMP_UNREACH_TOSNET 70692685Sdarrenr# define ICMP_UNREACH_TOSNET 11 70792685Sdarrenr#endif 70892685Sdarrenr#ifndef ICMP_UNREACH_TOSHOST 70992685Sdarrenr# define ICMP_UNREACH_TOSHOST 12 71092685Sdarrenr#endif 71192685Sdarrenr#ifndef ICMP_UNREACH_ADMIN_PROHIBIT 71292685Sdarrenr# define ICMP_UNREACH_ADMIN_PROHIBIT 13 71392685Sdarrenr#endif 71492685Sdarrenr#ifndef ICMP_UNREACH_HOST_PRECEDENCE 71592685Sdarrenr# define ICMP_UNREACH_HOST_PRECEDENCE 14 71692685Sdarrenr#endif 71792685Sdarrenr#ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF 71892685Sdarrenr# define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 71992685Sdarrenr#endif 72053642Sguido#ifndef ICMP_SOURCEQUENCH 72192685Sdarrenr# define ICMP_SOURCEQUENCH 4 72253642Sguido#endif 72392685Sdarrenr#ifndef ICMP_REDIRECT_NET 72492685Sdarrenr# define ICMP_REDIRECT_NET 0 72592685Sdarrenr#endif 72692685Sdarrenr#ifndef ICMP_REDIRECT_HOST 72792685Sdarrenr# define ICMP_REDIRECT_HOST 1 72892685Sdarrenr#endif 72992685Sdarrenr#ifndef ICMP_REDIRECT_TOSNET 73092685Sdarrenr# define ICMP_REDIRECT_TOSNET 2 73192685Sdarrenr#endif 73292685Sdarrenr#ifndef ICMP_REDIRECT_TOSHOST 73392685Sdarrenr# define ICMP_REDIRECT_TOSHOST 3 73492685Sdarrenr#endif 73592685Sdarrenr#ifndef ICMP_ALTHOSTADDR 73692685Sdarrenr# define ICMP_ALTHOSTADDR 6 73792685Sdarrenr#endif 73853642Sguido#ifndef ICMP_TIMXCEED 73992685Sdarrenr# define ICMP_TIMXCEED 11 74053642Sguido#endif 74192685Sdarrenr#ifndef ICMP_TIMXCEED_INTRANS 74292685Sdarrenr# define ICMP_TIMXCEED_INTRANS 0 74392685Sdarrenr#endif 74492685Sdarrenr#ifndef ICMP_TIMXCEED_REASS 74592685Sdarrenr# define ICMP_TIMXCEED_REASS 1 74692685Sdarrenr#endif 74753642Sguido#ifndef ICMP_PARAMPROB 74892685Sdarrenr# define ICMP_PARAMPROB 12 74953642Sguido#endif 75092685Sdarrenr#ifndef ICMP_PARAMPROB_ERRATPTR 75192685Sdarrenr# define ICMP_PARAMPROB_ERRATPTR 0 75292685Sdarrenr#endif 75392685Sdarrenr#ifndef ICMP_PARAMPROB_OPTABSENT 75492685Sdarrenr# define ICMP_PARAMPROB_OPTABSENT 1 75592685Sdarrenr#endif 75692685Sdarrenr#ifndef ICMP_PARAMPROB_LENGTH 75792685Sdarrenr# define ICMP_PARAMPROB_LENGTH 2 75892685Sdarrenr#endif 75953642Sguido#ifndef ICMP_TSTAMP 76092685Sdarrenr# define ICMP_TSTAMP 13 76153642Sguido#endif 76253642Sguido#ifndef ICMP_TSTAMPREPLY 76392685Sdarrenr# define ICMP_TSTAMPREPLY 14 76453642Sguido#endif 76553642Sguido#ifndef ICMP_IREQ 76692685Sdarrenr# define ICMP_IREQ 15 76753642Sguido#endif 76853642Sguido#ifndef ICMP_IREQREPLY 76992685Sdarrenr# define ICMP_IREQREPLY 16 77053642Sguido#endif 77153642Sguido#ifndef ICMP_MASKREQ 77292685Sdarrenr# define ICMP_MASKREQ 17 77353642Sguido#endif 77453642Sguido#ifndef ICMP_MASKREPLY 77592685Sdarrenr# define ICMP_MASKREPLY 18 77653642Sguido#endif 77792685Sdarrenr#ifndef ICMP_TRACEROUTE 77892685Sdarrenr# define ICMP_TRACEROUTE 30 77980482Sdarrenr#endif 78092685Sdarrenr#ifndef ICMP_DATACONVERR 78192685Sdarrenr# define ICMP_DATACONVERR 31 78292685Sdarrenr#endif 78392685Sdarrenr#ifndef ICMP_MOBILE_REDIRECT 78492685Sdarrenr# define ICMP_MOBILE_REDIRECT 32 78592685Sdarrenr#endif 78692685Sdarrenr#ifndef ICMP_IPV6_WHEREAREYOU 78792685Sdarrenr# define ICMP_IPV6_WHEREAREYOU 33 78892685Sdarrenr#endif 78992685Sdarrenr#ifndef ICMP_IPV6_IAMHERE 79092685Sdarrenr# define ICMP_IPV6_IAMHERE 34 79192685Sdarrenr#endif 79292685Sdarrenr#ifndef ICMP_MOBILE_REGREQUEST 79392685Sdarrenr# define ICMP_MOBILE_REGREQUEST 35 79492685Sdarrenr#endif 79592685Sdarrenr#ifndef ICMP_MOBILE_REGREPLY 79692685Sdarrenr# define ICMP_MOBILE_REGREPLY 36 79792685Sdarrenr#endif 79892685Sdarrenr#ifndef ICMP_SKIP 79992685Sdarrenr# define ICMP_SKIP 39 80092685Sdarrenr#endif 80192685Sdarrenr#ifndef ICMP_PHOTURIS 80292685Sdarrenr# define ICMP_PHOTURIS 40 80392685Sdarrenr#endif 80492685Sdarrenr#ifndef ICMP_PHOTURIS_UNKNOWN_INDEX 80592685Sdarrenr# define ICMP_PHOTURIS_UNKNOWN_INDEX 1 80692685Sdarrenr#endif 80792685Sdarrenr#ifndef ICMP_PHOTURIS_AUTH_FAILED 80892685Sdarrenr# define ICMP_PHOTURIS_AUTH_FAILED 2 80992685Sdarrenr#endif 81092685Sdarrenr#ifndef ICMP_PHOTURIS_DECRYPT_FAILED 81192685Sdarrenr# define ICMP_PHOTURIS_DECRYPT_FAILED 3 81292685Sdarrenr#endif 81353642Sguido#ifndef IPVERSION 81453642Sguido# define IPVERSION 4 81553642Sguido#endif 81653642Sguido#ifndef IPOPT_MINOFF 81753642Sguido# define IPOPT_MINOFF 4 81853642Sguido#endif 81953642Sguido#ifndef IPOPT_COPIED 82053642Sguido# define IPOPT_COPIED(x) ((x)&0x80) 82153642Sguido#endif 82253642Sguido#ifndef IPOPT_EOL 82353642Sguido# define IPOPT_EOL 0 82453642Sguido#endif 82553642Sguido#ifndef IPOPT_NOP 82653642Sguido# define IPOPT_NOP 1 82753642Sguido#endif 82853642Sguido#ifndef IP_MF 82953642Sguido# define IP_MF ((u_short)0x2000) 83053642Sguido#endif 83153642Sguido#ifndef ETHERTYPE_IP 83253642Sguido# define ETHERTYPE_IP ((u_short)0x0800) 83353642Sguido#endif 83453642Sguido#ifndef TH_FIN 83553642Sguido# define TH_FIN 0x01 83653642Sguido#endif 83753642Sguido#ifndef TH_SYN 83853642Sguido# define TH_SYN 0x02 83953642Sguido#endif 84053642Sguido#ifndef TH_RST 84153642Sguido# define TH_RST 0x04 84253642Sguido#endif 84353642Sguido#ifndef TH_PUSH 84453642Sguido# define TH_PUSH 0x08 84553642Sguido#endif 84653642Sguido#ifndef TH_ACK 84753642Sguido# define TH_ACK 0x10 84853642Sguido#endif 84953642Sguido#ifndef TH_URG 85053642Sguido# define TH_URG 0x20 85153642Sguido#endif 85253642Sguido#ifndef IPOPT_EOL 85353642Sguido# define IPOPT_EOL 0 85453642Sguido#endif 85553642Sguido#ifndef IPOPT_NOP 85653642Sguido# define IPOPT_NOP 1 85753642Sguido#endif 85853642Sguido#ifndef IPOPT_RR 85953642Sguido# define IPOPT_RR 7 86053642Sguido#endif 86153642Sguido#ifndef IPOPT_TS 86253642Sguido# define IPOPT_TS 68 86353642Sguido#endif 86453642Sguido#ifndef IPOPT_SECURITY 86553642Sguido# define IPOPT_SECURITY 130 86653642Sguido#endif 86753642Sguido#ifndef IPOPT_LSRR 86853642Sguido# define IPOPT_LSRR 131 86953642Sguido#endif 87053642Sguido#ifndef IPOPT_SATID 87153642Sguido# define IPOPT_SATID 136 87253642Sguido#endif 87353642Sguido#ifndef IPOPT_SSRR 87453642Sguido# define IPOPT_SSRR 137 87553642Sguido#endif 87653642Sguido#ifndef IPOPT_SECUR_UNCLASS 87753642Sguido# define IPOPT_SECUR_UNCLASS ((u_short)0x0000) 87853642Sguido#endif 87953642Sguido#ifndef IPOPT_SECUR_CONFID 88053642Sguido# define IPOPT_SECUR_CONFID ((u_short)0xf135) 88153642Sguido#endif 88253642Sguido#ifndef IPOPT_SECUR_EFTO 88353642Sguido# define IPOPT_SECUR_EFTO ((u_short)0x789a) 88453642Sguido#endif 88553642Sguido#ifndef IPOPT_SECUR_MMMM 88653642Sguido# define IPOPT_SECUR_MMMM ((u_short)0xbc4d) 88753642Sguido#endif 88853642Sguido#ifndef IPOPT_SECUR_RESTR 88953642Sguido# define IPOPT_SECUR_RESTR ((u_short)0xaf13) 89053642Sguido#endif 89153642Sguido#ifndef IPOPT_SECUR_SECRET 89253642Sguido# define IPOPT_SECUR_SECRET ((u_short)0xd788) 89353642Sguido#endif 89453642Sguido#ifndef IPOPT_SECUR_TOPSECRET 89553642Sguido# define IPOPT_SECUR_TOPSECRET ((u_short)0x6bc5) 89653642Sguido#endif 89753642Sguido#ifndef IPOPT_OLEN 89853642Sguido# define IPOPT_OLEN 1 89953642Sguido#endif 90092685Sdarrenr#ifndef IPPROTO_GRE 90192685Sdarrenr# define IPPROTO_GRE 47 /* GRE encaps RFC 1701 */ 90292685Sdarrenr#endif 90392685Sdarrenr#ifndef IPPROTO_ESP 90492685Sdarrenr# define IPPROTO_ESP 50 90592685Sdarrenr#endif 90692685Sdarrenr#ifndef IPPROTO_ICMPV6 90792685Sdarrenr# define IPPROTO_ICMPV6 58 90892685Sdarrenr#endif 90953642Sguido 91053642Sguido#ifdef linux 91153642Sguido#include <linux/in_systm.h> 91253642Sguido/* 91353642Sguido * TCP States 91453642Sguido */ 91553642Sguido#define TCPS_CLOSED 0 /* closed */ 91653642Sguido#define TCPS_LISTEN 1 /* listening for connection */ 91753642Sguido#define TCPS_SYN_SENT 2 /* active, have sent syn */ 91853642Sguido#define TCPS_SYN_RECEIVED 3 /* have send and received syn */ 91953642Sguido/* states < TCPS_ESTABLISHED are those where connections not established */ 92053642Sguido#define TCPS_ESTABLISHED 4 /* established */ 92153642Sguido#define TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */ 92253642Sguido/* states > TCPS_CLOSE_WAIT are those where user has closed */ 92353642Sguido#define TCPS_FIN_WAIT_1 6 /* have closed, sent fin */ 92453642Sguido#define TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */ 92553642Sguido#define TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */ 92653642Sguido/* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */ 92753642Sguido#define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */ 92853642Sguido#define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */ 92953642Sguido 93053642Sguido/* 93153642Sguido * file flags. 93253642Sguido */ 93353642Sguido#ifdef WRITE 93453642Sguido#define FWRITE WRITE 93553642Sguido#define FREAD READ 93653642Sguido#else 93753642Sguido#define FWRITE _IOC_WRITE 93853642Sguido#define FREAD _IOC_READ 93953642Sguido#endif 94053642Sguido/* 94153642Sguido * mbuf related problems. 94253642Sguido */ 94353642Sguido#define mtod(m,t) (t)((m)->data) 94453642Sguido#define m_len len 94553642Sguido#define m_next next 94653642Sguido 94753642Sguido#ifdef IP_DF 94853642Sguido#undef IP_DF 94953642Sguido#endif 95053642Sguido#define IP_DF 0x4000 95153642Sguido 95253642Sguidotypedef struct { 95353642Sguido __u16 th_sport; 95453642Sguido __u16 th_dport; 95553642Sguido __u32 th_seq; 95653642Sguido __u32 th_ack; 95753642Sguido# if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\ 95853642Sguido defined(vax) 95953642Sguido __u8 th_res:4; 96053642Sguido __u8 th_off:4; 96153642Sguido#else 96253642Sguido __u8 th_off:4; 96353642Sguido __u8 th_res:4; 96453642Sguido#endif 96553642Sguido __u8 th_flags; 96653642Sguido __u16 th_win; 96753642Sguido __u16 th_sum; 96853642Sguido __u16 th_urp; 96953642Sguido} tcphdr_t; 97053642Sguido 97153642Sguidotypedef struct { 97253642Sguido __u16 uh_sport; 97353642Sguido __u16 uh_dport; 97453642Sguido __u16 uh_ulen; 97553642Sguido __u16 uh_sum; 97653642Sguido} udphdr_t; 97753642Sguido 97853642Sguidotypedef struct { 97953642Sguido# if defined(__i386__) || defined(__MIPSEL__) || defined(__alpha__) ||\ 98053642Sguido defined(vax) 98153642Sguido __u8 ip_hl:4; 98253642Sguido __u8 ip_v:4; 98353642Sguido# else 98455929Sguido __u8 ip_v:4; 98553642Sguido __u8 ip_hl:4; 98653642Sguido# endif 98753642Sguido __u8 ip_tos; 98853642Sguido __u16 ip_len; 98953642Sguido __u16 ip_id; 99053642Sguido __u16 ip_off; 99153642Sguido __u8 ip_ttl; 99253642Sguido __u8 ip_p; 99353642Sguido __u16 ip_sum; 99453642Sguido struct in_addr ip_src; 99553642Sguido struct in_addr ip_dst; 99653642Sguido} ip_t; 99753642Sguido 99853642Sguido/* 99953642Sguido * Structure of an icmp header. 100053642Sguido */ 100153642Sguidotypedef struct icmp { 100253642Sguido __u8 icmp_type; /* type of message, see below */ 100353642Sguido __u8 icmp_code; /* type sub code */ 100453642Sguido __u16 icmp_cksum; /* ones complement cksum of struct */ 100553642Sguido union { 100653642Sguido __u8 ih_pptr; /* ICMP_PARAMPROB */ 100753642Sguido struct in_addr ih_gwaddr; /* ICMP_REDIRECT */ 100853642Sguido struct ih_idseq { 100953642Sguido __u16 icd_id; 101053642Sguido __u16 icd_seq; 101153642Sguido } ih_idseq; 101253642Sguido int ih_void; 101353642Sguido } icmp_hun; 101453642Sguido# define icmp_pptr icmp_hun.ih_pptr 101553642Sguido# define icmp_gwaddr icmp_hun.ih_gwaddr 101653642Sguido# define icmp_id icmp_hun.ih_idseq.icd_id 101753642Sguido# define icmp_seq icmp_hun.ih_idseq.icd_seq 101853642Sguido# define icmp_void icmp_hun.ih_void 101953642Sguido union { 102053642Sguido struct id_ts { 102153642Sguido n_time its_otime; 102253642Sguido n_time its_rtime; 102353642Sguido n_time its_ttime; 102453642Sguido } id_ts; 102553642Sguido struct id_ip { 102653642Sguido ip_t idi_ip; 102753642Sguido /* options and then 64 bits of data */ 102853642Sguido } id_ip; 102953642Sguido u_long id_mask; 103053642Sguido char id_data[1]; 103153642Sguido } icmp_dun; 103253642Sguido# define icmp_otime icmp_dun.id_ts.its_otime 103353642Sguido# define icmp_rtime icmp_dun.id_ts.its_rtime 103453642Sguido# define icmp_ttime icmp_dun.id_ts.its_ttime 103553642Sguido# define icmp_ip icmp_dun.id_ip.idi_ip 103653642Sguido# define icmp_mask icmp_dun.id_mask 103753642Sguido# define icmp_data icmp_dun.id_data 103853642Sguido} icmphdr_t; 103953642Sguido 104053642Sguido# ifndef LINUX_IPOVLY 104153642Sguido# define LINUX_IPOVLY 104253642Sguidostruct ipovly { 104353642Sguido caddr_t ih_next, ih_prev; /* for protocol sequence q's */ 104453642Sguido u_char ih_x1; /* (unused) */ 104553642Sguido u_char ih_pr; /* protocol */ 104653642Sguido short ih_len; /* protocol length */ 104753642Sguido struct in_addr ih_src; /* source internet address */ 104853642Sguido struct in_addr ih_dst; /* destination internet address */ 104953642Sguido}; 105053642Sguido# endif 105153642Sguido 105253642Sguidotypedef struct { 105353642Sguido __u8 ether_dhost[6]; 105453642Sguido __u8 ether_shost[6]; 105553642Sguido __u16 ether_type; 105653642Sguido} ether_header_t; 105753642Sguido 105853642Sguidotypedef struct uio { 105953642Sguido int uio_resid; 106053642Sguido int uio_rw; 106153642Sguido caddr_t uio_buf; 106253642Sguido} uio_t; 106353642Sguido 106453642Sguido# define UIO_READ 0 106553642Sguido# define UIO_WRITE 1 106653642Sguido# define UIOMOVE(a, b, c, d) uiomove(a,b,c,d) 106753642Sguido 106853642Sguido/* 106953642Sguido * For masking struct ifnet onto struct device 107053642Sguido */ 107153642Sguido# define if_name name 107253642Sguido 107353642Sguido# ifdef KERNEL 107460857Sdarrenr# define GETUNIT(x, v) dev_get(x) 107553642Sguido# define FREE_MB_T(m) kfree_skb(m, FREE_WRITE) 107653642Sguido# define uniqtime do_gettimeofday 107753642Sguido# undef INT_MAX 107853642Sguido# undef UINT_MAX 107953642Sguido# undef LONG_MAX 108053642Sguido# undef ULONG_MAX 108153642Sguido# include <linux/netdevice.h> 108253642Sguido# define SPL_X(x) 108353642Sguido# define SPL_NET(x) 108453642Sguido# define SPL_IMP(x) 108553642Sguido 108653642Sguido# define bcmp(a,b,c) memcmp(a,b,c) 108753642Sguido# define bcopy(a,b,c) memcpy(b,a,c) 108853642Sguido# define bzero(a,c) memset(a,0,c) 108953642Sguido 109053642Sguido# define UNITNAME(n) dev_get((n)) 109153642Sguido 109253642Sguido# define KMALLOC(a,b) (a) = (b)kmalloc(sizeof(*(a)), GFP_ATOMIC) 109353642Sguido# define KMALLOCS(a,b,c) (a) = (b)kmalloc((c), GFP_ATOMIC) 109453642Sguido# define KFREE(x) kfree_s((x), sizeof(*(x))) 109553642Sguido# define KFREES(x,s) kfree_s((x), (s)) 109660857Sdarrenr#define IRCOPY(const void *a, void *b, size_t c) { \ 109760857Sdarrenr int error; \ 109860857Sdarrenr 109960857Sdarrenr error = verify_area(VERIFY_READ, a ,c); \ 110060857Sdarrenr if (!error) \ 110160857Sdarrenr memcpy_fromfs(b, a, c); \ 110260857Sdarrenr return error; \ 110360857Sdarrenr} 110460857Sdarrenrstatic inline int IWCOPY(const void *a, void *b, size_t c) 110560857Sdarrenr{ 110660857Sdarrenr int error; 110760857Sdarrenr 110860857Sdarrenr error = verify_area(VERIFY_WRITE, b, c); 110960857Sdarrenr if (!error) 111060857Sdarrenr memcpy_tofs(b, a, c); 111160857Sdarrenr return error; 111260857Sdarrenr} 111360857Sdarrenrstatic inline int IRCOPYPTR(const void *a, void *b, size_t c) { 111460857Sdarrenr caddr_t ca; 111560857Sdarrenr int error; 111660857Sdarrenr 111760857Sdarrenr error = verify_area(VERIFY_READ, a ,sizeof(ca)); 111860857Sdarrenr if (!error) { 111960857Sdarrenr memcpy_fromfs(ca, a, sizeof(ca)); 112060857Sdarrenr error = verify_area(VERIFY_READ, ca , c); 112160857Sdarrenr if (!error) 112260857Sdarrenr memcpy_fromfs(b, ca, c); 112360857Sdarrenr } 112460857Sdarrenr return error; 112560857Sdarrenr} 112660857Sdarrenrstatic inline int IWCOPYPTR(const void *a, void *b, size_t c) { 112760857Sdarrenr caddr_t ca; 112860857Sdarrenr int error; 112960857Sdarrenr 113060857Sdarrenr 113160857Sdarrenr error = verify_area(VERIFY_READ, b ,sizeof(ca)); 113260857Sdarrenr if (!error) { 113360857Sdarrenr memcpy_fromfs(ca, b, sizeof(ca)); 113460857Sdarrenr error = verify_area(VERIFY_WRITE, ca, c); 113560857Sdarrenr if (!error) 113660857Sdarrenr memcpy_tofs(ca, a, c); 113760857Sdarrenr } 113860857Sdarrenr return error; 113960857Sdarrenr} 114053642Sguido# else 114153642Sguido# define __KERNEL__ 114253642Sguido# undef INT_MAX 114353642Sguido# undef UINT_MAX 114453642Sguido# undef LONG_MAX 114553642Sguido# undef ULONG_MAX 114653642Sguido# define s8 __s8 114753642Sguido# define u8 __u8 114853642Sguido# define s16 __s16 114953642Sguido# define u16 __u16 115053642Sguido# define s32 __s32 115153642Sguido# define u32 __u32 115253642Sguido# include <linux/netdevice.h> 115353642Sguido# undef __KERNEL__ 115453642Sguido# endif 115553642Sguido# define ifnet device 115653642Sguido#else 115753642Sguidotypedef struct tcphdr tcphdr_t; 115853642Sguidotypedef struct udphdr udphdr_t; 115953642Sguidotypedef struct icmp icmphdr_t; 116053642Sguidotypedef struct ip ip_t; 116153642Sguidotypedef struct ether_header ether_header_t; 116253642Sguido#endif /* linux */ 116353642Sguidotypedef struct tcpiphdr tcpiphdr_t; 116453642Sguido 116553642Sguido#if defined(hpux) || defined(linux) 116653642Sguidostruct ether_addr { 116753642Sguido char ether_addr_octet[6]; 116853642Sguido}; 116953642Sguido#endif 117053642Sguido 117153642Sguido/* 117253642Sguido * XXX - This is one of those *awful* hacks which nobody likes 117353642Sguido */ 117453642Sguido#ifdef ultrix 117553642Sguido#define A_A 117653642Sguido#else 117753642Sguido#define A_A & 117853642Sguido#endif 117953642Sguido 118092685Sdarrenr#if (BSD >= 199306) && !defined(m_act) 118192685Sdarrenr# define m_act m_nextpkt 118292685Sdarrenr#endif 118392685Sdarrenr 118453642Sguido#ifndef ICMP_ROUTERADVERT 118553642Sguido# define ICMP_ROUTERADVERT 9 118653642Sguido#endif 118753642Sguido#ifndef ICMP_ROUTERSOLICIT 118853642Sguido# define ICMP_ROUTERSOLICIT 10 118953642Sguido#endif 119060857Sdarrenr#undef ICMP_MAX_UNREACH 119160857Sdarrenr#define ICMP_MAX_UNREACH 14 119260857Sdarrenr#undef ICMP_MAXTYPE 119360857Sdarrenr#define ICMP_MAXTYPE 18 119453642Sguido/* 119553642Sguido * ICMP error replies have an IP header (20 bytes), 8 bytes of ICMP data, 119653642Sguido * another IP header and then 64 bits of data, totalling 56. Of course, 119753642Sguido * the last 64 bits is dependant on that being available. 119853642Sguido */ 119953642Sguido#define ICMPERR_ICMPHLEN 8 120053642Sguido#define ICMPERR_IPICMPHLEN (20 + 8) 120153642Sguido#define ICMPERR_MINPKTLEN (20 + 8 + 20) 120253642Sguido#define ICMPERR_MAXPKTLEN (20 + 8 + 20 + 8) 120392685Sdarrenr#define ICMP6_MINLEN 8 120472006Sdarrenr#define ICMP6ERR_MINPKTLEN (40 + 8) 120572006Sdarrenr#define ICMP6ERR_IPICMPHLEN (40 + 8 + 40) 120653642Sguido 120792685Sdarrenr#ifndef ICMP6_DST_UNREACH 120892685Sdarrenr# define ICMP6_DST_UNREACH 1 120992685Sdarrenr#endif 121092685Sdarrenr#ifndef ICMP6_PACKET_TOO_BIG 121192685Sdarrenr# define ICMP6_PACKET_TOO_BIG 2 121292685Sdarrenr#endif 121392685Sdarrenr#ifndef ICMP6_TIME_EXCEEDED 121492685Sdarrenr# define ICMP6_TIME_EXCEEDED 3 121592685Sdarrenr#endif 121692685Sdarrenr#ifndef ICMP6_PARAM_PROB 121792685Sdarrenr# define ICMP6_PARAM_PROB 4 121892685Sdarrenr#endif 121992685Sdarrenr 122092685Sdarrenr#ifndef ICMP6_ECHO_REQUEST 122192685Sdarrenr# define ICMP6_ECHO_REQUEST 128 122292685Sdarrenr#endif 122392685Sdarrenr#ifndef ICMP6_ECHO_REPLY 122492685Sdarrenr# define ICMP6_ECHO_REPLY 129 122592685Sdarrenr#endif 122692685Sdarrenr#ifndef ICMP6_MEMBERSHIP_QUERY 122792685Sdarrenr# define ICMP6_MEMBERSHIP_QUERY 130 122892685Sdarrenr#endif 122992685Sdarrenr#ifndef MLD6_LISTENER_QUERY 123092685Sdarrenr# define MLD6_LISTENER_QUERY 130 123192685Sdarrenr#endif 123292685Sdarrenr#ifndef ICMP6_MEMBERSHIP_REPORT 123392685Sdarrenr# define ICMP6_MEMBERSHIP_REPORT 131 123492685Sdarrenr#endif 123592685Sdarrenr#ifndef MLD6_LISTENER_REPORT 123692685Sdarrenr# define MLD6_LISTENER_REPORT 131 123792685Sdarrenr#endif 123892685Sdarrenr#ifndef ICMP6_MEMBERSHIP_REDUCTION 123992685Sdarrenr# define ICMP6_MEMBERSHIP_REDUCTION 132 124092685Sdarrenr#endif 124192685Sdarrenr#ifndef MLD6_LISTENER_DONE 124292685Sdarrenr# define MLD6_LISTENER_DONE 132 124392685Sdarrenr#endif 124492685Sdarrenr#ifndef ND_ROUTER_SOLICIT 124592685Sdarrenr# define ND_ROUTER_SOLICIT 133 124692685Sdarrenr#endif 124792685Sdarrenr#ifndef ND_ROUTER_ADVERT 124892685Sdarrenr# define ND_ROUTER_ADVERT 134 124992685Sdarrenr#endif 125092685Sdarrenr#ifndef ND_NEIGHBOR_SOLICIT 125192685Sdarrenr# define ND_NEIGHBOR_SOLICIT 135 125292685Sdarrenr#endif 125392685Sdarrenr#ifndef ND_NEIGHBOR_ADVERT 125492685Sdarrenr# define ND_NEIGHBOR_ADVERT 136 125592685Sdarrenr#endif 125692685Sdarrenr#ifndef ND_REDIRECT 125792685Sdarrenr# define ND_REDIRECT 137 125892685Sdarrenr#endif 125992685Sdarrenr#ifndef ICMP6_ROUTER_RENUMBERING 126092685Sdarrenr# define ICMP6_ROUTER_RENUMBERING 138 126192685Sdarrenr#endif 126292685Sdarrenr#ifndef ICMP6_WRUREQUEST 126392685Sdarrenr# define ICMP6_WRUREQUEST 139 126492685Sdarrenr#endif 126592685Sdarrenr#ifndef ICMP6_WRUREPLY 126692685Sdarrenr# define ICMP6_WRUREPLY 140 126792685Sdarrenr#endif 126892685Sdarrenr#ifndef ICMP6_FQDN_QUERY 126992685Sdarrenr# define ICMP6_FQDN_QUERY 139 127092685Sdarrenr#endif 127192685Sdarrenr#ifndef ICMP6_FQDN_REPLY 127292685Sdarrenr# define ICMP6_FQDN_REPLY 140 127392685Sdarrenr#endif 127492685Sdarrenr#ifndef ICMP6_NI_QUERY 127592685Sdarrenr# define ICMP6_NI_QUERY 139 127692685Sdarrenr#endif 127792685Sdarrenr#ifndef ICMP6_NI_REPLY 127892685Sdarrenr# define ICMP6_NI_REPLY 140 127992685Sdarrenr#endif 128092685Sdarrenr#ifndef MLD6_MTRACE_RESP 128192685Sdarrenr# define MLD6_MTRACE_RESP 200 128292685Sdarrenr#endif 128392685Sdarrenr#ifndef MLD6_MTRACE 128492685Sdarrenr# define MLD6_MTRACE 201 128592685Sdarrenr#endif 128692685Sdarrenr#ifndef ICMP6_HADISCOV_REQUEST 128792685Sdarrenr# define ICMP6_HADISCOV_REQUEST 202 128892685Sdarrenr#endif 128992685Sdarrenr#ifndef ICMP6_HADISCOV_REPLY 129092685Sdarrenr# define ICMP6_HADISCOV_REPLY 203 129192685Sdarrenr#endif 129292685Sdarrenr#ifndef ICMP6_MOBILEPREFIX_SOLICIT 129392685Sdarrenr# define ICMP6_MOBILEPREFIX_SOLICIT 204 129492685Sdarrenr#endif 129592685Sdarrenr#ifndef ICMP6_MOBILEPREFIX_ADVERT 129692685Sdarrenr# define ICMP6_MOBILEPREFIX_ADVERT 205 129792685Sdarrenr#endif 129892685Sdarrenr#ifndef ICMP6_MAXTYPE 129992685Sdarrenr# define ICMP6_MAXTYPE 205 130092685Sdarrenr#endif 130192685Sdarrenr 130292685Sdarrenr#ifndef ICMP6_DST_UNREACH_NOROUTE 130392685Sdarrenr# define ICMP6_DST_UNREACH_NOROUTE 0 130492685Sdarrenr#endif 130592685Sdarrenr#ifndef ICMP6_DST_UNREACH_ADMIN 130692685Sdarrenr# define ICMP6_DST_UNREACH_ADMIN 1 130792685Sdarrenr#endif 130892685Sdarrenr#ifndef ICMP6_DST_UNREACH_NOTNEIGHBOR 130992685Sdarrenr# define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 131092685Sdarrenr#endif 131192685Sdarrenr#ifndef ICMP6_DST_UNREACH_BEYONDSCOPE 131292685Sdarrenr# define ICMP6_DST_UNREACH_BEYONDSCOPE 2 131392685Sdarrenr#endif 131492685Sdarrenr#ifndef ICMP6_DST_UNREACH_ADDR 131592685Sdarrenr# define ICMP6_DST_UNREACH_ADDR 3 131692685Sdarrenr#endif 131792685Sdarrenr#ifndef ICMP6_DST_UNREACH_NOPORT 131892685Sdarrenr# define ICMP6_DST_UNREACH_NOPORT 4 131992685Sdarrenr#endif 132092685Sdarrenr#ifndef ICMP6_TIME_EXCEED_TRANSIT 132192685Sdarrenr# define ICMP6_TIME_EXCEED_TRANSIT 0 132292685Sdarrenr#endif 132392685Sdarrenr#ifndef ICMP6_TIME_EXCEED_REASSEMBLY 132492685Sdarrenr# define ICMP6_TIME_EXCEED_REASSEMBLY 1 132592685Sdarrenr#endif 132692685Sdarrenr 132792685Sdarrenr#ifndef ICMP6_NI_SUCCESS 132892685Sdarrenr# define ICMP6_NI_SUCCESS 0 132992685Sdarrenr#endif 133092685Sdarrenr#ifndef ICMP6_NI_REFUSED 133192685Sdarrenr# define ICMP6_NI_REFUSED 1 133292685Sdarrenr#endif 133392685Sdarrenr#ifndef ICMP6_NI_UNKNOWN 133492685Sdarrenr# define ICMP6_NI_UNKNOWN 2 133592685Sdarrenr#endif 133692685Sdarrenr 133792685Sdarrenr#ifndef ICMP6_ROUTER_RENUMBERING_COMMAND 133892685Sdarrenr# define ICMP6_ROUTER_RENUMBERING_COMMAND 0 133992685Sdarrenr#endif 134092685Sdarrenr#ifndef ICMP6_ROUTER_RENUMBERING_RESULT 134192685Sdarrenr# define ICMP6_ROUTER_RENUMBERING_RESULT 1 134292685Sdarrenr#endif 134392685Sdarrenr#ifndef ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 134492685Sdarrenr# define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 134592685Sdarrenr#endif 134692685Sdarrenr 134792685Sdarrenr#ifndef ICMP6_PARAMPROB_HEADER 134892685Sdarrenr# define ICMP6_PARAMPROB_HEADER 0 134992685Sdarrenr#endif 135092685Sdarrenr#ifndef ICMP6_PARAMPROB_NEXTHEADER 135192685Sdarrenr# define ICMP6_PARAMPROB_NEXTHEADER 1 135292685Sdarrenr#endif 135392685Sdarrenr#ifndef ICMP6_PARAMPROB_OPTION 135492685Sdarrenr# define ICMP6_PARAMPROB_OPTION 2 135592685Sdarrenr#endif 135692685Sdarrenr 135792685Sdarrenr#ifndef ICMP6_NI_SUBJ_IPV6 135892685Sdarrenr# define ICMP6_NI_SUBJ_IPV6 0 135992685Sdarrenr#endif 136092685Sdarrenr#ifndef ICMP6_NI_SUBJ_FQDN 136192685Sdarrenr# define ICMP6_NI_SUBJ_FQDN 1 136292685Sdarrenr#endif 136392685Sdarrenr#ifndef ICMP6_NI_SUBJ_IPV4 136492685Sdarrenr# define ICMP6_NI_SUBJ_IPV4 2 136592685Sdarrenr#endif 136692685Sdarrenr 136772006Sdarrenr/* 136872006Sdarrenr * ECN is a new addition to TCP - RFC 2481 136972006Sdarrenr */ 137072006Sdarrenr#ifndef TH_ECN 137172006Sdarrenr# define TH_ECN 0x40 137272006Sdarrenr#endif 137372006Sdarrenr#ifndef TH_CWR 137472006Sdarrenr# define TH_CWR 0x80 137572006Sdarrenr#endif 137672006Sdarrenr#define TH_ECNALL (TH_ECN|TH_CWR) 137772006Sdarrenr 137872006Sdarrenr#define TCPF_ALL (TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG|TH_ECN|TH_CWR) 137972006Sdarrenr 138053642Sguido#endif /* __IP_COMPAT_H__ */ 1381