*
* $Id$
*
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
#include <epan/packet_info.h>
#include <epan/epan.h>
#include <epan/value_string.h>
-
-#include "tap_menu.h"
#include <epan/tap.h>
#include <epan/dissectors/packet-ldap.h>
-#include "../register.h"
+
#include "../timestats.h"
-#include "compat_macros.h"
#include "../simple_dialog.h"
-#include "ui_util.h"
-#include "dlg_utils.h"
#include "../file.h"
-#include "../globals.h"
-#include "filter_dlg.h"
-#include "service_response_time_table.h"
-#include "gtkglobals.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/gtkglobals.h"
+#include "gtk/main.h"
/* used to keep track of the statistics for an entire program interface */
}
static int
-ldapstat_packet(void *pldap, packet_info *pinfo, epan_dissect_t *edt _U_, void *psi)
+ldapstat_packet(void *pldap, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi)
{
- ldap_call_response_t *ldap=(ldap_call_response_t *)psi;
+ const ldap_call_response_t *ldap=psi;
ldapstat_t *fs=(ldapstat_t *)pldap;
/* we are only interested in reply packets */
return 0;
}
/* if we havnt seen the request, just ignore it */
- if(!ldap->req_frame){
+ if(!ldap->req_frame){
return 0;
}
}
-void protect_thread_critical_region(void);
-void unprotect_thread_critical_region(void);
static void
win_destroy_cb(GtkWindow *win _U_, gpointer data)
{
static void
-gtk_ldapstat_init(char *optarg)
+gtk_ldapstat_init(const char *optarg, void *userdata _U_)
{
ldapstat_t *ldap;
- char *filter=NULL;
+ const char *filter=NULL;
GtkWidget *label;
- char filter_string[256];
+ char *filter_string;
GString *error_string;
GtkWidget *vbox;
- GtkWidget *bbox;
- GtkWidget *close_bt;
+ GtkWidget *bbox;
+ GtkWidget *close_bt;
if(!strncmp(optarg,"ldap,srt,",9)){
filter=optarg+9;
ldap=g_malloc(sizeof(ldapstat_t));
- ldap->win=window_new(GTK_WINDOW_TOPLEVEL, "ldap-stat");
+ ldap->win = dlg_window_new("ldap-stat");
+ gtk_window_set_destroy_with_parent (GTK_WINDOW(ldap->win), TRUE);
gtk_window_set_default_size(GTK_WINDOW(ldap->win), 550, 400);
ldapstat_set_title(ldap);
label=gtk_label_new("LDAP Service Response Time statistics");
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
- g_snprintf(filter_string,255,"Filter:%s",filter?filter:"");
+ filter_string = g_strdup_printf("Filter: %s", filter ? filter : "");
label=gtk_label_new(filter_string);
+ g_free(filter_string);
+ gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
label=gtk_label_new("LDAP Commands");
init_srt_table_row(&ldap->ldap_srt_table, 23, "Extended");
- error_string=register_tap_listener("ldap", ldap, filter, ldapstat_reset, ldapstat_packet, ldapstat_draw);
+ error_string=register_tap_listener("ldap", ldap, filter, 0, ldapstat_reset, ldapstat_packet, ldapstat_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(ldap);
return;
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
- close_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
- window_set_cancel_button(ldap->win, close_bt, window_cancel_button_cb);
-
- SIGNAL_CONNECT(ldap->win, "delete_event", window_delete_event_cb, NULL);
- SIGNAL_CONNECT(ldap->win, "destroy", win_destroy_cb, ldap);
-
- gtk_widget_show_all(ldap->win);
- window_present(ldap->win);
-
- retap_packets(&cfile);
-}
-
-
+ close_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
+ window_set_cancel_button(ldap->win, close_bt, window_cancel_button_cb);
-static GtkWidget *dlg=NULL;
-static GtkWidget *filter_entry;
-
-static void
-dlg_destroy_cb(void)
-{
- dlg=NULL;
-}
+ g_signal_connect(ldap->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
+ g_signal_connect(ldap->win, "destroy", G_CALLBACK(win_destroy_cb), ldap);
-static void
-ldapstat_start_button_clicked(GtkWidget *item _U_, gpointer data _U_)
-{
- GString *str;
- char *filter;
+ gtk_widget_show_all(ldap->win);
+ window_present(ldap->win);
- str = g_string_new("ldap,srt");
- filter=(char *)gtk_entry_get_text(GTK_ENTRY(filter_entry));
- if(filter[0]!=0){
- g_string_sprintfa(str,",%s", filter);
- }
- gtk_ldapstat_init(str->str);
- g_string_free(str, TRUE);
+ cf_retap_packets(&cfile);
+ gdk_window_raise(ldap->win->window);
}
-static void
-gtk_ldapstat_cb(GtkWidget *w _U_, gpointer d _U_)
-{
- GtkWidget *dlg_box;
- GtkWidget *filter_box, *filter_bt;
- GtkWidget *bbox, *start_button, *cancel_button;
- const char *filter;
- static construct_args_t args = {
- "Service Response Time Statistics Filter",
- TRUE,
- FALSE
- };
-
- /* if the window is already open, bring it to front */
- if(dlg){
- gdk_window_raise(dlg->window);
- return;
- }
-
- dlg=dlg_window_new("Ethereal: Compute LDAP Service Response Time statistics");
- gtk_window_set_default_size(GTK_WINDOW(dlg), 300, -1);
-
- dlg_box=gtk_vbox_new(FALSE, 10);
- gtk_container_border_width(GTK_CONTAINER(dlg_box), 10);
- gtk_container_add(GTK_CONTAINER(dlg), dlg_box);
- gtk_widget_show(dlg_box);
-
- /* Filter box */
- filter_box=gtk_hbox_new(FALSE, 3);
-
- /* Filter button */
- filter_bt=BUTTON_NEW_FROM_STOCK(ETHEREAL_STOCK_DISPLAY_FILTER_ENTRY);
- SIGNAL_CONNECT(filter_bt, "clicked", display_filter_construct_cb, &args);
- gtk_box_pack_start(GTK_BOX(filter_box), filter_bt, FALSE, FALSE, 0);
- gtk_widget_show(filter_bt);
-
- /* Filter entry */
- filter_entry=gtk_entry_new();
- SIGNAL_CONNECT(filter_entry, "changed", filter_te_syntax_check_cb, NULL);
-
- /* filter prefs dialog */
- OBJECT_SET_DATA(filter_bt, E_FILT_TE_PTR_KEY, filter_entry);
- /* filter prefs dialog */
-
- gtk_box_pack_start(GTK_BOX(filter_box), filter_entry, TRUE, TRUE, 0);
- filter=gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
- if(filter){
- gtk_entry_set_text(GTK_ENTRY(filter_entry), filter);
- }
- gtk_widget_show(filter_entry);
-
- gtk_box_pack_start(GTK_BOX(dlg_box), filter_box, TRUE, TRUE, 0);
- gtk_widget_show(filter_box);
-
- /* button box */
- bbox = dlg_button_row_new(ETHEREAL_STOCK_CREATE_STAT, GTK_STOCK_CANCEL, NULL);
- gtk_box_pack_start(GTK_BOX(dlg_box), bbox, FALSE, FALSE, 0);
- gtk_widget_show(bbox);
-
- start_button = OBJECT_GET_DATA(bbox, ETHEREAL_STOCK_CREATE_STAT);
- SIGNAL_CONNECT_OBJECT(start_button, "clicked",
- ldapstat_start_button_clicked, NULL);
-
- cancel_button = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
- window_set_cancel_button(dlg, cancel_button, window_cancel_button_cb);
-
- /* Catch the "activate" signal on the filter text entry, so that
- if the user types Return there, we act as if the "Create Stat"
- button had been selected, as happens if Return is typed if some
- widget that *doesn't* handle the Return key has the input
- focus. */
- dlg_set_activate(filter_entry, start_button);
-
- gtk_widget_grab_default(start_button );
-
- /* Give the initial focus to the "Filter" entry box. */
- gtk_widget_grab_focus(filter_entry);
-
- SIGNAL_CONNECT(dlg, "destroy", dlg_destroy_cb, NULL);
-
- gtk_widget_show_all(dlg);
- window_present(dlg);
-}
+static tap_dfilter_dlg ldap_stat_dlg = {
+ "LDAP Service Response Time Statistics",
+ "ldap,srt",
+ gtk_ldapstat_init,
+ -1
+};
void
register_tap_listener_gtkldapstat(void)
{
- register_ethereal_tap("ldap,srt", gtk_ldapstat_init);
-
- register_tap_menu_item("LDAP...", REGISTER_TAP_GROUP_RESPONSE_TIME,
- gtk_ldapstat_cb, NULL, NULL, NULL);
+ register_dfilter_stat(&ldap_stat_dlg, "LDAP",
+ REGISTER_STAT_GROUP_RESPONSE_TIME);
}