Ethereal-dev: Re: [Ethereal-dev] Can I reuse ett_xxxx variables for an arbitrary number of sub
From: Kelly Byrd
| The dissector I'm working on, daap, creates a number of nested
subtrees
| during a dissection. The number of subtrees isn't known at compile
time as
| it's determined by the contents of the packet. Daap data is a list
of tags
| that each may contain data or other tags. My dissector recurses if
it
| finds a container tag, creating a new subtree for each recursive
call.
|
| I've got a static ett_daap that's passed to proto_item_add_subtree()
for
| the top of the daap protocol tree. I've got another, ett_daap_sub,
that I
| reuse when I create each recursive subtree. I also reuse my two
static
| hf_daap_xxxx variables for each tag. This compiles and appears to
work
| correctly (my limited testing), but I'm not sure it's the correct
thing to
| do.
That's no problem. I do the same for the WSP dissector where I assign
one "type" of ett_XXX per use (not per header). One side effect that I
particularly like about this, is that if you open/close one subtree
and then click again on the packet you're dissecting from the packet
list, then all subtrees registered as the same ett_XXX will open/close
(if they are visible).
Best regards,
Olivier