Add support for PARAM_ENUM tap parameters, and use the tap_param_dlg
[obnox/wireshark/wip.git] / gtk / gtp_stat.c
index efb7f3a78263313b15f6de21a025f98d11f37857..21b3f51d9eb889b990c59f9bc1dba58e8f229802 100644 (file)
 #include <epan/tap.h>
 #include <epan/dissectors/packet-gtp.h>
 
-#include "../register.h"
 #include "../timestats.h"
 #include "../simple_dialog.h"
 #include "../file.h"
-#include "../globals.h"
 #include "../stat_menu.h"
 
 #include "gtk/gui_utils.h"
 #include "gtk/dlg_utils.h"
-#include "gtk/filter_dlg.h"
 #include "gtk/service_response_time_table.h"
-#include "gtk/tap_dfilter_dlg.h"
+#include "gtk/tap_param_dlg.h"
 #include "gtk/gtkglobals.h"
 #include "gtk/main.h"
 
@@ -87,7 +84,7 @@ gtpstat_packet(void *pgtp, packet_info *pinfo, epan_dissect_t *edt _U_, const vo
 {
        const gtp_msg_hash_t *gtp=psi;
        gtpstat_t *fs=(gtpstat_t *)pgtp;
-       int index=0;
+       int idx=0;
 
        /* we are only interested in reply packets */
        if(gtp->is_request){
@@ -99,25 +96,25 @@ gtpstat_packet(void *pgtp, packet_info *pinfo, epan_dissect_t *edt _U_, const vo
        }
 
        /* Only use the commands we know how to handle, this is not a comprehensive list */
-    /* Redoing the message indexing is bit reduntant,*/
-   /*  but using message type as such would yield a long gtp_srt_table.*/
-   /*  Only a fragtion of the messages are matchable req/resp pairs,*/
-   /*  it's just doesn't feel feasible*/
+       /* Redoing the message indexing is bit reduntant,                    */
+       /*  but using message type as such would yield a long gtp_srt_table. */
+       /*  Only a fraction of the messages are matchable req/resp pairs,    */
+       /*  it just doesn't feel feasible.                                   */
 
        switch(gtp->msgtype){
-       case GTP_MSG_ECHO_REQ: index=0;
-       break;  
-       case GTP_MSG_CREATE_PDP_REQ: index=1;
-       break;
-    case GTP_MSG_UPDATE_PDP_REQ: index=2;
-       break;
-    case GTP_MSG_DELETE_PDP_REQ: index=3;
-       break;
+       case GTP_MSG_ECHO_REQ: idx=0;
+               break;
+       case GTP_MSG_CREATE_PDP_REQ: idx=1;
+               break;
+       case GTP_MSG_UPDATE_PDP_REQ: idx=2;
+               break;
+       case GTP_MSG_DELETE_PDP_REQ: idx=3;
+               break;
        default:
                return 0;
        }
 
-       add_srt_table_data(&fs->gtp_srt_table, index, &gtp->req_time, pinfo);
+       add_srt_table_data(&fs->gtp_srt_table, idx, &gtp->req_time, pinfo);
 
        return 1;
 }
@@ -167,7 +164,9 @@ gtk_gtpstat_init(const char *optarg, void *userdata _U_)
 
        gtp=g_malloc(sizeof(gtpstat_t));
 
-       gtp->win=window_new(GTK_WINDOW_TOPLEVEL, "gtp-stat");
+       gtp->win = dlg_window_new("gtp-stat");  /* transient_for top_level */
+       gtk_window_set_destroy_with_parent (GTK_WINDOW(gtp->win), TRUE);
+
        gtk_window_set_default_size(GTK_WINDOW(gtp->win), 550, 400);
        gtpstat_set_title(gtp);
 
@@ -196,9 +195,9 @@ gtk_gtpstat_init(const char *optarg, void *userdata _U_)
        init_srt_table_row(&gtp->gtp_srt_table, 2, "Update PDP context");
        init_srt_table_row(&gtp->gtp_srt_table, 3, "Delete PDP context");
 
-       error_string=register_tap_listener("gtp", gtp, filter, gtpstat_reset, gtpstat_packet, gtpstat_draw);
+       error_string=register_tap_listener("gtp", gtp, filter, 0, gtpstat_reset, gtpstat_packet, gtpstat_draw);
        if(error_string){
-               simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, error_string->str);
+               simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
                g_string_free(error_string, TRUE);
                g_free(gtp);
                return;
@@ -217,15 +216,21 @@ gtk_gtpstat_init(const char *optarg, void *userdata _U_)
        gtk_widget_show_all(gtp->win);
        window_present(gtp->win);
 
-       cf_retap_packets(&cfile, FALSE);
+       cf_retap_packets(&cfile);
        gdk_window_raise(gtp->win->window);
 }
 
-static tap_dfilter_dlg gtp_stat_dlg = {
+static tap_param gtp_stat_params[] = {
+       { PARAM_FILTER, "Filter", NULL }
+};
+
+static tap_param_dlg gtp_stat_dlg = {
        "GTP Control Plane Response Time Statistics",
        "gtp",
        gtk_gtpstat_init,
-       -1
+       -1,
+       G_N_ELEMENTS(gtp_stat_params),
+       gtp_stat_params
 };
 
 void