summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ip6t_MAP66.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/ip6t_MAP66.c b/ip6t_MAP66.c
index 2f880e5..c9453c2 100644
--- a/ip6t_MAP66.c
+++ b/ip6t_MAP66.c
@@ -7,9 +7,15 @@
#include <linux/module.h>
#include <linux/version.h>
#include <linux/netfilter_ipv6/ip6_tables.h>
-#include <linux/dccp.h>
#include <net/ipv6.h>
+#include <linux/tcp.h>
+#include <linux/udp.h>
+#include <linux/icmpv6.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
+# include <linux/dccp.h>
+#endif
+
#include "ip6t_MAP66.h"
MODULE_AUTHOR("Sven-Ola <sven-ola()gmx.de>");
@@ -170,28 +176,36 @@ static unsigned int MAP66_tg6(
if (0 != (IP6T_MAP66_OPT_CSUM & info->mapflags)) {
u8 nexthdr = hdr->nexthdr;
- int hoff = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &nexthdr);
- if (hoff < 0) {
- pr_devel("MAP66: Unsupported packet dropped\n");
- return NF_DROP;
+ unsigned char* transport = (unsigned char* )hdr + sizeof(struct ipv6hdr);
+ if (ipv6_ext_hdr(nexthdr)) {
+ int hoff = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &nexthdr
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ , skb->len - sizeof(struct ipv6hdr)
+#endif
+ );
+ if (hoff < 0) {
+ pr_devel("MAP66: Unsupported packet dropped\n");
+ return NF_DROP;
+ }
+ transport += hoff;
}
switch(nexthdr) {
case IPPROTO_TCP:
- csum_transport = skb_header_pointer(
- skb, hoff+offsetof(struct tcphdr, check), 0, NULL);
+ csum_transport = &((struct tcphdr*)transport)->check;
break;
case IPPROTO_UDP:
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
case IPPROTO_UDPLITE:
- csum_transport = skb_header_pointer(
- skb, hoff+offsetof(struct udphdr, check), 0, NULL);
+#endif
+ csum_transport = &((struct udphdr*)transport)->check;
break;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
case IPPROTO_DCCP:
- csum_transport = skb_header_pointer(
- skb, hoff+offsetof(struct dccp_hdr, dccph_checksum), 0, NULL);
+ csum_transport = &((struct dccp_hdr*)transport)->dccph_checksum;
break;
+#endif
case IPPROTO_ICMPV6:
- csum_transport = skb_header_pointer(
- skb, hoff+offsetof(struct icmp6hdr, icmp6_cksum), 0, NULL);
+ csum_transport = &((struct icmp6hdr*)transport)->icmp6_cksum;
break;
default:
pr_devel("MAP66: Unsupported protocol %d\n", nexthdr);