Ethereal

Re: [Ethereal-dev] FT_IPv4 and little_endian = 1 (Bug report for proto_tree_add_item)
Google
 
Web Ethereal.com

Home | Introduction | Documentation | Lists | FAQ | Development | Wiki | Bugs

Ethereal-dev: September 2004


How about this one (FT_IPv4 ignoring little_endian = 1)?
Does anyone want to take a stand?
If no arguments shoots a hole in this, how do I add the suggested change in proto.c to CVS (who approves that)?


/ Peter

Peter Johansson wrote:

The protocol I am writing a dissector for sends (among other things) the IP address that the data connection should be made on (similar to FTP).
The problem I have is that the IP v4 address is in little endian format in the protocol data. Hence I tried:


proto_tree_add_item(dsd_tree,
                   hf_dsd_ip_address_1,
                   tvb,
                   OCP_HEADER_SIZE + DSD_HEADER_SIZE + 6,
                   4,
                   TRUE); /* DATA IS LITTLE ENDIAN */


hf_dsd_ip_address_1 is defined as: &hf_dsd_ip_address_1, { "IP address 1", "ocp.dsd.addr_1", FT_IPv4, BASE_NONE, NULL, 0x0, "" }

The problem is that the address that should be shown as i.e. 192.168.1.2 is shown as 2.1.168.192 since proto_tree_add_item in proto.c ignores the little_endian flag for the type FT_IPv4.
Is this by design or is it a misfeature (bug)?


I suggest a change in proto.c from:
proto_tree_set_ipv4(new_fi, value);

to:
proto_tree_set_ipv4(new_fi, little_endian ? GUINT32_TO_BE(value) : value);
Since proto_tree_set_ipv4 expects big endian data, the value must be converted to BE if LE.


diff -u information follows:

--- proto.c Fri Aug 13 00:41:54 2004
+++ modified_proto.c Thu Sep 02 12:06:25 2004
@@ -722,7 +722,7 @@
case FT_IPv4:
g_assert(length == 4);
tvb_memcpy(tvb, (guint8 *)&value, start, 4);
- proto_tree_set_ipv4(new_fi, value);
+ proto_tree_set_ipv4(new_fi, little_endian ? GUINT32_TO_BE(value) : value);
break;


               case FT_IPXNET:

/ Regards, Peter

_______________________________________________
Ethereal-dev mailing list
Ethereal-dev@xxxxxxxxxxxx
http://www.ethereal.com/mailman/listinfo/ethereal-dev


-- ____________________________________________________________ Peter Johansson Phone : +46 (0)8 752 81 00 Contactor Data AB Mobile: +46 (0)70 608 3063 Finlandsgatan 14 MailTo:Peter.Johansson@xxxxxxxxxxxx 164 74 Kista SMS :Peter.Johansson.sms@xxxxxxxxxxxx SWEDEN



Powered by MHonArc 2.6.10