From 99270048bcd7fbd80a8f3ce19683f7fad5bcf1ae Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Wed, 21 Jun 2017 10:45:29 -0400 Subject: TCP: Make the header length display consistent with IPv4. Format tcp.hdr_len in the tree similar to ip.hdr_len. Add comments noting that they should be consistent. Change-Id: Ic64282d8386c8ed339811bc9c22b5962c707d292 Reviewed-on: https://code.wireshark.org/review/22314 Reviewed-by: Gerald Combs Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman (cherry picked from commit b370c02a02cef0e26f327342e085fa45b4e06e3f) Reviewed-on: https://code.wireshark.org/review/22355 --- epan/dissectors/packet-ip.c | 1 + epan/dissectors/packet-tcp.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c index 689f6d9f2c..0e97ecf25a 100644 --- a/epan/dissectors/packet-ip.c +++ b/epan/dissectors/packet-ip.c @@ -1933,6 +1933,7 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* return tvb_captured_length(tvb); } + // This should be consistent with tcp.hdr_len. proto_tree_add_uint_bits_format_value(ip_tree, hf_ip_hdr_len, tvb, (offset<<3)+4, 4, hlen, "%u bytes (%u)", hlen, hlen>>2); diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index d943c9fcac..a9852d6e02 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -5999,7 +5999,9 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) } if (tree) { - proto_tree_add_uint(tcp_tree, hf_tcp_hdr_len, tvb, offset + 12, 1, tcph->th_hlen); + // This should be consistent with ip.hdr_len. + proto_tree_add_uint_bits_format_value(tcp_tree, hf_tcp_hdr_len, tvb, (offset + 12) << 3, 4, tcph->th_hlen, + "%u bytes (%u)", tcph->th_hlen, tcph->th_hlen>>2); tf = proto_tree_add_uint_format(tcp_tree, hf_tcp_flags, tvb, offset + 12, 2, tcph->th_flags, "Flags: 0x%03x (%s)", tcph->th_flags, flags_str); field_tree = proto_item_add_subtree(tf, ett_tcp_flags); @@ -6497,7 +6499,7 @@ proto_register_tcp(void) NULL, HFILL }}, { &hf_tcp_hdr_len, - { "Header Length", "tcp.hdr_len", FT_UINT8, BASE_DEC|BASE_UNIT_STRING, &units_byte_bytes, 0x0, + { "Header Length", "tcp.hdr_len", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, { &hf_tcp_flags, -- cgit v1.2.1