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 <mmann78@netscape.net>
This commit is contained in:
Michael Mann 2014-10-31 09:01:57 -04:00
parent c6feecff74
commit 54efe5dad1
1 changed files with 29 additions and 7 deletions

View File

@ -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;