Ethereal-dev: Re: [Ethereal-dev] first patch for ip_to_str/tvb_get_ptr removal

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

From: "Ronnie Sahlberg" <rsahlber@xxxxxxxxxxxxxx>
Date: Fri, 15 Jun 2001 19:08:36 +1000
OK, sorry.
mt /dev/discussion rewind

For whatever reason which is not really important right now I think that
several uses of tvb_get_ptr()
are inappropriate.
The usage of tvb_get_ptr() I object to are the cases when tvb_get_ptr() is
used only to extract a pointer to
4 bytes representing an ipv4-address.
I think that tvb_get_letohl() would be much more appropriate to use if one
only needs to read a 32-bit integer
(ipv4 address) from a tvbuff.
There already exists perfectly good accessors to extract a 32bit quantity
from a tvbuff and there is therefore no
good reason to use tvb_get_ptr() to do this.

The patch I attached at the start of this discussion shows how
ipv4_addr_str() can be changed to take a 32 bit integer as a
parameter and convert it in to a string representation of a ipv4-address.
After applying this patch and testing it on Intel the IP layer dissector
still seems to work as always.

As an example, the patch changed packet-wccp.c and packet-ip.c to show how
this would affect the dissectors.
packet-wccp.c shows how trivial it is to change most usage of
ip_to_str(tvb_get_ptr(... into the more appropriate
ipv4_addr_str(tvb_get_letohl(...


For whatever reason I might have I think that it would be good to replace
these instances of tvb_get_ptr() with
tvb_get_letohl() since it is a 32 bit quantity we extract and we already
have accessors specifically designed to extract
such 32 bit quantities from a tvbuff.

I belive there is no real need to use tvb_get_ptr() in order to extract a 32
bit quantity which is what the patch tries to
address.
I am willing to create incremental patches to ethereal to change all reads
of 32 bit ipv4 addresses from using tvb_get_ptr() into
tvb_get_letohl().


Please comment.
Thanks
    ronnie sahlberg