Ethereal-dev: Re: [Ethereal-dev] Creating a new Dissector

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

From: Brad Hards <bhards@xxxxxxxxxxxxxx>
Date: Mon, 7 Oct 2002 15:51:16 +1000
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 7 Oct 2002 13:36, Richard Sharpe wrote:
> On Mon, 7 Oct 2002, pevee wrote:
> > Hi,
> >
> >    Here is a segment of code...I did used tvb_get_ntohl();
> I suspect that ntohl and add_ipv4 are fighting with each other! Change the
> ntohl to one that does not do byte swapping and see what happens.
There is a specific warning against this in doc/README.developer:
NOTE: IPv4 addresses are not to be converted to host byte order before
being passed to "proto_tree_add_ipv4()".  You should use "tvb_memcpy()"
to fetch them, not "tvb_get_ntohl()" *OR* "tvb_get_letohl()" - don't,
for example, try to use "tvb_get_ntohl()", find that it gives you the
wrong answer on the PC on which you're doing development, and try
"tvb_get_letohl()" instead, as "tvb_get_letohl()" will give the wrong
answer on big-endian machines.

> Anyway, why aren't you using proto_tree_add_item(...) and specifying an
> hf_xyz that refers to an FT_IPv4 item?
This would seem better.

Brad
- -- 
http://conf.linux.org.au. 22-25Jan2003. Perth, Aust. Tickets booked.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9oSDUW6pHgIdAuOMRAto+AKC8zICjHY6xda+3r0to6yPtZ/DBxwCfYYh7
lPR42Z4hIFm5+q2DIcs2tn8=
=vw7E
-----END PGP SIGNATURE-----