Hi,
Le mercredi 08 octobre 2008 ᅵ 17:02 +0200,
david.castleford@xxxxxxxxxxxxxxxxxx a ï¿œcrit :
> Hi,
>
> I've submitted a new dissector for Simulcrypt protocol and it contains
> TLV parameters (still fixing bugs).
>
> I have a loop navigating through TLV parameters.
>
> For each parameter I initally had:
>
> proto_tree_add_item_hidden( simulcrypt_message_tree,
> hf_simulcrypt_parameter_type, tvb, offset, 2, FALSE );
>
> (the benefit is being to search for simulcrypt.parameter_type)
>
> And then I have a switch according to parameter type and use e.g.:
>
> simulcrypt_item=proto_tree_add_item( simulcrypt_message_tree,
> hf_simulcrypt_ecm_channel_id, tvb, offset-plen,plen,FALSE);
> proto_item_append_text(simulcrypt_item, ", Length %d (bytes), Type 0x%
> 04x", plen,ptype); /* add length + type info to parameter */
>
> This gave me one line per parameter being displayed (value, length,
> type):
>
> ECM Channel ID: 0, Length 2 (bytes), Type 0x000e
>
> Now before uploading a patch, I saw that the _hidden functions had
> been made obsolete, so I removed the _hidden, but it has the
> side effect of displaying an extra line per parameter, before the
> actual item being added:
>
> Parameter Type: ECM_CHANNEL_ID (0x000e)
> <- this was originally hidden from display
> ECM Channel ID: 0, Length 2 (bytes), Type 0x000e
>
> As I have several parameters it is much less readable than when I had
> the _hidden part!
>
> What do you recommend as a solution?
> Leave it as it is i.e. Parameter type on one length, then actual
> parameter value below?
> Or is there an easy fix (other than not adding the parameter type each
> time, losing the ability to search for simulcrypt.parameter_type)?
Did you try with a subtree?
simulcrypt_item=proto_tree_add_item( simulcrypt_message_tree,hf_simulcrypt_ecm_channel_id,tvb, offset-plen,plen,FALSE);
proto_item_append_text(simulcrypt_item, ", Length %d (bytes), Type 0x%
04x", plen,ptype);
tree = proto_item_add_subtree(simulcrypt_item, ett_foo);
proto_tree_add_item( tree, hf_simulcrypt_parameter_type, tvb, offset, 2,
FALSE );
A drawback: there's only one expand/collapse state per ett_foo
Didier
>