From 29a98d1c7f09cba3a1e20ae6bfce76cf13e134fe Mon Sep 17 00:00:00 2001 From: Jeff Morriss Date: Sun, 17 Jul 2016 18:24:45 -0400 Subject: [PATCH] Allow BASE_NONE (with strings conversion) for integral values again. This mostly reverts SVN rev 43412 (3fa645481f82e32d5ad01ebce9c482c4edae31ae) with the addition of documenting that FT_*INT*'s with BASE_NONE and a FIELDCONVERT tells the Wireshark core that the field's numeric value is meaningless and should not be shown to the user. Use BASE_NONE again with the expert info group and severity fields. This (finally) resolves the complaint from: https://www.wireshark.org/lists/wireshark-dev/201206/msg00188.html (yes, this mail's been sitting in my "todo" pile since then! ) Change-Id: I1c6dd2864e7a2e959c97c409f277853af74a8d93 Reviewed-on: https://code.wireshark.org/review/16518 Petri-Dish: Jeff Morriss Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- doc/README.dissector | 13 ++++++++++--- epan/expert.c | 4 ++-- epan/proto.c | 18 +++++++++++++++--- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/doc/README.dissector b/doc/README.dissector index 36367696ff..17b3273336 100644 --- a/doc/README.dissector +++ b/doc/README.dissector @@ -112,11 +112,18 @@ FIELDTYPE FT_NONE, FT_BOOLEAN, FT_UINT8, FT_UINT16, FT_UINT24, FT_IPv6, FT_IPXNET, FT_FRAMENUM, FT_PROTOCOL, FT_GUID, FT_OID, FT_REL_OID, FT_AX25, FT_VINES, FT_SYSTEM_ID, FT_FC, FT_FCWWN FIELDDISPLAY --For FT_UINT{8,16,24,32,40,48,56,64} and - FT_INT{8,16,24,32,40,48,56,64): + FT_INT{8,16,24,32,40,48,56,64): BASE_DEC, BASE_HEX, BASE_OCT, BASE_DEC_HEX, BASE_HEX_DEC, - or BASE_CUSTOM, possibly ORed with BASE_RANGE_STRING, - BASE_EXT_STRING or BASE_VAL64_STRING + BASE_CUSTOM, or BASE_NONE, possibly ORed with + BASE_RANGE_STRING, BASE_EXT_STRING or BASE_VAL64_STRING. + + BASE_NONE may be used with a non-NULL FIELDCONVERT when the + numeric value of the field itself is not of significance to + the user (for example, the number is a generated field). + When this is the case the numeric value is not shown to the + user in the protocol decode nor is it used when preparing + filters for the field in question. --For FT_UINT16: diff --git a/epan/expert.c b/epan/expert.c index c4d106e7f6..b45541da2e 100644 --- a/epan/expert.c +++ b/epan/expert.c @@ -205,10 +205,10 @@ expert_packet_init(void) { "Message", "_ws.expert.message", FT_STRING, BASE_NONE, NULL, 0, "Wireshark expert information", HFILL } }, { &hf_expert_group, - { "Group", "_ws.expert.group", FT_UINT32, BASE_HEX, VALS(expert_group_vals), 0, "Wireshark expert group", HFILL } + { "Group", "_ws.expert.group", FT_UINT32, BASE_NONE, VALS(expert_group_vals), 0, "Wireshark expert group", HFILL } }, { &hf_expert_severity, - { "Severity level", "_ws.expert.severity", FT_UINT32, BASE_HEX, VALS(expert_severity_vals), 0, "Wireshark expert severity level", HFILL } + { "Severity level", "_ws.expert.severity", FT_UINT32, BASE_NONE, VALS(expert_severity_vals), 0, "Wireshark expert severity level", HFILL } } }; static gint *ett[] = { diff --git a/epan/proto.c b/epan/proto.c index aa457649b3..268e443221 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -6526,12 +6526,16 @@ tmp_fld_check_assert(header_field_info *hfinfo) wmem_free(NULL, tmp_str); break; } + /* Require integral types (other than frame number, * which is always displayed in decimal) to have a * number base. - * If there is a strings value then this base is not - * normally used except when constructing a display - * filter for a value not found in the strings lookup. + * + * If the display value is BASE_NONE and there is a + * strings conversion then the dissector writer is + * telling us that the field's numerical value is + * meaningless; we'll avoid showing the value to the + * user. */ switch (hfinfo->display & FIELD_DISPLAY_E_MASK) { case BASE_DEC: @@ -6541,6 +6545,14 @@ tmp_fld_check_assert(header_field_info *hfinfo) case BASE_HEX_DEC: case BASE_CUSTOM: /* hfinfo_numeric_value_format() treats this as decimal */ break; + case BASE_NONE: + if (hfinfo->strings == NULL) + g_error("Field '%s' (%s) is an integral value (%s)" + " but is being displayed as BASE_NONE but" + " without a strings conversion", + hfinfo->name, hfinfo->abbrev, + ftype_name(hfinfo->type)); + break; default: tmp_str = val_to_str_wmem(NULL, hfinfo->display, hf_display, "(Unknown: 0x%x)"); g_error("Field '%s' (%s) is an integral value (%s)"