hi ethereal developers,

find attached a patch that opens up a new subtree for dissecting
  the lsp-entry TLV;
the isis_lsp_decode_lsp_id() routine is removed
  as the same functionality is better served using print_system_id();
the patch contains also a small bugfix for print_system_id();

/hannes
Index: packet-isis-snp.c
===================================================================
RCS file: /cvsroot/ethereal/packet-isis-snp.c,v
retrieving revision 1.19
diff -u -r1.19 packet-isis-snp.c
--- packet-isis-snp.c   2002/08/29 18:52:51     1.19
+++ packet-isis-snp.c   2002/08/31 22:24:17
@@ -55,15 +55,17 @@
        proto_tree *tree, int offset, int id_length, int length);
 static void dissect_l2_snp_authentication_clv(tvbuff_t *tvb,
        proto_tree *tree, int offset, int id_length, int length);
-static void dissect_snp_lsp_entries(tvbuff_t *tvb,
+static void dissect_csnp_lsp_entries(tvbuff_t *tvb,
        proto_tree *tree, int offset, int id_length, int length);
+static void dissect_psnp_lsp_entries(tvbuff_t *tvb,
+       proto_tree *tree, int offset, int id_length, int length);
 
 static const isis_clv_handle_t clv_l1_csnp_opts[] = {
        {
                ISIS_CLV_L1_CSNP_LSP_ENTRIES,
                "LSP entries",
                &ett_isis_csnp_lsp_entries,
-               dissect_snp_lsp_entries
+               dissect_csnp_lsp_entries
        },
        {
                ISIS_CLV_L1_CSNP_AUTHENTICATION_NS,
@@ -87,7 +89,7 @@
                ISIS_CLV_L2_CSNP_LSP_ENTRIES,
                "LSP entries",
                &ett_isis_csnp_lsp_entries,
-               dissect_snp_lsp_entries
+               dissect_csnp_lsp_entries
        },
        {
                ISIS_CLV_L2_CSNP_AUTHENTICATION_NS,
@@ -111,7 +113,7 @@
                ISIS_CLV_L1_PSNP_LSP_ENTRIES,
                "LSP entries",
                &ett_isis_psnp_lsp_entries,
-               dissect_snp_lsp_entries
+               dissect_psnp_lsp_entries
        },
        {
                ISIS_CLV_L1_PSNP_AUTHENTICATION_NS,
@@ -135,7 +137,7 @@
                ISIS_CLV_L2_PSNP_LSP_ENTRIES,
                "LSP entries",
                &ett_isis_psnp_lsp_entries,
-               dissect_snp_lsp_entries
+               dissect_psnp_lsp_entries
        },
        {
                ISIS_CLV_L2_PSNP_AUTHENTICATION,
@@ -153,6 +155,7 @@
                0, "", NULL, NULL
        }
 };
+
 /*
  * Name: dissect_snp_lsp_entries()
  *
@@ -175,9 +178,11 @@
  *      void, but we will add to proto tree if !NULL.
  */
 static void
-dissect_snp_lsp_entries(tvbuff_t *tvb, proto_tree *tree, int offset,
+dissect_csnp_lsp_entries(tvbuff_t *tvb, proto_tree *tree, int offset,
        int id_length, int length)
 {
+        proto_tree *subtree,*ti;
+
        while ( length > 0 ) {
                if ( length < 2+id_length+2+4+2 ) {
                        isis_dissect_unknown(tvb, tree, offset,
@@ -186,27 +191,77 @@
                        return;
                }
 
-               proto_tree_add_text(tree, tvb, offset, 2, "Remaining life      : %d",
+               ti = proto_tree_add_text(tree, tvb, offset, 16,
+                                    "LSP-ID: %s, Sequence: 0x%08x, Lifetime: %5us, 
Checksum: 0x%04x",
+                                           print_system_id( tvb_get_ptr(tvb, 
offset+2, id_length+2), id_length+2 ),
+                                           tvb_get_ntohl(tvb, offset+10),
+                                           tvb_get_ntohs(tvb, offset),
+                                           tvb_get_ntohs(tvb, offset+14));
+
+                subtree = proto_item_add_subtree(ti,ett_isis_csnp_lsp_entries);
+
+               proto_tree_add_text(subtree, tvb, offset+2, 8,
+                       "LSP-ID:             : %s",
+                       print_system_id( tvb_get_ptr(tvb, offset+2, id_length+2), 
id_length+2 ));
+
+               proto_tree_add_text(subtree, tvb, offset+10, 4,
+                       "LSP Sequence Number : 0x%08x",
+                       tvb_get_ntohl(tvb, offset+10));
+
+               proto_tree_add_text(subtree, tvb, offset, 2,
+                       "Remaining Lifetime  : %us",
                        tvb_get_ntohs(tvb, offset));
-               length -= 2;
-               offset += 2;
+
+               proto_tree_add_text(subtree, tvb, offset+14, 2,
+                       "LSP checksum        : 0x%04x",
+                       tvb_get_ntohs(tvb, offset+14));
+
+               length -= 16;
+               offset += 16;
+       }
+
+}
+static void
+dissect_psnp_lsp_entries(tvbuff_t *tvb, proto_tree *tree, int offset,
+       int id_length, int length)
+{
+        proto_tree *subtree,*ti;
 
-               isis_lsp_decode_lsp_id(tvb, tree, offset,
-                        "LSP ID              ", id_length);
-               length -= id_length + 2;
-               offset += id_length + 2;
-
-               proto_tree_add_text(tree, tvb, offset, 4,
-                       "LSP Sequence Number : 0x%04x",
-                       tvb_get_ntohl(tvb, offset));
-               length -= 4;
-               offset += 4;
+       while ( length > 0 ) {
+               if ( length < 2+id_length+2+4+2 ) {
+                       isis_dissect_unknown(tvb, tree, offset,
+                               "Short SNP header entry (%d vs %d)", length,
+                               2+id_length+2+4+2 );
+                       return;
+               }
+
+               ti = proto_tree_add_text(tree, tvb, offset, 16,
+                                    "LSP-ID: %s, Sequence: 0x%08x, Lifetime: %5us, 
Checksum: 0x%04x",
+                                           print_system_id( tvb_get_ptr(tvb, 
offset+2, id_length+2), id_length+2 ),
+                                           tvb_get_ntohl(tvb, offset+10),
+                                           tvb_get_ntohs(tvb, offset),
+                                           tvb_get_ntohs(tvb, offset+14));
+
+                subtree = proto_item_add_subtree(ti,ett_isis_psnp_lsp_entries);
+
+               proto_tree_add_text(subtree, tvb, offset+2, 8,
+                       "LSP-ID:             : %s",
+                       print_system_id( tvb_get_ptr(tvb, offset+2, id_length+2), 
id_length+2 ));
+
+               proto_tree_add_text(subtree, tvb, offset+10, 4,
+                       "LSP Sequence Number : 0x%08x",
+                       tvb_get_ntohl(tvb, offset+10));
 
-               proto_tree_add_text(tree, tvb, offset, 2,
-                       "LSP checksum        : 0x%02x",
+               proto_tree_add_text(subtree, tvb, offset, 2,
+                       "Remaining Lifetime  : %us",
                        tvb_get_ntohs(tvb, offset));
-               length -= 2;
-               offset += 2;
+
+               proto_tree_add_text(subtree, tvb, offset+14, 2,
+                       "LSP checksum        : 0x%04x",
+                       tvb_get_ntohs(tvb, offset+14));
+
+               length -= 16;
+               offset += 16;
        }
 
 }
@@ -263,8 +318,9 @@
        offset += id_length + 1;
 
        if (tree) {
-               isis_lsp_decode_lsp_id(tvb, csnp_tree, offset,
-                       "Start LSP-ID", id_length );
+               proto_tree_add_text(csnp_tree, tvb, offset, id_length + 2,
+                       "Start LSP-ID: %s",
+                                    print_system_id( tvb_get_ptr(tvb, offset, 
id_length+2), id_length+2 ) );                
        }
        if (check_col(pinfo->cinfo, COL_INFO)) {
                col_append_fstr(pinfo->cinfo, COL_INFO, ", Start LSP-ID: %s",
@@ -273,8 +329,9 @@
        offset += id_length + 2;
 
        if (tree) {
-               isis_lsp_decode_lsp_id(tvb, csnp_tree, offset,
-                        "End LSP-ID  ", id_length );
+               proto_tree_add_text(csnp_tree, tvb, offset, id_length + 2,
+                       "End LSP-ID: %s",
+                                    print_system_id( tvb_get_ptr(tvb, offset, 
id_length+2), id_length+2 ) );  
        }
        if (check_col(pinfo->cinfo, COL_INFO)) {
                col_append_fstr(pinfo->cinfo, COL_INFO, ", End LSP-ID: %s",
Index: packet-isis-lsp.c
===================================================================
RCS file: /cvsroot/ethereal/packet-isis-lsp.c,v
retrieving revision 1.35
diff -u -r1.35 packet-isis-lsp.c
--- packet-isis-lsp.c   2002/08/29 18:52:51     1.35
+++ packet-isis-lsp.c   2002/08/31 22:24:24
@@ -1479,33 +1479,6 @@
 }
 
 /*
- * Name: isis_lsp_decode_lsp_id()
- *
- * Description:
- *     Display a LSP id into the display tree.
- *
- * Input:
- *     tvbuff_t * : tvbuffer for packet data
- *     proto_tree * : tree to display into. REQUIRED
- *     int : offset into packet data where we are.
- *     char * : title string
- *     int : length of IDs in packet.
- *
- * Output:
- *      void, but we will add to proto tree
- */
-void
-isis_lsp_decode_lsp_id(tvbuff_t *tvb, proto_tree *tree, int offset,
-       char *tstr, int id_length)
-{
-       proto_tree_add_text(tree, tvb, offset, id_length + 2,
-               "%s: %s.%02x-%02x", tstr,
-                       print_system_id( tvb_get_ptr(tvb, offset, id_length), 
id_length ),
-                       tvb_get_guint8(tvb, offset+id_length),
-                       tvb_get_guint8(tvb, offset+id_length+1) );
-}
-
-/*
  * Name: isis_dissect_isis_lsp()
  *
  * Description:
@@ -1547,15 +1520,18 @@
        offset += 2;
 
        if (tree) {
-               proto_tree_add_uint(lsp_tree, hf_isis_lsp_remaining_life, tvb,
-                       offset, 2, tvb_get_ntohs(tvb, offset));
+               proto_tree_add_text(lsp_tree, tvb, offset, 2,
+                                    "Remaining Lifetime: %us",
+                                    tvb_get_ntohs(tvb, offset));
        }
        offset += 2;
 
        if (tree) {
-               isis_lsp_decode_lsp_id(tvb, lsp_tree, offset,
-                       "LSP-ID", id_length);
+               proto_tree_add_text(lsp_tree, tvb, offset, id_length + 2,
+                                    "LSP-ID: %s",
+                                    print_system_id( tvb_get_ptr(tvb, offset, 
id_length+2), id_length+2 ) );                
        }
+
        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 ) );
Index: packet-isis-lsp.h
===================================================================
RCS file: /cvsroot/ethereal/packet-isis-lsp.h,v
retrieving revision 1.14
diff -u -r1.14 packet-isis-lsp.h
--- packet-isis-lsp.h   2002/08/29 18:52:51     1.14
+++ packet-isis-lsp.h   2002/08/31 22:24:25
@@ -110,8 +110,6 @@
  */
 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);
 extern void isis_register_lsp(int proto_isis);
 
 #endif /* _PACKET_ISIS_LSP_H */
Index: epan/osi-utils.c
===================================================================
RCS file: /cvsroot/ethereal/epan/osi-utils.c,v
retrieving revision 1.9
diff -u -r1.9 osi-utils.c
--- osi-utils.c 2002/08/29 18:52:54     1.9
+++ osi-utils.c 2002/08/31 22:24:25
@@ -84,10 +84,10 @@
                     buffer[2], buffer[3], buffer[4], buffer[5] );
     if ( ( 7 == length ) ||
          ( 8 == length )) {
-        sprintf( cur, ".%02x", buffer[6] );
+        cur += sprintf( cur, ".%02x", buffer[6] );
     }
     if ( 8 == length ) {
-        sprintf( cur, "-%02x", buffer[7] );
+        cur += sprintf( cur, "-%02x", buffer[7] );
     }
   }
   else {

Reply via email to