From Didier:
authorsahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 7 Apr 2005 12:00:03 +0000 (12:00 +0000)
committersahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 7 Apr 2005 12:00:03 +0000 (12:00 +0000)
optimization for COLUMNS to make ethereal faster when filtering

optimization to make the slow find_protocol_by_id() fast.
(idea from Didier, implementation modified by me to be less intrusive)

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

epan/proto.c
epan/proto.h
gtk/rtp_analysis.c
gtk/sctp_assoc_analyse.c
proto_hier_stats.c

index 6602b14a2df70c7ccba9d39f7b8671f7760c9ce8..e45a77e963d365f15394180bb606023459cfd8e9 100644 (file)
@@ -2442,7 +2442,7 @@ proto_register_protocol(char *name, char *short_name, char *filter_name)
     hfinfo->name = name;
     hfinfo->abbrev = filter_name;
     hfinfo->type = FT_PROTOCOL;
-    hfinfo->strings = NULL;
+    hfinfo->strings = protocol;
     hfinfo->bitmask = 0;
     hfinfo->bitshift = 0;
     hfinfo->blurb = "";
@@ -2515,27 +2515,17 @@ proto_get_next_protocol_field(void **cookie)
        return &ptr->hfinfo;
 }
 
-/*
- * Find the protocol list entry for a protocol given its field ID.
- */
-static gint
-compare_proto_id(gconstpointer proto_arg, gconstpointer id_arg)
-{
-       const protocol_t *protocol = proto_arg;
-       const int *id_ptr = id_arg;
-
-       return (protocol->proto_id == *id_ptr) ? 0 : 1;
-}
-
 protocol_t *
 find_protocol_by_id(int proto_id)
 {
-       GList *list_entry;
+       header_field_info *hfinfo;
 
-       list_entry = g_list_find_custom(protocols, &proto_id, compare_proto_id);
-       if (list_entry == NULL)
+       if(proto_id<0)
                return NULL;
-       return list_entry->data;
+
+       PROTO_REGISTRAR_GET_NTH(proto_id, hfinfo);
+       DISSECTOR_ASSERT(hfinfo->type==FT_PROTOCOL);
+       return (protocol_t *)hfinfo->strings;
 }
 
 static gint compare_filter_name(gconstpointer proto_arg,
@@ -2668,7 +2658,7 @@ proto_register_field_init(header_field_info *hfinfo, int parent)
        DISSECTOR_ASSERT(hfinfo->name);
        DISSECTOR_ASSERT(hfinfo->abbrev);
 
-       /* These types of fields are allowed to have value_strings or true_false_strings */
+       /* These types of fields are allowed to have value_strings, true_false_strings or a protocol_t struct*/
        DISSECTOR_ASSERT((hfinfo->strings == NULL) || (
                        (hfinfo->type == FT_UINT8) ||
                        (hfinfo->type == FT_UINT16) ||
@@ -2679,6 +2669,7 @@ proto_register_field_init(header_field_info *hfinfo, int parent)
                        (hfinfo->type == FT_INT24) ||
                        (hfinfo->type == FT_INT32) ||
                        (hfinfo->type == FT_BOOLEAN) ||
+                       (hfinfo->type == FT_PROTOCOL) ||
                        (hfinfo->type == FT_FRAMENUM) ));
 
        switch (hfinfo->type) {
index b91cc77b0efbc0906f01df6386208050c8d8dfb9..db01f62935bf6588c8d88ff17319e73a79d51a25 100644 (file)
@@ -147,7 +147,7 @@ struct _header_field_info {
        char                            *abbrev;    /**< abbreviated name of this field */
        enum ftenum                     type;       /**< field type, one of FT_ (from ftypes.h) */
        int                                     display;        /**< one of BASE_, or number of field bits for FT_BOOLEAN */
-       const void                      *strings;       /**< _value_string (or true_false_string for FT_BOOLEAN), typically converted by VALS() or TFS() */
+       const void                      *strings;       /**< _value_string (or true_false_string for FT_BOOLEAN), typically converted by VALS() or TFS() If this is an FT_PROTOCOL then it points to the associated protocol_t structure*/
        guint32                         bitmask;    /**< FT_BOOLEAN only: bitmask of interesting bits */
        char                            *blurb;         /**< Brief description of field. */
 
index b1f4ab43ae0550407aca785e45f08c1fc4360190..a488468e3b3489c4ac3a5e4627b40b806f9c2326 100644 (file)
@@ -3549,7 +3549,7 @@ void rtp_analysis_cb(GtkWidget *w _U_, gpointer data _U_)
        }
        edt = epan_dissect_new(TRUE, FALSE);
        epan_dissect_prime_dfilter(edt, sfcode);
-       epan_dissect_run(edt, &cf->pseudo_header, cf->pd, fdata, &cf->cinfo);
+       epan_dissect_run(edt, &cf->pseudo_header, cf->pd, fdata, NULL);
        frame_matched = dfilter_apply_edt(sfcode, edt);
        
        /* if it is not an rtp frame, show the rtpstream dialog */
index 6a76e603fda544b6736f72da6028d0d8fe54f674..87411bdf5a26af32206cd2751ea3b729a5b1595c 100644 (file)
@@ -742,7 +742,7 @@ void sctp_analyse_cb(struct sctp_analyse* u_data)
 
        edt = epan_dissect_new(TRUE, FALSE);
        epan_dissect_prime_dfilter(edt, sfcode);
-       epan_dissect_run(edt, &cf->pseudo_header, cf->pd, fdata, &cf->cinfo);
+       epan_dissect_run(edt, &cf->pseudo_header, cf->pd, fdata, NULL);
        frame_matched = dfilter_apply_edt(sfcode, edt);
 
        /* if it is not an sctp frame, show the dialog */
index 8974e52ac1ca59275887c73ef4d6398a3f0d7be8..995a5c30f779cc84aaf05c32a08a8808cc2fb0fb 100644 (file)
@@ -145,7 +145,7 @@ process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps)
                return FALSE;   /* failure */
        }
 
-       /* Dissect the frame */
+       /* Dissect the frame   tree  not visible */
        edt = epan_dissect_new(TRUE, FALSE);
        epan_dissect_run(edt, &phdr, pd, frame, cinfo);
 
@@ -253,8 +253,9 @@ ph_stats_new(void)
                                ps->first_time = cur_time;
                                ps->last_time = cur_time;
                        }
-
-                       if (!process_frame(frame, &cfile.cinfo, ps)) {
+                       
+                       /* we don't care about colinfo */
+                       if (!process_frame(frame, NULL, ps)) {
                                /*
                                 * Give up, and set "stop_flag" so we
                                 * just abort rather than popping up