From fa65ee1d1ed6894954c2782f76402b9a37c7d44e Mon Sep 17 00:00:00 2001 From: Gilbert Ramirez Date: Fri, 20 Aug 1999 19:43:10 +0000 Subject: [PATCH] Cleaned up the two routines besides the main display filter mechanism that use display filters, TCP follow and Match Selected. In Match Selected, I made it put the display filter that it creates in the text entry widget. The code was already there, but it didn't work because code was missing in the GUI initialization routine that runs when Ethereal starts. The text entry widget pointer was not being passed to the Match Selected menu item. In TCP follow, I made it _not_ put the display filter that it creates in the text entry widget. I find it annoying that a really long display filter is left in the widget, and others have voiced their opinion on this too. In addition, after applying the display filter and retreiving the TCP data, the display filter (if any) that the user had in place _before_ running TCP follow is put back and the packet list is set back to the way it was before TCP follow is run. I think this is more expected. The drawback is that display filtering is run twice, once to retreive the TCP data and once to reset the display. svn path=/trunk/; revision=529 --- ethereal.c | 63 +++++++++++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 39 deletions(-) diff --git a/ethereal.c b/ethereal.c index 6f409b710d..ce380d8ce9 100644 --- a/ethereal.c +++ b/ethereal.c @@ -1,6 +1,6 @@ /* ethereal.c * - * $Id: ethereal.c,v 1.97 1999/08/20 04:41:31 guy Exp $ + * $Id: ethereal.c,v 1.98 1999/08/20 19:43:10 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -193,11 +193,8 @@ void follow_stream_cb( GtkWidget *w, gpointer data ) { char filename1[128+1]; GtkWidget *streamwindow, *box, *text, *vscrollbar, *table; - GtkWidget *filter_te = NULL; int tmp_fd; - - if (w) - filter_te = gtk_object_get_data(GTK_OBJECT(w), E_DFILTER_TE_KEY); + gchar *old_dfilter; if( pi.ipproto == 6 ) { /* we got tcp so we can follow */ @@ -224,23 +221,20 @@ follow_stream_cb( GtkWidget *w, gpointer data ) { return; } - /* Delete any display filter we currently have. */ - if( cf.dfilter != NULL ) { - /* get rid of this one */ - g_free( cf.dfilter ); - cf.dfilter = NULL; - } + /* Save any display filter we currently have. */ + old_dfilter = cf.dfilter; /* Create a new filter that matches all packets in the TCP stream, and set the display filter entry accordingly */ reset_tcp_reassembly(); cf.dfilter = build_follow_filter( &pi ); - if (filter_te) - gtk_entry_set_text(GTK_ENTRY(filter_te), cf.dfilter); + /* Run the display filter so it goes in effect. */ filter_packets(&cf); + /* the data_out_file should now be full of the streams information */ fclose( data_out_file ); + /* the filename1 file now has all the text that was in the session */ streamwindow = gtk_window_new( GTK_WINDOW_TOPLEVEL); gtk_widget_set_name( streamwindow, "TCP stream window" ); @@ -257,15 +251,18 @@ follow_stream_cb( GtkWidget *w, gpointer data ) { } gtk_widget_set_usize( GTK_WIDGET(streamwindow), DEF_WIDTH, DEF_HEIGHT ); gtk_container_border_width( GTK_CONTAINER(streamwindow), 2 ); + /* setup the container */ box = gtk_vbox_new( FALSE, 0 ); gtk_container_add( GTK_CONTAINER(streamwindow), box ); gtk_widget_show( box ); + /* set up the table we attach to */ table = gtk_table_new( 1, 2, FALSE ); gtk_table_set_col_spacing( GTK_TABLE(table), 0, 2); gtk_box_pack_start( GTK_BOX(box), table, TRUE, TRUE, 0 ); gtk_widget_show( table ); + /* create a text box */ text = gtk_text_new( NULL, NULL ); gtk_text_set_editable( GTK_TEXT(text), FALSE); @@ -273,12 +270,14 @@ follow_stream_cb( GtkWidget *w, gpointer data ) { GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0 ); gtk_widget_show(text); + /* create the scrollbar */ vscrollbar = gtk_vscrollbar_new( GTK_TEXT(text)->vadj ); gtk_table_attach( GTK_TABLE(table), vscrollbar, 1, 2, 0, 1, GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0 ); gtk_widget_show( vscrollbar ); gtk_widget_realize( text ); + /* stop the updates while we fill the text box */ gtk_text_freeze( GTK_TEXT(text) ); data_out_file = fopen( filename1, "r" ); @@ -307,8 +306,9 @@ follow_stream_cb( GtkWidget *w, gpointer data ) { gtk_widget_show( streamwindow ); if( cf.dfilter != NULL ) { g_free( cf.dfilter ); - cf.dfilter = NULL; } + cf.dfilter = old_dfilter; + filter_packets(&cf); } else { simple_dialog(ESD_TYPE_WARN, NULL, "Error following stream. Please make\n" @@ -326,7 +326,6 @@ match_selected_cb(GtkWidget *w, gpointer data) int i; guint8 *c; - if (w) filter_te = gtk_object_get_data(GTK_OBJECT(w), E_DFILTER_TE_KEY); if (tree_selected_start<0) { @@ -337,26 +336,12 @@ match_selected_cb(GtkWidget *w, gpointer data) return; } -/* sprintf(buf, "("); ptr = buf+strlen(buf); - for (i=0, c=cf.pd+tree_selected_start; i+4