summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ip6t_MAP66.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/ip6t_MAP66.c b/ip6t_MAP66.c
index c9453c2..18765b5 100644
--- a/ip6t_MAP66.c
+++ b/ip6t_MAP66.c
@@ -16,6 +16,9 @@
# include <linux/dccp.h>
#endif
+// SOT
+#include <net/checksum.h>
+
#include "ip6t_MAP66.h"
MODULE_AUTHOR("Sven-Ola <sven-ola()gmx.de>");
@@ -63,6 +66,16 @@ static void map_csum(
u_int16_t csum_to,
u_int16_t* csum_transport)
{
+ printk("SOT len=%d, csum = %04hx\n", len_to,
+ ~add16(
+ add16(
+ ~(*csum_transport),
+ ~csum16((u_int16_t *)&addr, len_to)
+ ),
+ csum16((u_int16_t *)&to, len_to)
+ )
+ );
+
*csum_transport = ~add16(
~csum_to,
add16(~*csum_transport, ~csum16((u_int16_t *)&addr, len_to))
@@ -177,6 +190,7 @@ static unsigned int MAP66_tg6(
if (0 != (IP6T_MAP66_OPT_CSUM & info->mapflags)) {
u8 nexthdr = hdr->nexthdr;
unsigned char* transport = (unsigned char* )hdr + sizeof(struct ipv6hdr);
+ pr_devel("SOT: hdr=%p, nexthdr=%d, transport=%p\n", hdr, nexthdr, transport);
if (ipv6_ext_hdr(nexthdr)) {
int hoff = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &nexthdr
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
@@ -188,6 +202,7 @@ static unsigned int MAP66_tg6(
return NF_DROP;
}
transport += hoff;
+ pr_devel("SOT: nexthdr=%d, transport%p\n", nexthdr, transport);
}
switch(nexthdr) {
case IPPROTO_TCP:
@@ -206,6 +221,19 @@ static unsigned int MAP66_tg6(
#endif
case IPPROTO_ICMPV6:
csum_transport = &((struct icmp6hdr*)transport)->icmp6_cksum;
+ pr_devel("SOT icmpv6:, transport=%p, cksum=%p(%04hx)\n", transport, csum_transport, *csum_transport);
+ {
+ u_int16_t csum = 0;
+ u_int16_t old_csum = *csum_transport;
+ *csum_transport = 0;
+ csum = add16(csum, csum16((u_int16_t*)&hdr->saddr, sizeof(hdr->saddr) / 2));
+ csum = add16(csum, csum16((u_int16_t*)&hdr->daddr, sizeof(hdr->daddr) / 2));
+ csum = add16(csum, hdr->payload_len);
+ csum = add16(csum, ntohs(hdr->nexthdr));
+ csum = add16(csum, csum16((u_int16_t*)transport, ntohs(hdr->payload_len) / 2));
+ pr_devel("SOT: csum should=%04hx\n", ~csum);
+ *csum_transport = old_csum;
+ }
break;
default:
pr_devel("MAP66: Unsupported protocol %d\n", nexthdr);
@@ -220,6 +248,7 @@ static unsigned int MAP66_tg6(
{
if (0 != (IP6T_MAP66_OPT_CSUM & info->mapflags)) {
map_csum(&hdr->daddr, &info->pfix_dst_to, info->pfix_dst_len, info->pfix_dst_csum, csum_transport);
+ pr_devel("SOT dst: cksum=%p(%04hx)\n", csum_transport, *csum_transport);
}
else {
map16(&hdr->daddr, &info->pfix_dst_to, info->pfix_dst_len, info->pfix_dst_csum);
@@ -231,6 +260,19 @@ static unsigned int MAP66_tg6(
pr_devel("MAP66: SRC_TO, ip_summed=%d\n", skb->ip_summed);
if (0 != (IP6T_MAP66_OPT_CSUM & info->mapflags)) {
map_csum(&hdr->saddr, &info->pfix_src_to, info->pfix_src_len, info->pfix_src_csum, csum_transport);
+ pr_devel("SOT src: cksum=%p(%04hx)\n", csum_transport, *csum_transport);
+ {
+ u_int16_t csum = 0;
+ u_int16_t old_csum = *csum_transport;
+ *csum_transport = 0;
+ csum = add16(csum, csum16((u_int16_t*)&hdr->saddr, sizeof(hdr->saddr) / 2));
+ csum = add16(csum, csum16((u_int16_t*)&hdr->daddr, sizeof(hdr->daddr) / 2));
+ csum = add16(csum, hdr->payload_len);
+ csum = add16(csum, ntohs(hdr->nexthdr));
+ csum = add16(csum, csum16(((u_int16_t*)hdr) + 20, ntohs(hdr->payload_len) / 2));
+ pr_devel("SOT: csum should=%04hx\n", ~csum);
+ *csum_transport = old_csum;
+ }
}
else {
map16(&hdr->saddr, &info->pfix_src_to, info->pfix_src_len, info->pfix_src_csum);