- if (IP_V(ip) == 4 && vflag && !Kflag && !fragmented) {
- u_int16_t sum, tcp_sum;
- if (TTEST2(tp->th_sport, length)) {
- sum = tcp_cksum(ip, tp, length);
-
- (void)printf(", cksum 0x%04x",EXTRACT_16BITS(&tp->th_sum));
- if (sum != 0) {
- tcp_sum = EXTRACT_16BITS(&tp->th_sum);
- (void)printf(" (incorrect -> 0x%04x)",in_cksum_shouldbe(tcp_sum, sum));
- } else
- (void)printf(" (correct)");
- }
- }
-#ifdef INET6
- if (IP_V(ip) == 6 && ip6->ip6_plen && vflag && !Kflag && !fragmented) {
- u_int16_t sum,tcp_sum;
- if (TTEST2(tp->th_sport, length)) {
- sum = tcp6_cksum(ip6, tp, length);
- (void)printf(", cksum 0x%04x",EXTRACT_16BITS(&tp->th_sum));
- if (sum != 0) {
- tcp_sum = EXTRACT_16BITS(&tp->th_sum);
- (void)printf(" (incorrect -> 0x%04x)",in_cksum_shouldbe(tcp_sum, sum));
- } else
- (void)printf(" (correct)");
+ if (ndo->ndo_vflag && !ndo->ndo_Kflag && !fragmented) {
+ /* Check the checksum, if possible. */
+ uint16_t sum, tcp_sum;
+
+ if (IP_V(ip) == 4) {
+ if (ND_TTEST2(tp->th_sport, length)) {
+ sum = tcp_cksum(ndo, ip, tp, length);
+ tcp_sum = EXTRACT_BE_U_2(&tp->th_sum);
+
+ ND_PRINT((ndo, ", cksum 0x%04x", tcp_sum));
+ if (sum != 0)
+ ND_PRINT((ndo, " (incorrect -> 0x%04x)",
+ in_cksum_shouldbe(tcp_sum, sum)));
+ else
+ ND_PRINT((ndo, " (correct)"));
+ }
+ } else if (IP_V(ip) == 6 && ip6->ip6_plen) {
+ if (ND_TTEST2(tp->th_sport, length)) {
+ sum = tcp6_cksum(ndo, ip6, tp, length);
+ tcp_sum = EXTRACT_BE_U_2(&tp->th_sum);
+
+ ND_PRINT((ndo, ", cksum 0x%04x", tcp_sum));
+ if (sum != 0)
+ ND_PRINT((ndo, " (incorrect -> 0x%04x)",
+ in_cksum_shouldbe(tcp_sum, sum)));
+ else
+ ND_PRINT((ndo, " (correct)"));