Ethereal-dev: [Ethereal-dev] patch to packet-bootp.c

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

From: Yaniv Kaul <ykaul@xxxxxxxxxxxx>
Date: Sun, 26 Dec 2004 17:08:40 +0200
Attached please find patch to packet-bootp.c which adds Ethernet resolving to client hardware address.

Index: packet-bootp.c
===================================================================
--- packet-bootp.c	(revision 12836)
+++ packet-bootp.c	(working copy)
@@ -70,7 +70,7 @@
 #include <epan/packet.h>
 #include "packet-arp.h"
 #include "packet-dns.h"				/* for get_dns_name() */
-
+#include <epan/addr_resolv.h>
 #include <epan/prefs.h>
 #include <epan/tap.h>
 #include <epan/strutil.h>
@@ -107,7 +107,7 @@
 static int hf_bootp_fqdn_asciiname = -1;
 static int hf_bootp_pkt_mtacap_len = -1;
 static int hf_bootp_docsis_cmcap_len = -1;
-
+static int hf_bootp_hw_ether_addr = -1;
 static gint ett_bootp = -1;
 static gint ett_bootp_flags = -1;
 static gint ett_bootp_option = -1;
@@ -867,9 +867,12 @@
 				"Hardware type: %s",
 				arphrdtype_to_str(byte,
 					"Unknown (0x%02x)"));
-			proto_tree_add_text(v_tree, tvb, optoff+1, 6,
-				"Client hardware address: %s",
-				arphrdaddr_to_str(tvb_get_ptr(tvb, optoff+1, 6),
+			if (byte == 1 || byte == 6)
+				proto_tree_add_ether(v_tree, hf_bootp_hw_ether_addr, tvb, optoff+1, 6, tvb_get_ptr(tvb, optoff+1, 6));
+			else
+				proto_tree_add_text(v_tree, tvb, optoff+1, 6,
+					"Client hardware address: %s",
+					arphrdaddr_to_str(tvb_get_ptr(tvb, optoff+1, 6),
 					6, byte));
 		} else {
 			/* otherwise, it's opaque data */
@@ -2715,6 +2718,7 @@
 		/*
 		 * In case we throw an exception fetching the opcode, etc.
 		 */
+		
 		col_clear(pinfo->cinfo, COL_INFO);
 	}
 
@@ -2725,6 +2729,10 @@
 		switch (op) {
 
 		case BOOTREQUEST:
+			if ((htype == 1 || htype == 6) && hlen == 6)
+				col_add_fstr(pinfo->cinfo, COL_INFO, "Boot Request from %s (%s)",
+					arphrdaddr_to_str(tvb_get_ptr(tvb, 28, hlen), hlen, htype), get_ether_name(tvb_get_ptr(tvb, 28, hlen)));
+			else
 			col_add_fstr(pinfo->cinfo, COL_INFO, "Boot Request from %s",
 				arphrdaddr_to_str(tvb_get_ptr(tvb, 28, hlen),
 					hlen, htype));
@@ -2781,8 +2789,11 @@
 		proto_tree_add_item(bp_tree, hf_bootp_ip_relay, tvb,
 				    24, 4, FALSE);
 
-		if (hlen > 0) {
+		if (hlen > 0 && hlen <= 16) {
 			haddr = tvb_get_ptr(tvb, 28, hlen);
+			if((htype == 1 || htype == 6) && hlen == 6)
+				proto_tree_add_ether(bp_tree, hf_bootp_hw_ether_addr, tvb, 28, 6, haddr);
+			else
 			proto_tree_add_bytes_format(bp_tree, hf_bootp_hw_addr, tvb,
 				/* The chaddr element is 16 bytes in length, although
 				   only the first hlen bytes are used */
@@ -2984,6 +2995,11 @@
         BASE_NONE,			NULL,		 0x0,
       	"", HFILL }},
 
+    { &hf_bootp_hw_ether_addr,
+      { "Client Ethernet address",	"bootp.hw.ether_addr", FT_ETHER,
+        BASE_NONE,			NULL,		 0x0,
+      	"", HFILL }},
+
     { &hf_bootp_server,
       { "Server host name",		"bootp.server",  FT_STRING,
         BASE_NONE,			NULL,		 0x0,