From 54efe5dad1e76983a5d0dac46f838f92e8f16563 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Fri, 31 Oct 2014 09:01:57 -0400 Subject: Improve the "guessing" of the hf_ field and encoding values. Change-Id: Iaa042ef8b794c265870a04f6659720c321978697 Reviewed-on: https://code.wireshark.org/review/5026 Reviewed-by: Michael Mann --- tools/convert_proto_tree_add_text.pl | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'tools/convert_proto_tree_add_text.pl') diff --git a/tools/convert_proto_tree_add_text.pl b/tools/convert_proto_tree_add_text.pl index a81dd49a21..58e0e5459c 100755 --- a/tools/convert_proto_tree_add_text.pl +++ b/tools/convert_proto_tree_add_text.pl @@ -430,31 +430,31 @@ sub generate_hfs { #field type if (scalar @args > 5) { if ($args[5] =~ /tvb_get_guint8/) { - if ($args[4] =~ /%[0-9]*[di]/) { + if ($args[4] =~ /%[0-9]*[i]/) { $proto_tree_item[9] = "FT_INT8"; } else { $proto_tree_item[9] = "FT_UINT8"; } } elsif ($args[5] =~ /tvb_get_(n|"le")tohs/) { - if ($args[4] =~ /%[0-9]*[di]/) { + if ($args[4] =~ /%[0-9]*[i]/) { $proto_tree_item[9] = "FT_INT16"; } else { $proto_tree_item[9] = "FT_UINT16"; } } elsif ($args[5] =~ /tvb_get_(n|"le")toh24/) { - if ($args[4] =~ /%[0-9]*[di]/) { + if ($args[4] =~ /%[0-9]*[i]/) { $proto_tree_item[9] = "FT_INT24"; } else { $proto_tree_item[9] = "FT_UINT24"; } } elsif ($args[5] =~ /tvb_get_(n|"le")tohl/) { - if ($args[4] =~ /%[0-9]*[di]/) { + if ($args[4] =~ /%[0-9]*[i]/) { $proto_tree_item[9] = "FT_INT32"; } else { $proto_tree_item[9] = "FT_UINT32"; } } elsif ($args[5] =~ /tvb_get_(n|"le")toh("40"|"48"|"56"|"64")/) { - if ($args[4] =~ /%[0-9]*[di]/) { + if ($args[4] =~ /%[0-9]*[i]/) { $proto_tree_item[9] = "FT_INT64"; } else { $proto_tree_item[9] = "FT_UINT64"; @@ -477,13 +477,31 @@ sub generate_hfs { } elsif (($args[5] =~ /tvb_get_ephemeral_string/) || ($args[5] =~ /tvb_format_text/)){ $proto_tree_item[9] = "FT_STRING"; - } elsif ($args[5] =~ /tvb_bytes_to_str/) { + } elsif (($args[5] =~ /tvb_bytes_to_str/) || + ($args[5] =~ /tvb_bytes_to_ep_str/)) { $proto_tree_item[9] = "FT_BYTES"; } elsif ($args[5] =~ /tvb_ether_to_str/) { $proto_tree_item[9] = "FT_ETHER"; } elsif ($args[5] =~ /tvb_vines_addr_to_str/) { $proto_tree_item[9] = "FT_VINES"; - } + } + + #if we still can't determine type, assume a constant length + #value means we have an unsigned value + if ($proto_tree_item[9] eq "fieldtype") { + my $len_str = trim($args[3]); + if ($len_str eq "1") { + $proto_tree_item[9] = "FT_UINT8"; + } elsif ($len_str eq "2") { + $proto_tree_item[9] = "FT_UINT16"; + } elsif ($len_str eq "3") { + $proto_tree_item[9] = "FT_UINT24"; + } elsif ($len_str eq "4") { + $proto_tree_item[9] = "FT_UINT32"; + } elsif ($len_str eq "8") { + $proto_tree_item[9] = "FT_UINT64"; + } + } } #display base @@ -498,6 +516,10 @@ sub generate_hfs { $proto_tree_item[11] .= "|BASE_EXT_STRING"; } + if (($proto_tree_item[7] eq "encoding") && ($proto_tree_item[9] eq "FT_BYTES")) { + $proto_tree_item[7] = "ENC_NA"; + } + push(@proto_tree_list, \@proto_tree_item); $num_items += 1; -- cgit v1.2.3