Ethereal-dev: Re: [ethereal-dev] proto_tree_add_ipv4

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: Sat, 8 Jul 2000 00:58:10 -0700
On Fri, Jul 07, 2000 at 08:01:57AM -0500, Gilbert Ramirez wrote:
> 2) Your example of having proto_tree_add_ipv4() accept a pointer.
> The dissector looks like this:
> 
> 	proto_tree_add_ipv4(..., tvb_get_ptr(.., 4))
> 
> It still assumes a certain byte order in the packet, which is good,
> since proto_tree_add_item() will still work for FT_IPv4 fields.

Note that in some cases the pointer handed to "proto_tree_add_ipv4()"
will have to be a pointer to a local variable on the stack - the ONC RPC
"bootparams" protocol appears to have, as one of the fields, an IP
address represented as four XDR-format integral values, one per octet of
the address, which means four 32-bit (and apparently signed...) integral
quantities.

Are there any situations where one would use "proto_tree_add_ipv4()"
with a pointer argument where one couldn't just use
"proto_tree_add_item()" (other than code that hasn't yet been converted
to use tvbuffs, as "proto_tree_add_item()" extracts the value of the
field with tvbuff calls)?