Capitalising hex strings in dissector field output?
Hello,
Is there a way to capitalise hex output in the field output like we can with the string formatter "0x%04X"?
I'm using that to add the details to the INFO column but not sure how to get similar formatting in the dissected fields:
PACKED_SIM_GROUP_M3UA_S (0xCFDC) from IPDU-3 to GISU-7 via EMB-0
For example, I have the field is being output like below:
DMX message number: PACKED_SIM_GROUP_M3UA_S (0xcfdc)
But I'd prefer to have the hex number printed as 0xCFDC (just makes it simpler for us to see the message number).
I am poking around the source for proto_tree_add_item to pin down where the actual hex digit printing occurs ... haven't figured it out yet.
In my dissector I'm doing this:
static const value_string dmxMessageNumber[] = {
...
{ 0xCFDC, "PACKED_SIM_GROUP_M3UA_S" },
...
};
proto_tree_add_item(dmx_tree, hf_emb_msg_header_t_number, tvb,
offset, 2, ENC_LITTLE_ENDIAN);
...
{ &hf_emb_msg_header_t_number,
{"DMX message number", "emb.dmx.number",
FT_UINT16, BASE_HEX, VALS(dmxMessageNumber),
0x0, "DX message number (message_number_t)", HFILL}},
Thanks, Brett.
I guess one workaround would be to simply use the column editing mode to copy the hex number in my dmxMessageNumber array so it's part of the text output string, something like:
That would only take a few seconds to do for all 120+ array members I have at the moment.
In that case, is there any way to suppress the output of the (0xcfdc)?
Ah huh, in PROTO.C I think I've found where the actual formatting is done?
So I could get it to print all hex strings capitalised by modifying this function and recompiling?
Nope and nope. I've modified in EPAN/PROTO.C and also a similar one I found in EPAN/PRINT.C and neither had any effect:
I'm a big fan of "patch and pray" coding so maybe try changing
epan/to_str.c
. Or maybe a better long term solution is to useBASE_CUSTOM
: doc/README.dissectorHa ha, indeed! It's also a good way to figure out how things work.
I did consider BASE_CUSTOM when I came upon it in the code but then also saw a comment in PROTO.C that said:
So I discounted it without further investigation - I'll have a proper look at how it works.
And you're right about TO_STR.C ... patched that one and now all my hex strings are capitalised ... happiness ;)
(more)