]> The Tcpdump Group git mirrors - tcpdump/commitdiff
DCCP: Factorize some code
authorFrancois-Xavier Le Bail <[email protected]>
Fri, 14 Jan 2022 16:19:24 +0000 (17:19 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Fri, 14 Jan 2022 16:21:44 +0000 (17:21 +0100)
All the code is in verbose mode.

print-dccp.c

index 2d7fc369b5621906f7b46ec6f425e6b009c62ddd..6ad4027292f65f0ecf84fc5cbf1bb1cffb603b4d 100644 (file)
@@ -327,26 +327,24 @@ dccp_print(netdissect_options *ndo, const u_char *bp, const u_char *data2,
        /* other variables in generic header */
        if (ndo->ndo_vflag) {
                ND_PRINT(" (CCVal %u, CsCov %u", DCCPH_CCVAL(dh), DCCPH_CSCOV(dh));
-       }
-
-       /* checksum calculation */
-       if (ndo->ndo_vflag && ND_TTEST_LEN(bp, len)) {
-               uint16_t sum = 0, dccp_sum;
-
-               dccp_sum = GET_BE_U_2(dh->dccph_checksum);
-               ND_PRINT(", cksum 0x%04x ", dccp_sum);
-               if (IP_V(ip) == 4)
-                       sum = dccp_cksum(ndo, ip, dh, len);
-               else if (IP_V(ip) == 6)
-                       sum = dccp6_cksum(ndo, ip6, dh, len);
-               if (sum != 0)
-                       ND_PRINT("(incorrect -> 0x%04x)",in_cksum_shouldbe(dccp_sum, sum));
-               else
-                       ND_PRINT("(correct)");
-       }
 
-       if (ndo->ndo_vflag)
+               /* checksum calculation */
+               if (ND_TTEST_LEN(bp, len)) {
+                       uint16_t sum = 0, dccp_sum;
+
+                       dccp_sum = GET_BE_U_2(dh->dccph_checksum);
+                       ND_PRINT(", cksum 0x%04x ", dccp_sum);
+                       if (IP_V(ip) == 4)
+                               sum = dccp_cksum(ndo, ip, dh, len);
+                       else if (IP_V(ip) == 6)
+                               sum = dccp6_cksum(ndo, ip6, dh, len);
+                       if (sum != 0)
+                               ND_PRINT("(incorrect -> 0x%04x)",in_cksum_shouldbe(dccp_sum, sum));
+                       else
+                               ND_PRINT("(correct)");
+               }
                ND_PRINT(")");
+       }
        ND_PRINT(" ");
 
        dccph_type = DCCPH_TYPE(dh);