Ethereal-dev: Re: [Ethereal-dev] Patch: endian fixes and mtrace for packet-igmp.c

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

From: Guy Harris <guy@xxxxxxxxxx>
Date: Tue, 10 Jul 2001 13:32:55 -0700 (PDT)
> This patch fixes a few endian problems with proto_tree_add_ipv4 by
> changing them to proto_tree_add_item.

Yes, The problem is that IP addresses were being extracted with
"tvb_get_letohl()" and handed to "proto_tree_add_ipv4()"; the correct
way to extract IP addresses, *IF* you're going to process them, is with
"tvb_memcpy()", as "proto_tree_add_ipv4()" expects the address in the
host byte order, not big-endian (network) *OR* little-endian order.

However, if you're not going to process the address,
"proto_tree_add_item()" is the right answer - i.e., code that does

	proto_tree_add_XXX(tree, hf_YYY, tvb, offset, size,
	    tvb_get_ZZZ(tvb, offset));

should usually just be done as

	proto_tree_add_item(tree, hf_YYY, tvb, offset, size,,
	    byteorder);

as per your changes.