Hi list.
While looking at how to extend the tvbuff semantics to get more powerful
tvbuff handling
I came on to a problem with the function tvb_get_ptr() (which often occurs
together with ip_to_str()))
which I think would be nice if ethereal could get rid of.
The problem with tvb_get_ptr() is that it basically will g_malloc() an area
to store the tvbuff data in
which is currently not a problem since this will never happen (no COMPOSITE
tvbuffs exist in ethereal yet).
If ethereal were to start using COMPOSITEs this would greatly increase the
emory footprint of ethereal
and thus make COMPOSITEs useless. (what is the point to use COMPOSITEs if
they will be converted to
contignous g_malloc()ed buffers anyway.
I think tvb_get_ptr() should be completely unexported from the tvbuff.c file
and can start producing patches to do so.
tvb_get_ptr() often occur together with the function ip_to_str() which also
have a few other problems.
ip_to_str() basically perform the same function as ipv4_addr_str() (which
just calls ip_to_str()) and I think ip_to_str() should be removed.
Another problem with ip_to_str() is that it returns the string in one of a
few (3,4?) static string buffers it cycles through.
Not nice.
The attached patch changes ipv4_addr_str() to take slightly different
parameters (changing the pointer usually produced by tvb_get_ptr() to the
guint32 usually produced by tvb_get_letohl()) as well as a dedicated storage
buffer to store the dotted-decimal representation of
the ipv4 address.
The patch also changes a few dissectors to use ipv4_addr_str() instead of
ip_to_str().
One of the dissectors changed are packet-ip.c so it should be easy to test
it.
Please test this patch on a non-intel-endianess host to verify that I got it
correct in packet-ip.c .
After this patch is verified and committed I plan to change all other
dissectors to use ipv4_addr_str() instead of ip_to_str().
As can be seen in the example packet-wccp.c most of this work is pure
mechanical replacement and should not take too much time.
This will then allow us to remove ip_to_str() and ip_to_str_buf() completely
(and as a sideeffect get rid of some 100+ instances where get_tvb_ptr() is
used).
After this I plan to try to get rid of the rest of the calls to
get_tvb_ptr() calls, one by one.
Please test on non-intel and commit if it is OK.
best regards
ronnie sahlberg
Attachment:
patch_1.diff
Description: Binary data