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: Guy Harris <guy@xxxxxxxxxx>
Date: Fri, 15 Jun 2001 20:09:12 -0700 (PDT)
> 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.

Why are IPv4 addresses any different from 16-byte IPv6 addresses? (Note
that I don't consider "one of them fits into an integral data type and
the other doesn't" to be a valid answer, as I don't consider that an
*interesting* difference.)

I.e., I don't consider something that eliminates *only* the uses of
"tvb_get_ptr()" that fetch IPv4 addresses interesting.  There are plenty
of other data types, and if they continue to need "tvb_get_ptr()", I
have no problem whatsoever continuing to use them for IPv4 addresses as
well.

> 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 translate it from the byte order in the packet to the host's byte
order.

However, currently many pieces of Ethereal expect that an IPv4 address
will be in *network* byte order, not *host* byte order, so that code
will have to be changed if those accessors are used.