tcpdump mailing list archives

Re: print-tcp.c: remove commas from output, to be consistent


From: Kevin Steves <stevesk () pobox com>
Date: Sun, 28 Jan 2007 10:54:44 -0800

On Thu, Jan 18, 2007 at 08:36:34AM +0100, Hannes Gredler wrote:
: well the correct thing would then be:
: 
: 1. embrace .SFP into Flags [.SPF],
: 2. add commas to sep. the rest of the field

I don't see commas (in general) adding to readability of fields
when you have 'field-name value' or when position identifies
field (as in TCP flags).

But the patch was fixing an issue where commas were (erroneously
I think) added in a verbose case only.

today:

10:38:15.209982 IP (tos 0x10, ttl 64, id 11085, offset 0, flags [DF], proto TCP (6), length 52) 172.29.9.106.4169 > 
10.155.111.210.22: ., cksum 0x5b7c (correct), 48:48(0) ack 193 win 16384 <nop,nop,timestamp 4031724762 1895009024>

I think this is just as readable:

10:38:15.209982 IP (tos 0x10 ttl 64 id 11085 offset 0 flags [DF] proto TCP (6) length 52) 172.29.9.106.4169 > 
10.155.111.210.22: . cksum 0x5b7c (correct) 48:48(0) ack 193 win 16384 <nop,nop,timestamp 4031724762 1895009024>

though, looking at an older style format (from OpenBSD), tcpdump has
always mixed comma, no-comma format:

10:38:15.209981 172.29.9.106.4169 > 10.155.111.210.22: . [tcp sum ok] 48:48(0) ack 193 win 16384 <nop,nop,timestamp 
4031724762 1895009024> (DF) [tos 0x10] (ttl 64, id 11085, len 52)

here is the patch again:

Index: print-tcp.c
===================================================================
RCS file: /tcpdump/master/tcpdump/print-tcp.c,v
retrieving revision 1.126
diff -u -r1.126 print-tcp.c
--- print-tcp.c 2 Nov 2006 08:56:16 -0000       1.126
+++ print-tcp.c 17 Jan 2007 19:45:14 -0000
@@ -411,12 +411,12 @@
                if (TTEST2(tp->th_sport, length)) {
                        sum = tcp_cksum(ip, tp, length);
 
-                        (void)printf(", cksum 0x%04x",EXTRACT_16BITS(&tp->th_sum));
+                        (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));
+                               (void)printf(" (incorrect -> 0x%04x)",in_cksum_shouldbe(tcp_sum, sum));
                        } else
-                               (void)printf(" (correct),");
+                               (void)printf(" (correct)");
                }
        }
 #ifdef INET6
@@ -424,12 +424,12 @@
                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));
+                        (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));
+                               (void)printf(" (incorrect (-> 0x%04x)",in_cksum_shouldbe(tcp_sum, sum));
                        } else
-                               (void)printf(" (correct),");
+                               (void)printf(" (correct)");
 
                }
        }
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.


Current thread: