]> The Tcpdump Group git mirrors - tcpdump/commitdiff
From Gerrit Renker:
authorguy <guy>
Fri, 9 Nov 2007 00:44:09 +0000 (00:44 +0000)
committerguy <guy>
Fri, 9 Nov 2007 00:44:09 +0000 (00:44 +0000)
don't compute checksums when the snapshot length is less than
the packet length;

combine duplicate code;

eliminate unnecessary test.

print-dccp.c

index 634c27e9fcaa7892c761721695ee37f71468cf53..2022fc8a491c1b4c816092486c65c4d69c8e7f56 100644 (file)
@@ -9,7 +9,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-dccp.c,v 1.7 2006-11-02 09:05:23 hannes Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-dccp.c,v 1.8 2007-11-09 00:44:09 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -277,32 +277,21 @@ void dccp_print(const u_char *bp, const u_char *data2, u_int len)
        }
 
        /* checksum calculation */
-#ifdef INET6
-       if (ip6) {
-               if (ip6->ip6_plen && vflag) {
-                       u_int16_t sum, dccp_sum;
+       if (vflag && TTEST2(bp[0], len)) {
+               u_int16_t sum = 0, dccp_sum;
 
+               dccp_sum = EXTRACT_16BITS(&dh->dccph_checksum);
+               (void)printf("cksum 0x%04x ", dccp_sum);
+               if (IP_V(ip) == 4)
+                       sum = dccp_cksum(ip, dh, len);
+#ifdef INET6
+               else if (IP_V(ip) == 6)
                        sum = dccp6_cksum(ip6, dh, len);
-                       dccp_sum = EXTRACT_16BITS(&dh->dccph_checksum);         
-                       printf("cksum 0x%04x", dccp_sum);               
-                       if (sum != 0) {
-                               (void)printf(" (incorrect -> 0x%04x), ",in_cksum_shouldbe(dccp_sum, sum));
-                       } else
-                               (void)printf(" (correct), ");
-               }                                       
-       } else 
-#endif /* INET6 */
-       if (vflag)
-       {
-               u_int16_t sum, dccp_sum;
-
-               sum = dccp_cksum(ip, dh, len);
-               dccp_sum = EXTRACT_16BITS(&dh->dccph_checksum);         
-               printf("cksum 0x%04x", dccp_sum);               
-               if (sum != 0) {
-                       (void)printf(" (incorrect (-> 0x%04x), ",in_cksum_shouldbe(dccp_sum, sum));
-               } else
-                       (void)printf(" (correct), ");
+#endif
+               if (sum != 0)
+                       (void)printf("(incorrect -> 0x%04x), ",in_cksum_shouldbe(dccp_sum, sum));
+               else
+                       (void)printf("(correct), ");
        }
 
        switch (DCCPH_TYPE(dh)) {