Ethereal-dev: Re: [Ethereal-dev] new accessors

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

From: Guy Harris <gharris@xxxxxxxxx>
Date: Mon, 18 Jun 2001 00:59:42 -0700
On Sat, Jun 16, 2001 at 02:35:50PM +1000, Ronnie Sahlberg wrote:
> Before I start coding. Would a patch that added accessors similar to
> ipv4_t *tvb_get_ipv4(tvbuff_t *tvb, int offset, ipv4_t *buf)
> ipv6_t *tvb_get_ipv6(tvbuff_t *tvb, int offset, ipv6_t *buf)
> ether_t *tvb_get_ether(tvbuff_t *tvb, inf offset, ether_t *buf)
> to tvbuff.c be considered?

Yes, if

	1) filtering on IPv4 addresses still works correctly on both
	   big-endian and little-endian platforms;

	2) all the calls to "SET_ADDRESS()" continue to work correctly.

The former means you may have to change the filtering code if you use
"tvb_get_ntohl()" to extract IPv4 addresses.

The latter means you can't extract an IPv4 address into an automatic
variable and hand that to "SET_ADDRESS()" - the "SET_ADDRESS()" calls
have to set the addresses from pointers to storage that remains valid
even *after* the dissector that calls "SET_ADDRESS()" returns.  A static
buffer, although a bit unattractive (as it means you have to make sure
there are no reentrancy issues), should work (if there aren't any
reentrancy issues).