This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Don’t display Unknown when using ProtoField with partial valuestring table

0

There is a field in my protocol that I would like to display as base.DEC_HEX, except when it is a reserved value, in which case I would like to display a string (with a dec or hex value in parentheses).

I do NOT want the values to show as Unknown (value), which is what happens when I create a string table with just the reserved value and reference it in the ProtoField.new call.

What is the best way to accomplish this? I know I can use an if statement and assign a label when calling tree:add() but this seems less than ideal, and would be a pain if I had several reserved values instead of just one.

asked 10 Feb '15, 10:00

chojiao's gravatar image

chojiao
11225
accept rate: 0%


One Answer:

0

Extract the value and decide what code path to follow to represent it in the tree. That's how you can divide the complexity into existing functions. Yes there's some duplication of data points, unfortunately.

answered 11 Feb '15, 06:04

Jaap's gravatar image

Jaap ♦
11.7k16101
accept rate: 14%