Ethereal-dev: [Ethereal-dev] Fix/Update for BOOTP (DHCP) Dissector

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

From: Greg Kilfoyle <gregk@xxxxxxxxxxx>
Date: Mon, 12 Feb 2001 11:20:18 -0800
Hi,

I've updated the BOOTP dissector so that it breaks out option 82 (Relay Agent
Information Option). Previously option 82 was being displayed as the Agent
Circuit ID, when it should have been displayed as Agent Information Option. 83
and 84 were being treated as Agent Remote ID and Agent Subnet Mask, when they
are actually sub-options of the 82 option. 83 and 84 are now listed as
"unassigned".

The unified diff is attached.

Cheers, Greg.
? cscope.files
? cscope.out
Index: packet-bootp.c
===================================================================
RCS file: /cvsroot/ethereal/packet-bootp.c,v
retrieving revision 1.46
diff -u -r1.46 packet-bootp.c
--- packet-bootp.c	2001/01/22 08:03:44	1.46
+++ packet-bootp.c	2001/02/12 19:11:13
@@ -10,6 +10,7 @@
  * RFC 2131: Dynamic Host Configuration Protocol
  * RFC 2132: DHCP Options and BOOTP Vendor Extensions
  * RFC 2489: Procedure for Defining New DHCP Options
+ * RFC 3046: DHCP Relay Agent Information Option
  * BOOTP and DHCP Parameters
  *     http://www.isi.edu/in-notes/iana/assignments/bootp-dhcp-parameters
  *
@@ -84,6 +85,8 @@
 
 static int dissect_netware_ip_suboption(proto_tree *v_tree, tvbuff_t *tvb,
     int optp);
+static int bootp_dhcp_decode_agent_info(proto_tree *v_tree, tvbuff_t *tvb,
+    int optp);
 
 static const char *
 get_dhcp_type(guint8 byte)
@@ -212,9 +215,9 @@
 		/*  79 */ { "Service Location Agent Scope",			opaque },
 		/*  80 */ { "Naming Authority",						opaque },
 		/*  81 */ { "Client Fully Qualified Domain Name",	opaque },
-		/*  82 */ { "Agent Circuit ID",						opaque },
-		/*  83 */ { "Agent Remote ID",						opaque },
-		/*  84 */ { "Agent Subnet Mask",					opaque },
+		/*  82 */ { "Agent Information Option",                 special },
+		/*  83 */ { "Unassigned",				opaque },
+		/*  84 */ { "Unassigned",				opaque },
 		/*  85 */ { "Novell Directory Services Servers",	opaque },
 		/*  86 */ { "Novell Directory Services Tree Name",	opaque },
 		/*  87 */ { "Novell Directory Services Context",	opaque },
@@ -411,6 +414,17 @@
 			optp = dissect_netware_ip_suboption(v_tree, tvb, optp);
 		break;
 
+	case 82:        /* Relay Agent Information Option */
+		vti = proto_tree_add_text(bp_tree, tvb, voff, consumed,
+					  "Option %d: %s (%d bytes)",
+					  code, text, vlen);
+		v_tree = proto_item_add_subtree(vti, ett_bootp_option);
+		optp = voff+2;
+		while (optp < voff+consumed) {
+			optp = bootp_dhcp_decode_agent_info(v_tree, tvb, optp);
+		}
+		break;
+
 	default:	/* not special */
 		break;
 	}
@@ -533,6 +547,32 @@
 	}
 
 	return consumed;
+}
+
+static int
+bootp_dhcp_decode_agent_info(proto_tree *v_tree, tvbuff_t *tvb, int optp)
+{
+	guint8 subopt;
+	guint8 subopt_len;
+	
+	subopt = tvb_get_guint8(tvb, optp);
+	subopt_len = tvb_get_guint8(tvb, optp+1);
+	switch (subopt) {
+	case 1:
+		proto_tree_add_text(v_tree, tvb, optp, subopt_len + 2,
+				    "Agent Circuit ID (%d bytes)", subopt_len);
+		break;
+	case 2:
+		proto_tree_add_text(v_tree, tvb, optp, subopt_len + 2,
+				    "Agent Remote ID (%d bytes)", subopt_len);
+		break;
+	default:
+		proto_tree_add_text(v_tree, tvb, optp, subopt_len + 2,
+				    "Unknown agent option: %d", subopt);
+		break;
+	}
+	optp += (subopt_len + 2);
+	return optp;
 }
 
 static int