Title: controlling the display of the leading bit string when bitmask != 0
Is there a mechanism to control whether I want the bit string
displayed when the bitmask field is non-zero? Granted, in most
circumstances, it looks good for data elements that consist of
consecutive bits, but in others it just looks jarring.
For example, I have a character attribute that has three data
elements, where two of the data elements are stored in a nibble,
followed by one that is in a byte.
0000 .... Field 1 - Char 1 (4 bit)
.... 0000 Field 2 - Char 1 (4 bit)
Field 3 - Char 1 (8 bit)
0000 .... Field 1 - Char 2
.... 0000 Field 2 - Char 2
Field 3 - Char 2
etc. for 24 characters
I need to display an array of this data, and it would be nice
to just remove the leading bit string altogether. I can see
something in 'proto_tree_set_representation_value' (1.10.6) that
triggers off of 'bitmask != 0', but I don't see anything that
would hide that string using the normal api.
I hacked something crudely together to do it manually.
\code snippet
header_field_info *hf;
guint32 value;
guint32 tmpval;
...
/* Emit the code to display a data element without the leading
bitmask display. */
#define EMIT_HF_NO_BITMASK(hf_index, tvb_offset) \
hf = proto_registrar_get_nth(hf_index); \
value = tvb_get_guint8(tvb, (tvb_offset)); \
tmpval = (value & hf->bitmask) >> hf->bitshift; \
if (hf->strings) { \
proto_tree_add_uint_format(tree, hf_index, tvb, (tvb_offset), 1, tmpval, \
"%s: %s (%u)", \
hf->name, val_to_str_const(tmpval, cVALS(hf->strings), "Unknown"), tmpval); \
} \
else { \
proto_tree_add_uint_format(tree, hf_index, tvb, (tvb_offset), 1, tmpval, \
"%s: %u", \
hf->name, tmpval); \
}
\endif
I'm tempted to add another bit next to BASE_RANGE_STRING
and BASE_EXT_STRING to flip the bit string display off in
'proto_tree_set_representation_value' so that I can just use
'proto_tree_add_item' and be done with it.
Or perhaps I missed something completely obvious. Any
suggestions?
Thanks,
John Dill