When dissecting DNS or NBNS queries or replies, add the item to the tree
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 4 Dec 1998 05:59:14 +0000 (05:59 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 4 Dec 1998 05:59:14 +0000 (05:59 +0000)
for the queries or replies first, then create and add the subtree and
populate it, and, when that's done, set the length of the item
appropriately; if you add the subtree later, the subtree's top-level
node appears to have level 0, rather than 1 greater than the tree of
which it's a subtree, which causes those trees not to print correctly.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@122 f5534014-38df-0310-8fa8-9805f1628bb7

packet-dns.c
packet-nbns.c
packet.c
packet.h

index 5416706934bbef84dbb37ca48b52370df82165e9..a7c1f2af92eb615cf18f970e3365e029507e1e0a 100644 (file)
@@ -1,7 +1,7 @@
 /* packet-dns.c
  * Routines for DNS packet disassembly
  *
- * $Id: packet-dns.c,v 1.9 1998/11/17 04:28:51 gerald Exp $
+ * $Id: packet-dns.c,v 1.10 1998/12/04 05:59:10 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -407,14 +407,14 @@ dissect_query_records(const u_char *dns_data_ptr, int count, const u_char *pd,
   int start_off;
   GtkWidget *qatree, *ti;
   
-  qatree = gtk_tree_new();
   start_off = cur_off;
-  
-  while (count-- > 0)
-    cur_off += dissect_dns_query(dns_data_ptr, pd, cur_off, qatree);
   ti = add_item_to_tree(GTK_WIDGET(dns_tree), 
-                       start_off, cur_off - start_off, "Queries");
+                       start_off, 0, "Queries");
+  qatree = gtk_tree_new();
   add_subtree(ti, qatree, ETT_DNS_QRY);
+  while (count-- > 0)
+    cur_off += dissect_dns_query(dns_data_ptr, pd, cur_off, qatree);
+  set_item_len(ti, cur_off - start_off);
 
   return cur_off - start_off;
 }
@@ -429,13 +429,14 @@ dissect_answer_records(const u_char *dns_data_ptr, int count,
   int start_off;
   GtkWidget *qatree, *ti;
   
-  qatree = gtk_tree_new();
   start_off = cur_off;
-
+  ti = add_item_to_tree(GTK_WIDGET(dns_tree),
+                       start_off, 0, name);
+  qatree = gtk_tree_new();
+  add_subtree(ti, qatree, ETT_DNS_ANS);
   while (count-- > 0)
     cur_off += dissect_dns_answer(dns_data_ptr, pd, cur_off, qatree);
-  ti = add_item_to_tree(GTK_WIDGET(dns_tree), start_off, cur_off - start_off, name);
-  add_subtree(ti, qatree, ETT_DNS_ANS);
+  set_item_len(ti, cur_off - start_off);
 
   return cur_off - start_off;
 }
index c74c1c3eba998804e43b12cbb9cba20b94b9fbfb..e14b637592b3f9f4a7aebf49acb7fc9f3f2898a5 100644 (file)
@@ -3,7 +3,7 @@
  * Gilbert Ramirez <gram@verdict.uthscsa.edu>
  * Much stuff added by Guy Harris <guy@netapp.com>
  *
- * $Id: packet-nbns.c,v 1.9 1998/11/21 04:00:31 guy Exp $
+ * $Id: packet-nbns.c,v 1.10 1998/12/04 05:59:12 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -642,14 +642,14 @@ dissect_query_records(const u_char *nbns_data_ptr, int count, const u_char *pd,
        int start_off;
        GtkWidget *qatree, *ti;
        
-       qatree = gtk_tree_new();
        start_off = cur_off;
-       
-       while (count-- > 0)
-               cur_off += dissect_nbns_query(nbns_data_ptr, pd, cur_off, qatree);
        ti = add_item_to_tree(GTK_WIDGET(nbns_tree), 
-                       start_off, cur_off - start_off, "Queries");
+                       start_off, 0, "Queries");
+       qatree = gtk_tree_new();
        add_subtree(ti, qatree, ETT_NBNS_QRY);
+       while (count-- > 0)
+               cur_off += dissect_nbns_query(nbns_data_ptr, pd, cur_off, qatree);
+       set_item_len(ti, cur_off - start_off);
 
        return cur_off - start_off;
 }
@@ -663,15 +663,15 @@ dissect_answer_records(const u_char *nbns_data_ptr, int count,
        int start_off;
        GtkWidget *qatree, *ti;
        
-       qatree = gtk_tree_new();
        start_off = cur_off;
-
+       ti = add_item_to_tree(GTK_WIDGET(nbns_tree),
+                       start_off, 0, name);
+       qatree = gtk_tree_new();
+       add_subtree(ti, qatree, ETT_NBNS_ANS);
        while (count-- > 0)
                cur_off += dissect_nbns_answer(nbns_data_ptr, pd, cur_off,
                                        qatree, opcode);
-       ti = add_item_to_tree(GTK_WIDGET(nbns_tree), start_off, cur_off - start_off, name);
-       add_subtree(ti, qatree, ETT_NBNS_ANS);
-
+       set_item_len(ti, cur_off - start_off);
        return cur_off - start_off;
 }
 
index 0c4a5c6d75797119cf04aa36e6a377c21b1b97cc..7e67701fb0d83963bb4813924c5f67d5a344d56f 100644 (file)
--- a/packet.c
+++ b/packet.c
@@ -1,7 +1,7 @@
 /* packet.c
  * Routines for packet disassembly
  *
- * $Id: packet.c,v 1.12 1998/11/18 03:01:38 gerald Exp $
+ * $Id: packet.c,v 1.13 1998/12/04 05:59:13 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -167,6 +167,12 @@ add_item_to_tree(GtkWidget *tree, gint start, gint len,
   return ti;
 }
 
+void
+set_item_len(GtkWidget *ti, gint len)
+{
+  gtk_object_set_data(GTK_OBJECT(ti), E_TREEINFO_LEN_KEY, (gpointer) len);
+}
+
 void
 add_subtree(GtkWidget *ti, GtkWidget *subtree, gint idx) {
   static gint tree_type[NUM_TREE_TYPES];
index ab7a71f1b65d31a7196d3bb317b1f1b79be09117..d5c1a53da25401bd2d0dcd9810d6c753be8978f8 100644 (file)
--- a/packet.h
+++ b/packet.h
@@ -1,7 +1,7 @@
 /* packet.h
  * Definitions for packet disassembly structures and routines
  *
- * $Id: packet.h,v 1.26 1998/11/20 05:58:42 gram Exp $
+ * $Id: packet.h,v 1.27 1998/12/04 05:59:14 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -486,6 +486,7 @@ GtkWidget* add_item_to_tree(GtkWidget *, gint, gint, gchar *, ...)
 #else
 GtkWidget* add_item_to_tree(GtkWidget *, gint, gint, gchar *, ...);
 #endif
+void       set_item_len(GtkWidget *, gint);
 gchar*     val_to_str(guint32, const value_string *, const char *);
 gchar*     match_strval(guint32, const value_string*);
 gint       check_col(frame_data *, gint);