ip_compat.h (153084) | ip_compat.h (153876) |
---|---|
1/* 2 * Copyright (C) 1993-2001, 2003 by Darren Reed. 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 * 6 * @(#)ip_compat.h 1.8 1/14/96 | 1/* 2 * Copyright (C) 1993-2001, 2003 by Darren Reed. 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 * 6 * @(#)ip_compat.h 1.8 1/14/96 |
7 * $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_compat.h 153084 2005-12-04 10:06:06Z ru $ | 7 * $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_compat.h 153876 2005-12-30 11:32:23Z guido $ |
8 * Id: ip_compat.h,v 2.142.2.25 2005/03/28 09:33:36 darrenr Exp 9 */ 10 11#ifndef __IP_COMPAT_H__ 12#define __IP_COMPAT_H__ 13 14#ifndef __P 15# ifdef __STDC__ --- 1100 unchanged lines hidden (view full) --- 1116typedef struct sk_buff mb_t; 1117extern void m_copydata __P((mb_t *, int, int, caddr_t)); 1118extern void m_copyback __P((mb_t *, int, int, caddr_t)); 1119extern void m_adj __P((mb_t *, int)); 1120extern mb_t *m_pullup __P((mb_t *, int)); 1121# define mbuf sk_buff 1122 1123# define mtod(m, t) ((t)(m)->data) | 8 * Id: ip_compat.h,v 2.142.2.25 2005/03/28 09:33:36 darrenr Exp 9 */ 10 11#ifndef __IP_COMPAT_H__ 12#define __IP_COMPAT_H__ 13 14#ifndef __P 15# ifdef __STDC__ --- 1100 unchanged lines hidden (view full) --- 1116typedef struct sk_buff mb_t; 1117extern void m_copydata __P((mb_t *, int, int, caddr_t)); 1118extern void m_copyback __P((mb_t *, int, int, caddr_t)); 1119extern void m_adj __P((mb_t *, int)); 1120extern mb_t *m_pullup __P((mb_t *, int)); 1121# define mbuf sk_buff 1122 1123# define mtod(m, t) ((t)(m)->data) |
1124# define m_data data |
|
1124# define m_len len 1125# define m_next next 1126# define M_DUPLICATE(m) skb_clone((m), in_interrupt() ? GFP_ATOMIC : \ 1127 GFP_KERNEL) 1128# define MSGDSIZE(m) (m)->len 1129# define M_LEN(m) (m)->len 1130 1131# define splnet(x) ; --- 68 unchanged lines hidden (view full) --- 1200typedef u_int32_t u_32_t; 1201# define U_32_T 1 1202 1203# define OS_RECOGNISED 1 1204 1205#endif 1206 1207 | 1125# define m_len len 1126# define m_next next 1127# define M_DUPLICATE(m) skb_clone((m), in_interrupt() ? GFP_ATOMIC : \ 1128 GFP_KERNEL) 1129# define MSGDSIZE(m) (m)->len 1130# define M_LEN(m) (m)->len 1131 1132# define splnet(x) ; --- 68 unchanged lines hidden (view full) --- 1201typedef u_int32_t u_32_t; 1202# define U_32_T 1 1203 1204# define OS_RECOGNISED 1 1205 1206#endif 1207 1208 |
1209/* ----------------------------------------------------------------------- */ 1210/* A I X */ 1211/* ----------------------------------------------------------------------- */ 1212#if defined(_AIX51) 1213# undef MENTAT 1214 1215# include <sys/lock.h> 1216# include <sys/sysmacros.h> 1217 1218# ifdef _KERNEL 1219# define rw_read_locked(x) 0 1220# include <net/net_globals.h> 1221# include <net/net_malloc.h> 1222# define KMUTEX_T simple_lock_t 1223# define KRWLOCK_T complex_lock_t 1224# define USE_MUTEXES 1 1225# define USE_SPL 1 1226# define READ_ENTER(x) lock_read((x)->ipf_lk) 1227# define WRITE_ENTER(x) lock_write((x)->ipf_lk) 1228# define MUTEX_DOWNGRADE(x) lock_write_to_read((x)->ipf_lk) 1229# define RWLOCK_INIT(x, y) lock_alloc(&(x)->ipf_lk, \ 1230 LOCK_ALLOC_PIN, \ 1231 (u_short)y, 0); \ 1232 lock_init((x)->ipf_lk, TRUE) 1233# define RWLOCK_EXIT(x) lock_done((x)->ipf_lk) 1234# define RW_DESTROY(x) lock_free(&(x)->ipf_lk) 1235# define MUTEX_ENTER(x) simple_lock((x)->ipf_lk) 1236# define MUTEX_INIT(x, y) lock_alloc(&(x)->ipf_lk, \ 1237 LOCK_ALLOC_PIN, \ 1238 (u_short)y, 0); \ 1239 simple_lock_init((x)->ipf_lk) 1240# define MUTEX_DESTROY(x) lock_free(&(x)->ipf_lk) 1241# define MUTEX_EXIT(x) simple_unlock((x)->ipf_lk) 1242# define MUTEX_NUKE(x) bzero(&(x)->ipf_lk, sizeof((x)->ipf_lk)) 1243# define ATOMIC_INC64(x) { MUTEX_ENTER(&ipf_rw); (x)++; \ 1244 MUTEX_EXIT(&ipf_rw); } 1245# define ATOMIC_DEC64(x) { MUTEX_ENTER(&ipf_rw); (x)--; \ 1246 MUTEX_EXIT(&ipf_rw); } 1247# define ATOMIC_INC32(x) { MUTEX_ENTER(&ipf_rw); (x)++; \ 1248 MUTEX_EXIT(&ipf_rw); } 1249# define ATOMIC_DEC32(x) { MUTEX_ENTER(&ipf_rw); (x)--; \ 1250 MUTEX_EXIT(&ipf_rw); } 1251# define ATOMIC_INCL(x) { MUTEX_ENTER(&ipf_rw); (x)++; \ 1252 MUTEX_EXIT(&ipf_rw); } 1253# define ATOMIC_DECL(x) { MUTEX_ENTER(&ipf_rw); (x)--; \ 1254 MUTEX_EXIT(&ipf_rw); } 1255# define ATOMIC_INC(x) { MUTEX_ENTER(&ipf_rw); (x)++; \ 1256 MUTEX_EXIT(&ipf_rw); } 1257# define ATOMIC_DEC(x) { MUTEX_ENTER(&ipf_rw); (x)--; \ 1258 MUTEX_EXIT(&ipf_rw); } 1259# define SPL_NET(x) x = splnet() 1260# define SPL_IMP(x) x = splimp() 1261# undef SPL_X 1262# define SPL_X(x) splx(x) 1263# define UIOMOVE(a,b,c,d) uiomove((caddr_t)a,b,c,d) 1264extern void* getifp __P((char *, int)); 1265# define GETIFP(n, v) getifp(n, v) 1266# define GET_MINOR minor 1267# define SLEEP(id, n) sleepx((id), PZERO+1, 0) 1268# define WAKEUP(id,x) wakeup(id) 1269# define COPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c)) 1270# define COPYOUT(a,b,c) copyout((caddr_t)(a), (caddr_t)(b), (c)) 1271# define BCOPYIN(a,b,c) bcopy((caddr_t)(a), (caddr_t)(b), (c)) 1272# define BCOPYOUT(a,b,c) bcopy((caddr_t)(a), (caddr_t)(b), (c)) 1273# define KMALLOC(a, b) MALLOC((a), b, sizeof(*(a)), M_TEMP, M_NOWAIT) 1274# define KMALLOCS(a, b, c) MALLOC((a), b, (c), M_TEMP, \ 1275 ((c) > 4096) ? M_WAITOK : M_NOWAIT) 1276# define KFREE(x) FREE((x), M_TEMP) 1277# define KFREES(x,s) FREE((x), M_TEMP) 1278# define MSGDSIZE(x) mbufchainlen(x) 1279# define M_LEN(x) (x)->m_len 1280# define M_DUPLICATE(x) m_copy((x), 0, M_COPYALL) 1281# define GETKTIME(x) 1282# define CACHE_HASH(x) ((IFNAME(fin->fin_ifp)[0] + \ 1283 ((struct ifnet *)fin->fin_ifp)->if_unit) & 7) 1284# define IPF_PANIC(x,y) 1285typedef struct mbuf mb_t; 1286# endif /* _KERNEL */ 1287 1288/* 1289 * These are from's Solaris' #defines for little endian. 1290 */ 1291#if !defined(IP6F_MORE_FRAG) 1292# define IP6F_MORE_FRAG 0x0100 1293#endif 1294#if !defined(IP6F_RESERVED_MASK) 1295# define IP6F_RESERVED_MASK 0x0600 1296#endif 1297#if !defined(IP6F_OFF_MASK) 1298# define IP6F_OFF_MASK 0xf8ff 1299#endif 1300 1301struct ip6_ext { 1302 u_char ip6e_nxt; 1303 u_char ip6e_len; 1304}; 1305 1306typedef int ioctlcmd_t; 1307typedef int minor_t; 1308/* 1309 * Really, any arch where sizeof(long) != sizeof(int). 1310 */ 1311typedef unsigned int u_32_t; 1312# define U_32_T 1 1313 1314# define OS_RECOGNISED 1 1315#endif /* _AIX51 */ 1316 1317 |
|
1208#ifndef OS_RECOGNISED 1209#error ip_compat.h does not recognise this platform/OS. 1210#endif 1211 1212 1213/* ----------------------------------------------------------------------- */ 1214/* G E N E R I C */ 1215/* ----------------------------------------------------------------------- */ 1216#ifndef OS_RECOGNISED 1217#endif 1218 1219/* 1220 * For BSD kernels, if bpf is in the kernel, enable ipfilter to use bpf in 1221 * filter rules. 1222 */ | 1318#ifndef OS_RECOGNISED 1319#error ip_compat.h does not recognise this platform/OS. 1320#endif 1321 1322 1323/* ----------------------------------------------------------------------- */ 1324/* G E N E R I C */ 1325/* ----------------------------------------------------------------------- */ 1326#ifndef OS_RECOGNISED 1327#endif 1328 1329/* 1330 * For BSD kernels, if bpf is in the kernel, enable ipfilter to use bpf in 1331 * filter rules. 1332 */ |
1223#if !defined(IPFILTER_BPF) && \ 1224 ((defined(NBPF) && NBPF > 0) || \ 1225 (defined(NBPFILTER) && NBPFILTER > 0) || \ 1226 (defined(DEV_BPF) && DEV_BPF >0)) 1227# define IPFILTER_BPF | 1333#if !defined(IPFILTER_BPF) 1334# if (defined(NBPF) && (NBPF > 0)) || (defined(DEV_BPF) && (DEV_BPF > 0)) || \ 1335 (defined(NBPFILTER) && (NBPFILTER > 0)) 1336# define IPFILTER_BPF 1337# endif |
1228#endif 1229 1230/* 1231 * Userland locking primitives 1232 */ 1233typedef struct { 1234 char *eMm_owner; 1235 char *eMm_heldin; --- 51 unchanged lines hidden (view full) --- 1287# ifndef INLINE 1288# define INLINE 1289# endif 1290#else 1291# define INLINE __inline__ 1292#endif 1293 1294#if defined(linux) && defined(_KERNEL) | 1338#endif 1339 1340/* 1341 * Userland locking primitives 1342 */ 1343typedef struct { 1344 char *eMm_owner; 1345 char *eMm_heldin; --- 51 unchanged lines hidden (view full) --- 1397# ifndef INLINE 1398# define INLINE 1399# endif 1400#else 1401# define INLINE __inline__ 1402#endif 1403 1404#if defined(linux) && defined(_KERNEL) |
1295extern INLINE void ipf_read_enter __P((ipfrwlock_t *)); 1296extern INLINE void ipf_write_enter __P((ipfrwlock_t *)); 1297extern INLINE void ipf_rw_exit __P((ipfrwlock_t *)); 1298extern INLINE void ipf_rw_downgrade __P((ipfrwlock_t *)); | 1405extern void ipf_read_enter __P((ipfrwlock_t *)); 1406extern void ipf_write_enter __P((ipfrwlock_t *)); 1407extern void ipf_rw_exit __P((ipfrwlock_t *)); 1408extern void ipf_rw_downgrade __P((ipfrwlock_t *)); |
1299#endif 1300 1301/* 1302 * In a non-kernel environment, there are a lot of macros that need to be 1303 * filled in to be null-ops or to point to some compatibility function, 1304 * somewhere in userland. 1305 */ 1306#ifndef _KERNEL 1307typedef struct mb_s { 1308 struct mb_s *mb_next; 1309 int mb_len; 1310 u_long mb_buf[2048]; 1311} mb_t; 1312# undef m_next 1313# define m_next mb_next 1314# define MSGDSIZE(x) (x)->mb_len /* XXX - from ipt.c */ 1315# define M_LEN(x) (x)->mb_len 1316# define M_DUPLICATE(x) (x) 1317# define GETKTIME(x) gettimeofday((struct timeval *)(x), NULL) | 1409#endif 1410 1411/* 1412 * In a non-kernel environment, there are a lot of macros that need to be 1413 * filled in to be null-ops or to point to some compatibility function, 1414 * somewhere in userland. 1415 */ 1416#ifndef _KERNEL 1417typedef struct mb_s { 1418 struct mb_s *mb_next; 1419 int mb_len; 1420 u_long mb_buf[2048]; 1421} mb_t; 1422# undef m_next 1423# define m_next mb_next 1424# define MSGDSIZE(x) (x)->mb_len /* XXX - from ipt.c */ 1425# define M_LEN(x) (x)->mb_len 1426# define M_DUPLICATE(x) (x) 1427# define GETKTIME(x) gettimeofday((struct timeval *)(x), NULL) |
1428# undef MTOD |
|
1318# define MTOD(m, t) ((t)(m)->mb_buf) 1319# define FREE_MB_T(x) 1320# define SLEEP(x,y) 1; 1321# define WAKEUP(x,y) ; 1322# define IPF_PANIC(x,y) ; 1323# define PANIC(x,y) ; 1324# define SPL_NET(x) ; 1325# define SPL_IMP(x) ; 1326# define SPL_X(x) ; 1327# define KMALLOC(a,b) (a) = (b)malloc(sizeof(*a)) 1328# define KMALLOCS(a,b,c) (a) = (b)malloc(c) 1329# define KFREE(x) free(x) 1330# define KFREES(x,s) free(x) 1331# define GETIFP(x, v) get_unit(x,v) | 1429# define MTOD(m, t) ((t)(m)->mb_buf) 1430# define FREE_MB_T(x) 1431# define SLEEP(x,y) 1; 1432# define WAKEUP(x,y) ; 1433# define IPF_PANIC(x,y) ; 1434# define PANIC(x,y) ; 1435# define SPL_NET(x) ; 1436# define SPL_IMP(x) ; 1437# define SPL_X(x) ; 1438# define KMALLOC(a,b) (a) = (b)malloc(sizeof(*a)) 1439# define KMALLOCS(a,b,c) (a) = (b)malloc(c) 1440# define KFREE(x) free(x) 1441# define KFREES(x,s) free(x) 1442# define GETIFP(x, v) get_unit(x,v) |
1332# define COPYIN(a,b,c) (bcopy((a), (b), (c)), 0) 1333# define COPYOUT(a,b,c) (bcopy((a), (b), (c)), 0) | 1443# define COPYIN(a,b,c) bcopywrap((a), (b), (c)) 1444# define COPYOUT(a,b,c) bcopywrap((a), (b), (c)) |
1334# define BCOPYIN(a,b,c) (bcopy((a), (b), (c)), 0) 1335# define BCOPYOUT(a,b,c) (bcopy((a), (b), (c)), 0) 1336# define COPYDATA(m, o, l, b) bcopy(MTOD((mb_t *)m, char *) + (o), \ 1337 (b), (l)) 1338# define COPYBACK(m, o, l, b) bcopy((b), \ 1339 MTOD((mb_t *)m, char *) + (o), \ 1340 (l)) 1341# define UIOMOVE(a,b,c,d) ipfuiomove(a,b,c,d) --- 218 unchanged lines hidden (view full) --- 1560# define MUTEX_DESTROY(x) ; 1561# define MUTEX_NUKE(x) ; 1562#endif /* !USE_MUTEXES */ 1563#ifndef ATOMIC_INC 1564# define ATOMIC_INC(x) (x)++ 1565# define ATOMIC_DEC(x) (x)-- 1566#endif 1567 | 1445# define BCOPYIN(a,b,c) (bcopy((a), (b), (c)), 0) 1446# define BCOPYOUT(a,b,c) (bcopy((a), (b), (c)), 0) 1447# define COPYDATA(m, o, l, b) bcopy(MTOD((mb_t *)m, char *) + (o), \ 1448 (b), (l)) 1449# define COPYBACK(m, o, l, b) bcopy((b), \ 1450 MTOD((mb_t *)m, char *) + (o), \ 1451 (l)) 1452# define UIOMOVE(a,b,c,d) ipfuiomove(a,b,c,d) --- 218 unchanged lines hidden (view full) --- 1671# define MUTEX_DESTROY(x) ; 1672# define MUTEX_NUKE(x) ; 1673#endif /* !USE_MUTEXES */ 1674#ifndef ATOMIC_INC 1675# define ATOMIC_INC(x) (x)++ 1676# define ATOMIC_DEC(x) (x)-- 1677#endif 1678 |
1679#if defined(USE_SPL) && defined(_KERNEL) 1680# define SPL_INT(x) int x 1681#else 1682# define SPL_INT(x) 1683#endif 1684 |
|
1568/* 1569 * If there are no atomic operations for bit sizes defined, define them to all 1570 * use a generic one that works for all sizes. 1571 */ 1572#ifndef ATOMIC_INCL 1573# define ATOMIC_INCL ATOMIC_INC 1574# define ATOMIC_INC64 ATOMIC_INC 1575# define ATOMIC_INC32 ATOMIC_INC --- 458 unchanged lines hidden (view full) --- 2034# define IPPROTO_ICMPV6 58 2035#endif 2036#ifndef IPPROTO_NONE 2037# define IPPROTO_NONE 59 2038#endif 2039#ifndef IPPROTO_DSTOPTS 2040# define IPPROTO_DSTOPTS 60 2041#endif | 1685/* 1686 * If there are no atomic operations for bit sizes defined, define them to all 1687 * use a generic one that works for all sizes. 1688 */ 1689#ifndef ATOMIC_INCL 1690# define ATOMIC_INCL ATOMIC_INC 1691# define ATOMIC_INC64 ATOMIC_INC 1692# define ATOMIC_INC32 ATOMIC_INC --- 458 unchanged lines hidden (view full) --- 2151# define IPPROTO_ICMPV6 58 2152#endif 2153#ifndef IPPROTO_NONE 2154# define IPPROTO_NONE 59 2155#endif 2156#ifndef IPPROTO_DSTOPTS 2157# define IPPROTO_DSTOPTS 60 2158#endif |
2042#ifndef IPPROTO_FRAGMENT 2043# define IPPROTO_FRAGMENT 44 | 2159#ifndef IPPROTO_MOBILITY 2160# define IPPROTO_MOBILITY 135 |
2044#endif | 2161#endif |
2162 |
|
2045#ifndef ICMP_ROUTERADVERT 2046# define ICMP_ROUTERADVERT 9 2047#endif 2048#ifndef ICMP_ROUTERSOLICIT 2049# define ICMP_ROUTERSOLICIT 10 2050#endif 2051#ifndef ICMP6_DST_UNREACH 2052# define ICMP6_DST_UNREACH 1 --- 217 unchanged lines hidden (view full) --- 2270#endif 2271#ifndef LOG_CONSOLE 2272# define LOG_CONSOLE (14<<3) 2273#endif 2274 2275/* 2276 * ICMP error replies have an IP header (20 bytes), 8 bytes of ICMP data, 2277 * another IP header and then 64 bits of data, totalling 56. Of course, | 2163#ifndef ICMP_ROUTERADVERT 2164# define ICMP_ROUTERADVERT 9 2165#endif 2166#ifndef ICMP_ROUTERSOLICIT 2167# define ICMP_ROUTERSOLICIT 10 2168#endif 2169#ifndef ICMP6_DST_UNREACH 2170# define ICMP6_DST_UNREACH 1 --- 217 unchanged lines hidden (view full) --- 2388#endif 2389#ifndef LOG_CONSOLE 2390# define LOG_CONSOLE (14<<3) 2391#endif 2392 2393/* 2394 * ICMP error replies have an IP header (20 bytes), 8 bytes of ICMP data, 2395 * another IP header and then 64 bits of data, totalling 56. Of course, |
2278 * the last 64 bits is dependant on that being available. | 2396 * the last 64 bits is dependent on that being available. |
2279 */ 2280#define ICMPERR_ICMPHLEN 8 2281#define ICMPERR_IPICMPHLEN (20 + 8) 2282#define ICMPERR_MINPKTLEN (20 + 8 + 20) 2283#define ICMPERR_MAXPKTLEN (20 + 8 + 20 + 8) 2284#define ICMP6ERR_MINPKTLEN (40 + 8) 2285#define ICMP6ERR_IPICMPHLEN (40 + 8 + 40) 2286 --- 15 unchanged lines hidden --- | 2397 */ 2398#define ICMPERR_ICMPHLEN 8 2399#define ICMPERR_IPICMPHLEN (20 + 8) 2400#define ICMPERR_MINPKTLEN (20 + 8 + 20) 2401#define ICMPERR_MAXPKTLEN (20 + 8 + 20 + 8) 2402#define ICMP6ERR_MINPKTLEN (40 + 8) 2403#define ICMP6ERR_IPICMPHLEN (40 + 8 + 40) 2404 --- 15 unchanged lines hidden --- |