Ethereal-dev: [Ethereal-dev] more verbose IS-IS dissector ...

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: Thu, 29 Aug 2002 11:20:38 +0200
hi ethereal dedvelopers,

pls find attached a patch that makes IS-IS more verbose in the INFO field;

specifically for
  IIHs  the System-ID of the Hello
  LSPs  the LSP-ID, Sequence #, Lifetime
  CSNPs the LAN-ID, Start LSP-ID, End LSP-ID

/hannes


? epan/COS-TEst-RSVP.doc
Index: packet-esis.c
===================================================================
RCS file: /cvsroot/ethereal/packet-esis.c,v
retrieving revision 1.26
diff -u -r1.26 packet-esis.c
--- packet-esis.c	2002/08/02 23:35:49	1.26
+++ packet-esis.c	2002/08/28 13:19:36
@@ -32,6 +32,7 @@
 #include <string.h>
 #include <glib.h>
 #include <epan/packet.h>
+#include <epan/resolv.h>
 #include "nlpid.h"
 #include "packet-osi.h"
 #include "packet-osi-options.h"
@@ -442,4 +443,7 @@
 
   esis_handle = create_dissector_handle(dissect_esis, proto_esis);
   dissector_add("osinl", NLPID_ISO9542_ESIS, esis_handle);
+
+  /* lets register the well-known MAC address */
+  add_eth_byname("\x09\x00\x2b\x00\x00\x04","AllESs");
 }
Index: packet-isis-hello.c
===================================================================
RCS file: /cvsroot/ethereal/packet-isis-hello.c,v
retrieving revision 1.31
diff -u -r1.31 packet-isis-hello.c
--- packet-isis-hello.c	2002/08/02 23:35:51	1.31
+++ packet-isis-hello.c	2002/08/28 13:19:40
@@ -625,7 +625,7 @@
  *	void, will modify proto_tree if not NULL.
  */	
 void 
-isis_dissect_isis_hello(tvbuff_t *tvb, proto_tree *tree, int offset,
+isis_dissect_isis_hello(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,
 	int hello_type, int header_length, int id_length)
 {
 	proto_item	*ti;
@@ -656,9 +656,13 @@
 		source_id = tvb_get_ptr(tvb, offset, id_length);
 		proto_tree_add_bytes_format(hello_tree, hf_isis_hello_source_id, tvb,
 			            offset, id_length, source_id,
-			            "SystemID{ Sender of PDU } : %s", 
+			            "System-ID {Sender of PDU} : %s", 
 			            print_system_id( source_id, id_length ) );
         }
+        if (check_col(pinfo->cinfo, COL_INFO)) {
+            col_append_fstr(pinfo->cinfo, COL_INFO, ", System-ID: %s",
+                         print_system_id( tvb_get_ptr(tvb, offset, id_length), id_length ) );
+        }
 	offset += id_length;
 
 	if (tree) {
@@ -696,7 +700,7 @@
 			lan_id = tvb_get_ptr(tvb, offset, id_length+1);
 			proto_tree_add_bytes_format(hello_tree, hf_isis_hello_lan_id, tvb, 
 		                     offset, id_length + 1, lan_id,
-				         "SystemID{ Designated IS } : %s",
+				         "System-ID {Designated IS} : %s",
 					      print_system_id( lan_id, id_length + 1 ) );
 		}
 		offset += id_length + 1;
Index: packet-isis-hello.h
===================================================================
RCS file: /cvsroot/ethereal/packet-isis-hello.h,v
retrieving revision 1.8
diff -u -r1.8 packet-isis-hello.h
--- packet-isis-hello.h	2002/04/07 22:36:55	1.8
+++ packet-isis-hello.h	2002/08/28 13:19:40
@@ -105,7 +105,7 @@
  * Published API functions.  NOTE, this are "local" API functions and
  * are only valid from with isis decodes.
  */
-extern void isis_dissect_isis_hello(tvbuff_t *tvb, proto_tree *tree,
+extern void isis_dissect_isis_hello(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
 	int offset, int hello_type, int header_length,int id_length);
 extern void isis_register_hello(int proto_isis);
 
Index: packet-isis-lsp.c
===================================================================
RCS file: /cvsroot/ethereal/packet-isis-lsp.c,v
retrieving revision 1.33
diff -u -r1.33 packet-isis-lsp.c
--- packet-isis-lsp.c	2002/08/04 09:08:03	1.33
+++ packet-isis-lsp.c	2002/08/28 13:19:48
@@ -1524,7 +1524,7 @@
  *      void, but we will add to proto tree if !NULL.
  */
 void 
-isis_dissect_isis_lsp(tvbuff_t *tvb, proto_tree *tree, int offset,
+isis_dissect_isis_lsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,
 	int lsp_type, int header_length, int id_length)
 {
 	proto_item	*ti;
@@ -1554,8 +1554,12 @@
 
 	if (tree) {
 		isis_lsp_decode_lsp_id(tvb, lsp_tree, offset, 
-			"LSP ID", id_length);
+			"LSP-ID", id_length);
 	}
+        if (check_col(pinfo->cinfo, COL_INFO)) {
+            col_append_fstr(pinfo->cinfo, COL_INFO, ", LSP-ID: %s",
+                         print_system_id( tvb_get_ptr(tvb, offset, id_length+2), id_length+2 ) );
+        }
 	offset += id_length + 2;
 
 	if (tree) {
@@ -1563,6 +1567,11 @@
 			offset, 4, 
 			tvb_get_ntohl(tvb, offset));
 	}
+        if (check_col(pinfo->cinfo, COL_INFO)) {
+            col_append_fstr(pinfo->cinfo, COL_INFO, ", Sequence: 0x%08x, Lifetime: %5us",
+                         tvb_get_ntohl(tvb, offset),
+                         tvb_get_ntohs(tvb, offset - (id_length+2+2)));
+        }
 	offset += 4;
 
 	if (tree) {
Index: packet-isis-lsp.h
===================================================================
RCS file: /cvsroot/ethereal/packet-isis-lsp.h,v
retrieving revision 1.12
diff -u -r1.12 packet-isis-lsp.h
--- packet-isis-lsp.h	2002/04/07 22:36:55	1.12
+++ packet-isis-lsp.h	2002/08/28 13:19:49
@@ -108,7 +108,7 @@
  * Published API functions.  NOTE, this are "local" API functions and
  * are only valid from with isis decodes.
  */
-extern void isis_dissect_isis_lsp(tvbuff_t *tvb, proto_tree *tree,
+extern void isis_dissect_isis_lsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
 	int offset, int hello_type, int header_length, int id_length);
 extern void isis_lsp_decode_lsp_id(tvbuff_t *tvb, proto_tree *tree,
 	int offset, char *tstr, int id_length);
Index: packet-isis-snp.c
===================================================================
RCS file: /cvsroot/ethereal/packet-isis-snp.c,v
retrieving revision 1.17
diff -u -r1.17 packet-isis-snp.c
--- packet-isis-snp.c	2002/08/02 23:35:52	1.17
+++ packet-isis-snp.c	2002/08/28 13:19:51
@@ -230,7 +230,7 @@
  *      void, but we will add to proto tree if !NULL.
  */
 void 
-isis_dissect_isis_csnp(tvbuff_t *tvb, proto_tree *tree, int offset,
+isis_dissect_isis_csnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,
 	int type, int header_length, int id_length)
 {
 	proto_item	*ti;
@@ -253,21 +253,33 @@
 
 	if (tree) {
 		proto_tree_add_text(csnp_tree, tvb, offset, id_length + 1, 
-			"Source id    : %s",
+			"Source-ID:    %s",
 				print_system_id( tvb_get_ptr(tvb, offset, id_length+1), id_length+1 ) );
 	}
+        if (check_col(pinfo->cinfo, COL_INFO)) {
+            col_append_fstr(pinfo->cinfo, COL_INFO, ", Source-ID: %s",
+                         print_system_id( tvb_get_ptr(tvb, offset, id_length+1), id_length+1 ) );
+        }
 	offset += id_length + 1;
 
 	if (tree) {
 		isis_lsp_decode_lsp_id(tvb, csnp_tree, offset,
-			"Start LSP id ", id_length );
+			"Start LSP-ID", id_length );
 	}
+        if (check_col(pinfo->cinfo, COL_INFO)) {
+            col_append_fstr(pinfo->cinfo, COL_INFO, ", Start LSP-ID: %s",
+                         print_system_id( tvb_get_ptr(tvb, offset, id_length+2), id_length+2 ) );
+        }
 	offset += id_length + 2;
 
 	if (tree) {
 		isis_lsp_decode_lsp_id(tvb, csnp_tree, offset,
-			 "End   LSP id ", id_length );
+			 "End LSP-ID  ", id_length );
 	}
+        if (check_col(pinfo->cinfo, COL_INFO)) {
+            col_append_fstr(pinfo->cinfo, COL_INFO, ", End LSP-ID: %s",
+                         print_system_id( tvb_get_ptr(tvb, offset, id_length+2), id_length+2 ) );
+        }
 	offset += id_length + 2;
 
 	len = pdu_length - header_length;
@@ -305,7 +317,7 @@
  *      void, but we will add to proto tree if !NULL.
  */
 void 
-isis_dissect_isis_psnp(tvbuff_t *tvb, proto_tree *tree, int offset,
+isis_dissect_isis_psnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,
 	int type, int header_length, int id_length)
 {
 	proto_item	*ti;
@@ -328,9 +340,13 @@
 
 	if (tree) {
 		proto_tree_add_text(psnp_tree, tvb, offset, id_length + 1,
-			"Source id: %s",
+			"Source-ID: %s",
 			print_system_id( tvb_get_ptr(tvb, offset, id_length+1), id_length + 1 ) );
 	}
+        if (check_col(pinfo->cinfo, COL_INFO)) {
+            col_append_fstr(pinfo->cinfo, COL_INFO, ", Source-ID: %s",
+                         print_system_id( tvb_get_ptr(tvb, offset, id_length+1), id_length+1 ) );
+        }
 	offset += id_length + 1;
 
 	len = pdu_length - header_length;
Index: packet-isis-snp.h
===================================================================
RCS file: /cvsroot/ethereal/packet-isis-snp.h,v
retrieving revision 1.5
diff -u -r1.5 packet-isis-snp.h
--- packet-isis-snp.h	2002/04/07 22:36:55	1.5
+++ packet-isis-snp.h	2002/08/28 13:19:51
@@ -63,10 +63,10 @@
  * Published API functions.  NOTE, this are "local" API functions and
  * are only valid from with isis decodes.
  */
-extern void isis_dissect_isis_csnp(tvbuff_t *tvb, proto_tree *tree,
+extern void isis_dissect_isis_csnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
 	int offset, int type, int header_length, int id_length);
 extern void isis_register_csnp(int proto_isis);
-extern void isis_dissect_isis_psnp(tvbuff_t *tvb, proto_tree *tree,
+extern void isis_dissect_isis_psnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
 	int offset, int type, int header_length, int id_length);
 extern void isis_register_psnp(int proto_isis);
 
Index: packet-isis.c
===================================================================
RCS file: /cvsroot/ethereal/packet-isis.c,v
retrieving revision 1.32
diff -u -r1.32 packet-isis.c
--- packet-isis.c	2002/08/02 23:35:52	1.32
+++ packet-isis.c	2002/08/28 13:19:52
@@ -32,6 +32,7 @@
 #include <string.h>
 #include <glib.h>
 #include <epan/packet.h>
+#include <epan/resolv.h>
 #include "nlpid.h"
 #include "packet-osi.h"
 #include "packet-isis.h"
@@ -221,22 +222,22 @@
 	case ISIS_TYPE_L1_HELLO:
 	case ISIS_TYPE_L2_HELLO:
 	case ISIS_TYPE_PTP_HELLO:
-		isis_dissect_isis_hello(tvb, isis_tree, offset,
+		isis_dissect_isis_hello(tvb, pinfo, isis_tree, offset,
 			isis_type, isis_header_length, isis_system_id_len);
 		break;
 	case ISIS_TYPE_L1_LSP:
 	case ISIS_TYPE_L2_LSP:
-		isis_dissect_isis_lsp(tvb, isis_tree, offset,
+		isis_dissect_isis_lsp(tvb, pinfo, isis_tree, offset,
 			isis_type, isis_header_length, isis_system_id_len);
 		break;
 	case ISIS_TYPE_L1_CSNP:
 	case ISIS_TYPE_L2_CSNP:
-		isis_dissect_isis_csnp(tvb, isis_tree, offset,
+		isis_dissect_isis_csnp(tvb, pinfo, isis_tree, offset,
 			isis_type, isis_header_length, isis_system_id_len);
 		break;
 	case ISIS_TYPE_L1_PSNP:
 	case ISIS_TYPE_L2_PSNP:
-		isis_dissect_isis_psnp(tvb, isis_tree, offset,
+		isis_dissect_isis_psnp(tvb, pinfo, isis_tree, offset,
 			isis_type, isis_header_length, isis_system_id_len);
 		break;
 	default:
@@ -326,4 +327,9 @@
 
     isis_handle = create_dissector_handle(dissect_isis, proto_isis);
     dissector_add("osinl", NLPID_ISO10589_ISIS, isis_handle);
+
+    /* lets register the well-known MAC addresses */
+    add_eth_byname("\x01\x80\xc2\x00\x00\x14","AllL1ISs");
+    add_eth_byname("\x01\x80\xc2\x00\x00\x15","AllL2ISs");
+    add_eth_byname("\x09\x00\x2b\x00\x00\x05","AllISs");
 }
Index: epan/osi-utils.c
===================================================================
RCS file: /cvsroot/ethereal/epan/osi-utils.c,v
retrieving revision 1.7
diff -u -r1.7 osi-utils.c
--- osi-utils.c	2002/08/02 21:29:39	1.7
+++ osi-utils.c	2002/08/28 13:19:56
@@ -77,11 +77,17 @@
   }  
  
   cur = str;
-  if ( ( 6 == length ) || ( 7 == length ) ) { /* Special case, print as MAC */
+  if ( ( 6 == length ) || /* System-ID */
+       ( 7 == length ) || /* LAN-ID */
+       ( 8 == length )) { /* LSP-ID */
     cur += sprintf(cur, "%02x%02x.%02x%02x.%02x%02x", buffer[0], buffer[1],
                     buffer[2], buffer[3], buffer[4], buffer[5] );
-    if ( 7 == length ) {
-      sprintf( cur, ".%02x", buffer[6] );
+    if ( ( 7 == length ) ||
+         ( 8 == length )) {
+        sprintf( cur, ".%02x", buffer[6] );
+    }
+    if ( 8 == length ) {
+        sprintf( cur, "-%02x", buffer[7] );
     }
   }
   else {
Index: epan/resolv.c
===================================================================
RCS file: /cvsroot/ethereal/epan/resolv.c,v
retrieving revision 1.24
diff -u -r1.24 resolv.c
--- resolv.c	2002/08/02 21:29:40	1.24
+++ resolv.c	2002/08/28 13:20:01
@@ -1300,6 +1300,12 @@
 
 } /* add_ether_byip */
 
+extern void add_eth_byname(const guint8 *addr, const guchar *name)
+{
+    add_eth_name(addr, name);
+
+} /* add_eth_byname */
+
 extern const guchar *get_ipxnet_name(const guint32 addr)
 {
 
Index: epan/resolv.h
===================================================================
RCS file: /cvsroot/ethereal/epan/resolv.h,v
retrieving revision 1.8
diff -u -r1.8 resolv.h
--- resolv.h	2002/01/13 20:35:10	1.8
+++ resolv.h	2002/08/28 13:20:01
@@ -102,6 +102,9 @@
 /* add ethernet address / name corresponding to IP address  */
 extern void add_ether_byip(guint ip, const guint8 *eth);
 
+/* add wellknown ethernet address */
+extern void add_eth_byname(const guint8 *addr, const guchar *name);
+
 /* Translates a string representing the hostname or dotted-decimal IP address
  * into a numeric IP address value, returning TRUE if it succeeds and
  * FALSE if it fails. */
@@ -115,3 +118,4 @@
 gboolean get_host_ipaddr6(const char *host, struct e_in6_addr *addrp);
 
 #endif /* __RESOLV_H__ */
+