]> The Tcpdump Group git mirrors - tcpdump/commitdiff
fix partial checksum errors in DCCP decoder, IPv4 case 363/head
authorFrancois-Xavier Le Bail <[email protected]>
Sat, 15 Feb 2014 11:32:44 +0000 (12:32 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Sat, 15 Feb 2014 11:36:02 +0000 (12:36 +0100)
ip.h
netdissect.h
print-dccp.c
print-ip.c
print-tcp.c
print-udp.c
tests/TESTLIST
tests/dccp_partial_csum_v4_longer.out [new file with mode: 0644]
tests/dccp_partial_csum_v4_longer.pcap [new file with mode: 0644]
tests/dccp_partial_csum_v4_simple.out [new file with mode: 0644]
tests/dccp_partial_csum_v4_simple.pcap [new file with mode: 0644]

diff --git a/ip.h b/ip.h
index fd8ee92b59743c9f640ec13f0aba32b26d4decca..2fcb40eaffa9c04a15471b9d0d47e77be019fd0b 100644 (file)
--- a/ip.h
+++ b/ip.h
@@ -160,4 +160,4 @@ struct      ip_timestamp {
 #define        IP_MSS          576             /* default maximum segment size */
 
 /* in print-ip.c */
-extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int);
+extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int, u_int);
index bdf2ebdb82f6e647754423af4461c3c3316ed116..37bc59e0dd77004f03258219ed98de60adbd93f5 100644 (file)
@@ -416,7 +416,6 @@ extern void igmp_print(netdissect_options *,
                       register const u_char *, u_int);
 extern void igrp_print(netdissect_options *,const u_char *, u_int,
                       const u_char *);
-extern int nextproto4_cksum(const struct ip *, const u_int8_t *, u_int, u_int);
 extern void ipN_print(netdissect_options *,const u_char *, u_int);
 extern void ipx_print(netdissect_options *,const u_char *, u_int);
 extern void isoclns_print(netdissect_options *,const u_char *,
index 1c354a6a89a969bbff7226342fb7a11f83cb25a7..0d020d656aca75144fe29f676e43c6ec9f529f84 100644 (file)
@@ -184,8 +184,8 @@ static inline u_int dccp_csum_coverage(const struct dccp_hdr* dh, u_int len)
 static int dccp_cksum(const struct ip *ip,
        const struct dccp_hdr *dh, u_int len)
 {
-       return nextproto4_cksum(ip, (const u_int8_t *)(void *)dh,
-           dccp_csum_coverage(dh, len), IPPROTO_DCCP);
+       return nextproto4_cksum(ip, (const u_int8_t *)(void *)dh, len,
+                               dccp_csum_coverage(dh, len), IPPROTO_DCCP);
 }
 
 #ifdef INET6
index 22bd80054775e055fce7555b4f0d5f27c0c4cfc7..3c7f107f31b76b98fcd478b967a9ba83d204382e 100644 (file)
@@ -131,7 +131,7 @@ trunc:
  */
 int
 nextproto4_cksum(const struct ip *ip, const u_int8_t *data,
-                u_int len, u_int next_proto)
+                u_int len, u_int covlen, u_int next_proto)
 {
        struct phdr {
                u_int32_t src;
@@ -155,7 +155,7 @@ nextproto4_cksum(const struct ip *ip, const u_int8_t *data,
        vec[0].ptr = (const u_int8_t *)(void *)&ph;
        vec[0].len = sizeof(ph);
        vec[1].ptr = data;
-       vec[1].len = len;
+       vec[1].len = covlen;
        return (in_cksum(vec, 2));
 }
 
index bb76ac7c506177b57a8ea59a30c60d9f2b3d3000..eee98fe925ac6c71a7aad7ff280a6e21e3e165f8 100644 (file)
@@ -142,8 +142,8 @@ static int tcp_cksum(register const struct ip *ip,
                     register const struct tcphdr *tp,
                     register u_int len)
 {
-       return (nextproto4_cksum(ip, (const u_int8_t *)tp, len,
-           IPPROTO_TCP));
+       return nextproto4_cksum(ip, (const u_int8_t *)tp, len, len,
+                               IPPROTO_TCP);
 }
 
 void
index babdf7c2593f26b5b1a44cf4ef34adb50c98f5b4..a8566d04048b6352bd640c7fe0c2108756431a8f 100644 (file)
@@ -281,8 +281,8 @@ static int udp_cksum(register const struct ip *ip,
                     register const struct udphdr *up,
                     register u_int len)
 {
-       return (nextproto4_cksum(ip, (const u_int8_t *)(void *)up, len,
-           IPPROTO_UDP));
+       return nextproto4_cksum(ip, (const u_int8_t *)(void *)up, len, len,
+                               IPPROTO_UDP);
 }
 
 #ifdef INET6
index f2ab95b908b1a764dbf95b421398fcdeef845967..4f4d9ea6b424d3fa259b358a079c350623517073 100644 (file)
@@ -173,3 +173,7 @@ ipv6-bad-version.pcap       ipv6-bad-version.pcap   ipv6-bad-version.out    -t
 
 # Loopback/CTP test case
 loopback       loopback.pcap           loopback.out            -t
+
+# DCCP partial checksums tests
+dccp_partial_csum_v4_simple    dccp_partial_csum_v4_simple.pcap        dccp_partial_csum_v4_simple.out -t -v
+dccp_partial_csum_v4_longer    dccp_partial_csum_v4_longer.pcap        dccp_partial_csum_v4_longer.out -t -v
diff --git a/tests/dccp_partial_csum_v4_longer.out b/tests/dccp_partial_csum_v4_longer.out
new file mode 100644 (file)
index 0000000..a9b6413
--- /dev/null
@@ -0,0 +1,30 @@
+IP (tos 0x0, ttl 64, id 65312, offset 0, flags [DF], proto DCCP (33), length 52)
+    139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xaaf3 (correct), request (service=0) 
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto DCCP (33), length 68)
+    139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xb04b (correct), response (service=0) (ack=38464816766) 
+IP (tos 0x0, ttl 64, id 65313, offset 0, flags [DF], proto DCCP (33), length 56)
+    139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xf53a (correct), ack (ack=1960341146) 
+IP (tos 0x0, ttl 64, id 65314, offset 0, flags [DF], proto DCCP (33), length 152)
+    139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 6, cksum 0x7d28 (correct), dataack (ack=1960341146) 
+IP (tos 0x0, ttl 64, id 3176, offset 0, flags [DF], proto DCCP (33), length 52)
+    139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xfc63 (correct), ack (ack=38464816768) 
+IP (tos 0x0, ttl 64, id 65315, offset 0, flags [DF], proto DCCP (33), length 148)
+    139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 6, cksum 0x5e05 (correct), dataack (ack=1960341147) 
+IP (tos 0x0, ttl 64, id 3177, offset 0, flags [DF], proto DCCP (33), length 52)
+    139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0x0165 (correct), ack (ack=38464816769) 
+IP (tos 0x0, ttl 64, id 65316, offset 0, flags [DF], proto DCCP (33), length 148)
+    139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 6, cksum 0x5e1e (correct), dataack (ack=1960341148) 
+IP (tos 0x0, ttl 64, id 65317, offset 0, flags [DF], proto DCCP (33), length 148)
+    139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 6, cksum 0x5e15 (correct), dataack (ack=1960341148) 
+IP (tos 0x0, ttl 64, id 3178, offset 0, flags [DF], proto DCCP (33), length 56)
+    139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xfb32 (correct), ack (ack=38464816770) 
+IP (tos 0x0, ttl 64, id 3179, offset 0, flags [DF], proto DCCP (33), length 56)
+    139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xfa2f (correct), ack (ack=38464816771) 
+IP (tos 0x0, ttl 64, id 65318, offset 0, flags [DF], proto DCCP (33), length 148)
+    139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 6, cksum 0x5e35 (correct), dataack (ack=1960341150) 
+IP (tos 0x0, ttl 64, id 65319, offset 0, flags [DF], proto DCCP (33), length 52)
+    139.133.209.176.39420 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xf638 (correct), close (ack=1960341150) 
+IP (tos 0x0, ttl 64, id 3180, offset 0, flags [DF], proto DCCP (33), length 56)
+    139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xfb2c (correct), ack (ack=38464816772) 
+IP (tos 0x0, ttl 64, id 3181, offset 0, flags [DF], proto DCCP (33), length 60)
+    139.133.209.65.5001 > 139.133.209.176.39420: CCVal 0, CsCov 0, cksum 0xef25 (correct), reset (code=closed) (ack=38464816773) 
diff --git a/tests/dccp_partial_csum_v4_longer.pcap b/tests/dccp_partial_csum_v4_longer.pcap
new file mode 100644 (file)
index 0000000..f1176c0
Binary files /dev/null and b/tests/dccp_partial_csum_v4_longer.pcap differ
diff --git a/tests/dccp_partial_csum_v4_simple.out b/tests/dccp_partial_csum_v4_simple.out
new file mode 100644 (file)
index 0000000..413ae05
--- /dev/null
@@ -0,0 +1,14 @@
+IP (tos 0x0, ttl 64, id 30095, offset 0, flags [DF], proto DCCP (33), length 52)
+    139.133.209.176.52667 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xa766 (correct), request (service=0) 
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto DCCP (33), length 68)
+    139.133.209.65.5001 > 139.133.209.176.52667: CCVal 0, CsCov 0, cksum 0x9a1a (correct), response (service=0) (ack=33164071488) 
+IP (tos 0x0, ttl 64, id 30096, offset 0, flags [DF], proto DCCP (33), length 56)
+    139.133.209.176.52667 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xdf09 (correct), ack (ack=1925546833) 
+IP (tos 0x0, ttl 64, id 30097, offset 0, flags [DF], proto DCCP (33), length 68)
+    139.133.209.176.52667 > 139.133.209.65.5001: CCVal 0, CsCov 1, cksum 0x9dfa (correct), dataack (ack=1925546833) 
+IP (tos 0x0, ttl 64, id 24713, offset 0, flags [DF], proto DCCP (33), length 52)
+    139.133.209.65.5001 > 139.133.209.176.52667: CCVal 0, CsCov 0, cksum 0xe632 (correct), ack (ack=33164071490) 
+IP (tos 0x0, ttl 64, id 30098, offset 0, flags [DF], proto DCCP (33), length 52)
+    139.133.209.176.52667 > 139.133.209.65.5001: CCVal 0, CsCov 0, cksum 0xdf8d (correct), close (ack=1925546834) 
+IP (tos 0x0, ttl 64, id 24714, offset 0, flags [DF], proto DCCP (33), length 60)
+    139.133.209.65.5001 > 139.133.209.176.52667: CCVal 0, CsCov 0, cksum 0xd900 (correct), reset (code=closed) (ack=33164071491) 
diff --git a/tests/dccp_partial_csum_v4_simple.pcap b/tests/dccp_partial_csum_v4_simple.pcap
new file mode 100644 (file)
index 0000000..a9c3d66
Binary files /dev/null and b/tests/dccp_partial_csum_v4_simple.pcap differ