diff options
author | sven-ola <sven-ola@3484d885-4da6-438d-b19d-107d078dd756> | 2010-10-15 13:17:36 +0200 |
---|---|---|
committer | sven-ola <sven-ola@3484d885-4da6-438d-b19d-107d078dd756> | 2010-10-15 13:17:36 +0200 |
commit | a09a05fdf2e977951e0621cbf05b23b70b698f99 (patch) | |
tree | 3573743b65c1524fb737c1f43e0025dc52b1e4a7 | |
parent | c7d08bea342b95105f6bd787aa8df7663aa4cebc (diff) | |
download | NPTv6-a09a05fdf2e977951e0621cbf05b23b70b698f99.tar NPTv6-a09a05fdf2e977951e0621cbf05b23b70b698f99.zip |
git-svn-id: https://map66.svn.sourceforge.net/svnroot/map66@43 3484d885-4da6-438d-b19d-107d078dd756
-rw-r--r-- | ip6t_MAP66.c | 40 |
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); |