From a09a05fdf2e977951e0621cbf05b23b70b698f99 Mon Sep 17 00:00:00 2001 From: sven-ola Date: Fri, 15 Oct 2010 11:17:36 +0000 Subject: git-svn-id: https://map66.svn.sourceforge.net/svnroot/map66@43 3484d885-4da6-438d-b19d-107d078dd756 --- ip6t_MAP66.c | 40 +++++++++++++++++++++++++++------------- 1 file 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 #include #include -#include #include +#include +#include +#include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14) +# include +#endif + #include "ip6t_MAP66.h" MODULE_AUTHOR("Sven-Ola "); @@ -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); -- cgit v1.2.3