Add BASE_NO_DISPLAY_VALUE to allow field value to not be shown.

There are times when byte arrays don't want to show their value
in the packet tree or there is a field that is the "header" of
a subtree where showing the field value distracts from the tree
display.  For these cases, BASE_NO_DISPLAY_VALUE can be used
to not display the value.

Change-Id: I8c9f1f57cd2e663dbee07e2289e7f5e1f22d1e32
Reviewed-on: https://code.wireshark.org/review/19479
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Michael Mann 2016-12-30 12:26:34 -05:00
parent 2d8615948e
commit 13964595ad
3 changed files with 28 additions and 17 deletions

View File

@ -117,7 +117,7 @@ FIELDDISPLAY --For FT_UINT{8,16,24,32,40,48,56,64} and
BASE_DEC, BASE_HEX, BASE_OCT, BASE_DEC_HEX, BASE_HEX_DEC,
BASE_CUSTOM, or BASE_NONE, possibly ORed with
BASE_RANGE_STRING, BASE_EXT_STRING, BASE_VAL64_STRING,
BASE_ALLOW_ZERO or BASE_UNIT_STRING
BASE_ALLOW_ZERO, BASE_UNIT_STRING or BASE_NO_DISPLAY_VALUE
BASE_NONE may be used with a non-NULL FIELDCONVERT when the
numeric value of the field itself is not of significance to
@ -126,6 +126,11 @@ FIELDDISPLAY --For FT_UINT{8,16,24,32,40,48,56,64} and
user in the protocol decode nor is it used when preparing
filters for the field in question.
BASE_NO_DISPLAY_VALUE will just display the field name with
no value. It is intended for byte arrays (FT_BYTES) or
header fields above a subtree. The value will still be
filterable, just not displayed.
--For FT_UINT16:
BASE_PT_UDP, BASE_PT_TCP, BASE_PT_DCCP or BASE_PT_SCTP

View File

@ -7198,8 +7198,10 @@ label_fill(char *label_str, gsize pos, const header_field_info *hfinfo, const ch
/* "%s: %s", hfinfo->name, text */
name_pos = pos = label_concat(label_str, pos, hfinfo->name);
pos = label_concat(label_str, pos, ": ");
pos = label_concat(label_str, pos, text ? text : "(null)");
if (!(hfinfo->display & BASE_NO_DISPLAY_VALUE)) {
pos = label_concat(label_str, pos, ": ");
pos = label_concat(label_str, pos, text ? text : "(null)");
}
if (pos >= ITEM_LABEL_LENGTH) {
/* Uh oh, we don't have enough room. Tell the user that the field is truncated. */
@ -7216,15 +7218,17 @@ label_fill_descr(char *label_str, gsize pos, const header_field_info *hfinfo, co
/* "%s: %s (%s)", hfinfo->name, text, descr */
name_pos = pos = label_concat(label_str, pos, hfinfo->name);
pos = label_concat(label_str, pos, ": ");
if (hfinfo->display & BASE_UNIT_STRING) {
pos = label_concat(label_str, pos, descr ? descr : "(null)");
pos = label_concat(label_str, pos, text ? text : "(null)");
} else {
pos = label_concat(label_str, pos, text ? text : "(null)");
pos = label_concat(label_str, pos, " (");
pos = label_concat(label_str, pos, descr ? descr : "(null)");
pos = label_concat(label_str, pos, ")");
if (!(hfinfo->display & BASE_NO_DISPLAY_VALUE)) {
pos = label_concat(label_str, pos, ": ");
if (hfinfo->display & BASE_UNIT_STRING) {
pos = label_concat(label_str, pos, descr ? descr : "(null)");
pos = label_concat(label_str, pos, text ? text : "(null)");
} else {
pos = label_concat(label_str, pos, text ? text : "(null)");
pos = label_concat(label_str, pos, " (");
pos = label_concat(label_str, pos, descr ? descr : "(null)");
pos = label_concat(label_str, pos, ")");
}
}
if (pos >= ITEM_LABEL_LENGTH) {

View File

@ -547,11 +547,13 @@ typedef enum {
/* Following constants have to be ORed with a field_display_e when dissector
* want to use specials value-string MACROs for a header_field_info */
#define BASE_RANGE_STRING 0x100
#define BASE_EXT_STRING 0x200
#define BASE_VAL64_STRING 0x400
#define BASE_ALLOW_ZERO 0x800 /**< Display <none> instead of <MISSING> for zero sized byte array */
#define BASE_UNIT_STRING 0x1000 /**< Add unit text to the field value */
#define BASE_RANGE_STRING 0x0100
#define BASE_EXT_STRING 0x0200
#define BASE_VAL64_STRING 0x0400
#define BASE_ALLOW_ZERO 0x0800 /**< Display <none> instead of <MISSING> for zero sized byte array */
#define BASE_UNIT_STRING 0x1000 /**< Add unit text to the field value */
#define BASE_NO_DISPLAY_VALUE 0x2000 /**< Just display the field name with no value. Intended for
byte arrays or header fields above a subtree */
/** BASE_ values that cause the field value to be displayed twice */
#define IS_BASE_DUAL(b) ((b)==BASE_DEC_HEX||(b)==BASE_HEX_DEC)