Ethereal-dev: [ethereal-dev] Patch to diferentiate between BOOTP and DHCP

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

From: Paul Ionescu <ipaul@xxxxxxxxx>
Date: Wed, 17 May 2000 12:25:26 +0300
I have made a quick patch for identifying DHCP packets and displaying in
the COL_INFO and COL_PROTOCOL relevant info.
Sometimes is useful to quickly differentiate between BOOTP and DHCP.
I don't know if I should make and register a proto_register_dhcp
function to be able to quick filter DHCP packets.

Index: ethereal/packet-bootp.c
===================================================================
RCS file: /cvsroot/ethereal/packet-bootp.c,v
retrieving revision 1.31
diff -u -r1.31 packet-bootp.c
--- packet-bootp.c	2000/05/11 08:15:00	1.31
+++ packet-bootp.c	2000/05/17 09:25:24
@@ -61,6 +61,8 @@
 static guint ett_bootp = -1;
 static guint ett_bootp_option = -1;
 
+static char * is_dhcp ;
+
 #define UDP_PORT_BOOTPS  67
 
 enum field_type { none, ipv4, string, toggle, yes_no, special, opaque,
@@ -299,6 +301,7 @@
 			}
 			proto_tree_add_text(bp_tree, NullTVB, voff, 3, "Option %d: %s = DHCP %s",
 				code, text, opt53_text[i]);
+			is_dhcp = (char *) opt53_text[i];
 			break;
 
 		/* Parameter Request List */
@@ -562,6 +565,8 @@
 	int			voff, eoff; /* vender offset, end offset */
 	guint32		ip_addr;
 
+	is_dhcp = NULL;
+
 	if (check_col(fd, COL_PROTOCOL))
 		col_add_str(fd, COL_PROTOCOL, "BOOTP");
 
@@ -670,6 +675,12 @@
 		while (voff < eoff) {
 			voff += bootp_option(pd, bp_tree, voff, eoff);
 		}
+		if (is_dhcp != NULL ) {
+			if (check_col(fd, COL_PROTOCOL))
+				col_add_str(fd, COL_PROTOCOL, "DHCP");
+			if (check_col(fd, COL_INFO))
+				col_add_fstr(fd, COL_INFO, "DHCP %-8s - Trans. ID 0x%x", is_dhcp, pntohl(&pd[offset+4]) );
+			}
 	}
 }