aboutsummaryrefslogtreecommitdiffstats
path: root/sys/contrib/ipfilter/netinet/ip_compat.h
diff options
context:
space:
mode:
authorDarren Reed <darrenr@FreeBSD.org>2007-06-04 02:50:28 +0000
committerDarren Reed <darrenr@FreeBSD.org>2007-06-04 02:50:28 +0000
commit103b406762fd9664783670aae8479f3a8ec71c61 (patch)
tree4a85b8476e1218a7ef6991f70ee02ffe60e6ec9b /sys/contrib/ipfilter/netinet/ip_compat.h
parent0be1832174307c242b42db3dac9d7e762f0c693b (diff)
downloadsrc-103b406762fd9664783670aae8479f3a8ec71c61.tar.gz
src-103b406762fd9664783670aae8479f3a8ec71c61.zip
Import IPFilter 4.1.23 to vendor branch.
See src/contrib/ipfilter/HISTORY for details of changes since 4.1.13
Notes
Notes: svn path=/vendor-sys/ipfilter/dist/; revision=170263
Diffstat (limited to 'sys/contrib/ipfilter/netinet/ip_compat.h')
-rw-r--r--sys/contrib/ipfilter/netinet/ip_compat.h122
1 files changed, 63 insertions, 59 deletions
diff --git a/sys/contrib/ipfilter/netinet/ip_compat.h b/sys/contrib/ipfilter/netinet/ip_compat.h
index 0a294cff58d8..5dc1d442ea26 100644
--- a/sys/contrib/ipfilter/netinet/ip_compat.h
+++ b/sys/contrib/ipfilter/netinet/ip_compat.h
@@ -4,7 +4,7 @@
* See the IPFILTER.LICENCE file for details on licencing.
*
* @(#)ip_compat.h 1.8 1/14/96
- * $Id: ip_compat.h,v 2.142.2.36 2006/03/26 05:50:29 darrenr Exp $
+ * $Id: ip_compat.h,v 2.142.2.48 2007/05/31 12:27:34 darrenr Exp $
*/
#ifndef __IP_COMPAT_H__
@@ -238,11 +238,12 @@ typedef unsigned int u_32_t;
# define MUTEX_EXIT(x) mutex_exit(&(x)->ipf_lk)
# define COPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c))
# define COPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c))
-# define BCOPYIN(a,b,c) (void) copyin((caddr_t)(a), (caddr_t)(b), (c))
-# define BCOPYOUT(a,b,c) (void) copyout((caddr_t)(a), (caddr_t)(b), (c))
+# define BCOPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c))
+# define BCOPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c))
# define UIOMOVE(a,b,c,d) uiomove((caddr_t)a,b,c,d)
# define KFREE(x) kmem_free((char *)(x), sizeof(*(x)))
# define KFREES(x,s) kmem_free((char *)(x), (s))
+# define SPL_SCHED(x) ;
# define SPL_NET(x) ;
# define SPL_IMP(x) ;
# undef SPL_X
@@ -415,13 +416,7 @@ typedef struct iplog_select_s {
# define RW_DESTROY(x)
# define COPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c))
# define COPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c))
-# if HPUXREV >= 1111
-# define BCOPYIN(a,b,c) 0; bcopy((caddr_t)(a), (caddr_t)(b), (c))
-# define BCOPYOUT(a,b,c) 0; bcopy((caddr_t)(a), (caddr_t)(b), (c))
-# else
-# define BCOPYIN(a,b,c) bcopy((caddr_t)(a), (caddr_t)(b), (c))
-# define BCOPYOUT(a,b,c) bcopy((caddr_t)(a), (caddr_t)(b), (c))
-# endif
+# define SPL_SCHED(x) ;
# define SPL_NET(x) ;
# define SPL_IMP(x) ;
# undef SPL_X
@@ -574,8 +569,6 @@ typedef struct {
# define MTOD(m,t) mtod(m,t)
# define COPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
# define COPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
-# define BCOPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
-# define BCOPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
# define UIOMOVE(a,b,c,d) uiomove((caddr_t)a,b,c,d)
# define SLEEP(id, n) sleep((id), PZERO+1)
# define WAKEUP(id,x) wakeup(id+x)
@@ -591,6 +584,7 @@ typedef struct {
# define USE_SPL 1
# define SPL_IMP(x) (x) = splimp()
# define SPL_NET(x) (x) = splnet()
+# define SPL_SCHED(x) (x) = splsched()
# define SPL_X(x) (void) splx(x)
extern void m_copydata __P((struct mbuf *, int, int, caddr_t));
extern void m_copyback __P((struct mbuf *, int, int, caddr_t));
@@ -651,6 +645,7 @@ typedef struct mbuf mb_t;
simple_unlock(&ipf_rw); }
# define ATOMIC_DEC(x) { simple_lock(&ipf_rw); (x)--; \
simple_unlock(&ipf_rw); }
+# define SPL_SCHED(x) ;
# define SPL_NET(x) ;
# define SPL_IMP(x) ;
# undef SPL_X
@@ -664,8 +659,6 @@ typedef struct mbuf mb_t;
# define POLLWAKEUP(x) ;
# define COPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c))
# define COPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c))
-# define BCOPYIN(a,b,c) bcopy((caddr_t)(a), (caddr_t)(b), (c))
-# define BCOPYOUT(a,b,c) bcopy((caddr_t)(a), (caddr_t)(b), (c))
# define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), M_PFILT, M_NOWAIT)
# define KMALLOCS(a, b, c) MALLOC((a), b, (c), M_PFILT, \
((c) > 4096) ? M_WAITOK : M_NOWAIT)
@@ -718,6 +711,14 @@ typedef unsigned int u_32_t;
/* N E T B S D */
/* ----------------------------------------------------------------------- */
#ifdef __NetBSD__
+# if (NetBSD >= 199905) && !defined(IPFILTER_LKM) && defined(_KERNEL)
+# include "opt_ipfilter.h"
+# endif
+# if defined(_KERNEL)
+# include <sys/systm.h>
+# else
+# include <stddef.h>
+# endif
# if defined(_KERNEL) && !defined(IPFILTER_LKM)
# include "bpfilter.h"
# if defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 104110000)
@@ -731,7 +732,14 @@ typedef unsigned int u_32_t;
# endif
# endif
+# if (__NetBSD_Version__ >= 499000000)
+typedef char * caddr_t;
+# endif
+
# ifdef _KERNEL
+# if (__NetBSD_Version__ >= 399001400)
+# define KMALLOCS(a, b, c) (a) = (b)malloc((c), _M_IPF, M_NOWAIT)
+# endif
# define MSGDSIZE(x) mbufchainlen(x)
# define M_LEN(x) (x)->m_len
# define M_DUPLICATE(x) m_copy((x), 0, M_COPYALL)
@@ -739,8 +747,6 @@ typedef unsigned int u_32_t;
# define IPF_PANIC(x,y) if (x) { printf y; panic("ipf_panic"); }
# define COPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c))
# define COPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c))
-# define BCOPYIN(a,b,c) bcopy((caddr_t)(a), (caddr_t)(b), (c))
-# define BCOPYOUT(a,b,c) bcopy((caddr_t)(a), (caddr_t)(b), (c))
typedef struct mbuf mb_t;
# endif /* _KERNEL */
# if (NetBSD <= 1991011) && (NetBSD >= 199606)
@@ -754,7 +760,6 @@ typedef struct mbuf mb_t;
# define CACHE_HASH(x) ((IFNAME(fin->fin_ifp)[0] + \
((struct ifnet *)fin->fin_ifp)->if_unit) & 7)
# endif
-
typedef struct uio uio_t;
typedef u_long ioctlcmd_t;
typedef int minor_t;
@@ -796,8 +801,6 @@ typedef u_int32_t u_32_t;
# endif
# define COPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c))
# define COPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c))
-# define BCOPYIN(a,b,c) bcopy((caddr_t)(a), (caddr_t)(b), (c))
-# define BCOPYOUT(a,b,c) bcopy((caddr_t)(a), (caddr_t)(b), (c))
# if (__FreeBSD_version >= 500043)
# define NETBSD_PF
@@ -813,7 +816,7 @@ typedef u_int32_t u_32_t;
* with a WITNESS kernel, it generates LOR messages.
*/
# define KMUTEX_T struct mtx
-# if 1
+# if (__FreeBSD_version < 700000)
# define KRWLOCK_T struct mtx
# else
# define KRWLOCK_T struct sx
@@ -857,7 +860,7 @@ typedef u_int32_t u_32_t;
* for what we want to use them for, despite testing showing they work -
* with a WITNESS kernel, it generates LOR messages.
*/
-# if 1
+# if (__FreeBSD_version < 700000)
# define READ_ENTER(x) mtx_lock(&(x)->ipf_lk)
# define WRITE_ENTER(x) mtx_lock(&(x)->ipf_lk)
# define RWLOCK_EXIT(x) mtx_unlock(&(x)->ipf_lk)
@@ -872,7 +875,7 @@ typedef u_int32_t u_32_t;
# define RWLOCK_INIT(x, y) sx_init(&(x)->ipf_lk, (y))
# define RW_DESTROY(x) sx_destroy(&(x)->ipf_lk)
# ifdef sx_unlock
-# define RWLOCK_EXIT(x) sx_unlock(x)
+# define RWLOCK_EXIT(x) sx_unlock(&(x)->ipf_lk)
# else
# define RWLOCK_EXIT(x) do { \
if ((x)->ipf_lk.sx_cnt < 0) \
@@ -889,15 +892,16 @@ typedef u_int32_t u_32_t;
mtx_unlock(&ipf_rw.ipf_lk); }
# define ATOMIC_INCL(x) atomic_add_long(&(x), 1)
# define ATOMIC_INC64(x) ATOMIC_INC(x)
-# define ATOMIC_INC32(x) atomic_add_32(&(x), 1)
+# define ATOMIC_INC32(x) atomic_add_32((u_int *)&(x), 1)
# define ATOMIC_INC16(x) atomic_add_16(&(x), 1)
# define ATOMIC_DECL(x) atomic_add_long(&(x), -1)
# define ATOMIC_DEC64(x) ATOMIC_DEC(x)
-# define ATOMIC_DEC32(x) atomic_add_32(&(x), -1)
+# define ATOMIC_DEC32(x) atomic_add_32((u_int *)&(x), -1)
# define ATOMIC_DEC16(x) atomic_add_16(&(x), -1)
# define SPL_X(x) ;
# define SPL_NET(x) ;
# define SPL_IMP(x) ;
+# define SPL_SCHED(x) ;
extern int in_cksum __P((struct mbuf *, int));
# endif /* __FreeBSD_version >= 500043 */
# define MSGDSIZE(x) mbufchainlen(x)
@@ -955,8 +959,6 @@ typedef u_int32_t u_32_t;
# endif
# define COPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c))
# define COPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c))
-# define BCOPYIN(a,b,c) bcopy((caddr_t)(a), (caddr_t)(b), (c))
-# define BCOPYOUT(a,b,c) bcopy((caddr_t)(a), (caddr_t)(b), (c))
# define GETKTIME(x) microtime((struct timeval *)x)
# define MSGDSIZE(x) mbufchainlen(x)
# define M_LEN(x) (x)->m_len
@@ -1058,7 +1060,7 @@ typedef unsigned int u_32_t;
#if defined(linux) && !defined(OS_RECOGNISED)
#include <linux/config.h>
#include <linux/version.h>
-# if LINUX >= 20600
+# if (LINUX >= 20600) && defined(_KERNEL)
# define HDR_T_PRIVATE 1
# endif
# undef USE_INET6
@@ -1071,15 +1073,17 @@ struct ip6_ext {
# ifdef _KERNEL
# define IPF_PANIC(x,y) if (x) { printf y; panic("ipf_panic"); }
-# define BCOPYIN(a,b,c) bcopy((caddr_t)(a), (caddr_t)(b), (c))
-# define BCOPYOUT(a,b,c) bcopy((caddr_t)(a), (caddr_t)(b), (c))
# define COPYIN(a,b,c) copy_from_user((caddr_t)(b), (caddr_t)(a), (c))
# define COPYOUT(a,b,c) copy_to_user((caddr_t)(b), (caddr_t)(a), (c))
# define FREE_MB_T(m) kfree_skb(m)
# define GETKTIME(x) do_gettimeofday((struct timeval *)x)
-# define SLEEP(x,s) 0, interruptible_sleep_on(x##_linux)
# define POLLWAKEUP(x) ;
-# define WAKEUP(x,y) wake_up(x##_linux + y)
+# ifdef wait_event_interruptible
+# define SLEEP(x,s) wait_event_interruptible((*(x##_linux)), 0)
+# else
+# define SLEEP(x,s) 0, interruptible_sleep_on(x##_linux)
+# endif
+# define WAKEUP(x,y) wake_up(x##_linux + y)
# define UIOMOVE(a,b,c,d) uiomove(a,b,c,d)
# define USE_MUTEXES
# define KRWLOCK_T rwlock_t
@@ -1091,7 +1095,7 @@ struct ip6_ext {
# define MUTEX_NUKE(x) bzero(&(x)->ipf_lk, sizeof((x)->ipf_lk))
# define READ_ENTER(x) ipf_read_enter(x)
# define WRITE_ENTER(x) ipf_write_enter(x)
-# define RWLOCK_INIT(x,y) rwlock_init(&(x)->ipf_lk)
+# define RWLOCK_INIT(x,y) ipf_rw_init(x, y)
# define RW_DESTROY(x) do { } while (0)
# define RWLOCK_EXIT(x) ipf_rw_exit(x)
# define MUTEX_DOWNGRADE(x) ipf_rw_downgrade(x)
@@ -1111,6 +1115,7 @@ struct ip6_ext {
MUTEX_EXIT(&ipf_rw)
# define ATOMIC_DEC16(x) MUTEX_ENTER(&ipf_rw); (x)--; \
MUTEX_EXIT(&ipf_rw)
+# define SPL_SCHED(x) do { } while (0)
# define SPL_IMP(x) do { } while (0)
# define SPL_NET(x) do { } while (0)
# define SPL_X(x) do { } while (0)
@@ -1260,6 +1265,7 @@ typedef u_int32_t u_32_t;
MUTEX_EXIT(&ipf_rw); }
# define ATOMIC_DEC(x) { MUTEX_ENTER(&ipf_rw); (x)--; \
MUTEX_EXIT(&ipf_rw); }
+# define SPL_SCHED(x) x = splsched()
# define SPL_NET(x) x = splnet()
# define SPL_IMP(x) x = splimp()
# undef SPL_X
@@ -1273,8 +1279,6 @@ extern void* getifp __P((char *, int));
# define POLLWAKEUP(x) ;
# define COPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c))
# define COPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c))
-# define BCOPYIN(a,b,c) bcopy((caddr_t)(a), (caddr_t)(b), (c))
-# define BCOPYOUT(a,b,c) bcopy((caddr_t)(a), (caddr_t)(b), (c))
# define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), M_TEMP, M_NOWAIT)
# define KMALLOCS(a, b, c) MALLOC((a), b, (c), M_TEMP, \
((c) > 4096) ? M_WAITOK : M_NOWAIT)
@@ -1351,7 +1355,7 @@ typedef struct {
u_int eMm_magic;
int eMm_held;
int eMm_heldat;
-#ifdef __hpux
+#if defined(__hpux) || defined(__linux)
char eMm_fill[8];
#endif
} eMmutex_t;
@@ -1410,6 +1414,7 @@ typedef union {
extern void ipf_read_enter __P((ipfrwlock_t *));
extern void ipf_write_enter __P((ipfrwlock_t *));
extern void ipf_rw_exit __P((ipfrwlock_t *));
+extern void ipf_rw_init __P((ipfrwlock_t *, char *));
extern void ipf_rw_downgrade __P((ipfrwlock_t *));
#endif
@@ -1438,6 +1443,7 @@ typedef struct mb_s {
# define POLLWAKEUP(y) ;
# define IPF_PANIC(x,y) ;
# define PANIC(x,y) ;
+# define SPL_SCHED(x) ;
# define SPL_NET(x) ;
# define SPL_IMP(x) ;
# define SPL_X(x) ;
@@ -1448,8 +1454,6 @@ typedef struct mb_s {
# define GETIFP(x, v) get_unit(x,v)
# define COPYIN(a,b,c) bcopywrap((a), (b), (c))
# define COPYOUT(a,b,c) bcopywrap((a), (b), (c))
-# define BCOPYIN(a,b,c) (bcopy((a), (b), (c)), 0)
-# define BCOPYOUT(a,b,c) (bcopy((a), (b), (c)), 0)
# define COPYDATA(m, o, l, b) bcopy(MTOD((mb_t *)m, char *) + (o), \
(b), (l))
# define COPYBACK(m, o, l, b) bcopy((b), \
@@ -1537,9 +1541,6 @@ typedef struct ip6_hdr ip6_t;
#endif
#if defined(_KERNEL)
-# ifdef BSD
-extern struct selinfo ipfselwait[];
-# endif
# ifdef MENTAT
# define COPYDATA mb_copydata
# define COPYBACK mb_copyback
@@ -1583,7 +1584,9 @@ MALLOC_DECLARE(M_IPFILTER);
# endif /* M_PFIL */
# endif /* IPFILTER_M_IPFILTER */
# define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), _M_IPF, M_NOWAIT)
-# define KMALLOCS(a, b, c) MALLOC((a), b, (c), _M_IPF, M_NOWAIT)
+# if !defined(KMALLOCS)
+# define KMALLOCS(a, b, c) MALLOC((a), b, (c), _M_IPF, M_NOWAIT)
+# endif
# define KFREE(x) FREE((x), _M_IPF)
# define KFREES(x,s) FREE((x), _M_IPF)
# define UIOMOVE(a,b,c,d) uiomove(a,b,d)
@@ -1601,6 +1604,7 @@ MALLOC_DECLARE(M_IPFILTER);
# define SPL_IMP(x) x = splimp()
# define SPL_NET(x) x = splnet()
# endif /* NetBSD && (NetBSD <= 1991011) && (NetBSD >= 199407) */
+# define SPL_SCHED(x) x = splsched()
# define SPL_X(x) (void) splx(x)
# endif /* !USE_MUTEXES */
@@ -1615,8 +1619,6 @@ MALLOC_DECLARE(M_IPFILTER);
# ifndef COPYIN
# define COPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
# define COPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
-# define BCOPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
-# define BCOPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
# endif
# ifndef KMALLOC
@@ -1645,6 +1647,11 @@ extern char *fr_getifname __P((struct ifnet *, char *));
# define ASSERT(x)
#endif
+#ifndef BCOPYIN
+# define BCOPYIN(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
+# define BCOPYOUT(a,b,c) (bcopy((caddr_t)(a), (caddr_t)(b), (c)), 0)
+#endif
+
/*
* Because the ctype(3) posix definition, if used "safely" in code everywhere,
* would mean all normal code that walks through strings needed casts. Yuck.
@@ -1721,9 +1728,6 @@ typedef struct tcpiphdr tcpiphdr_t;
# define FR_GROUPLEN 16
#endif
-#ifdef offsetof
-# undef offsetof
-#endif
#ifndef offsetof
# define offsetof(t,m) (int)((&((t *)0L)->m))
#endif
@@ -1743,7 +1747,7 @@ typedef struct tcpiphdr tcpiphdr_t;
# define IP_HL(x) (x)->ip_hl
#endif
#ifndef IP_HL_A
-# define IP_HL_A(x,y) (x)->ip_hl = (y)
+# define IP_HL_A(x,y) (x)->ip_hl = ((y) & 0xf)
#endif
#ifndef TCP_X2
# define TCP_X2(x) (x)->th_x2
@@ -2351,21 +2355,21 @@ typedef struct tcpiphdr tcpiphdr_t;
/*
* TCP States
*/
-#define IPF_TCPS_CLOSED 0 /* closed */
-#define IPF_TCPS_LISTEN 1 /* listening for connection */
-#define IPF_TCPS_SYN_SENT 2 /* active, have sent syn */
-#define IPF_TCPS_SYN_RECEIVED 3 /* have send and received syn */
-#define IPF_TCPS_HALF_ESTAB 4 /* for connections not fully "up" */
+#define IPF_TCPS_LISTEN 0 /* listening for connection */
+#define IPF_TCPS_SYN_SENT 1 /* active, have sent syn */
+#define IPF_TCPS_SYN_RECEIVED 2 /* have send and received syn */
+#define IPF_TCPS_HALF_ESTAB 3 /* for connections not fully "up" */
/* states < IPF_TCPS_ESTABLISHED are those where connections not established */
-#define IPF_TCPS_ESTABLISHED 5 /* established */
-#define IPF_TCPS_CLOSE_WAIT 6 /* rcvd fin, waiting for close */
+#define IPF_TCPS_ESTABLISHED 4 /* established */
+#define IPF_TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */
/* states > IPF_TCPS_CLOSE_WAIT are those where user has closed */
-#define IPF_TCPS_FIN_WAIT_1 7 /* have closed, sent fin */
-#define IPF_TCPS_CLOSING 8 /* closed xchd FIN; await FIN ACK */
-#define IPF_TCPS_LAST_ACK 9 /* had fin and close; await FIN ACK */
+#define IPF_TCPS_FIN_WAIT_1 6 /* have closed, sent fin */
+#define IPF_TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */
+#define IPF_TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */
/* states > IPF_TCPS_CLOSE_WAIT && < IPF_TCPS_FIN_WAIT_2 await ACK of FIN */
-#define IPF_TCPS_FIN_WAIT_2 10 /* have closed, fin is acked */
-#define IPF_TCPS_TIME_WAIT 11 /* in 2*msl quiet wait after close */
+#define IPF_TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */
+#define IPF_TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */
+#define IPF_TCPS_CLOSED 11 /* closed */
#define IPF_TCP_NSTATES 12
#define TCP_MSL 120