I think those accessors would be useful.
But for IPv4 (and friends) I think the dissectors should use something like
char *tvb_get_ipv4(tvbuff_t *tvb, int offset, char *buf) /* 4 byte
address */
char *tvb_get_ipv6(tvbuff_t *tvb, int offset, char *buf) /* 6 byte
address */
char *tvb_get_ether(tvbuff_t *tvb, int offset, char *buf) /* 16 byte
address */
To keep the code in the dissector similar regardless of what kind of address
is read.
---
Something like :
gchar *
tvb_get_ipv4(tvbuff_t *tvb, int offset, gchar *buf)
{
/*... some error checking */
memcpy(buf, tvb_get_ptr(tvb, offset, 4), 4);
return buf;
}
---
buf would have to be gchar buf[4] in the caller.
With this pointer/array one could then call ip_to_str_buf() directly to
convert it into a dotted-decimal string.
----- Original Message -----
From: "Heikki Vatiainen"
To: <ethereal-dev@xxxxxxxxxxxx>
Sent: Saturday, June 23, 2001 6:19 AM
Subject: [Ethereal-dev] Patch proposal: Network-order tvbuff accessors
> I'm proposing a new tvbuff accessor for accessing 64,32,24 and 16 bit
> ints in network byte order. This is useful e.g. with
> proto_tree_add_ipv4 which expects a network byte order address as its
> argument. Currently e.g. IGMP dissector uses tvb_get_letohl for
> proto_tree_add_ipv4 which breaks with big endian hosts.
>
> There was some discussion relating to this about a year ago [1] I
> guess no patch became of it. This preprocessor method at least gets
> rid of memcpy and extra byteswapping on little endian machines. The
> patch is a little bit of hackery, but does not add requirements for
> copying memory or doing extra bytes swapping.
>
> Any chance for the patch to go in? I already have a patch ready for
> packet-igmp.c.