Ethereal-dev: [ethereal-dev] Added "proto_tree_add_notext()" and "proto_item_set_text()"

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

From: Guy Harris <gharris@xxxxxxxxxxxx>
Date: Fri, 21 Jan 2000 21:06:31 -0800
In many cases, an interior node of a protocol tree should be decorated
with a string summarizing the nodes below it, but you don't know what
the summary should look like until you've dissected all the nodes below
it.

For example, in the Cisco Discovery Protocol, an "Addresses" item has a
count of addresses and a list of addresses; each address in the list has
a protocol type, a protocol length, a protocol string-of-bytes
describing the protocol to which the address applies, an address length,
and an address.  A good summary would be something indicating the type
of the address and its value, but you don't know what that is until
you've dissected all the other fields.  However, you had to create a
node under which to hang all those fields before dissecting them, and
you had to specify the string for that node when you created it.

This made the code to dissect them a bit complicated - I wasn't creating
the summary node until I either found that the address would have run
past the end of the "Addresses" item, or finished figuring out what type
of address it was.

This was similar to a problem with DNS resource records, where sometimes
you didn't know how long they were until you finished dissecting them;
to handle that, you can create the summary item with a length of 0, and
set the length later with "proto_item_set_len()".

So I added:

	"proto_tree_add_notext()" - like "proto_tree_add_text()", except
	that it leaves the string for the item null;

	"proto_item_set_text()" - lets you set the text for an item, by
	passing a format string and arguments for that string.

Using those routines let me significantly simplify the routine to
dissect addresses in a CDP "Addresses" item.

I'm not particularly wedded to the name "proto_tree_add_notext()"; if
anybody has any better suggestions....