Ethereal-dev: [ethereal-dev] l2tp error code AVP fix

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

From: Florian Lohoff <flo@xxxxxxxxxx>
Date: Wed, 22 Mar 2000 10:19:41 +0100
Hi,
here is a patch against packet-l2tp.c containing a fix concerning
Result code and the optional error code which was not displayed.
I think there also was a bug in displaying the optional Error message
which i cant prove because i havnt got any trace or equipment returning
an ascii message but the offset was obviously incorrect.

Index: packet-l2tp.c
===================================================================
RCS file: /cvsroot/ethereal/packet-l2tp.c,v
retrieving revision 1.5
diff -u -r1.5 packet-l2tp.c
--- packet-l2tp.c	2000/03/14 06:03:23	1.5
+++ packet-l2tp.c	2000/03/22 09:19:29
@@ -253,7 +253,8 @@
   unsigned short avp_type;
   unsigned short msg_type;
   unsigned short avp_len;
-  unsigned short error_type;
+  unsigned short result_code;
+  unsigned short error_code;
   unsigned short avp_ver;
   unsigned short avp_rev;
   unsigned short framing;
@@ -395,20 +396,25 @@
                             break;
 
 			case RESULT_ERROR_CODE:
-				if ( avp_len >= 10 ) {
-					memcpy(&error_type,(tmp_ptr+=2),sizeof(unsigned short));
-					error_type=htons(error_type);
+				if ( avp_len >= 8 ) {
+					memcpy(&result_code,(tmp_ptr+=2),sizeof(unsigned short));
+					result_code=htons(result_code);
 					proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 6,
 					  2, rhcode,
-					  " Error Type: %d",  error_type  );
+					  " Result code: %d",  result_code  );
 			
 				}
-
+				if ( avp_len >= 10 ) {
+					memcpy(&error_code,(tmp_ptr+=2),sizeof(unsigned short));
+					error_code=htons(error_code);
+					proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code,offset + 8,
+					  2, rhcode,
+					  " Error code: %d", error_code);
+				}
 				if ( avp_len > 10 ) {
 					memset(error_string,'\0' ,sizeof(error_string));
-					tmp_ptr+=4;
 					strncpy(error_string,(tmp_ptr),(avp_len - 10));
-					proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 9, (avp_len - 10),
+					proto_tree_add_uint_format(l2tp_avp_tree,hf_l2tp_code, offset + 10, (avp_len - 10),
 					  rhcode, " Error Message: %s",  error_string  );
 				}
 				break;
Flo
-- 
Florian Lohoff		flo@xxxxxxxxxx		      	+49-5241-470566
"Technology is a constant battle between manufacturers producing bigger and
more idiot-proof systems and nature producing bigger and better idiots."