Ethereal-dev: [Ethereal-dev] Ethereal patch for C-HDLC

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

From: Hannes Gredler <hannes@xxxxxxxxxxx>
Date: Fri, 1 Apr 2005 17:05:59 +0200
hi ethereal developers,

pls find attach a patch for the c-hdlc dissector;

the patch adds some heuristics to not insert a
padbyte for the OSI proto-id 0xfefe if the byte
following the proto-id is 0x81,0x82,0x83 (CLNP,ESIS,ISIS);

reason is that older SW releases on Juniper routers does
not insert the padbyte and still be able to decode traces;

this is similar what tcpdump does
  http://cvs.tcpdump.org/cgi-bin/cvsweb/tcpdump/print-chdlc.c?rev=1.31
and is not known to break anything;

/hannes
Index: epan/dissectors/packet-chdlc.c
===================================================================
--- epan/dissectors/packet-chdlc.c	(revision 14000)
+++ epan/dissectors/packet-chdlc.c	(working copy)
@@ -31,6 +31,7 @@
 #include "etypes.h"
 #include <epan/prefs.h>
 #include "chdlctypes.h"
+#include "nlpid.h"
 #include <epan/addr_resolv.h>
 #include "packet-chdlc.h"
 #include "packet-ppp.h"
@@ -127,16 +128,21 @@
 	  int chdlctype_id)
 {
   tvbuff_t   *next_tvb;
+  int padbyte = 0;
 
   if (tree) {
     proto_tree_add_uint(fh_tree, chdlctype_id, tvb,
 			offset_after_chdlctype - 2, 2, chdlctype);
   }
 
-  if (chdlctype == CHDLCTYPE_OSI) {
+  padbyte = tvb_get_guint8(tvb, offset_after_chdlctype);
+  if (chdlctype == CHDLCTYPE_OSI &&
+    !( padbyte == NLPID_ISO8473_CLNP || /* older Juniper SW does not send a padbyte */
+       padbyte == NLPID_ISO9542_ESIS ||
+       padbyte == NLPID_ISO10589_ISIS)) {      
     /* There is a Padding Byte for CLNS protocols over Cisco HDLC */
     proto_tree_add_text(fh_tree, tvb, offset_after_chdlctype, 1, "CLNS Padding: 0x%02x",
-        tvb_get_guint8(tvb, offset_after_chdlctype));
+        padbyte);
     next_tvb = tvb_new_subset(tvb, offset_after_chdlctype + 1, -1, -1);
   } else {
     next_tvb = tvb_new_subset(tvb, offset_after_chdlctype, -1, -1);