Fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8908 :
[metze/wireshark/wip.git] / proto_hier_stats.c
index 1265c816fcad4899952dc4eb9f23e774e4206afb..4ff34ba10b34dae1cd2e49db96575567984ffe7c 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
 
 #include <stdio.h>
 
 #include "globals.h"
 #include "proto_hier_stats.h"
+#include "frame_tvbuff.h"
 #include "ui/progress_dlg.h"
 #include <epan/epan_dissect.h>
 #include <wtap.h>
@@ -87,8 +86,9 @@ process_node(proto_node *ptree_node, GNode *parent_stat_node, ph_stats_t *ps, gu
        GNode                   *stat_node;
 
        finfo = PNODE_FINFO(ptree_node);
-       /* We don't fake protocol nodes we expect them to have a field_info */
-       g_assert(finfo && "dissection with faked proto tree?");
+       /* We don't fake protocol nodes we expect them to have a field_info.
+        * Dissection with faked proto tree? */
+       g_assert(finfo);
 
        /* If the field info isn't related to a protocol but to a field,
         * don't count them, as they don't belong to any protocol.
@@ -141,19 +141,20 @@ static gboolean
 process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps)
 {
        epan_dissect_t                  edt;
-       union wtap_pseudo_header        phdr;
-       guint8                          pd[WTAP_MAX_PACKET_SIZE];
+       struct wtap_pkthdr              phdr;
+       Buffer                          buf;
        double                          cur_time;
 
        /* Load the frame from the capture file */
-       if (!cf_read_frame_r(&cfile, frame, &phdr, pd))
+       buffer_init(&buf, 1500);
+       if (!cf_read_frame_r(&cfile, frame, &phdr, &buf))
                return FALSE;   /* failure */
 
        /* Dissect the frame   tree  not visible */
        epan_dissect_init(&edt, TRUE, FALSE);
        /* Don't fake protocols. We need them for the protocol hierarchy */
        epan_dissect_fake_protocols(&edt, FALSE);
-       epan_dissect_run(&edt, &phdr, pd, frame, cinfo);
+       epan_dissect_run(&edt, &phdr, frame_tvbuff_new_buffer(frame, &buf), frame, cinfo);
 
        /* Get stats from this protocol tree */
        process_tree(edt.tree, ps, frame->pkt_len);
@@ -169,6 +170,7 @@ process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps)
 
        /* Free our memory. */
        epan_dissect_cleanup(&edt);
+       buffer_free(&buf);
 
        return TRUE;    /* success */
 }
@@ -224,7 +226,8 @@ ph_stats_new(void)
                   to get to the next progress bar step). */
                if (progbar == NULL)
                        progbar = delayed_create_progress_dlg(
-                           "Computing", "protocol hierarchy statistics",
+                           cfile.window, "Computing",
+                           "protocol hierarchy statistics",
                            TRUE, &stop_flag, &start_time, progbar_val);
 
                /* Update the progress bar, but do it only N_PROGBAR_UPDATES