As a follow-up to yesterday's e-mail about ANSI bitfields, here's a patch
to fix the e_ip structure, the IP header in packet.h. I didn't attempt IGMP
since I don't have a trace file with IGMP packets in it.
If no one has any complaints about the style of this patch, then I'll fix the
other structs with bitfields in packet.h (e_igmp and e_tcphdr), and submit
the changes to CVS.
--gilbert
diff -ur ethereal/packet-ip.c ethereal-ansi/packet-ip.c
--- ethereal/packet-ip.c Mon Dec 28 22:05:35 1998
+++ ethereal-ansi/packet-ip.c Tue Feb 2 12:29:41 1999
@@ -411,7 +411,8 @@
iph.ip_off = ntohs(iph.ip_off);
iph.ip_sum = ntohs(iph.ip_sum);
- hlen = iph.ip_hl * 4; /* IP header length, in bytes */
+ hlen = (iph.ip_v_hl & 0x0f) * 4; /* IP header length, in bytes */
+/* hlen = iph.ip_hl * 4; *//* IP header length, in bytes */
switch (iph.ip_p) {
case IP_PROTO_ICMP:
@@ -466,7 +467,9 @@
ti = add_item_to_tree(GTK_WIDGET(tree), offset, hlen, "Internet Protocol");
ip_tree = gtk_tree_new();
add_subtree(ti, ip_tree, ETT_IP);
- add_item_to_tree(ip_tree, offset, 1, "Version: %d", iph.ip_v);
+ /*add_item_to_tree(ip_tree, offset, 1, "Version: %d", iph.ip_v);*/
+ add_item_to_tree(ip_tree, offset, 1, "Version: %d",
+ (iph.ip_v_hl & 0xf0) >> 4);
add_item_to_tree(ip_tree, offset, 1, "Header length: %d bytes", hlen);
tf = add_item_to_tree(ip_tree, offset + 1, 1, "Type of service: 0x%02x (%s)",
iph.ip_tos, tos_str);
@@ -534,7 +537,7 @@
pi.destip = ip_to_str( (guint8 *) &iph.ip_dst);
pi.ipproto = iph.ip_p;
pi.iplen = iph.ip_len;
- pi.iphdrlen = iph.ip_hl;
+ pi.iphdrlen = (iph.ip_v_hl & 0x0f);
pi.ip_src = iph.ip_src;
offset += hlen;
diff -ur ethereal/packet.h ethereal-ansi/packet.h
--- ethereal/packet.h Thu Jan 28 15:29:36 1999
+++ ethereal-ansi/packet.h Tue Feb 2 12:31:25 1999
@@ -185,13 +185,7 @@
/* IP structs and definitions */
typedef struct _e_ip {
-#if BYTE_ORDER == BIG_ENDIAN
- guint8 ip_v:4;
- guint8 ip_hl:4;
-#else /* Little endian */
- guint8 ip_hl:4;
- guint8 ip_v:4;
-#endif
+ guint8 ip_v_hl; /* combines version and header length */
guint8 ip_tos;
guint16 ip_len;
guint16 ip_id;
--
Gilbert Ramirez Voice: +1 210 358 4032
Technical Services Fax: +1 210 358 1122
University Health System San Antonio, Texas, USA