Ethereal-dev: Re: [Ethereal-dev] tvb_get_ntohl and other

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

From: "Guy Harris" <gharris@xxxxxxxxx>
Date: Tue, 21 Mar 2006 10:15:21 -0800 (PST)
Sofia Altieri wrote:

> I'm fetching all values defined in my proto with tvb_get_ntoh(l/s). This
> because this routine
> converts byte from *network* order to host order. Skimming through other
> dissectors I've noticed that tvb_get_letoh(l/s) routines are often used.
> Now:
>
> a) Why should I use tvb_get_letoh(l/s) routines if a more general
> tvb_get_ntoh(l/s) routine exists?

As Gilbert noted, network byte order is big-endian, so the ntoh* routines
aren't more general than the letoh* routines, they're complementary -
ntoh* for big-endian, letoh* for little-endian.

> b) in process_reassembled_data (....., proto_tree * tree) must tree be an
> existent tree, like my proto_tree?

If you're building a tree, it should be the tree you're building - but, as
Jaap noted, that might be null.

Note that you should do the reassembly regardless of whether the protocol
tree handed to your dissector is null or not.

The protocol tree argument to process_reassembled_data() is there so that
it can put into the protocol tree a list of fragments or a "reassembled in
frame N" indication.  If you always pass it null, that stuff won't show up
in the packet detail pane.