Ask Your Question
0

Dissecting a field with a mixed content

asked 2020-08-27 08:46:51 +0000

dottedmag gravatar image

I'm writing a dissector for a protocol, and have stumbled upon the following field:

rxRSSIVal IN

RSSI measurement of the received frame. This is a signed 8-bit value.

  • Values from RSSI_RESERVED_START to 124 are reserved.
  • All values below RSSI_RESERVED_START are received power in dBms.
  • RSSI_NOT_AVAILABLE - RSSI measurement not available
  • RSSI_MAX_POWER_SATURATED - Receiver saturated. RSSI too high to measure precisely
  • RSSI_BELOW_SENSITIVITY - No signal detected. The RSSI is too low to measure precisely.

I understand how to mark reserved values as invalid via expert field.

How can I format other values in the packet tree node? I looked at various field types and none of them seem to fit. Is there a custom field type where dissector code can control the displayed value?

Ideally I'd also like to be able to support filtering myproto.rxrssi=max_power_saturated and myproto.rxrssi=10, but I'm not sure it is feasible.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-08-27 12:03:53 +0000

Jaap gravatar image

The flexible way to do this is have a tree item with the raw value (e.g. myproto.rxrssi) and a tree item hanging from that with the interpretation, based on the actual value (e.g, myproto.rxrssi.reserved or myproto.rxrssi.rssi etc.)

For example:

ti = proto_tree_add_item_ret_uint(tree,... hf_myproto_rxrssi,...., &rssi);
subtree = proto_item_add_subtree(ti, ...);
if (rssi >= RSSI_RESERVED_START && rssi < 124) {
    ti = proto_tree_add_item(subtree, ... hf_myproto_rxrssi_reserved, ....);
    proto_item_set_generated(ti); //optional, this creates square brackets around the field
} else
edit flag offensive delete link more

Comments

You could use a value string for the 3 enumerated values in the sub item.

grahamb gravatar imagegrahamb ( 2020-08-27 12:24:20 +0000 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-08-27 08:46:51 +0000

Seen: 293 times

Last updated: Aug 27 '20