X-Git-Url: http://git.onelab.eu/?p=ipfw.git;a=blobdiff_plain;f=glue.h;h=622ca4bf3ee319a4f276cc327d3de35365851bb4;hp=76dd0f9970fdffef5470e5987d4058d255638448;hb=HEAD;hpb=40445faa1db58b90083115bc315d095e7eb2fe51 diff --git a/glue.h b/glue.h index 76dd0f9..622ca4b 100644 --- a/glue.h +++ b/glue.h @@ -23,7 +23,7 @@ * SUCH DAMAGE. */ /* - * $Id: glue.h 5822 2010-03-23 10:39:56Z svn_magno $ + * $Id: glue.h 11277 2012-06-10 17:44:15Z marta $ * * glue code to adapt the FreeBSD version to linux and windows, * userland and kernel. @@ -38,6 +38,7 @@ #ifndef _GLUE_H #define _GLUE_H + /* * common definitions to allow portability */ @@ -60,11 +61,14 @@ #include #include #include -#include +#ifdef __linux__ +#include /* linux only 20111031 */ +#endif #else /* KERNEL_MODULE, kernel headers */ #ifdef __linux__ + #include #define ifnet net_device /* remap */ @@ -81,7 +85,8 @@ #endif /* on 2.6.22, msg.h requires spinlock_types.h */ -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0) && \ +/* XXX spinlock_type.h was introduced in 2.6.14 */ +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13) && \ LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23) #include #endif @@ -237,6 +242,7 @@ enum ipfw_msg_type { /* on freebsd sys/socket.h pf specific */ #define NET_RT_IFLIST 3 /* survey interface list */ +#if defined(__linux__) || defined(__CYGWIN32__) /* on freebsd net/if.h XXX used */ struct if_data { /* ... */ @@ -298,6 +304,11 @@ struct clockinfo { int profhz; /* profiling clock frequency */ }; +/* no sin_len in sockaddr, we only remap in userland */ +#define sin_len sin_zero[0] + +#endif /* Linux/Win */ + /* * linux does not have a reentrant version of qsort, * so we the FreeBSD stdlib version. @@ -330,8 +341,6 @@ long long int strtonum(const char *nptr, long long minval, int sysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen); -/* no sin_len in sockaddr, we only remap in userland */ -#define sin_len sin_zero[0] #else /* KERNEL_MODULE */ @@ -352,13 +361,41 @@ struct route_in6 { #include #endif -/* skb_dst() was introduced from linux 2.6.31 */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31) // or 2.4.x -#define skb_dst(_dummy) skb->dst +/* skb_dst() and skb_dst_set() was introduced from linux 2.6.31 */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31) +void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst); +struct dst_entry *skb_dst(const struct sk_buff *skb); +#endif + +/* The struct flowi changed */ +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38) // check boundaries +#define flow_daddr fl.u.ip4 +#else +#define flow_daddr fl.nl_u.ip4_u #endif #endif /* __linux__ */ +/* + * Do not load prio_heap.h header because of conflicting names + * with our heap functions defined in include/netinet/ipfw/dn_heap.h + */ +#define _LINUX_PRIO_HEAP_H +/* + * The following define prevent the ipv6.h header to be loaded. + * Starting from the 2.6.38 kernel the ipv6.h file, which is included + * by include/net/inetpeer.h in turn included by net/route.h + * include the system tcp.h file while we want to include + * our include/net/tcp.h instead. + */ +#ifndef _NET_IPV6_H +#define _NET_IPV6_H +static inline void ipv6_addr_copy(struct in6_addr *a1, const struct in6_addr *a2) +{ + memcpy(a1, a2, sizeof(struct in6_addr)); +} +#endif /* _NET_IPV6_H */ + #endif /* KERNEL_MODULE */ /*