Ethereal-dev: [Ethereal-dev] L2TP PPP disconnect cause code patch

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

From: Motonori Shindo <mshindo@xxxxxxxxxxx>
Date: Fri, 19 Oct 2001 16:35:10 +0900 (JST)
Hi,

RFC 3145 (L2TP Disconnect Cause Information) has been
published. Here's a patch to decode this new AVP. I don't have a trace
file that includes this AVP, so it's not thoroughly debugged. If
anyone has such  a trace, I'd be happy to take a look and debug if
necessary.

Regards,

=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=
 +----+----+     
 |.. .|    |     Motonori Shindo
 |_~__|    |     
 | .. |~~_~|     Sr. Systems Engineer
 | .  |    |     CoSine Communications Inc.
 +----+----+     
 C o S i n e     e-mail:  mshindo@xxxxxxxxxxxxx 
Communications
=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=


Index: packet-l2tp.c
===================================================================
RCS file: /cvsroot/ethereal/packet-l2tp.c,v
retrieving revision 1.25
diff -u -r1.25 packet-l2tp.c
--- packet-l2tp.c	2001/10/15 03:27:38	1.25
+++ packet-l2tp.c	2001/10/19 07:41:34
@@ -155,6 +155,13 @@
 	{ 0, NULL },
 };
 
+static const value_string cause_code_direction_vals[] = {
+	{ 0, "global error" },
+	{ 1, "at peer" },
+	{ 2, "at local" },
+	{ 0, NULL },
+};
+
 static const true_false_string l2tp_length_bit_truth =
 	{ "Length field is present", "Length field is not present" };
 
@@ -216,6 +223,7 @@
 #define  PRIVATE_GROUP_ID 37
 #define  RX_CONNECT_SPEED 38
 #define  SEQUENCING_REQUIRED 39
+#define  PPP_DISCONNECT_CAUSE_CODE 46	/* RFC 3145 */
 
 #define NUM_AVP_TYPES  40
 static const value_string avp_type_vals[] = {
@@ -258,6 +266,7 @@
   { PRIVATE_GROUP_ID,          "Private group ID" },
   { RX_CONNECT_SPEED,          "RxConnect Speed" },
   { SEQUENCING_REQUIRED,       "Sequencing Required" },
+  { PPP_DISCONNECT_CAUSE_CODE, "PPP Disconnect Cause Code" },
   { 0,                         NULL }
 };
 
@@ -920,6 +929,40 @@
 			proto_tree_add_text(l2tp_avp_tree, tvb, index, 4,
 			  "Rx Connect Speed: %u",
 			  tvb_get_ntohl(tvb, index));
+			break;
+
+		case PPP_DISCONNECT_CAUSE_CODE:
+			if (avp_len < 2)
+				break;
+			proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
+			  "Disconnect Code: %u",
+			  tvb_get_ntohs(tvb, index));
+			index += 2;
+			avp_len -= 2;
+
+			if (avp_len < 2)
+				break;
+			proto_tree_add_text(l2tp_avp_tree, tvb, index, 2,
+			  "Control Protocol Number: %u",
+			  tvb_get_ntohs(tvb, index));
+			index += 2;
+			avp_len -= 2;
+
+			if (avp_len < 1)
+				break;
+			proto_tree_add_text(l2tp_avp_tree, tvb, index, 1,
+			  "Direction: %s",
+			  val_to_str(tvb_get_guint8(tvb, index), 
+				     cause_code_direction_vals, 
+				     "Reserved (%u)"));
+			index += 1;
+			avp_len -= 1;
+
+			if (avp_len == 0)
+				break;
+			proto_tree_add_text(l2tp_avp_tree, tvb, index, avp_len,
+			  "Message: %.*s", avp_len,
+			  tvb_get_ptr(tvb, index, avp_len));
 			break;
 
 		default: