ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
July 17th, 2024 | 10:00am-11:55am SGT (UTC+8) | Online

Ethereal-dev: Re: [Ethereal-dev] Can I reuse ett_xxxx variables for an arbitrary number of sub

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: "Olivier Biot" <ethereal@xxxxxxxxxx>
Date: Mon, 16 Aug 2004 23:49:50 +0200
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