summaryrefslogtreecommitdiff
path: root/epan/proto.c
diff options
context:
space:
mode:
authorAlexis La Goutte <alexis.lagoutte@gmail.com>2017-03-27 06:42:03 -0400
committerMichael Mann <mmann78@netscape.net>2017-04-10 20:31:37 +0000
commit043df01c5645378bd61318c20cfdbf86c8f73288 (patch)
tree83cc90c67b765746aed3394ba1d1154e9a433155 /epan/proto.c
parentded9ad7017a9b04a9f63c9ea91961d19ff6b395e (diff)
downloadwireshark-043df01c5645378bd61318c20cfdbf86c8f73288.tar.gz
Add support for BASE_VALS_NO_UNKNOWN
BASE_VALS_NO_UNKNOWN is a special value_string value for only a single (maybe 2) numerical value(s). If a field has the numerical value that doesn't match anything in the value_string, just the number is supplied for the field (no "Unknown") Dissectors that had this use case have been converted in the patch. Change-Id: Ie63a36cceec2fe4436938ec7e3d7f9e690d2b8d9 Reviewed-on: https://code.wireshark.org/review/20736 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/proto.c')
-rw-r--r--epan/proto.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/epan/proto.c b/epan/proto.c
index 17c787a906..330d5a144a 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -7118,6 +7118,13 @@ tmp_fld_check_assert(header_field_info *hfinfo)
hfinfo->name, hfinfo->abbrev,
ftype_name(hfinfo->type));
}
+ if (hfinfo->display & BASE_VALS_NO_UNKNOWN) {
+ g_error("Field '%s' (%s) is an integral value (%s)"
+ " that is being displayed as BASE_NONE but"
+ " with BASE_VALS_NO_UNKNOWN",
+ hfinfo->name, hfinfo->abbrev,
+ ftype_name(hfinfo->type));
+ }
break;
default:
@@ -8269,13 +8276,28 @@ fill_label_number(field_info *fi, gchar *label_str, gboolean is_signed)
* frame-number field - they're just integers giving
* the ordinal frame number.
*/
- const char *val_str = hf_try_val_to_str_const(value, hfinfo, "Unknown");
+ const char *val_str = hf_try_val_to_str(value, hfinfo);
out = hfinfo_number_vals_format(hfinfo, buf, value);
- if (out == NULL) /* BASE_NONE so don't put integer in descr */
- label_fill(label_str, 0, hfinfo, val_str);
- else
- label_fill_descr(label_str, 0, hfinfo, val_str, out);
+ if (hfinfo->display & BASE_VALS_NO_UNKNOWN) {
+ /*
+ * Unique values only display value_string string
+ * if there is a match. Otherwise it's just a number
+ */
+ if (val_str) {
+ label_fill_descr(label_str, 0, hfinfo, val_str, out);
+ } else {
+ label_fill(label_str, 0, hfinfo, out);
+ }
+ } else {
+ if (val_str == NULL)
+ val_str = "Unknown";
+
+ if (out == NULL) /* BASE_NONE so don't put integer in descr */
+ label_fill(label_str, 0, hfinfo, val_str);
+ else
+ label_fill_descr(label_str, 0, hfinfo, val_str, out);
+ }
}
else if (IS_BASE_PORT(hfinfo->display)) {
gchar tmp[ITEM_LABEL_LENGTH];