Ethereal-dev: [ethereal-dev] Including packet length on summary for TCP packets

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Fred Reimer <fwr@xxxxxxxxxxxxxxx>
Date: Sun, 27 Feb 2000 16:04:41 -0500
Here is a patch so that summary info for TCP packets include the length of the
data in the packet.  Since the other info inside the summary info for TCP
packets are the seq and ack numbers, which are incremented based on the amount
of "real" data it only makes sense to include the data length in the summary. 
The sequence numbers are generally useless without it unless you look at the
decode section to find the data length.  This makes the summary much more
useful (IMO).  I've included it as an attachment also, in case email screws up
formatting.

Please send any replies to me in addition to the list, as I'm not subscribed
(yet).

Fred Reimer


--- ethereal-0.8.3/packet-tcp.c	Mon Jan 17 01:08:46 2000
+++ ethereal-0.8.3.1/packet-tcp.c	Sun Feb 27 16:00:08 2000
@@ -418,19 +418,19 @@
   if (check_col(fd, COL_PROTOCOL))
     col_add_str(fd, COL_PROTOCOL, "TCP");
   if (check_col(fd, COL_INFO)) {
     /* Copy the data into info_str in case one of the option handling
        routines needs to append to it. */
     if (th.th_flags & TH_URG)
-      info_len = snprintf(info_str, COL_MAX_LEN, "%s > %s [%s] Seq=%u Ack=%u Win=%u Urg=%u",
+      info_len = snprintf(info_str, COL_MAX_LEN, "%s > %s [%s] Seq=%u Ack=%u Win=%u Urg=%u Len=%d",
         get_tcp_port(th.th_sport), get_tcp_port(th.th_dport), flags,
-        th.th_seq, th.th_ack, th.th_win, th.th_urp);
+        th.th_seq, th.th_ack, th.th_win, th.th_urp, pi.len - offset - hlen);
     else
-      info_len = snprintf(info_str, COL_MAX_LEN, "%s > %s [%s] Seq=%u Ack=%u Win=%u",
+      info_len = snprintf(info_str, COL_MAX_LEN, "%s > %s [%s] Seq=%u Ack=%u Win=%u Len=%d",
         get_tcp_port(th.th_sport), get_tcp_port(th.th_dport), flags,
-        th.th_seq, th.th_ack, th.th_win);
+        th.th_seq, th.th_ack, th.th_win, pi.len - offset - hlen);
     /* The info column is actually written after the options are decoded */
   }
   
   if (tree) {
     ti = proto_tree_add_item_format(tree, proto_tcp, offset, hlen, NULL, "Transmission Control Protocol, Src Port: %s (%u), Dst Port: %s (%u), Seq: %u, Ack: %u", get_tcp_port(th.th_sport), th.th_sport, get_tcp_port(th.th_dport), th.th_dport, th.th_seq, th.th_ack);
     tcp_tree = proto_item_add_subtree(ti, ett_tcp);

--- ethereal-0.8.3/packet-tcp.c	Mon Jan 17 01:08:46 2000
+++ ethereal-0.8.3.1/packet-tcp.c	Sun Feb 27 16:00:08 2000
@@ -418,19 +418,19 @@
   if (check_col(fd, COL_PROTOCOL))
     col_add_str(fd, COL_PROTOCOL, "TCP");
   if (check_col(fd, COL_INFO)) {
     /* Copy the data into info_str in case one of the option handling
        routines needs to append to it. */
     if (th.th_flags & TH_URG)
-      info_len = snprintf(info_str, COL_MAX_LEN, "%s > %s [%s] Seq=%u Ack=%u Win=%u Urg=%u",
+      info_len = snprintf(info_str, COL_MAX_LEN, "%s > %s [%s] Seq=%u Ack=%u Win=%u Urg=%u Len=%d",
         get_tcp_port(th.th_sport), get_tcp_port(th.th_dport), flags,
-        th.th_seq, th.th_ack, th.th_win, th.th_urp);
+        th.th_seq, th.th_ack, th.th_win, th.th_urp, pi.len - offset - hlen);
     else
-      info_len = snprintf(info_str, COL_MAX_LEN, "%s > %s [%s] Seq=%u Ack=%u Win=%u",
+      info_len = snprintf(info_str, COL_MAX_LEN, "%s > %s [%s] Seq=%u Ack=%u Win=%u Len=%d",
         get_tcp_port(th.th_sport), get_tcp_port(th.th_dport), flags,
-        th.th_seq, th.th_ack, th.th_win);
+        th.th_seq, th.th_ack, th.th_win, pi.len - offset - hlen);
     /* The info column is actually written after the options are decoded */
   }
   
   if (tree) {
     ti = proto_tree_add_item_format(tree, proto_tcp, offset, hlen, NULL, "Transmission Control Protocol, Src Port: %s (%u), Dst Port: %s (%u), Seq: %u, Ack: %u", get_tcp_port(th.th_sport), th.th_sport, get_tcp_port(th.th_dport), th.th_dport, th.th_seq, th.th_ack);
     tcp_tree = proto_item_add_subtree(ti, ett_tcp);