1999-09-11 12:38:18 +00:00
/* main.c
1998-09-16 03:22:19 +00:00
*
2004-07-18 00:24:25 +00:00
* $ Id $
1998-09-16 02:39:15 +00:00
*
2006-05-21 05:12:17 +00:00
* Wireshark - Network traffic analyzer
* By Gerald Combs < gerald @ wireshark . org >
1998-09-16 02:39:15 +00:00
* Copyright 1998 Gerald Combs
*
1999-02-19 05:28:38 +00:00
* Richard Sharpe , 13 - Feb - 1999 , added support for initializing structures
* needed by dissect routines
2001-03-23 14:44:04 +00:00
* Jeff Foster , 2001 / 03 / 12 , added support tabbed hex display windowss
2002-08-28 21:04:11 +00:00
*
*
1998-09-16 02:39:15 +00:00
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
2002-08-28 21:04:11 +00:00
*
1998-09-16 02:39:15 +00:00
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
2002-08-28 21:04:11 +00:00
*
1998-09-16 02:39:15 +00:00
* 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 .
*/
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include <gtk/gtk.h>
2006-11-18 05:05:18 +00:00
# include <gdk/gdkkeysyms.h>
1998-09-16 02:39:15 +00:00
# include <string.h>
2001-12-04 07:32:05 +00:00
# include <ctype.h>
1999-07-13 02:53:26 +00:00
2002-10-25 00:29:12 +00:00
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
1999-06-14 21:46:36 +00:00
# ifdef NEED_STRERROR_H
# include "strerror.h"
# endif
2000-03-28 20:20:11 +00:00
# ifdef NEED_GETOPT_H
# include "getopt.h"
# endif
2004-09-11 23:03:36 +00:00
# ifdef _WIN32 /* Needed for console I/O */
2001-02-20 04:09:37 +00:00
# include <fcntl.h>
# include <conio.h>
# endif
2006-09-12 20:23:57 +00:00
# ifdef HAVE_LIBPORTAUDIO
# include <portaudio.h>
# endif /* HAVE_LIBPORTAUDIO */
2002-01-21 07:37:49 +00:00
# include <epan/epan.h>
2001-04-02 09:53:46 +00:00
# include <epan/filesystem.h>
2006-02-06 03:11:34 +00:00
# include <epan/privileges.h>
2002-01-21 07:37:49 +00:00
# include <epan/epan_dissect.h>
# include <epan/timestamp.h>
# include <epan/packet.h>
2004-05-20 12:01:13 +00:00
# include <epan/plugins.h>
# include <epan/dfilter/dfilter.h>
# include <epan/strutil.h>
2004-08-06 19:57:49 +00:00
# include <epan/addr_resolv.h>
2005-09-01 09:03:29 +00:00
# include <epan/emem.h>
2006-02-07 22:08:12 +00:00
# include <epan/ex-opt.h>
2006-02-06 23:54:54 +00:00
# include <epan/funnel.h>
2006-09-22 23:49:08 +00:00
# include <epan/expert.h>
2007-08-17 19:34:14 +00:00
# include <epan/frequency-utils.h>
2004-05-20 12:01:13 +00:00
/* general (not GTK specific) */
1998-09-16 02:39:15 +00:00
# include "file.h"
2004-05-20 12:01:13 +00:00
# include "summary.h"
2001-01-28 04:52:29 +00:00
# include "filters.h"
2003-08-07 00:41:28 +00:00
# include "disabled_protos.h"
2004-09-27 22:55:15 +00:00
# include <epan/prefs.h>
2004-07-19 21:42:01 +00:00
# include "filter_dlg.h"
2004-05-20 12:01:13 +00:00
# include "layout_prefs.h"
2000-11-21 23:54:10 +00:00
# include "color.h"
2003-01-08 01:59:42 +00:00
# include "color_filters.h"
1998-09-16 02:39:15 +00:00
# include "print.h"
2004-05-20 12:01:13 +00:00
# include "simple_dialog.h"
# include "register.h"
2004-10-01 08:33:53 +00:00
# include <epan/prefs-int.h>
2004-05-20 12:01:13 +00:00
# include "ringbuffer.h"
2005-08-20 12:09:48 +00:00
# include "../ui_util.h"
2004-09-29 00:06:36 +00:00
# include <epan/tap.h>
2005-08-20 20:06:05 +00:00
# include <epan/stat_cmd_args.h>
2004-05-20 12:01:13 +00:00
# include "util.h"
2004-09-10 22:47:02 +00:00
# include "clopts_common.h"
2005-11-17 05:59:21 +00:00
# include "cmdarg_err.h"
2004-05-20 12:01:13 +00:00
# include "version_info.h"
2004-07-04 12:15:41 +00:00
# include "merge.h"
2006-08-26 17:55:21 +00:00
# include "u3.h"
2007-02-09 03:11:14 +00:00
# include "uat_gui.h"
2006-08-26 17:55:21 +00:00
2005-03-07 10:19:33 +00:00
2001-11-09 07:44:51 +00:00
# ifdef HAVE_LIBPCAP
2005-12-06 00:07:13 +00:00
# include "capture-pcap-util.h"
2005-03-07 10:19:33 +00:00
# include "capture.h"
2005-12-03 19:32:54 +00:00
# include "capture_sync.h"
2001-11-09 07:44:51 +00:00
# endif
2005-03-07 10:19:33 +00:00
2004-09-11 23:03:36 +00:00
# ifdef _WIN32
2004-05-20 12:01:13 +00:00
# include "capture-wpcap.h"
2005-05-20 22:23:00 +00:00
# include "capture_wpcap_packet.h"
2006-03-08 20:55:32 +00:00
# include <tchar.h> /* Needed for Unicode */
2006-02-16 15:27:03 +00:00
# if GTK_MAJOR_VERSION >= 2
# include <commctrl.h>
# endif /* GTK_MAJOR_VERSION >= 2 */
# endif /* _WIN32 */
2005-03-07 10:19:33 +00:00
2004-12-02 19:41:56 +00:00
# if GTK_MAJOR_VERSION < 2 && GTK_MINOR_VERSION < 3
2004-12-02 03:12:24 +00:00
# include "ethclist.h"
2004-12-02 19:41:56 +00:00
# endif
2004-05-20 12:01:13 +00:00
/* GTK related */
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
# include "statusbar.h"
2004-02-11 00:55:28 +00:00
# include "alert_box.h"
2006-04-30 01:47:58 +00:00
#if 0
2003-08-19 20:35:33 +00:00
# include "dlg_utils.h"
2006-04-30 01:47:58 +00:00
# endif
# include "file_dlg.h"
2004-05-20 12:01:13 +00:00
# include "gtkglobals.h"
# include "colors.h"
2005-08-20 12:09:48 +00:00
# include "gui_utils.h"
2004-05-20 12:01:13 +00:00
# include "compat_macros.h"
# include "main.h"
# include "menu.h"
2005-02-06 23:16:05 +00:00
# include "../main_window.h"
2004-05-20 12:01:13 +00:00
# include "../menu.h"
2006-04-29 23:03:57 +00:00
# include "capture_file_dlg.h"
2004-09-29 02:54:22 +00:00
# include <epan/column.h>
1999-09-09 02:42:40 +00:00
# include "proto_draw.h"
# include "keys.h"
2000-02-29 06:24:41 +00:00
# include "packet_win.h"
2003-10-15 19:40:42 +00:00
# include "toolbar.h"
2003-10-10 08:39:24 +00:00
# include "find_dlg.h"
2004-01-09 08:36:23 +00:00
# include "packet_list.h"
2004-01-19 00:42:12 +00:00
# include "recent.h"
2004-01-20 18:47:25 +00:00
# include "follow_dlg.h"
2004-06-17 16:35:26 +00:00
# include "font_utils.h"
2004-07-04 12:15:41 +00:00
# include "about_dlg.h"
2004-09-16 22:07:03 +00:00
# include "help_dlg.h"
2004-09-07 16:19:56 +00:00
# include "decode_as_dlg.h"
2005-01-17 21:48:51 +00:00
# include "webbrowser.h"
2005-02-05 23:12:44 +00:00
# include "capture_dlg.h"
2005-02-07 00:54:46 +00:00
# include "capture_ui_utils.h"
2005-05-26 17:50:27 +00:00
# include "log.h"
2005-07-22 07:46:58 +00:00
# include "../epan/emem.h"
2005-11-06 22:43:25 +00:00
# include "file_util.h"
2007-04-22 15:45:34 +00:00
# if GTK_MAJOR_VERSION >= 2
2007-08-22 18:56:20 +00:00
# ifdef HAVE_LIBPCAP
2006-06-02 05:43:38 +00:00
# include "../image/wsicon16.xpm"
# include "../image/wsicon32.xpm"
# include "../image/wsicon48.xpm"
# include "../image/wsicon64.xpm"
2006-06-07 04:03:18 +00:00
# include "../image/wsiconcap16.xpm"
# include "../image/wsiconcap32.xpm"
# include "../image/wsiconcap48.xpm"
2007-04-22 15:45:34 +00:00
# endif
2007-08-22 18:56:20 +00:00
# endif
2007-02-19 01:19:36 +00:00
# ifdef SHOW_WELCOME_PAGE
2007-01-31 03:08:39 +00:00
# include "../image/wssplash.xpm"
2007-02-19 01:19:36 +00:00
# endif
1999-04-06 16:24:50 +00:00
2006-08-16 18:01:25 +00:00
# ifdef HAVE_AIRPCAP
# include <airpcap.h>
# include "airpcap_loader.h"
# include "airpcap_dlg.h"
# include "airpcap_gui_utils.h"
# include "./gtk/toolbar.h"
# include "./image/toolbar/wep_closed_24.xpm"
# endif
2001-04-03 05:26:27 +00:00
2006-12-05 19:24:25 +00:00
# ifdef HAVE_AIRPDCAP
/* Davide Schiera (2006-11-22): including AirPDcap project */
2006-12-28 17:22:12 +00:00
# include <epan/crypt/airpdcap_ws.h>
2006-12-05 19:24:25 +00:00
/* Davide Schiera (2006-11-22) ---------------------------------------------- */
# endif
2004-06-01 17:33:37 +00:00
/*
2005-07-19 20:44:45 +00:00
* Files under personal and global preferences directories in which
2006-05-22 07:29:40 +00:00
* GTK settings for Wireshark are stored .
2004-06-01 17:33:37 +00:00
*/
# define RC_FILE "gtkrc"
# ifdef HAVE_LIBPCAP
# define DEF_READY_MESSAGE " Ready to load or capture"
# else
# define DEF_READY_MESSAGE " Ready to load file"
# endif
2000-06-27 04:36:03 +00:00
capture_file cfile ;
2003-08-19 10:09:20 +00:00
GtkWidget * main_display_filter_widget = NULL ;
2004-01-09 08:36:23 +00:00
GtkWidget * top_level = NULL , * tree_view , * byte_nb_ptr , * tv_scrollw ;
2007-06-04 20:15:10 +00:00
GtkWidget * pkt_scrollw ;
2004-08-31 02:49:28 +00:00
static GtkWidget * main_pane_v1 , * main_pane_v2 , * main_pane_h1 , * main_pane_h2 ;
2004-05-20 12:01:13 +00:00
static GtkWidget * main_first_pane , * main_second_pane ;
static GtkWidget * status_pane ;
2007-06-04 20:15:10 +00:00
static GtkWidget * menubar , * main_vbox , * main_tb , * stat_hbox , * filter_tb ;
2007-08-30 00:24:40 +00:00
static GtkWidget * priv_warning_dialog ;
2006-08-16 18:01:25 +00:00
# ifdef HAVE_AIRPCAP
GtkWidget * airpcap_tb ;
2006-11-05 00:54:17 +00:00
static GtkWidget * driver_warning_dialog ;
static int airpcap_dll_ret_val = - 1 ;
2006-08-16 18:01:25 +00:00
# endif
2007-08-30 00:24:40 +00:00
static GtkWidget * info_bar ;
2004-02-03 00:16:59 +00:00
static GtkWidget * packets_bar = NULL ;
2005-02-05 23:12:44 +00:00
static GtkWidget * welcome_pane ;
2006-10-19 00:48:03 +00:00
static guint main_ctx , file_ctx , help_ctx ;
2004-02-03 00:16:59 +00:00
static guint packets_ctx ;
static gchar * packets_str = NULL ;
2004-05-20 12:01:13 +00:00
GString * comp_info_str , * runtime_info_str ;
2005-02-05 17:53:39 +00:00
gboolean have_capture_file = FALSE ; /* XXX - is there an aquivalent in cfile? */
1998-09-16 02:39:15 +00:00
2004-09-11 23:03:36 +00:00
# ifdef _WIN32
2004-05-13 15:28:02 +00:00
static gboolean has_console ; /* TRUE if app has console */
2001-02-20 04:09:37 +00:00
static void destroy_console ( void ) ;
2005-05-26 17:50:27 +00:00
# endif
2001-02-20 04:09:37 +00:00
static void console_log_handler ( const char * log_domain ,
GLogLevelFlags log_level , const char * message , gpointer user_data ) ;
2004-01-08 20:39:51 +00:00
# ifdef HAVE_LIBPCAP
2003-11-01 02:30:18 +00:00
static gboolean list_link_layer_types ;
2004-12-29 09:09:35 +00:00
capture_options global_capture_opts ;
capture_options * capture_opts = & global_capture_opts ;
2004-01-08 20:39:51 +00:00
# endif
2003-11-01 02:30:18 +00:00
2006-08-16 18:01:25 +00:00
gboolean block_toolbar_signals = FALSE ;
2004-12-29 09:09:35 +00:00
2000-01-15 12:54:24 +00:00
static void create_main_window ( gint , gint , gint , e_prefs * ) ;
2005-02-07 02:09:30 +00:00
static void show_main_window ( gboolean ) ;
static void file_quit_answered_cb ( gpointer dialog , gint btn , gpointer data ) ;
2004-02-01 20:28:11 +00:00
static void main_save_window_geometry ( GtkWidget * widget ) ;
1998-10-12 01:40:57 +00:00
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
# define E_DFILTER_CM_KEY "display_filter_combo"
# define E_DFILTER_FL_KEY "display_filter_list"
1999-06-24 16:25:59 +00:00
/* Match selected byte pattern */
2002-04-08 20:30:56 +00:00
static void
2002-01-11 08:21:02 +00:00
match_selected_cb_do ( gpointer data , int action , gchar * text )
1999-06-24 16:25:59 +00:00
{
1999-11-26 05:23:40 +00:00
GtkWidget * filter_te ;
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
char * cur_filter , * new_filter ;
1999-06-24 16:25:59 +00:00
2007-03-08 23:37:55 +00:00
if ( ( ! text ) | | ( 0 = = strlen ( text ) ) ) {
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " Could not acquire information to build a filter! \n Try expanding or choosing another item. " ) ;
2002-01-11 08:21:02 +00:00
return ;
2007-03-08 23:37:55 +00:00
}
2002-01-11 08:21:02 +00:00
g_assert ( data ) ;
2002-11-10 11:36:39 +00:00
filter_te = OBJECT_GET_DATA ( data , E_DFILTER_TE_KEY ) ;
2002-01-11 08:21:02 +00:00
g_assert ( filter_te ) ;
1999-06-24 16:25:59 +00:00
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
cur_filter = gtk_editable_get_chars ( GTK_EDITABLE ( filter_te ) , 0 , - 1 ) ;
2002-01-11 08:21:02 +00:00
switch ( action & MATCH_SELECTED_MASK ) {
case MATCH_SELECTED_REPLACE :
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
new_filter = g_strdup ( text ) ;
2002-01-11 08:21:02 +00:00
break ;
case MATCH_SELECTED_AND :
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
if ( ( ! cur_filter ) | | ( 0 = = strlen ( cur_filter ) ) )
new_filter = g_strdup ( text ) ;
2002-01-11 08:21:02 +00:00
else
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
new_filter = g_strconcat ( " ( " , cur_filter , " ) && ( " , text , " ) " , NULL ) ;
2002-01-11 08:21:02 +00:00
break ;
case MATCH_SELECTED_OR :
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
if ( ( ! cur_filter ) | | ( 0 = = strlen ( cur_filter ) ) )
new_filter = g_strdup ( text ) ;
2002-01-11 08:21:02 +00:00
else
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
new_filter = g_strconcat ( " ( " , cur_filter , " ) || ( " , text , " ) " , NULL ) ;
2002-01-11 08:21:02 +00:00
break ;
case MATCH_SELECTED_NOT :
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
new_filter = g_strconcat ( " !( " , text , " ) " , NULL ) ;
2002-01-11 08:21:02 +00:00
break ;
case MATCH_SELECTED_AND_NOT :
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
if ( ( ! cur_filter ) | | ( 0 = = strlen ( cur_filter ) ) )
new_filter = g_strconcat ( " !( " , text , " ) " , NULL ) ;
2002-01-11 08:21:02 +00:00
else
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
new_filter = g_strconcat ( " ( " , cur_filter , " ) && !( " , text , " ) " , NULL ) ;
2002-01-11 08:21:02 +00:00
break ;
case MATCH_SELECTED_OR_NOT :
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
if ( ( ! cur_filter ) | | ( 0 = = strlen ( cur_filter ) ) )
new_filter = g_strconcat ( " !( " , text , " ) " , NULL ) ;
2002-01-11 08:21:02 +00:00
else
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
new_filter = g_strconcat ( " ( " , cur_filter , " ) || !( " , text , " ) " , NULL ) ;
2002-01-11 08:21:02 +00:00
break ;
default :
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
g_assert_not_reached ( ) ;
2002-05-03 03:30:15 +00:00
new_filter = NULL ;
2002-01-11 08:21:02 +00:00
break ;
}
1999-06-24 16:25:59 +00:00
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
/* Free up the copy we got of the old filter text. */
g_free ( cur_filter ) ;
2007-03-08 23:37:55 +00:00
/* Don't change the current display filter if we only want to copy the filter */
if ( action & MATCH_SELECTED_COPY_ONLY ) {
GString * gtk_text_str = g_string_new ( " " ) ;
g_string_sprintfa ( gtk_text_str , " %s " , new_filter ) ;
copy_to_clipboard ( gtk_text_str ) ;
g_string_free ( gtk_text_str , TRUE ) ;
} else {
/* create a new one and set the display filter entry accordingly */
gtk_entry_set_text ( GTK_ENTRY ( filter_te ) , new_filter ) ;
1999-11-26 05:23:40 +00:00
2007-03-08 23:37:55 +00:00
/* Run the display filter so it goes in effect. */
if ( action & MATCH_SELECTED_APPLY_NOW )
main_filter_packets ( & cfile , new_filter , FALSE ) ;
}
2002-01-11 08:21:02 +00:00
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
/* Free up the new filter text. */
g_free ( new_filter ) ;
2002-01-11 08:21:02 +00:00
}
void
2004-06-01 17:33:37 +00:00
match_selected_ptree_cb ( GtkWidget * w , gpointer data , MATCH_SELECTED_E action )
2002-01-11 08:21:02 +00:00
{
2006-11-23 21:16:46 +00:00
char * filter ;
if ( cfile . finfo_selected ) {
2006-11-24 18:25:23 +00:00
filter = proto_construct_match_selected_string ( cfile . finfo_selected ,
cfile . edt ) ;
2007-03-08 23:37:55 +00:00
match_selected_cb_do ( ( data ? data : w ) , action , filter ) ;
2006-11-23 21:16:46 +00:00
}
2002-01-11 08:21:02 +00:00
}
2005-01-18 22:24:07 +00:00
static void selected_ptree_info_answered_cb ( gpointer dialog _U_ , gint btn , gpointer data )
{
gchar * selected_proto_url ;
gchar * proto_abbrev = data ;
switch ( btn ) {
case ( ESD_BTN_OK ) :
if ( cfile . finfo_selected ) {
/* open wiki page using the protocol abbreviation */
2006-05-28 17:19:08 +00:00
selected_proto_url = g_strdup_printf ( " http://wiki.wireshark.org/Protocols/%s " , proto_abbrev ) ;
2005-01-18 22:24:07 +00:00
browser_open_url ( selected_proto_url ) ;
g_free ( selected_proto_url ) ;
}
break ;
case ( ESD_BTN_CANCEL ) :
break ;
default :
g_assert_not_reached ( ) ;
}
}
2006-02-16 15:27:03 +00:00
void
2005-01-17 22:25:16 +00:00
selected_ptree_info_cb ( GtkWidget * widget _U_ , gpointer data _U_ )
2005-01-17 21:48:51 +00:00
{
int field_id ;
2005-06-24 02:51:01 +00:00
const gchar * proto_abbrev ;
2005-01-18 22:24:07 +00:00
gpointer dialog ;
2005-01-17 21:48:51 +00:00
if ( cfile . finfo_selected ) {
/* convert selected field to protocol abbreviation */
/* XXX - could this conversion be simplified? */
field_id = cfile . finfo_selected - > hfinfo - > id ;
/* if the selected field isn't a protocol, get it's parent */
if ( ! proto_registrar_is_protocol ( field_id ) ) {
field_id = proto_registrar_get_parent ( cfile . finfo_selected - > hfinfo - > id ) ;
}
2005-01-18 22:24:07 +00:00
proto_abbrev = proto_registrar_get_abbrev ( field_id ) ;
/* ask the user if the wiki page really should be opened */
dialog = simple_dialog ( ESD_TYPE_CONFIRMATION , ESD_BTNS_OK_CANCEL ,
2006-05-28 17:19:08 +00:00
PRIMARY_TEXT_START " Open Wireshark Wiki page of protocol \" %s \" ? " PRIMARY_TEXT_END " \n "
2005-01-18 22:24:07 +00:00
" \n "
2006-05-28 17:19:08 +00:00
" This will open the \" %s \" related Wireshark Wiki page in your Web browser. \n "
2005-01-18 22:24:07 +00:00
" \n "
2006-05-28 17:19:08 +00:00
" The Wireshark Wiki is a collaborative approach to provide information \n "
" about Wireshark in several ways (not limited to protocol specifics). \n "
2005-01-18 22:24:07 +00:00
" \n "
" This Wiki is new, so the page of the selected protocol \n "
" may not exist and/or may not contain valuable information. \n "
" \n "
" As everyone can edit the Wiki and add new content (or extend existing), \n "
" you are encouraged to add information if you can. \n "
" \n "
" Hint 1: If you are new to wiki editing, try out editing the Sandbox first! \n "
" \n "
" Hint 2: If you want to add a new protocol page, you should use the ProtocolTemplate, \n "
" which will save you a lot of editing and will give a consistent look over the pages. " ,
proto_abbrev , proto_abbrev ) ;
2005-08-10 19:49:45 +00:00
simple_dialog_set_cb ( dialog , selected_ptree_info_answered_cb , ( gpointer ) proto_abbrev ) ;
2005-01-17 21:48:51 +00:00
}
}
2006-02-16 15:27:03 +00:00
void
2005-01-19 01:12:45 +00:00
selected_ptree_ref_cb ( GtkWidget * widget _U_ , gpointer data _U_ )
{
int field_id ;
2005-06-24 02:51:01 +00:00
const gchar * proto_abbrev ;
2005-01-19 01:12:45 +00:00
gchar * selected_proto_url ;
if ( cfile . finfo_selected ) {
/* convert selected field to protocol abbreviation */
/* XXX - could this conversion be simplified? */
field_id = cfile . finfo_selected - > hfinfo - > id ;
/* if the selected field isn't a protocol, get it's parent */
if ( ! proto_registrar_is_protocol ( field_id ) ) {
field_id = proto_registrar_get_parent ( cfile . finfo_selected - > hfinfo - > id ) ;
}
proto_abbrev = proto_registrar_get_abbrev ( field_id ) ;
/* open reference page using the protocol abbreviation */
2006-09-18 22:22:44 +00:00
selected_proto_url = g_strdup_printf ( " http://www.wireshark.org/docs/dfref/%c/%s.html " , proto_abbrev [ 0 ] , proto_abbrev ) ;
2005-01-19 01:12:45 +00:00
browser_open_url ( selected_proto_url ) ;
g_free ( selected_proto_url ) ;
}
}
2002-01-11 08:21:02 +00:00
static gchar *
get_text_from_packet_list ( gpointer data )
{
2004-02-06 14:59:52 +00:00
gint row = GPOINTER_TO_INT ( OBJECT_GET_DATA ( data , E_MPACKET_LIST_ROW_KEY ) ) ;
gint column = GPOINTER_TO_INT ( OBJECT_GET_DATA ( data , E_MPACKET_LIST_COL_KEY ) ) ;
2004-01-09 08:36:23 +00:00
frame_data * fdata = ( frame_data * ) packet_list_get_row_data ( row ) ;
2002-01-11 08:21:02 +00:00
epan_dissect_t * edt ;
gchar * buf = NULL ;
int len ;
2002-03-05 05:58:41 +00:00
int err ;
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
gchar * err_info ;
2002-01-11 08:21:02 +00:00
if ( fdata ! = NULL ) {
2003-09-03 23:32:40 +00:00
if ( ! wtap_seek_read ( cfile . wth , fdata - > file_off , & cfile . pseudo_header ,
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
cfile . pd , fdata - > cap_len , & err , & err_info ) ) {
2004-01-31 03:22:42 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK ,
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
cf_read_error_message ( err , err_info ) , cfile . filename ) ;
2003-09-03 23:32:40 +00:00
return NULL ;
}
2002-01-11 08:21:02 +00:00
edt = epan_dissect_new ( FALSE , FALSE ) ;
epan_dissect_run ( edt , & cfile . pseudo_header , cfile . pd , fdata ,
& cfile . cinfo ) ;
epan_dissect_fill_in_columns ( edt ) ;
if ( strlen ( cfile . cinfo . col_expr [ column ] ) ! = 0 & &
strlen ( cfile . cinfo . col_expr_val [ column ] ) ! = 0 ) {
len = strlen ( cfile . cinfo . col_expr [ column ] ) +
strlen ( cfile . cinfo . col_expr_val [ column ] ) + 5 ;
2005-09-01 09:03:29 +00:00
buf = ep_alloc0 ( len ) ;
2004-03-13 15:15:26 +00:00
g_snprintf ( buf , len , " %s == %s " , cfile . cinfo . col_expr [ column ] ,
2002-01-11 08:21:02 +00:00
cfile . cinfo . col_expr_val [ column ] ) ;
}
epan_dissect_free ( edt ) ;
}
2002-08-28 21:04:11 +00:00
2002-01-11 08:21:02 +00:00
return buf ;
}
void
2004-06-01 17:33:37 +00:00
match_selected_plist_cb ( GtkWidget * w _U_ , gpointer data , MATCH_SELECTED_E action )
2002-01-11 08:21:02 +00:00
{
match_selected_cb_do ( data ,
2004-06-01 17:33:37 +00:00
action ,
2002-01-11 08:21:02 +00:00
get_text_from_packet_list ( data ) ) ;
}
2006-05-11 05:08:00 +00:00
/* This function allows users to right click in the details window and copy the text
2006-08-16 18:01:25 +00:00
* information to the operating systems clipboard .
2006-05-11 05:08:00 +00:00
*
* We first check to see if a string representation is setup in the tree and then
* read the string . If not available then we try to grab the value . If all else
* fails we display a message to the user to indicate the copy could not be completed .
*/
void
copy_selected_plist_cb ( GtkWidget * w _U_ , gpointer data _U_ )
{
GString * gtk_text_str = g_string_new ( " " ) ;
char labelstring [ 256 ] ;
char * stringpointer = labelstring ;
if ( cfile . finfo_selected - > rep - > representation ! = 0 ) {
g_string_sprintfa ( gtk_text_str , " %s " , cfile . finfo_selected - > rep - > representation ) ; /* Get the represented data */
}
if ( gtk_text_str - > len = = 0 ) { /* If no representation then... */
proto_item_fill_label ( cfile . finfo_selected , stringpointer ) ; /* Try to read the value */
g_string_sprintfa ( gtk_text_str , " %s " , stringpointer ) ;
}
if ( gtk_text_str - > len = = 0 ) { /* Could not get item so display error msg */
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " Could not acquire information to copy, try expanding or choosing another item " ) ;
}
else
{
copy_to_clipboard ( gtk_text_str ) ; /* Copy string to clipboard */
}
g_string_free ( gtk_text_str , TRUE ) ; /* Free the memory */
}
1999-11-19 22:32:00 +00:00
2003-12-13 18:01:30 +00:00
2004-01-25 18:51:26 +00:00
/* XXX: use a preference for this setting! */
2003-12-13 18:01:30 +00:00
static guint dfilter_combo_max_recent = 10 ;
/* add a display filter to the combo box */
/* Note: a new filter string will replace an old identical one */
static gboolean
dfilter_combo_add ( GtkWidget * filter_cm , char * s ) {
GList * li ;
2005-03-25 22:52:45 +00:00
GList * dfilter_list = OBJECT_GET_DATA ( filter_cm , E_DFILTER_FL_KEY ) ;
2003-12-13 18:01:30 +00:00
/* GtkCombos don't let us get at their list contents easily, so we maintain
our own filter list , and feed it to gtk_combo_set_popdown_strings when
a new filter is added . */
2005-03-25 22:52:45 +00:00
li = g_list_first ( dfilter_list ) ;
2003-12-13 18:01:30 +00:00
while ( li ) {
2006-02-16 15:27:03 +00:00
/* If the filter is already in the list, remove the old one and
2003-12-13 18:01:30 +00:00
* append the new one at the latest position ( at g_list_append ( ) below ) */
if ( li - > data & & strcmp ( s , li - > data ) = = 0 ) {
2005-03-25 22:52:45 +00:00
dfilter_list = g_list_remove ( dfilter_list , li - > data ) ;
2003-12-13 18:01:30 +00:00
break ;
}
li = li - > next ;
}
2005-03-25 22:52:45 +00:00
dfilter_list = g_list_append ( dfilter_list , s ) ;
OBJECT_SET_DATA ( filter_cm , E_DFILTER_FL_KEY , dfilter_list ) ;
gtk_combo_set_popdown_strings ( GTK_COMBO ( filter_cm ) , dfilter_list ) ;
gtk_entry_set_text ( GTK_ENTRY ( GTK_COMBO ( filter_cm ) - > entry ) , g_list_last ( dfilter_list ) - > data ) ;
2003-12-13 18:01:30 +00:00
2003-12-13 22:05:08 +00:00
return TRUE ;
2003-12-13 18:01:30 +00:00
}
2006-02-16 15:27:03 +00:00
/* write all non empty display filters (until maximum count)
2003-12-13 18:01:30 +00:00
* of the combo box GList to the user ' s recent file */
void
2004-01-19 00:42:12 +00:00
dfilter_recent_combo_write_all ( FILE * rf ) {
2003-12-13 18:01:30 +00:00
GtkWidget * filter_cm = OBJECT_GET_DATA ( top_level , E_DFILTER_CM_KEY ) ;
2005-03-25 22:52:45 +00:00
GList * dfilter_list = OBJECT_GET_DATA ( filter_cm , E_DFILTER_FL_KEY ) ;
2003-12-13 18:01:30 +00:00
GList * li ;
2003-12-13 22:05:08 +00:00
guint max_count = 0 ;
2003-12-13 18:01:30 +00:00
/* write all non empty display filter strings to the recent file (until max count) */
2005-03-25 22:52:45 +00:00
li = g_list_first ( dfilter_list ) ;
2003-12-13 18:01:30 +00:00
while ( li & & ( max_count + + < = dfilter_combo_max_recent ) ) {
if ( strlen ( li - > data ) ) {
2003-12-13 22:05:08 +00:00
fprintf ( rf , RECENT_KEY_DISPLAY_FILTER " : %s \n " , ( char * ) li - > data ) ;
}
2003-12-13 18:01:30 +00:00
li = li - > next ;
}
}
2004-01-25 18:51:26 +00:00
/* empty the combobox entry field */
void
dfilter_combo_add_empty ( void ) {
GtkWidget * filter_cm = OBJECT_GET_DATA ( top_level , E_DFILTER_CM_KEY ) ;
gtk_entry_set_text ( GTK_ENTRY ( GTK_COMBO ( filter_cm ) - > entry ) , " " ) ;
}
2003-12-13 18:01:30 +00:00
/* add a display filter coming from the user's recent file to the dfilter combo box */
gboolean
dfilter_combo_add_recent ( gchar * s ) {
GtkWidget * filter_cm = OBJECT_GET_DATA ( top_level , E_DFILTER_CM_KEY ) ;
char * dup ;
dup = g_strdup ( s ) ;
if ( ! dfilter_combo_add ( filter_cm , dup ) ) {
g_free ( dup ) ;
2003-12-13 22:05:08 +00:00
return FALSE ;
2003-12-13 18:01:30 +00:00
}
return TRUE ;
}
2005-02-04 18:44:44 +00:00
/* call cf_filter_packets() and add this filter string to the recent filter list */
2004-02-23 22:48:52 +00:00
gboolean
main_filter_packets ( capture_file * cf , const gchar * dftext , gboolean force )
1999-08-13 23:47:43 +00:00
{
2004-01-25 18:51:26 +00:00
GtkCombo * filter_cm = OBJECT_GET_DATA ( top_level , E_DFILTER_CM_KEY ) ;
2005-03-25 22:52:45 +00:00
GList * dfilter_list = OBJECT_GET_DATA ( filter_cm , E_DFILTER_FL_KEY ) ;
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
GList * li ;
1999-11-25 18:02:25 +00:00
gboolean add_filter = TRUE ;
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
gboolean free_filter = TRUE ;
char * s ;
2005-02-05 12:50:47 +00:00
cf_status_t cf_status ;
2005-02-04 20:54:12 +00:00
2004-01-25 18:51:26 +00:00
s = g_strdup ( dftext ) ;
2002-08-28 21:04:11 +00:00
2007-05-04 11:28:01 +00:00
cf_status = cf_filter_packets ( cf , s , force ) ;
if ( ! s )
return ( cf_status = = CF_OK ) ;
1999-11-25 18:02:25 +00:00
/* GtkCombos don't let us get at their list contents easily, so we maintain
our own filter list , and feed it to gtk_combo_set_popdown_strings when
a new filter is added . */
2005-02-05 12:50:47 +00:00
if ( cf_status = = CF_OK ) {
2005-03-25 22:52:45 +00:00
li = g_list_first ( dfilter_list ) ;
1999-11-25 18:02:25 +00:00
while ( li ) {
if ( li - > data & & strcmp ( s , li - > data ) = = 0 )
add_filter = FALSE ;
li = li - > next ;
}
1999-08-13 23:47:43 +00:00
1999-11-25 18:02:25 +00:00
if ( add_filter ) {
2004-01-25 18:51:26 +00:00
/* trim list size first */
2005-03-25 22:52:45 +00:00
while ( g_list_length ( dfilter_list ) > = dfilter_combo_max_recent ) {
dfilter_list = g_list_remove ( dfilter_list , g_list_first ( dfilter_list ) - > data ) ;
2004-01-25 18:51:26 +00:00
}
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
free_filter = FALSE ;
2005-03-25 22:52:45 +00:00
dfilter_list = g_list_append ( dfilter_list , s ) ;
OBJECT_SET_DATA ( filter_cm , E_DFILTER_FL_KEY , dfilter_list ) ;
gtk_combo_set_popdown_strings ( filter_cm , dfilter_list ) ;
gtk_entry_set_text ( GTK_ENTRY ( filter_cm - > entry ) , g_list_last ( dfilter_list ) - > data ) ;
1999-11-25 18:02:25 +00:00
}
}
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
if ( free_filter )
g_free ( s ) ;
2004-01-25 18:51:26 +00:00
2005-02-05 12:50:47 +00:00
return ( cf_status = = CF_OK ) ;
2004-01-25 18:51:26 +00:00
}
/* Run the current display filter on the current packet set, and
redisplay . */
static void
2004-01-25 22:20:21 +00:00
filter_activate_cb ( GtkWidget * w _U_ , gpointer data )
2004-01-25 18:51:26 +00:00
{
const char * s ;
s = gtk_entry_get_text ( GTK_ENTRY ( data ) ) ;
2004-02-23 22:48:52 +00:00
main_filter_packets ( & cfile , s , FALSE ) ;
1999-07-11 08:40:52 +00:00
}
1999-11-21 15:06:07 +00:00
/* redisplay with no display filter */
static void
2002-03-05 11:56:00 +00:00
filter_reset_cb ( GtkWidget * w , gpointer data _U_ )
1999-11-21 15:06:07 +00:00
{
GtkWidget * filter_te = NULL ;
2002-11-10 11:36:39 +00:00
if ( ( filter_te = OBJECT_GET_DATA ( w , E_DFILTER_TE_KEY ) ) ) {
1999-11-21 15:06:07 +00:00
gtk_entry_set_text ( GTK_ENTRY ( filter_te ) , " " ) ;
}
2007-05-04 11:28:01 +00:00
main_filter_packets ( & cfile , NULL , FALSE ) ;
1999-11-21 15:06:07 +00:00
}
2003-09-12 02:48:23 +00:00
/* mark as reference time frame */
static void
set_frame_reftime ( gboolean set , frame_data * frame , gint row ) {
if ( row = = - 1 )
return ;
if ( set ) {
frame - > flags . ref_time = 1 ;
} else {
frame - > flags . ref_time = 0 ;
}
2005-02-04 18:44:44 +00:00
cf_reftime_packets ( & cfile ) ;
2003-09-12 02:48:23 +00:00
}
2006-06-29 19:04:33 +00:00
GtkWidget * reftime_dialog = NULL ;
static void reftime_answered_cb ( gpointer dialog _U_ , gint btn , gpointer data _U_ )
{
switch ( btn ) {
case ( ESD_BTN_YES ) :
timestamp_set_type ( TS_RELATIVE ) ;
recent . gui_time_format = TS_RELATIVE ;
cf_change_time_formats ( & cfile ) ;
break ;
case ( ESD_BTN_NO ) :
break ;
default :
g_assert_not_reached ( ) ;
}
if ( cfile . current_frame ) {
/* XXX hum, should better have a "cfile->current_row" here ... */
set_frame_reftime ( ! cfile . current_frame - > flags . ref_time ,
cfile . current_frame ,
packet_list_find_row_from_data ( cfile . current_frame ) ) ;
}
}
2006-02-16 15:27:03 +00:00
void
2004-06-01 17:33:37 +00:00
reftime_frame_cb ( GtkWidget * w _U_ , gpointer data _U_ , REFTIME_ACTION_E action )
2003-10-10 08:39:24 +00:00
{
switch ( action ) {
2004-06-01 17:33:37 +00:00
case REFTIME_TOGGLE :
2003-10-10 08:39:24 +00:00
if ( cfile . current_frame ) {
2006-06-29 19:04:33 +00:00
if ( recent . gui_time_format ! = TS_RELATIVE & & cfile . current_frame - > flags . ref_time = = 0 ) {
reftime_dialog = simple_dialog ( ESD_TYPE_CONFIRMATION , ESD_BTNS_YES_NO ,
PRIMARY_TEXT_START " Switch to the appropriate Time Display Format? " PRIMARY_TEXT_END " \n \n "
" Time References don't work well with the currently selected Time Display Format. \n \n "
" Do you want to switch to \" Seconds Since Beginning of Capture \" now? " ) ;
simple_dialog_set_cb ( reftime_dialog , reftime_answered_cb , NULL ) ;
} else {
2006-11-05 00:54:17 +00:00
/* XXX hum, should better have a "cfile->current_row" here ... */
set_frame_reftime ( ! cfile . current_frame - > flags . ref_time ,
cfile . current_frame ,
packet_list_find_row_from_data ( cfile . current_frame ) ) ;
}
2006-06-29 19:04:33 +00:00
}
2003-10-10 08:39:24 +00:00
break ;
2004-06-01 17:33:37 +00:00
case REFTIME_FIND_NEXT :
2003-10-10 08:39:24 +00:00
find_previous_next_frame_with_filter ( " frame.ref_time " , FALSE ) ;
break ;
2004-06-01 17:33:37 +00:00
case REFTIME_FIND_PREV :
2003-10-10 08:39:24 +00:00
find_previous_next_frame_with_filter ( " frame.ref_time " , TRUE ) ;
break ;
2003-09-12 02:48:23 +00:00
}
}
2006-06-12 19:35:26 +00:00
void
2006-06-13 05:36:27 +00:00
find_next_mark_cb ( GtkWidget * w _U_ , gpointer data _U_ , int action _U_ )
2006-06-12 19:35:26 +00:00
{
find_previous_next_frame_with_filter ( " frame.marked == TRUE " , FALSE ) ;
}
void
2006-06-13 05:36:27 +00:00
find_prev_mark_cb ( GtkWidget * w _U_ , gpointer data _U_ , int action _U_ )
2006-06-12 19:35:26 +00:00
{
find_previous_next_frame_with_filter ( " frame.marked == TRUE " , TRUE ) ;
}
2002-11-03 17:38:45 +00:00
# if GTK_MAJOR_VERSION < 2
static void
tree_view_select_row_cb ( GtkCTree * ctree , GList * node , gint column _U_ ,
gpointer user_data _U_ )
# else
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
static void
2002-11-03 17:38:45 +00:00
tree_view_selection_changed_cb ( GtkTreeSelection * sel , gpointer user_data _U_ )
# endif
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
{
2002-11-03 17:38:45 +00:00
field_info * finfo ;
gchar * help_str = NULL ;
gchar len_str [ 2 + 10 + 1 + 5 + 1 ] ; /* ", {N} bytes\0",
N < 4294967296 */
gboolean has_blurb = FALSE ;
guint length = 0 , byte_len ;
GtkWidget * byte_view ;
const guint8 * byte_data ;
# if GTK_MAJOR_VERSION >= 2
GtkTreeModel * model ;
GtkTreeIter iter ;
# endif
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
2002-11-03 17:38:45 +00:00
# if GTK_MAJOR_VERSION >= 2
/* if nothing is selected */
if ( ! gtk_tree_selection_get_selected ( sel , & model , & iter ) )
{
/*
* Which byte view is displaying the current protocol tree
* row ' s data ?
*/
byte_view = get_notebook_bv_ptr ( byte_nb_ptr ) ;
if ( byte_view = = NULL )
return ; /* none */
byte_data = get_byte_view_data_and_length ( byte_view , & byte_len ) ;
if ( byte_data = = NULL )
return ; /* none */
2005-02-04 18:44:44 +00:00
cf_unselect_field ( & cfile ) ;
2006-11-05 00:54:17 +00:00
packet_hex_print ( byte_view , byte_data ,
2002-11-03 17:38:45 +00:00
cfile . current_frame , NULL , byte_len ) ;
return ;
}
gtk_tree_model_get ( model , & iter , 1 , & finfo , - 1 ) ;
# else
g_assert ( node ) ;
finfo = gtk_ctree_node_get_row_data ( ctree , GTK_CTREE_NODE ( node ) ) ;
# endif
if ( ! finfo ) return ;
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
2002-11-03 17:38:45 +00:00
set_notebook_page ( byte_nb_ptr , finfo - > ds_tvb ) ;
2001-03-23 14:44:04 +00:00
2002-11-03 17:38:45 +00:00
byte_view = get_notebook_bv_ptr ( byte_nb_ptr ) ;
byte_data = get_byte_view_data_and_length ( byte_view , & byte_len ) ;
g_assert ( byte_data ! = NULL ) ;
2003-09-24 00:47:37 +00:00
cfile . finfo_selected = finfo ;
2003-09-24 02:36:35 +00:00
set_menus_for_selected_tree_row ( & cfile ) ;
2002-11-03 17:38:45 +00:00
2003-12-03 09:28:26 +00:00
if ( finfo - > hfinfo ) {
if ( finfo - > hfinfo - > blurb ! = NULL & &
finfo - > hfinfo - > blurb [ 0 ] ! = ' \0 ' ) {
2002-11-03 17:38:45 +00:00
has_blurb = TRUE ;
2003-12-03 09:28:26 +00:00
length = strlen ( finfo - > hfinfo - > blurb ) ;
2002-11-03 17:38:45 +00:00
} else {
2003-12-03 09:28:26 +00:00
length = strlen ( finfo - > hfinfo - > name ) ;
2002-11-03 17:38:45 +00:00
}
if ( finfo - > length = = 0 ) {
len_str [ 0 ] = ' \0 ' ;
} else if ( finfo - > length = = 1 ) {
strcpy ( len_str , " , 1 byte " ) ;
} else {
2004-03-13 14:07:14 +00:00
g_snprintf ( len_str , sizeof len_str , " , %d bytes " , finfo - > length ) ;
2002-11-03 17:38:45 +00:00
}
statusbar_pop_field_msg ( ) ; /* get rid of current help msg */
if ( length ) {
2004-03-13 14:07:14 +00:00
help_str = g_strdup_printf ( " %s (%s)%s " ,
2003-12-03 09:28:26 +00:00
( has_blurb ) ? finfo - > hfinfo - > blurb : finfo - > hfinfo - > name ,
finfo - > hfinfo - > abbrev , len_str ) ;
2002-11-03 17:38:45 +00:00
statusbar_push_field_msg ( help_str ) ;
g_free ( help_str ) ;
} else {
2001-04-19 23:06:23 +00:00
/*
2002-11-03 17:38:45 +00:00
* Don ' t show anything if the field name is zero - length ;
* the pseudo - field for " proto_tree_add_text() " is such
* a field , and we don ' t want " Text (text) " showing up
* on the status line if you ' ve selected such a field .
*
* XXX - there are zero - length fields for which we * do *
* want to show the field name .
*
* XXX - perhaps the name and abbrev field should be null
* pointers rather than null strings for that pseudo - field ,
* but we ' d have to add checks for null pointers in some
* places if we did that .
*
* Or perhaps protocol tree items added with
* " proto_tree_add_text() " should have - 1 as the field index ,
* with no pseudo - field being used , but that might also
* require special checks for - 1 to be added .
*/
statusbar_push_field_msg ( " " ) ;
}
}
2000-08-22 19:40:09 +00:00
2006-11-05 00:54:17 +00:00
packet_hex_print ( byte_view , byte_data , cfile . current_frame , finfo ,
byte_len ) ;
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
}
2002-11-03 17:38:45 +00:00
# if GTK_MAJOR_VERSION < 2
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
static void
2002-11-03 17:38:45 +00:00
tree_view_unselect_row_cb ( GtkCTree * ctree _U_ , GList * node _U_ , gint column _U_ ,
gpointer user_data _U_ )
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
{
2001-03-23 14:44:04 +00:00
GtkWidget * byte_view ;
2002-02-18 01:08:44 +00:00
const guint8 * data ;
2002-08-28 21:04:11 +00:00
guint len ;
2001-03-23 14:44:04 +00:00
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
/*
* Which byte view is displaying the current protocol tree
* row ' s data ?
*/
2002-02-18 01:08:44 +00:00
byte_view = get_notebook_bv_ptr ( byte_nb_ptr ) ;
if ( byte_view = = NULL )
return ; /* none */
data = get_byte_view_data_and_length ( byte_view , & len ) ;
if ( data = = NULL )
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
return ; /* none */
2001-03-23 14:44:04 +00:00
2005-02-04 18:44:44 +00:00
cf_unselect_field ( & cfile ) ;
2006-11-05 00:54:17 +00:00
packet_hex_print ( byte_view , data , cfile . current_frame , NULL , len ) ;
1998-09-16 02:39:15 +00:00
}
2002-11-03 17:38:45 +00:00
# endif
1998-09-16 02:39:15 +00:00
2002-03-05 11:56:00 +00:00
void collapse_all_cb ( GtkWidget * widget _U_ , gpointer data _U_ ) {
2001-12-06 04:25:09 +00:00
if ( cfile . edt - > tree )
collapse_all_tree ( cfile . edt - > tree , tree_view ) ;
1999-09-11 12:38:18 +00:00
}
2002-03-05 11:56:00 +00:00
void expand_all_cb ( GtkWidget * widget _U_ , gpointer data _U_ ) {
2001-12-06 04:25:09 +00:00
if ( cfile . edt - > tree )
expand_all_tree ( cfile . edt - > tree , tree_view ) ;
1999-09-11 12:38:18 +00:00
}
2004-03-19 06:23:38 +00:00
void expand_tree_cb ( GtkWidget * widget _U_ , gpointer data _U_ ) {
2006-02-16 15:27:03 +00:00
# if GTK_MAJOR_VERSION < 2
2004-03-19 06:23:38 +00:00
GtkCTreeNode * node ;
# else
GtkTreePath * path ;
# endif
# if GTK_MAJOR_VERSION < 2
node = gtk_ctree_find_by_row_data ( GTK_CTREE ( tree_view ) , NULL , cfile . finfo_selected ) ;
2005-05-18 00:55:44 +00:00
if ( node ) {
/* the mouse position is at an entry, expand that one */
2005-05-20 22:23:00 +00:00
gtk_ctree_expand_recursive ( GTK_CTREE ( tree_view ) , node ) ;
2005-05-18 00:55:44 +00:00
}
2004-03-19 06:23:38 +00:00
# else
2004-03-20 06:34:09 +00:00
path = tree_find_by_field_info ( GTK_TREE_VIEW ( tree_view ) , cfile . finfo_selected ) ;
2005-05-18 00:55:44 +00:00
if ( path ) {
/* the mouse position is at an entry, expand that one */
2005-05-20 22:23:00 +00:00
gtk_tree_view_expand_row ( GTK_TREE_VIEW ( tree_view ) , path , TRUE ) ;
gtk_tree_path_free ( path ) ;
2005-05-18 00:55:44 +00:00
}
2004-03-19 06:23:38 +00:00
# endif
}
2002-03-05 11:56:00 +00:00
void resolve_name_cb ( GtkWidget * widget _U_ , gpointer data _U_ ) {
2001-12-06 04:25:09 +00:00
if ( cfile . edt - > tree ) {
2002-01-13 20:35:12 +00:00
guint32 tmp = g_resolv_flags ;
g_resolv_flags = RESOLV_ALL ;
2001-12-06 04:25:09 +00:00
proto_tree_draw ( cfile . edt - > tree , tree_view ) ;
2002-01-13 20:35:12 +00:00
g_resolv_flags = tmp ;
2000-02-20 14:52:28 +00:00
}
}
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
/*
* Push a message referring to file access onto the statusbar .
*/
void
2007-05-25 19:13:49 +00:00
statusbar_push_file_msg ( const gchar * msg )
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
{
2005-04-10 19:36:56 +00:00
/*g_warning("statusbar_push: %s", msg);*/
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
gtk_statusbar_push ( GTK_STATUSBAR ( info_bar ) , file_ctx , msg ) ;
}
/*
* Pop a message referring to file access off the statusbar .
*/
void
statusbar_pop_file_msg ( void )
{
2005-04-10 19:36:56 +00:00
/*g_warning("statusbar_pop");*/
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
gtk_statusbar_pop ( GTK_STATUSBAR ( info_bar ) , file_ctx ) ;
}
/*
* XXX - do we need multiple statusbar contexts ?
*/
/*
* Push a message referring to the currently - selected field onto the statusbar .
*/
void
2007-05-25 19:13:49 +00:00
statusbar_push_field_msg ( const gchar * msg )
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
{
gtk_statusbar_push ( GTK_STATUSBAR ( info_bar ) , help_ctx , msg ) ;
}
/*
* Pop a message referring to the currently - selected field off the statusbar .
*/
void
statusbar_pop_field_msg ( void )
{
gtk_statusbar_pop ( GTK_STATUSBAR ( info_bar ) , help_ctx ) ;
}
2004-02-03 00:16:59 +00:00
/*
* update the packets statusbar to the current values
*/
void packets_bar_update ( void )
{
if ( packets_bar ) {
/* remove old status */
if ( packets_str ) {
g_free ( packets_str ) ;
gtk_statusbar_pop ( GTK_STATUSBAR ( packets_bar ) , packets_ctx ) ;
}
/* do we have any packets? */
if ( cfile . count ) {
2005-04-18 22:05:56 +00:00
if ( cfile . drops_known ) {
2006-02-16 15:27:03 +00:00
packets_str = g_strdup_printf ( " P: %u D: %u M: %u Drops: %u " ,
2005-04-18 22:05:56 +00:00
cfile . count , cfile . displayed_count , cfile . marked_count , cfile . drops ) ;
} else {
2006-02-16 15:27:03 +00:00
packets_str = g_strdup_printf ( " P: %u D: %u M: %u " ,
2005-04-18 22:05:56 +00:00
cfile . count , cfile . displayed_count , cfile . marked_count ) ;
}
2004-02-03 00:16:59 +00:00
} else {
packets_str = g_strdup ( " No Packets " ) ;
}
gtk_statusbar_push ( GTK_STATUSBAR ( packets_bar ) , packets_ctx , packets_str ) ;
}
}
2005-02-05 17:53:39 +00:00
void
main_set_for_capture_file ( gboolean have_capture_file_in )
{
have_capture_file = have_capture_file_in ;
main_widgets_show_or_hide ( ) ;
}
2004-02-03 00:16:59 +00:00
2004-01-29 23:11:38 +00:00
gboolean
main_do_quit ( void )
2000-02-13 10:36:06 +00:00
{
2005-03-26 01:05:29 +00:00
/* get the current geometry, before writing it to disk */
main_save_window_geometry ( top_level ) ;
2004-02-01 20:28:11 +00:00
2003-12-13 18:01:30 +00:00
/* write user's recent file to disk
* It is no problem to write this file , even if we do not quit */
2005-03-26 01:05:29 +00:00
write_recent ( ) ;
2003-12-13 18:01:30 +00:00
There's no need to catch the "delete_event" signal on "Follow TCP
Stream" windows - the window should always be deleted in that situation,
so there's no need for a signal handler that might return TRUE (meaning
"don't delete the window"), and the "destroy" handler gets called when
the window actually gets destroyed, so there's no need to do any cleanup
in the "delete_event" handler.
Catch the "delete_event" signal on the main window in a routine with the
right signature, and that returns FALSE so that the window actually gets
deleted.
Call "close_cap_file()" in the callback for the "File:Quit" menu item
(which is also called by the "delete_event" handler for the main
window), rather than calling it after "gtk_main()" returns -
"close_cap_file()" manipulates stuff in the main window, and if we do so
after "gtk_main()" returns, it appears that the main window may have
disappeared (if we are exiting because the user deleted the main
window), in which case we can get crashes or other errors when
"close_cap_file()" tries to manipulate stuff in the main window.
There's no need to catch the "destroy" signal on the main window - we do
some of the cleanup in the handler for "delete_event" (we have to, for
reasons described above), and we do the rest of it after the main
routine returns.
svn path=/trunk/; revision=1773
2000-04-01 11:30:53 +00:00
/* XXX - should we check whether the capture file is an
unsaved temporary file for a live capture and , if so ,
pop up a " do you want to exit without saving the capture
file ? " dialog, and then just return, leaving said dialog
box to forcibly quit if the user clicks " OK " ?
If so , note that this should be done in a subroutine that
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
returns TRUE if we do so , and FALSE otherwise , and if it
returns TRUE we should return TRUE without nuking anything .
Note that , if we do that , we might also want to check if
an " Update list of packets in real time " capture is in
progress and , if so , ask whether they want to terminate
the capture and discard it , and return TRUE , before nuking
any child capture , if they say they don ' t want to do so . */
2002-01-10 09:51:23 +00:00
# ifdef HAVE_LIBPCAP
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
/* Nuke any child capture in progress. */
2005-02-05 15:35:25 +00:00
capture_kill_child ( capture_opts ) ;
2002-01-10 09:51:23 +00:00
# endif
There's no need to catch the "delete_event" signal on "Follow TCP
Stream" windows - the window should always be deleted in that situation,
so there's no need for a signal handler that might return TRUE (meaning
"don't delete the window"), and the "destroy" handler gets called when
the window actually gets destroyed, so there's no need to do any cleanup
in the "delete_event" handler.
Catch the "delete_event" signal on the main window in a routine with the
right signature, and that returns FALSE so that the window actually gets
deleted.
Call "close_cap_file()" in the callback for the "File:Quit" menu item
(which is also called by the "delete_event" handler for the main
window), rather than calling it after "gtk_main()" returns -
"close_cap_file()" manipulates stuff in the main window, and if we do so
after "gtk_main()" returns, it appears that the main window may have
disappeared (if we are exiting because the user deleted the main
window), in which case we can get crashes or other errors when
"close_cap_file()" tries to manipulate stuff in the main window.
There's no need to catch the "destroy" signal on the main window - we do
some of the cleanup in the handler for "delete_event" (we have to, for
reasons described above), and we do the rest of it after the main
routine returns.
svn path=/trunk/; revision=1773
2000-04-01 11:30:53 +00:00
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
/* Are we in the middle of reading a capture? */
if ( cfile . state = = FILE_READ_IN_PROGRESS ) {
/* Yes, so we can't just close the file and quit, as
that may yank the rug out from under the read in
progress ; instead , just set the state to
" FILE_READ_ABORTED " and return - the code doing the read
will check for that and , if it sees that , will clean
up and quit . */
cfile . state = FILE_READ_ABORTED ;
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
/* Say that the window should *not* be deleted;
that ' ll be done by the code that cleans up . */
return TRUE ;
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
} else {
/* Close any capture file we have open; on some OSes, you
can ' t unlink a temporary capture file if you have it
open .
2003-09-15 22:48:42 +00:00
" cf_close() " will unlink it after closing it if
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
it ' s a temporary file .
We do this here , rather than after the main loop returns ,
as , after the main loop returns , the main window may have
been destroyed ( if this is called due to a " destroy "
even on the main window rather than due to the user
selecting a menu item ) , and there may be a crash
2003-09-15 22:48:42 +00:00
or other problem when " cf_close() " tries to
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
clean up stuff in the main window .
XXX - is there a better place to put this ?
Or should we have a routine that * just * closes the
capture file , and doesn ' t do anything with the UI ,
which we ' d call here , and another routine that
calls that routine and also cleans up the UI , which
we ' d call elsewhere ? */
2003-09-15 22:48:42 +00:00
cf_close ( & cfile ) ;
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
/* Exit by leaving the main loop, so that any quit functions
we registered get called . */
gtk_main_quit ( ) ;
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
/* Say that the window should be deleted. */
return FALSE ;
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
}
1998-09-16 02:39:15 +00:00
}
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
static gboolean
2002-03-05 11:56:00 +00:00
main_window_delete_event_cb ( GtkWidget * widget _U_ , GdkEvent * event _U_ , gpointer data _U_ )
2003-10-07 04:36:36 +00:00
{
2004-01-29 23:11:38 +00:00
gpointer dialog ;
2004-06-20 15:57:11 +00:00
if ( ( cfile . state ! = FILE_CLOSED ) & & ! cfile . user_saved & & prefs . gui_ask_unsaved ) {
2004-07-12 19:10:58 +00:00
# if GTK_MAJOR_VERSION >= 2
gtk_window_present ( GTK_WINDOW ( top_level ) ) ;
# endif
2004-01-29 23:11:38 +00:00
/* user didn't saved his current file, ask him */
2004-07-13 07:15:45 +00:00
dialog = simple_dialog ( ESD_TYPE_CONFIRMATION , ESD_BTNS_SAVE_DONTSAVE_CANCEL ,
2004-01-31 12:13:23 +00:00
PRIMARY_TEXT_START " Save capture file before program quit? " PRIMARY_TEXT_END " \n \n "
" If you quit the program without saving, your capture data will be discarded. " ) ;
2004-01-29 23:11:38 +00:00
simple_dialog_set_cb ( dialog , file_quit_answered_cb , NULL ) ;
return TRUE ;
} else {
/* unchanged file, just exit */
2004-07-13 07:15:45 +00:00
/* "main_do_quit()" indicates whether the main window should be deleted. */
return main_do_quit ( ) ;
2004-01-29 23:11:38 +00:00
}
2003-10-07 04:36:36 +00:00
}
2004-05-23 17:37:36 +00:00
2004-02-01 20:28:11 +00:00
static void
2004-05-23 17:37:36 +00:00
main_load_window_geometry ( GtkWidget * widget )
2004-02-01 20:28:11 +00:00
{
2004-05-23 17:37:36 +00:00
window_geometry_t geom ;
geom . set_pos = prefs . gui_geometry_save_position ;
geom . x = recent . gui_geometry_main_x ;
geom . y = recent . gui_geometry_main_y ;
geom . set_size = prefs . gui_geometry_save_size ;
2004-07-09 21:13:22 +00:00
if ( recent . gui_geometry_main_width > 0 & &
recent . gui_geometry_main_height > 0 ) {
geom . width = recent . gui_geometry_main_width ;
geom . height = recent . gui_geometry_main_height ;
geom . set_maximized = prefs . gui_geometry_save_maximized ;
} else {
/* We assume this means the width and height weren't set in
the " recent " file ( or that there is no " recent " file ) ,
and weren ' t set to a default value , so we don ' t set the
size . ( The " recent " file code rejects non - positive width
and height values . ) */
geom . set_size = FALSE ;
}
2004-05-23 17:37:36 +00:00
geom . maximized = recent . gui_geometry_main_maximized ;
window_set_geometry ( widget , & geom ) ;
2004-04-25 23:45:12 +00:00
2005-05-30 04:06:22 +00:00
if ( recent . has_gui_geometry_main_upper_pane & & recent . gui_geometry_main_upper_pane )
2004-04-29 17:03:27 +00:00
gtk_paned_set_position ( GTK_PANED ( main_first_pane ) , recent . gui_geometry_main_upper_pane ) ;
2005-05-30 04:06:22 +00:00
if ( recent . has_gui_geometry_main_lower_pane & & recent . gui_geometry_main_lower_pane )
2004-04-29 17:03:27 +00:00
gtk_paned_set_position ( GTK_PANED ( main_second_pane ) , recent . gui_geometry_main_lower_pane ) ;
2005-05-30 04:06:22 +00:00
if ( recent . has_gui_geometry_main_lower_pane & & recent . gui_geometry_status_pane )
2004-04-29 17:03:27 +00:00
gtk_paned_set_position ( GTK_PANED ( status_pane ) , recent . gui_geometry_status_pane ) ;
2004-02-01 20:28:11 +00:00
}
2004-05-23 17:37:36 +00:00
2004-02-01 20:28:11 +00:00
static void
main_save_window_geometry ( GtkWidget * widget )
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
{
2004-05-23 17:37:36 +00:00
window_geometry_t geom ;
2003-10-07 04:36:36 +00:00
2004-05-23 17:37:36 +00:00
window_get_geometry ( widget , & geom ) ;
2004-02-01 20:28:11 +00:00
if ( prefs . gui_geometry_save_position ) {
2004-05-23 17:37:36 +00:00
recent . gui_geometry_main_x = geom . x ;
recent . gui_geometry_main_y = geom . y ;
2004-02-01 20:28:11 +00:00
}
2003-10-07 04:36:36 +00:00
2004-02-01 20:28:11 +00:00
if ( prefs . gui_geometry_save_size ) {
2006-02-16 15:27:03 +00:00
recent . gui_geometry_main_width = geom . width ,
2004-05-23 17:37:36 +00:00
recent . gui_geometry_main_height = geom . height ;
2004-02-01 20:28:11 +00:00
}
2003-10-07 04:36:36 +00:00
2004-02-01 20:28:11 +00:00
# if GTK_MAJOR_VERSION >= 2
if ( prefs . gui_geometry_save_maximized ) {
2004-05-23 17:37:36 +00:00
recent . gui_geometry_main_maximized = geom . maximized ;
2004-02-01 20:28:11 +00:00
}
2004-04-25 23:45:12 +00:00
2004-04-29 17:03:27 +00:00
recent . gui_geometry_main_upper_pane = gtk_paned_get_position ( GTK_PANED ( main_first_pane ) ) ;
recent . gui_geometry_main_lower_pane = gtk_paned_get_position ( GTK_PANED ( main_second_pane ) ) ;
2004-04-27 19:16:11 +00:00
recent . gui_geometry_status_pane = gtk_paned_get_position ( GTK_PANED ( status_pane ) ) ;
2004-02-01 20:28:11 +00:00
# endif
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
}
2004-01-29 23:11:38 +00:00
static void file_quit_answered_cb ( gpointer dialog _U_ , gint btn , gpointer data _U_ )
{
switch ( btn ) {
2004-07-13 07:15:45 +00:00
case ( ESD_BTN_SAVE ) :
2004-01-29 23:11:38 +00:00
/* save file first */
file_save_as_cmd ( after_save_exit , NULL ) ;
break ;
2004-07-13 07:15:45 +00:00
case ( ESD_BTN_DONT_SAVE ) :
main_do_quit ( ) ;
2004-01-29 23:11:38 +00:00
break ;
case ( ESD_BTN_CANCEL ) :
break ;
default :
g_assert_not_reached ( ) ;
}
}
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
void
2004-01-29 23:11:38 +00:00
file_quit_cmd_cb ( GtkWidget * widget _U_ , gpointer data _U_ )
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
{
2004-01-29 23:11:38 +00:00
gpointer dialog ;
2004-06-20 15:57:11 +00:00
if ( ( cfile . state ! = FILE_CLOSED ) & & ! cfile . user_saved & & prefs . gui_ask_unsaved ) {
2004-01-29 23:11:38 +00:00
/* user didn't saved his current file, ask him */
2004-07-13 07:15:45 +00:00
dialog = simple_dialog ( ESD_TYPE_CONFIRMATION , ESD_BTNS_SAVE_DONTSAVE_CANCEL ,
2004-01-31 12:13:23 +00:00
PRIMARY_TEXT_START " Save capture file before program quit? " PRIMARY_TEXT_END " \n \n "
" If you quit the program without saving, your capture data will be discarded. " ) ;
2004-01-29 23:11:38 +00:00
simple_dialog_set_cb ( dialog , file_quit_answered_cb , NULL ) ;
} else {
/* unchanged file, just exit */
2004-07-13 07:15:45 +00:00
main_do_quit ( ) ;
2004-01-29 23:11:38 +00:00
}
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
}
2002-08-28 21:04:11 +00:00
static void
2002-05-22 23:22:56 +00:00
print_usage ( gboolean print_ver ) {
1998-09-16 02:39:15 +00:00
2004-01-18 02:19:07 +00:00
FILE * output ;
2005-06-09 19:58:02 +00:00
# ifdef _WIN32
create_console ( ) ;
# endif
2002-05-22 23:22:56 +00:00
if ( print_ver ) {
2004-01-18 02:19:07 +00:00
output = stdout ;
2006-05-22 07:29:40 +00:00
fprintf ( output , " Wireshark " VERSION " %s \n "
2006-01-12 01:32:06 +00:00
" Interactively dump and analyze network traffic. \n "
2006-05-28 17:19:08 +00:00
" See http://www.wireshark.org for more information. \n "
2005-12-21 08:59:52 +00:00
" \n "
2006-01-12 01:32:06 +00:00
" %s " ,
2007-02-06 02:27:59 +00:00
wireshark_svnversion , get_copyright_info ( ) ) ;
2004-01-18 02:19:07 +00:00
} else {
output = stderr ;
2002-08-28 21:04:11 +00:00
}
2006-01-12 01:32:06 +00:00
fprintf ( output , " \n " ) ;
2006-05-28 17:19:08 +00:00
fprintf ( output , " Usage: wireshark [options] ... [ <infile> ] \n " ) ;
2006-01-12 01:32:06 +00:00
fprintf ( output , " \n " ) ;
1999-12-07 07:12:49 +00:00
# ifdef HAVE_LIBPCAP
2006-01-12 01:32:06 +00:00
fprintf ( output , " Capture interface: \n " ) ;
2006-08-01 19:52:36 +00:00
fprintf ( output , " -i <interface> name or idx of interface (def: first non-loopback) \n " ) ;
2006-01-12 01:32:06 +00:00
fprintf ( output , " -f <capture filter> packet filter in libpcap filter syntax \n " ) ;
fprintf ( output , " -s <snaplen> packet snapshot length (def: 65535) \n " ) ;
fprintf ( output , " -p don't capture in promiscuous mode \n " ) ;
fprintf ( output , " -k start capturing immediately (def: do nothing) \n " ) ;
2006-05-22 07:29:40 +00:00
fprintf ( output , " -Q quit Wireshark after capturing \n " ) ;
2006-01-12 01:32:06 +00:00
fprintf ( output , " -S update packet display when new packets are captured \n " ) ;
fprintf ( output , " -l turn on automatic scrolling while -S is in use \n " ) ;
2005-11-17 04:10:31 +00:00
# ifdef _WIN32
2006-01-12 01:32:06 +00:00
fprintf ( output , " -B <buffer size> size of kernel buffer (def: 1MB) \n " ) ;
1999-12-07 07:12:49 +00:00
# endif
2006-01-12 01:32:06 +00:00
fprintf ( output , " -y <link type> link layer type (def: first appropriate) \n " ) ;
fprintf ( output , " -D print list of interfaces and exit \n " ) ;
fprintf ( output , " -L print list of link-layer types of iface and exit \n " ) ;
fprintf ( output , " \n " ) ;
fprintf ( output , " Capture stop conditions: \n " ) ;
fprintf ( output , " -c <packet count> stop after n packets (def: infinite) \n " ) ;
fprintf ( output , " -a <autostop cond.> ... duration:NUM - stop after NUM seconds \n " ) ;
fprintf ( output , " filesize:NUM - stop this file after NUM KB \n " ) ;
fprintf ( output , " files:NUM - stop after NUM files \n " ) ;
/*fprintf(output, "\n");*/
fprintf ( output , " Capture output: \n " ) ;
fprintf ( output , " -b <ringbuffer opt.> ... duration:NUM - switch to next file after NUM secs \n " ) ;
fprintf ( output , " filesize:NUM - switch to next file after NUM KB \n " ) ;
fprintf ( output , " files:NUM - ringbuffer: replace after NUM files \n " ) ;
# endif /* HAVE_LIBPCAP */
/*fprintf(output, "\n");*/
fprintf ( output , " Input file: \n " ) ;
fprintf ( output , " -r <infile> set the filename to read from (no pipes or stdin!) \n " ) ;
fprintf ( output , " \n " ) ;
fprintf ( output , " Processing: \n " ) ;
2006-05-22 07:29:40 +00:00
fprintf ( output , " -R <read filter> packet filter in Wireshark display filter syntax \n " ) ;
2006-01-12 01:32:06 +00:00
fprintf ( output , " -n disable all name resolutions (def: all enabled) \n " ) ;
fprintf ( output , " -N <name resolve flags> enable specific name resolution(s): \" mntC \" \n " ) ;
fprintf ( output , " \n " ) ;
fprintf ( output , " User interface: \n " ) ;
fprintf ( output , " -g <packet number> go to specified packet number after \" -r \" \n " ) ;
fprintf ( output , " -m <font> set the font name used for most text \n " ) ;
2007-03-23 18:08:17 +00:00
fprintf ( output , " -t ad|a|r|d|dd|e output format of time stamps (def: r: rel. to first) \n " ) ;
2006-02-07 22:08:12 +00:00
fprintf ( output , " -X <key>:<value> eXtension options, see man page for details \n " ) ;
2006-01-12 01:32:06 +00:00
fprintf ( output , " -z <statistics> show various statistics, see man page for details \n " ) ;
fprintf ( output , " \n " ) ;
fprintf ( output , " Output: \n " ) ;
2006-07-04 02:23:15 +00:00
fprintf ( output , " -w <outfile|-> set the output filename (or '-' for stdout) \n " ) ;
2006-01-12 01:32:06 +00:00
fprintf ( output , " \n " ) ;
2006-07-04 02:23:15 +00:00
fprintf ( output , " Miscellaneous: \n " ) ;
fprintf ( output , " -h display this help and exit \n " ) ;
fprintf ( output , " -v display version info and exit \n " ) ;
2007-05-05 12:20:37 +00:00
fprintf ( output , " -P <key>:<path> persconf:path - personal configuration files \n " ) ;
fprintf ( output , " persdata:path - personal data files \n " ) ;
2006-01-12 01:32:06 +00:00
fprintf ( output , " -o <name>:<value> ... override preference or recent setting \n " ) ;
2006-08-13 00:13:22 +00:00
# ifndef _WIN32
fprintf ( output , " --display=DISPLAY X display to use \n " ) ;
# endif
2005-06-09 19:58:02 +00:00
# ifdef _WIN32
destroy_console ( ) ;
# endif
1998-09-16 02:39:15 +00:00
}
2002-08-28 21:04:11 +00:00
static void
2001-02-20 04:09:37 +00:00
show_version ( void )
{
2004-09-11 23:03:36 +00:00
# ifdef _WIN32
2001-02-20 04:09:37 +00:00
create_console ( ) ;
# endif
2005-12-21 08:59:52 +00:00
printf ( PACKAGE " " VERSION " %s \n "
" \n "
" %s "
" \n "
" %s "
" \n "
" %s " ,
2007-02-06 02:27:59 +00:00
wireshark_svnversion , get_copyright_info ( ) , comp_info_str - > str ,
2005-12-21 08:59:52 +00:00
runtime_info_str - > str ) ;
2005-06-09 19:58:02 +00:00
# ifdef _WIN32
destroy_console ( ) ;
# endif
2001-02-20 04:09:37 +00:00
}
2005-11-17 05:59:21 +00:00
/*
* Report an error in command - line arguments .
* Creates a console on Windows .
* XXX - pop this up in a window of some sort on UNIX + X11 if the controlling
* terminal isn ' t the standard error ?
*/
void
cmdarg_err ( const char * fmt , . . . )
{
va_list ap ;
# ifdef _WIN32
create_console ( ) ;
# endif
va_start ( ap , fmt ) ;
2006-05-28 17:19:08 +00:00
fprintf ( stderr , " wireshark: " ) ;
2005-11-17 05:59:21 +00:00
vfprintf ( stderr , fmt , ap ) ;
fprintf ( stderr , " \n " ) ;
va_end ( ap ) ;
}
/*
* Report additional information for an error in command - line arguments .
* Creates a console on Windows .
* XXX - pop this up in a window of some sort on UNIX + X11 if the controlling
* terminal isn ' t the standard error ?
*/
void
cmdarg_err_cont ( const char * fmt , . . . )
{
va_list ap ;
# ifdef _WIN32
create_console ( ) ;
# endif
va_start ( ap , fmt ) ;
vfprintf ( stderr , fmt , ap ) ;
fprintf ( stderr , " \n " ) ;
va_end ( ap ) ;
}
2004-09-11 23:03:36 +00:00
# if defined(_WIN32) || GTK_MAJOR_VERSION < 2 || ! defined USE_THREADS
2006-02-16 15:27:03 +00:00
/*
2002-09-07 10:02:36 +00:00
Once every 3 seconds we get a callback here which we use to update
the tap extensions . Since Gtk1 is single threaded we dont have to
worry about any locking or critical regions .
*/
static gint
update_cb ( gpointer data _U_ )
{
draw_tap_listeners ( FALSE ) ;
return 1 ;
}
2002-11-03 17:38:45 +00:00
# else
2006-05-22 07:29:40 +00:00
/* if these three functions are copied to gtk1 Wireshark, since gtk1 does not
2006-02-16 15:27:03 +00:00
use threads all updte_thread_mutex can be dropped and protect / unprotect
2002-11-03 17:38:45 +00:00
would just be empty functions .
2006-02-16 15:27:03 +00:00
This allows gtk2 - rpcstat . c and friends to be copied unmodified to
2006-05-28 17:19:08 +00:00
gtk1 - wireshark and it will just work .
2002-11-03 17:38:45 +00:00
*/
static GStaticMutex update_thread_mutex = G_STATIC_MUTEX_INIT ;
gpointer
update_thread ( gpointer data _U_ )
{
while ( 1 ) {
GTimeVal tv1 , tv2 ;
g_get_current_time ( & tv1 ) ;
g_static_mutex_lock ( & update_thread_mutex ) ;
gdk_threads_enter ( ) ;
draw_tap_listeners ( FALSE ) ;
gdk_threads_leave ( ) ;
g_static_mutex_unlock ( & update_thread_mutex ) ;
g_thread_yield ( ) ;
g_get_current_time ( & tv2 ) ;
if ( ( ( tv1 . tv_sec + 2 ) * 1000000 + tv1 . tv_usec ) >
( tv2 . tv_sec * 1000000 + tv2 . tv_usec ) ) {
g_usleep ( ( ( tv1 . tv_sec + 2 ) * 1000000 + tv1 . tv_usec ) -
( tv2 . tv_sec * 1000000 + tv2 . tv_usec ) ) ;
}
}
return NULL ;
}
# endif
2002-09-07 10:02:36 +00:00
void
protect_thread_critical_region ( void )
{
2004-09-11 23:03:36 +00:00
# if !defined(_WIN32) && GTK_MAJOR_VERSION >= 2 && defined USE_THREADS
2002-11-03 17:38:45 +00:00
g_static_mutex_lock ( & update_thread_mutex ) ;
# endif
2002-09-07 10:02:36 +00:00
}
void
unprotect_thread_critical_region ( void )
{
2004-09-11 23:03:36 +00:00
# if !defined(_WIN32) && GTK_MAJOR_VERSION >= 2 && defined USE_THREADS
2002-11-03 17:38:45 +00:00
g_static_mutex_unlock ( & update_thread_mutex ) ;
# endif
2002-09-07 10:02:36 +00:00
}
2005-02-07 00:54:46 +00:00
/* Set the file name in the status line, in the name for the main window,
and in the name for the main window ' s icon . */
static void
set_display_filename ( capture_file * cf )
{
const gchar * name_ptr ;
2005-05-26 21:49:48 +00:00
gchar * status_msg ;
2005-02-07 00:54:46 +00:00
gchar * size_str ;
2005-05-26 21:49:48 +00:00
gchar * win_name ;
2005-02-07 00:54:46 +00:00
name_ptr = cf_get_display_name ( cf ) ;
2006-02-16 15:27:03 +00:00
2005-04-12 00:54:52 +00:00
if ( ! cf - > is_tempfile & & cf - > filename ) {
2005-02-07 00:54:46 +00:00
/* Add this filename to the list of recent files in the "Recent Files" submenu */
add_menu_recent_capture_file ( cf - > filename ) ;
}
2005-05-26 21:49:48 +00:00
/* convert file size */
2005-08-19 01:17:24 +00:00
if ( cf - > f_datalen / 1024 / 1024 > 10 ) {
2007-05-29 06:56:07 +00:00
size_str = g_strdup_printf ( " % " G_GINT64_MODIFIER " d MB " , cf - > f_datalen / 1024 / 1024 ) ;
2005-08-19 01:17:24 +00:00
} else if ( cf - > f_datalen / 1024 > 10 ) {
2007-05-29 06:56:07 +00:00
size_str = g_strdup_printf ( " % " G_GINT64_MODIFIER " d KB " , cf - > f_datalen / 1024 ) ;
2005-02-07 00:54:46 +00:00
} else {
2007-05-29 06:56:07 +00:00
size_str = g_strdup_printf ( " % " G_GINT64_MODIFIER " d Bytes " , cf - > f_datalen ) ;
2005-02-07 00:54:46 +00:00
}
2005-05-26 21:49:48 +00:00
/* statusbar */
2006-10-13 18:19:42 +00:00
#if 0
/* XXX - don't show the highest expert level unless the TCP checksum offloading is "solved" */
2006-09-22 23:49:08 +00:00
status_msg = g_strdup_printf ( " File: \" %s \" %s %02lu:%02lu:%02lu [Expert: %s] " ,
2005-06-09 19:55:55 +00:00
( cf - > filename ) ? cf - > filename : " " , size_str ,
2005-08-25 01:16:40 +00:00
( long ) cf - > elapsed_time . secs / 3600 ,
( long ) cf - > elapsed_time . secs % 3600 / 60 ,
2006-09-22 23:49:08 +00:00
( long ) cf - > elapsed_time . secs % 60 ,
val_to_str ( expert_get_highest_severity ( ) , expert_severity_vals , " Unknown (%u) " ) ) ;
2006-10-13 18:19:42 +00:00
# endif
status_msg = g_strdup_printf ( " File: \" %s \" %s %02lu:%02lu:%02lu " ,
( cf - > filename ) ? cf - > filename : " " , size_str ,
( long ) cf - > elapsed_time . secs / 3600 ,
( long ) cf - > elapsed_time . secs % 3600 / 60 ,
( long ) cf - > elapsed_time . secs % 60 ) ;
2005-03-23 22:49:32 +00:00
g_free ( size_str ) ;
2005-05-26 21:49:48 +00:00
statusbar_push_file_msg ( status_msg ) ;
g_free ( status_msg ) ;
2005-02-07 00:54:46 +00:00
2005-05-26 21:49:48 +00:00
/* window title */
2006-05-22 07:29:40 +00:00
win_name = g_strdup_printf ( " %s - Wireshark " , name_ptr ) ;
2005-02-07 00:54:46 +00:00
set_main_window_name ( win_name ) ;
g_free ( win_name ) ;
}
2005-09-20 08:42:35 +00:00
GtkWidget * close_dlg = NULL ;
2005-02-07 00:54:46 +00:00
2007-08-30 00:24:40 +00:00
static void
priv_warning_dialog_cb ( gpointer dialog , gint btn _U_ , gpointer data _U_ )
{
recent . privs_warn_if_elevated = ! simple_dialog_check_get ( dialog ) ;
}
2005-02-07 02:09:30 +00:00
static void
2005-09-20 08:42:35 +00:00
main_cf_cb_file_closing ( capture_file * cf )
2005-02-07 00:54:46 +00:00
{
2005-09-20 08:42:35 +00:00
2006-11-05 00:54:17 +00:00
/* if we have more than 10000 packets, show a splash screen while closing */
/* XXX - don't know a better way to decide wether to show or not,
* as most of the time is spend in a single eth_clist_clear function ,
* so we can ' t use a progress bar here ! */
if ( cf - > count > 10000 ) {
close_dlg = simple_dialog ( ESD_TYPE_STOP , ESD_BTN_NONE ,
" %sClosing file!%s \n \n Please wait ... " ,
simple_dialog_primary_start ( ) ,
simple_dialog_primary_end ( ) ) ;
2005-09-20 08:42:35 +00:00
# if GTK_MAJOR_VERSION >= 2
2006-11-05 00:54:17 +00:00
gtk_window_set_position ( GTK_WINDOW ( close_dlg ) , GTK_WIN_POS_CENTER_ON_PARENT ) ;
2005-09-20 08:42:35 +00:00
# else
2006-11-05 00:54:17 +00:00
gtk_window_set_position ( GTK_WINDOW ( close_dlg ) , GTK_WIN_POS_CENTER ) ;
2005-09-20 08:42:35 +00:00
# endif
2006-11-05 00:54:17 +00:00
}
2005-09-20 08:42:35 +00:00
2005-02-07 00:54:46 +00:00
/* Destroy all windows, which refer to the
capture file we ' re closing . */
2005-12-05 22:45:54 +00:00
destroy_packet_wins ( ) ;
file_save_as_destroy ( ) ;
2005-02-07 00:54:46 +00:00
/* Clear any file-related status bar messages.
XXX - should be " clear *ALL* file-related status bar messages;
will there ever be more than one on the stack ? */
statusbar_pop_file_msg ( ) ;
/* Restore the standard title bar message. */
2006-05-22 07:29:40 +00:00
set_main_window_name ( " The Wireshark Network Analyzer " ) ;
2005-02-07 00:54:46 +00:00
/* Disable all menu items that make sense only if you have a capture. */
2007-03-14 19:30:19 +00:00
set_menus_for_capture_file ( NULL ) ;
2005-02-07 00:54:46 +00:00
set_menus_for_captured_packets ( FALSE ) ;
set_menus_for_selected_packet ( cf ) ;
set_menus_for_capture_in_progress ( FALSE ) ;
set_menus_for_selected_tree_row ( cf ) ;
/* Set up main window for no capture file. */
main_set_for_capture_file ( FALSE ) ;
2005-09-20 08:42:35 +00:00
2005-09-21 01:34:04 +00:00
main_window_update ( ) ;
2005-09-20 08:42:35 +00:00
}
static void
2005-09-21 01:34:04 +00:00
main_cf_cb_file_closed ( capture_file * cf _U_ )
2005-09-20 08:42:35 +00:00
{
if ( close_dlg ! = NULL ) {
2005-09-21 01:34:04 +00:00
splash_destroy ( close_dlg ) ;
close_dlg = NULL ;
2005-09-20 08:42:35 +00:00
}
2005-10-07 04:26:29 +00:00
/* go back to "No packets" */
packets_bar_update ( ) ;
2005-02-07 00:54:46 +00:00
}
2005-02-07 02:09:30 +00:00
static void
2005-02-07 00:54:46 +00:00
main_cf_cb_file_read_start ( capture_file * cf )
{
const gchar * name_ptr ;
gchar * load_msg ;
name_ptr = get_basename ( cf - > filename ) ;
load_msg = g_strdup_printf ( " Loading: %s " , name_ptr ) ;
statusbar_push_file_msg ( load_msg ) ;
g_free ( load_msg ) ;
2006-11-21 00:45:38 +00:00
/* Set up main window for a capture file. */
main_set_for_capture_file ( TRUE ) ;
2005-02-07 00:54:46 +00:00
}
2005-02-07 02:09:30 +00:00
static void
2005-02-07 00:54:46 +00:00
main_cf_cb_file_read_finished ( capture_file * cf )
{
statusbar_pop_file_msg ( ) ;
set_display_filename ( cf ) ;
/* Enable menu items that make sense if you have a capture file you've
2007-03-14 19:30:19 +00:00
finished reading . */
set_menus_for_capture_file ( cf ) ;
2005-02-07 00:54:46 +00:00
/* Enable menu items that make sense if you have some captured packets. */
set_menus_for_captured_packets ( TRUE ) ;
}
2006-01-17 00:40:32 +00:00
# if GTK_MAJOR_VERSION >= 2
GList * icon_list_create (
2006-02-16 15:27:03 +00:00
const char * * icon16_xpm ,
const char * * icon32_xpm ,
const char * * icon48_xpm ,
2006-01-17 00:40:32 +00:00
const char * * icon64_xpm )
{
GList * icon_list = NULL ;
GdkPixbuf * pixbuf16 ;
GdkPixbuf * pixbuf32 ;
GdkPixbuf * pixbuf48 ;
GdkPixbuf * pixbuf64 ;
if ( icon16_xpm ! = NULL ) {
pixbuf16 = gdk_pixbuf_new_from_xpm_data ( icon16_xpm ) ;
g_assert ( pixbuf16 ) ;
icon_list = g_list_append ( icon_list , pixbuf16 ) ;
}
if ( icon32_xpm ! = NULL ) {
pixbuf32 = gdk_pixbuf_new_from_xpm_data ( icon32_xpm ) ;
g_assert ( pixbuf32 ) ;
icon_list = g_list_append ( icon_list , pixbuf32 ) ;
}
if ( icon48_xpm ! = NULL ) {
pixbuf48 = gdk_pixbuf_new_from_xpm_data ( icon48_xpm ) ;
g_assert ( pixbuf48 ) ;
icon_list = g_list_append ( icon_list , pixbuf48 ) ;
}
if ( icon64_xpm ! = NULL ) {
pixbuf64 = gdk_pixbuf_new_from_xpm_data ( icon64_xpm ) ;
g_assert ( pixbuf64 ) ;
icon_list = g_list_append ( icon_list , pixbuf64 ) ;
}
return icon_list ;
}
# endif
2005-02-07 20:52:59 +00:00
# ifdef HAVE_LIBPCAP
2005-02-08 19:57:16 +00:00
static void
2005-05-25 23:28:59 +00:00
main_cf_cb_live_capture_prepared ( capture_options * capture_opts )
2005-02-08 19:57:16 +00:00
{
gchar * title ;
2006-01-17 00:40:32 +00:00
# if GTK_MAJOR_VERSION >= 2
static GList * icon_list = NULL ;
# endif
2005-02-08 19:57:16 +00:00
2005-04-19 20:55:27 +00:00
if ( capture_opts - > iface ) {
2006-05-22 07:29:40 +00:00
title = g_strdup_printf ( " %s: Capturing - Wireshark " ,
2007-08-22 18:56:20 +00:00
get_iface_description ( capture_opts ) ) ;
2005-04-19 20:55:27 +00:00
} else {
2006-05-22 07:29:40 +00:00
title = g_strdup_printf ( " Capturing - Wireshark " ) ;
2005-04-19 20:55:27 +00:00
}
2005-02-08 19:57:16 +00:00
set_main_window_name ( title ) ;
g_free ( title ) ;
2005-02-07 00:54:46 +00:00
2006-01-17 00:40:32 +00:00
# if GTK_MAJOR_VERSION >= 2
if ( icon_list = = NULL ) {
2006-06-07 04:03:18 +00:00
icon_list = icon_list_create ( wsiconcap16_xpm , wsiconcap32_xpm , wsiconcap48_xpm , NULL ) ;
2006-01-17 00:40:32 +00:00
}
gtk_window_set_icon_list ( GTK_WINDOW ( top_level ) , icon_list ) ;
# endif
2005-02-07 00:54:46 +00:00
/* Disable menu items that make no sense if you're currently running
a capture . */
set_menus_for_capture_in_progress ( TRUE ) ;
2005-05-25 23:28:59 +00:00
/* update statusbar */
statusbar_push_file_msg ( " Waiting for capture input data ... " ) ;
/* Don't set up main window for a capture file. */
main_set_for_capture_file ( FALSE ) ;
}
static void
main_cf_cb_live_capture_update_started ( capture_options * capture_opts )
{
gchar * capture_msg ;
2005-10-05 23:56:36 +00:00
gchar * title ;
/* We've done this in "prepared" above, but it will be cleared while
switching to the next multiple file . */
if ( capture_opts - > iface ) {
2006-05-22 07:29:40 +00:00
title = g_strdup_printf ( " %s: Capturing - Wireshark " ,
2007-08-22 18:56:20 +00:00
get_iface_description ( capture_opts ) ) ;
2005-10-05 23:56:36 +00:00
} else {
2006-05-22 07:29:40 +00:00
title = g_strdup_printf ( " Capturing - Wireshark " ) ;
2005-10-05 23:56:36 +00:00
}
set_main_window_name ( title ) ;
g_free ( title ) ;
2005-05-25 23:28:59 +00:00
2005-10-05 23:56:36 +00:00
set_menus_for_capture_in_progress ( TRUE ) ;
2005-05-25 23:28:59 +00:00
2005-02-07 00:54:46 +00:00
/* Enable menu items that make sense if you have some captured
packets ( yes , I know , we don ' t have any * yet * ) . */
set_menus_for_captured_packets ( TRUE ) ;
2005-05-25 23:28:59 +00:00
statusbar_pop_file_msg ( ) ;
2006-03-07 22:14:12 +00:00
if ( capture_opts - > iface ) {
capture_msg = g_strdup_printf ( " %s: <live capture in progress> to file: %s " ,
2007-08-22 18:56:20 +00:00
get_iface_description ( capture_opts ) ,
2007-08-22 16:30:16 +00:00
( capture_opts - > save_file ) ? capture_opts - > save_file : " " ) ;
2006-03-07 22:14:12 +00:00
} else {
capture_msg = g_strdup_printf ( " <live capture in progress> to file: %s " ,
( capture_opts - > save_file ) ? capture_opts - > save_file : " " ) ;
}
2005-02-07 00:54:46 +00:00
statusbar_push_file_msg ( capture_msg ) ;
g_free ( capture_msg ) ;
/* Set up main window for a capture file. */
main_set_for_capture_file ( TRUE ) ;
}
2005-04-18 22:05:56 +00:00
static void
main_cf_cb_live_capture_update_continue ( capture_file * cf )
{
gchar * capture_msg ;
statusbar_pop_file_msg ( ) ;
2006-10-13 18:19:42 +00:00
#if 0
/* XXX - don't show the highest expert level unless the TCP checksum offloading is "solved" */
2005-08-19 01:17:24 +00:00
if ( cf - > f_datalen / 1024 / 1024 > 10 ) {
2006-11-05 22:46:44 +00:00
capture_msg = g_strdup_printf ( " %s: <live capture in progress> File: %s %lld MB [Expert: %s] " ,
2007-08-22 18:56:20 +00:00
get_iface_description ( capture_opts ) ,
2007-08-22 16:30:16 +00:00
capture_opts - > save_file ,
cf - > f_datalen / 1024 / 1024 ,
val_to_str ( expert_get_highest_severity ( ) ,
expert_severity_vals ,
" Unknown (%u) " ) ) ;
2005-08-19 01:17:24 +00:00
} else if ( cf - > f_datalen / 1024 > 10 ) {
2006-11-05 22:46:44 +00:00
capture_msg = g_strdup_printf ( " %s: <live capture in progress> File: %s %lld KB [Expert: %s] " ,
2007-08-22 18:56:20 +00:00
get_iface_description ( capture_opts ) ,
2007-08-22 16:30:16 +00:00
capture_opts - > save_file ,
cf - > f_datalen / 1024 ,
val_to_str ( expert_get_highest_severity ( ) ,
expert_severity_vals ,
" Unknown (%u) " ) ) ;
2005-04-18 22:05:56 +00:00
} else {
2006-11-05 22:46:44 +00:00
capture_msg = g_strdup_printf ( " %s: <live capture in progress> File: %s %lld Bytes [Expert: %s] " ,
2007-08-22 18:56:20 +00:00
get_iface_description ( capture_opts ) ,
2007-08-22 16:30:16 +00:00
capture_opts - > save_file ,
cf - > f_datalen ,
val_to_str ( expert_get_highest_severity ( ) ,
expert_severity_vals ,
" Unknown (%u) " ) ) ;
2005-04-18 22:05:56 +00:00
}
2006-10-13 18:19:42 +00:00
# endif
if ( cf - > f_datalen / 1024 / 1024 > 10 ) {
2007-05-29 06:56:07 +00:00
capture_msg = g_strdup_printf ( " %s: <live capture in progress> File: %s % " G_GINT64_MODIFIER " d MB " ,
2007-08-22 18:56:20 +00:00
get_iface_description ( capture_opts ) ,
2007-08-22 16:30:16 +00:00
capture_opts - > save_file ,
cf - > f_datalen / 1024 / 1024 ) ;
2006-10-13 18:19:42 +00:00
} else if ( cf - > f_datalen / 1024 > 10 ) {
2007-05-29 06:56:07 +00:00
capture_msg = g_strdup_printf ( " %s: <live capture in progress> File: %s % " G_GINT64_MODIFIER " d KB " ,
2007-08-22 18:56:20 +00:00
get_iface_description ( capture_opts ) ,
2007-08-22 16:30:16 +00:00
capture_opts - > save_file ,
cf - > f_datalen / 1024 ) ;
2006-10-13 18:19:42 +00:00
} else {
2007-05-29 06:56:07 +00:00
capture_msg = g_strdup_printf ( " %s: <live capture in progress> File: %s % " G_GINT64_MODIFIER " d Bytes " ,
2007-08-22 18:56:20 +00:00
get_iface_description ( capture_opts ) ,
2007-08-22 16:30:16 +00:00
capture_opts - > save_file ,
cf - > f_datalen ) ;
2006-10-13 18:19:42 +00:00
}
2005-04-18 22:05:56 +00:00
statusbar_push_file_msg ( capture_msg ) ;
}
2005-09-20 08:42:35 +00:00
GtkWidget * stop_dlg = NULL ;
2005-04-16 19:29:48 +00:00
static void
main_cf_cb_live_capture_update_finished ( capture_file * cf )
{
2006-02-11 17:08:32 +00:00
# if GTK_MAJOR_VERSION >= 2
static GList * icon_list = NULL ;
# endif
if ( stop_dlg ! = NULL ) {
2005-09-20 08:42:35 +00:00
simple_dialog_close ( stop_dlg ) ;
stop_dlg = NULL ;
}
2005-04-16 19:29:48 +00:00
/* Pop the "<live capture in progress>" message off the status bar. */
statusbar_pop_file_msg ( ) ;
set_display_filename ( cf ) ;
/* Enable menu items that make sense if you're not currently running
a capture . */
set_menus_for_capture_in_progress ( FALSE ) ;
/* Enable menu items that make sense if you have a capture file
2007-03-14 19:30:19 +00:00
you ' ve finished reading . */
set_menus_for_capture_file ( cf ) ;
2005-04-16 19:29:48 +00:00
/* Set up main window for a capture file. */
main_set_for_capture_file ( TRUE ) ;
2005-12-13 02:09:14 +00:00
2006-02-11 17:08:32 +00:00
# if GTK_MAJOR_VERSION >= 2
if ( icon_list = = NULL ) {
2006-06-02 05:43:38 +00:00
icon_list = icon_list_create ( wsicon16_xpm , wsicon32_xpm , wsicon48_xpm , wsicon64_xpm ) ;
2006-02-11 17:08:32 +00:00
}
gtk_window_set_icon_list ( GTK_WINDOW ( top_level ) , icon_list ) ;
# endif
2005-12-13 02:09:14 +00:00
if ( capture_opts - > quit_after_cap ) {
/* command line asked us to quit after the capture */
/* don't pop up a dialog to ask for unsaved files etc. */
main_do_quit ( ) ;
}
2005-04-16 19:29:48 +00:00
}
2005-02-07 02:09:30 +00:00
static void
2005-04-10 19:36:56 +00:00
main_cf_cb_live_capture_fixed_started ( capture_options * capture_opts )
{
gchar * capture_msg ;
2005-04-11 18:57:19 +00:00
2005-04-10 19:36:56 +00:00
/* Enable menu items that make sense if you have some captured
packets ( yes , I know , we don ' t have any * yet * ) . */
/*set_menus_for_captured_packets(TRUE);*/
2005-05-25 23:28:59 +00:00
statusbar_pop_file_msg ( ) ;
2006-02-16 15:27:03 +00:00
capture_msg = g_strdup_printf ( " %s: <live capture in progress> to file: %s " ,
2007-08-22 18:56:20 +00:00
get_iface_description ( capture_opts ) ,
2007-08-22 16:30:16 +00:00
( capture_opts - > save_file ) ? capture_opts - > save_file : " " ) ;
2005-04-10 19:36:56 +00:00
statusbar_push_file_msg ( capture_msg ) ;
2006-01-22 16:26:41 +00:00
gtk_statusbar_push ( GTK_STATUSBAR ( packets_bar ) , packets_ctx , " P: 0 " ) ;
2005-04-10 19:36:56 +00:00
g_free ( capture_msg ) ;
2005-04-11 18:57:19 +00:00
/* Don't set up main window for a capture file. */
2005-04-10 19:36:56 +00:00
main_set_for_capture_file ( FALSE ) ;
}
2006-01-22 16:26:41 +00:00
static void
main_cf_cb_live_capture_fixed_continue ( capture_file * cf )
{
gchar * capture_msg ;
2006-02-16 15:27:03 +00:00
2006-01-22 16:26:41 +00:00
gtk_statusbar_pop ( GTK_STATUSBAR ( packets_bar ) , packets_ctx ) ;
2006-02-16 15:27:03 +00:00
capture_msg = g_strdup_printf ( " P: %u " ,
2006-01-22 16:26:41 +00:00
cf_get_packet_count ( cf ) ) ;
gtk_statusbar_push ( GTK_STATUSBAR ( packets_bar ) , packets_ctx , capture_msg ) ;
g_free ( capture_msg ) ;
}
2005-04-10 19:36:56 +00:00
static void
2005-04-30 17:23:33 +00:00
main_cf_cb_live_capture_fixed_finished ( capture_file * cf _U_ )
2005-04-10 19:36:56 +00:00
{
2006-02-11 17:08:32 +00:00
# if GTK_MAJOR_VERSION >= 2
static GList * icon_list = NULL ;
# endif
if ( stop_dlg ! = NULL ) {
2005-09-20 08:42:35 +00:00
simple_dialog_close ( stop_dlg ) ;
stop_dlg = NULL ;
}
2005-04-10 19:36:56 +00:00
/* Pop the "<live capture in progress>" message off the status bar. */
statusbar_pop_file_msg ( ) ;
2005-04-11 18:57:19 +00:00
/* Pop the "<capturing>" message off the status bar */
gtk_statusbar_pop ( GTK_STATUSBAR ( packets_bar ) , packets_ctx ) ;
2005-04-10 19:36:56 +00:00
/*set_display_filename(cf);*/
/* Enable menu items that make sense if you're not currently running
a capture . */
set_menus_for_capture_in_progress ( FALSE ) ;
2005-12-13 02:09:14 +00:00
/* Restore the standard title bar message */
/* (just in case we have trouble opening the capture file). */
2006-05-22 07:29:40 +00:00
set_main_window_name ( " The Wireshark Network Analyzer " ) ;
2005-12-13 02:09:14 +00:00
2006-02-11 17:08:32 +00:00
# if GTK_MAJOR_VERSION >= 2
if ( icon_list = = NULL ) {
2006-06-02 05:43:38 +00:00
icon_list = icon_list_create ( wsicon16_xpm , wsicon32_xpm , wsicon48_xpm , wsicon64_xpm ) ;
2006-02-11 17:08:32 +00:00
}
gtk_window_set_icon_list ( GTK_WINDOW ( top_level ) , icon_list ) ;
# endif
2005-04-16 19:29:48 +00:00
/* We don't have loaded the capture file, this will be done later.
* For now we still have simply a blank screen . */
2005-12-13 02:09:14 +00:00
if ( capture_opts - > quit_after_cap ) {
/* command line asked us to quit after the capture */
/* don't pop up a dialog to ask for unsaved files etc. */
main_do_quit ( ) ;
}
2005-04-10 19:36:56 +00:00
}
2005-09-20 08:42:35 +00:00
static void
main_cf_cb_live_capture_stopping ( capture_file * cf _U_ )
{
2006-02-16 15:27:03 +00:00
/* Beware: this state won't be called, if the capture child
2006-02-11 17:08:32 +00:00
* closes the capturing on it ' s own ! */
2005-10-17 19:46:29 +00:00
#if 0
2006-11-05 00:54:17 +00:00
/* XXX - the time to stop the capture has been reduced (this was only a
* problem on Win32 because of the capture piping ) , so showing a splash
* isn ' t really necessary any longer . Unfortunately , the GTKClist packet
* list seems to have problems updating after the dialog is closed , so
* this was disabled here . */
2006-02-16 15:27:03 +00:00
stop_dlg = simple_dialog ( ESD_TYPE_STOP , ESD_BTN_NONE , " %sCapture stop!%s \n \n Please wait ... " ,
2005-09-20 08:42:35 +00:00
simple_dialog_primary_start ( ) , simple_dialog_primary_end ( ) ) ;
# if GTK_MAJOR_VERSION >= 2
2006-11-05 00:54:17 +00:00
gtk_window_set_position ( GTK_WINDOW ( stop_dlg ) , GTK_WIN_POS_CENTER_ON_PARENT ) ;
2005-09-20 08:42:35 +00:00
# else
2006-11-05 00:54:17 +00:00
gtk_window_set_position ( GTK_WINDOW ( stop_dlg ) , GTK_WIN_POS_CENTER ) ;
2005-09-20 08:42:35 +00:00
# endif
2005-10-17 19:46:29 +00:00
# endif
2005-09-20 08:42:35 +00:00
}
2005-02-07 20:52:59 +00:00
# endif
2005-02-07 00:54:46 +00:00
2005-02-07 02:09:30 +00:00
static void
2005-02-07 00:54:46 +00:00
main_cf_cb_packet_selected ( gpointer data )
{
capture_file * cf = data ;
/* Display the GUI protocol tree and hex dump.
XXX - why do we dump core if we call " proto_tree_draw() "
before calling " add_byte_views() " ? */
add_main_byte_views ( cf - > edt ) ;
main_proto_tree_draw ( cf - > edt - > tree ) ;
2006-11-14 22:35:22 +00:00
/* The user is searching for a string in the data or a hex value,
* highlight the field that is found in the tree and hex displays . */
# if GTK_MAJOR_VERSION < 2
if ( ( cfile . string | | cfile . hex ) & & cfile . search_pos ! = 0 ) {
highlight_field ( cf - > edt - > tvb , cfile . search_pos ,
( GtkCTree * ) tree_view , cf - > edt - > tree ) ;
# else
if ( ( cfile . string | | cfile . hex ) & & cfile . search_pos ! = 0 ) {
highlight_field ( cf - > edt - > tvb , cfile . search_pos ,
( GtkTreeView * ) tree_view , cf - > edt - > tree ) ;
# endif
cfile . search_pos = 0 ; /* Reset the position */
}
2005-02-07 00:54:46 +00:00
/* A packet is selected. */
set_menus_for_selected_packet ( cf ) ;
}
2005-02-07 02:09:30 +00:00
static void
2005-02-07 00:54:46 +00:00
main_cf_cb_packet_unselected ( capture_file * cf )
{
/* Clear out the display of that packet. */
clear_tree_and_hex_views ( ) ;
/* No packet is selected. */
set_menus_for_selected_packet ( cf ) ;
}
2005-02-07 02:09:30 +00:00
static void
2005-02-07 00:54:46 +00:00
main_cf_cb_field_unselected ( capture_file * cf )
{
statusbar_pop_field_msg ( ) ;
set_menus_for_selected_tree_row ( cf ) ;
}
2005-02-07 02:09:30 +00:00
static void
2005-02-07 00:54:46 +00:00
main_cf_cb_file_safe_started ( gchar * filename )
{
const gchar * name_ptr ;
gchar * save_msg ;
name_ptr = get_basename ( filename ) ;
save_msg = g_strdup_printf ( " Saving: %s... " , name_ptr ) ;
statusbar_push_file_msg ( save_msg ) ;
g_free ( save_msg ) ;
}
2005-02-07 02:09:30 +00:00
static void
2005-02-07 00:54:46 +00:00
main_cf_cb_file_safe_finished ( gpointer data _U_ )
{
/* Pop the "Saving:" message off the status bar. */
statusbar_pop_file_msg ( ) ;
}
2005-02-07 02:09:30 +00:00
static void
2005-02-07 00:54:46 +00:00
main_cf_cb_file_safe_failed ( gpointer data _U_ )
{
/* Pop the "Saving:" message off the status bar. */
statusbar_pop_file_msg ( ) ;
}
2005-02-07 02:09:30 +00:00
static void
2005-02-07 00:54:46 +00:00
main_cf_cb_file_safe_reload_finished ( gpointer data _U_ )
{
2007-03-14 19:30:19 +00:00
set_menus_for_capture_file ( & cfile ) ;
2005-02-07 00:54:46 +00:00
}
2005-08-02 04:47:15 +00:00
static void main_cf_callback ( gint event , gpointer data , gpointer user_data _U_ )
2005-02-07 00:54:46 +00:00
{
switch ( event ) {
2005-09-20 08:42:35 +00:00
case ( cf_cb_file_closing ) :
2006-11-05 00:54:17 +00:00
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_DEBUG , " Callback: Closing " ) ;
2005-09-20 08:42:35 +00:00
main_cf_cb_file_closing ( data ) ;
break ;
2005-02-07 00:54:46 +00:00
case ( cf_cb_file_closed ) :
2006-11-05 00:54:17 +00:00
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_DEBUG , " Callback: Closed " ) ;
2005-02-07 00:54:46 +00:00
main_cf_cb_file_closed ( data ) ;
break ;
case ( cf_cb_file_read_start ) :
2006-11-05 00:54:17 +00:00
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_DEBUG , " Callback: Read start " ) ;
2005-02-07 00:54:46 +00:00
main_cf_cb_file_read_start ( data ) ;
break ;
case ( cf_cb_file_read_finished ) :
2006-11-05 00:54:17 +00:00
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_DEBUG , " Callback: Read finished " ) ;
2005-02-07 00:54:46 +00:00
main_cf_cb_file_read_finished ( data ) ;
break ;
2005-02-07 20:52:59 +00:00
# ifdef HAVE_LIBPCAP
2005-05-25 23:28:59 +00:00
case ( cf_cb_live_capture_prepared ) :
2006-11-05 00:54:17 +00:00
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_DEBUG , " Callback: capture prepared " ) ;
2005-05-25 23:28:59 +00:00
main_cf_cb_live_capture_prepared ( data ) ;
break ;
2005-04-10 19:36:56 +00:00
case ( cf_cb_live_capture_update_started ) :
2006-11-05 00:54:17 +00:00
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_DEBUG , " Callback: capture update started " ) ;
2005-04-10 19:36:56 +00:00
main_cf_cb_live_capture_update_started ( data ) ;
break ;
2005-04-18 22:05:56 +00:00
case ( cf_cb_live_capture_update_continue ) :
2006-11-05 00:54:17 +00:00
/*g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update continue");*/
2005-04-18 22:05:56 +00:00
main_cf_cb_live_capture_update_continue ( data ) ;
break ;
2006-01-22 16:26:41 +00:00
case ( cf_cb_live_capture_update_finished ) :
2006-11-05 00:54:17 +00:00
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_DEBUG , " Callback: capture update finished " ) ;
2006-01-22 16:26:41 +00:00
main_cf_cb_live_capture_update_finished ( data ) ;
break ;
2005-04-10 19:36:56 +00:00
case ( cf_cb_live_capture_fixed_started ) :
2006-11-05 00:54:17 +00:00
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_DEBUG , " Callback: capture fixed started " ) ;
2005-04-10 19:36:56 +00:00
main_cf_cb_live_capture_fixed_started ( data ) ;
break ;
2006-01-22 16:26:41 +00:00
case ( cf_cb_live_capture_fixed_continue ) :
2007-08-24 15:29:13 +00:00
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_DEBUG , " Callback: capture fixed continue " ) ;
2006-01-22 16:26:41 +00:00
main_cf_cb_live_capture_fixed_continue ( data ) ;
2005-02-07 00:54:46 +00:00
break ;
2005-04-10 19:36:56 +00:00
case ( cf_cb_live_capture_fixed_finished ) :
2006-11-05 00:54:17 +00:00
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_DEBUG , " Callback: capture fixed finished " ) ;
2005-04-10 19:36:56 +00:00
main_cf_cb_live_capture_fixed_finished ( data ) ;
2005-02-07 00:54:46 +00:00
break ;
2005-09-20 08:42:35 +00:00
case ( cf_cb_live_capture_stopping ) :
2006-11-05 00:54:17 +00:00
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_DEBUG , " Callback: capture stopping " ) ;
2005-09-20 08:42:35 +00:00
main_cf_cb_live_capture_stopping ( data ) ;
break ;
2005-02-07 20:52:59 +00:00
# endif
2005-02-07 00:54:46 +00:00
case ( cf_cb_packet_selected ) :
main_cf_cb_packet_selected ( data ) ;
break ;
case ( cf_cb_packet_unselected ) :
main_cf_cb_packet_unselected ( data ) ;
break ;
case ( cf_cb_field_unselected ) :
main_cf_cb_field_unselected ( data ) ;
break ;
case ( cf_cb_file_safe_started ) :
2006-11-05 00:54:17 +00:00
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_DEBUG , " Callback: safe started " ) ;
2005-02-07 00:54:46 +00:00
main_cf_cb_file_safe_started ( data ) ;
break ;
case ( cf_cb_file_safe_finished ) :
2006-11-05 00:54:17 +00:00
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_DEBUG , " Callback: safe finished " ) ;
2005-02-07 00:54:46 +00:00
main_cf_cb_file_safe_finished ( data ) ;
break ;
case ( cf_cb_file_safe_reload_finished ) :
2006-11-05 00:54:17 +00:00
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_DEBUG , " Callback: reload finished " ) ;
2005-02-07 00:54:46 +00:00
main_cf_cb_file_safe_reload_finished ( data ) ;
break ;
case ( cf_cb_file_safe_failed ) :
2006-11-05 00:54:17 +00:00
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_DEBUG , " Callback: safe failed " ) ;
2005-02-07 00:54:46 +00:00
main_cf_cb_file_safe_failed ( data ) ;
break ;
default :
g_warning ( " main_cf_callback: event %u unknown " , event ) ;
g_assert_not_reached ( ) ;
}
}
2004-01-31 18:32:37 +00:00
2006-10-19 18:43:12 +00:00
static void
2006-10-19 22:43:38 +00:00
get_gui_compiled_info ( GString * str )
2006-10-19 18:43:12 +00:00
{
2006-10-19 21:17:23 +00:00
get_epan_compiled_version_info ( str ) ;
g_string_append ( str , " , " ) ;
2006-10-21 17:48:45 +00:00
# ifdef HAVE_LIBPORTAUDIO
2006-10-19 18:43:12 +00:00
# ifdef PORTAUDIO_API_1
g_string_append ( str , " with PortAudio <= V18 " ) ;
# else /* PORTAUDIO_API_1 */
g_string_append ( str , " with PortAudio " ) ;
g_string_append ( str , Pa_GetVersionText ( ) ) ;
# endif /* PORTAUDIO_API_1 */
# else /* HAVE_LIBPORTAUDIO */
g_string_append ( str , " without PortAudio " ) ;
# endif /* HAVE_LIBPORTAUDIO */
2006-10-19 22:43:38 +00:00
g_string_append ( str , " , " ) ;
# ifdef HAVE_AIRPCAP
get_compiled_airpcap_version ( str ) ;
# else
g_string_append ( str , " without AirPcap " ) ;
# endif
}
static void
2006-10-20 09:06:24 +00:00
get_gui_runtime_info ( GString * str
# ifndef HAVE_AIRPCAP
_U_
# endif
)
2006-10-19 22:43:38 +00:00
{
# ifdef HAVE_AIRPCAP
2006-10-20 09:06:24 +00:00
g_string_append ( str , " , " ) ;
2006-10-19 22:43:38 +00:00
get_runtime_airpcap_version ( str ) ;
# endif
2007-02-04 12:39:07 +00:00
if ( u3_active ( ) ) {
g_string_append ( str , " , " ) ;
u3_runtime_info ( str ) ;
}
2006-10-19 18:43:12 +00:00
}
1998-11-17 04:29:13 +00:00
/* And now our feature presentation... [ fade to music ] */
1998-09-16 02:39:15 +00:00
int
main ( int argc , char * argv [ ] )
{
2006-05-01 06:51:14 +00:00
char * init_progfile_dir_error ;
1999-10-21 21:47:08 +00:00
char * s ;
1999-07-13 02:53:26 +00:00
int opt ;
1998-09-16 02:39:15 +00:00
extern char * optarg ;
1999-12-07 07:12:49 +00:00
gboolean arg_error = FALSE ;
2002-08-28 21:04:11 +00:00
2004-09-11 23:03:36 +00:00
# ifdef _WIN32
2002-08-28 21:04:11 +00:00
WSADATA wsaData ;
2004-09-11 23:03:36 +00:00
# endif /* _WIN32 */
2000-10-27 17:19:23 +00:00
2003-12-13 18:01:30 +00:00
char * rf_path ;
int rf_open_errno ;
2003-08-07 00:41:28 +00:00
char * gpf_path , * pf_path ;
2004-01-03 18:40:08 +00:00
char * cf_path , * df_path ;
char * gdp_path , * dp_path ;
2003-08-07 00:41:28 +00:00
int gpf_open_errno , gpf_read_errno ;
int pf_open_errno , pf_read_errno ;
int cf_open_errno , df_open_errno ;
2004-01-03 18:40:08 +00:00
int gdp_open_errno , gdp_read_errno ;
2003-08-07 00:41:28 +00:00
int dp_open_errno , dp_read_errno ;
1999-12-07 07:12:49 +00:00
int err ;
Add a new global flag "capture_child", which is TRUE if we're a child
process for a sync mode or fork mode capture.
Have that flag control whether we do things that *only* the parent or
*only* the child should do, rather than basing it solely on the setting
of "sync_mode" or "fork_mode" (or, in the case of stuff done in the
child process either in sync mode or fork mode, rather than basing it on
the setting of those flags at all).
Split "do_capture()" into a "run_capture()" routine that starts a
capture (possibly by forking off and execing a child process, if we're
supposed to do sync mode or fork mode captures), and that assumes the
file to which the capture is to write has already been opened and that
"cf.save_file_fd" is the file descriptor for that file, and a
"do_capture()" routine that creates a temporary file, getting an FD for
it, and calls "run_capture()".
Use "run_capture()", rather than "capture()", for "-k" captures, so that
it'll do the capture in a child process if "-S" or "-F" was specified
("do_capture()" won't do because "-k" captures should write to the file
specified by the "-w" flag, not some random temporary file).
For child process captures, however, just use "capture()" - the child
process shouldn't itself fork off a child if we're in sync or fork mode,
and should just write to the file whose file descriptor was specified by
the "-W" flag on the command line.
All this allows you to do "ethereal -S -w <file> -i <interface> -k" to
start a sync mode capture from the command line.
svn path=/trunk/; revision=740
1999-09-30 06:50:01 +00:00
# ifdef HAVE_LIBPCAP
1999-12-07 07:12:49 +00:00
gboolean start_capture = FALSE ;
# else
gboolean capture_option_specified = FALSE ;
Add a new global flag "capture_child", which is TRUE if we're a child
process for a sync mode or fork mode capture.
Have that flag control whether we do things that *only* the parent or
*only* the child should do, rather than basing it solely on the setting
of "sync_mode" or "fork_mode" (or, in the case of stuff done in the
child process either in sync mode or fork mode, rather than basing it on
the setting of those flags at all).
Split "do_capture()" into a "run_capture()" routine that starts a
capture (possibly by forking off and execing a child process, if we're
supposed to do sync mode or fork mode captures), and that assumes the
file to which the capture is to write has already been opened and that
"cf.save_file_fd" is the file descriptor for that file, and a
"do_capture()" routine that creates a temporary file, getting an FD for
it, and calls "run_capture()".
Use "run_capture()", rather than "capture()", for "-k" captures, so that
it'll do the capture in a child process if "-S" or "-F" was specified
("do_capture()" won't do because "-k" captures should write to the file
specified by the "-w" flag, not some random temporary file).
For child process captures, however, just use "capture()" - the child
process shouldn't itself fork off a child if we're in sync or fork mode,
and should just write to the file whose file descriptor was specified by
the "-W" flag on the command line.
All this allows you to do "ethereal -S -w <file> -i <interface> -k" to
start a sync mode capture from the command line.
svn path=/trunk/; revision=740
1999-09-30 06:50:01 +00:00
# endif
1998-11-18 03:01:44 +00:00
gint pl_size = 280 , tv_size = 95 , bv_size = 75 ;
1999-08-10 07:16:47 +00:00
gchar * rc_file , * cf_name = NULL , * rfilter = NULL ;
2001-02-01 20:21:25 +00:00
dfilter_t * rfcode = NULL ;
1999-08-15 19:18:46 +00:00
gboolean rfilter_parse_failed = FALSE ;
1998-11-17 04:29:13 +00:00
e_prefs * prefs ;
2001-05-31 08:36:46 +00:00
char badopt ;
2004-07-06 19:16:04 +00:00
GtkWidget * splash_win = NULL ;
2005-05-26 17:50:27 +00:00
GLogLevelFlags log_flags ;
2005-05-31 21:30:40 +00:00
guint go_to_packet = 0 ;
2005-06-10 19:09:49 +00:00
int optind_initial ;
2006-02-10 02:05:30 +00:00
int status ;
2007-08-30 00:24:40 +00:00
gchar * cur_user , * cur_group ;
2001-12-31 04:41:50 +00:00
2006-08-16 18:01:25 +00:00
# ifdef HAVE_AIRPCAP
2007-01-23 20:12:09 +00:00
char * err_str ;
2007-01-28 23:48:53 +00:00
/*gchar *cant_get_if_list_errstr;*/
2006-08-16 18:01:25 +00:00
# endif
2007-03-14 02:55:54 +00:00
# define OPTSTRING_INIT "a:b:c:Df:g:Hhi:klLm:nN:o:P:pQr:R:Ss:t:vw:X:y:z:"
2002-05-22 23:22:56 +00:00
2006-02-11 23:47:03 +00:00
# if defined HAVE_LIBPCAP && defined _WIN32
2005-05-30 04:46:25 +00:00
# define OPTSTRING_WIN32 "B:"
2002-05-22 23:22:56 +00:00
# else
2005-05-30 04:46:25 +00:00
# define OPTSTRING_WIN32 ""
2006-02-11 23:47:03 +00:00
# endif
2002-05-22 23:22:56 +00:00
2006-02-11 23:47:03 +00:00
char optstring [ sizeof ( OPTSTRING_INIT ) + sizeof ( OPTSTRING_WIN32 ) - 1 ] =
2005-05-30 04:46:25 +00:00
OPTSTRING_INIT OPTSTRING_WIN32 ;
1998-09-16 02:39:15 +00:00
Add a routine to attempt to get the absolute pathname of the executable
file, strip off the last component to get the pathname of the directory
containing the executable file, and save it for future use. On Windows,
you can get that from the OS, but, on UN*X, you have to look at argv[0]
and derive the absolute path from that (argv[0] is not guaranteed to be
an absolute path, or even a path at all). (In addition, if you're
running from the build directory, you might have to strip off a ".libs/"
added to argv[0] as an artifact of the libtoolizing script.)
Use that in the About dialog, and use it to construct the path of
dumpcap.
Don't put quotes into the path of dumpcap; you don't have to quote
strings with spaces in them when handing them to execvp and, in fact,
you *mustn't* quote them, as the quotes will be treated as part of the
pathname.
svn path=/trunk/; revision=17267
2006-02-12 03:15:29 +00:00
/*
2007-08-30 00:24:40 +00:00
* Get credential information for later use , and drop privileges
* before doing anything else .
* Let the user know if anything happened .
Add a routine to attempt to get the absolute pathname of the executable
file, strip off the last component to get the pathname of the directory
containing the executable file, and save it for future use. On Windows,
you can get that from the OS, but, on UN*X, you have to look at argv[0]
and derive the absolute path from that (argv[0] is not guaranteed to be
an absolute path, or even a path at all). (In addition, if you're
running from the build directory, you might have to strip off a ".libs/"
added to argv[0] as an artifact of the libtoolizing script.)
Use that in the About dialog, and use it to construct the path of
dumpcap.
Don't put quotes into the path of dumpcap; you don't have to quote
strings with spaces in them when handing them to execvp and, in fact,
you *mustn't* quote them, as the quotes will be treated as part of the
pathname.
svn path=/trunk/; revision=17267
2006-02-12 03:15:29 +00:00
*/
2007-05-21 20:31:45 +00:00
get_credential_info ( ) ;
2007-08-30 00:24:40 +00:00
relinquish_special_privs_perm ( ) ;
Add a routine to attempt to get the absolute pathname of the executable
file, strip off the last component to get the pathname of the directory
containing the executable file, and save it for future use. On Windows,
you can get that from the OS, but, on UN*X, you have to look at argv[0]
and derive the absolute path from that (argv[0] is not guaranteed to be
an absolute path, or even a path at all). (In addition, if you're
running from the build directory, you might have to strip off a ".libs/"
added to argv[0] as an artifact of the libtoolizing script.)
Use that in the About dialog, and use it to construct the path of
dumpcap.
Don't put quotes into the path of dumpcap; you don't have to quote
strings with spaces in them when handing them to execvp and, in fact,
you *mustn't* quote them, as the quotes will be treated as part of the
pathname.
svn path=/trunk/; revision=17267
2006-02-12 03:15:29 +00:00
2006-02-06 03:11:34 +00:00
/*
2007-05-21 20:31:45 +00:00
* Attempt to get the pathname of the executable file .
2006-02-06 03:11:34 +00:00
*/
2007-05-21 20:31:45 +00:00
init_progfile_dir_error = init_progfile_dir ( argv [ 0 ] ) ;
2006-02-06 03:11:34 +00:00
2006-02-06 23:54:54 +00:00
/* initialize the funnel mini-api */
initialize_funnel_ops ( ) ;
2006-02-16 15:27:03 +00:00
2007-08-30 00:24:40 +00:00
# ifdef HAVE_AIRPDCAP
/* Davide Schiera (2006-11-18): init AirPDcap context */
AirPDcapInitContext ( & airpdcap_ctx ) ;
/* Davide Schiera (2006-11-18) ------------------------------------------- */
# endif
2005-06-23 21:19:05 +00:00
# ifdef _WIN32
/* Load wpcap if possible. Do this before collecting the run-time version information */
load_wpcap ( ) ;
/* ... and also load the packet.dll from wpcap */
wpcap_packet_load ( ) ;
2006-10-19 22:43:38 +00:00
# ifdef HAVE_AIRPCAP
2007-01-21 23:45:36 +00:00
/* Load the airpcap.dll. This must also be done before collecting
* run - time version information . */
2006-10-30 06:34:31 +00:00
airpcap_dll_ret_val = load_airpcap ( ) ;
2006-11-05 00:54:17 +00:00
switch ( airpcap_dll_ret_val ) {
case AIRPCAP_DLL_OK :
/* load the airpcap interfaces */
2007-01-23 20:12:09 +00:00
airpcap_if_list = get_airpcap_interface_list ( & err , & err_str ) ;
2006-11-05 00:54:17 +00:00
2007-05-18 21:06:20 +00:00
if ( airpcap_if_list = = NULL | | g_list_length ( airpcap_if_list ) = = 0 ) {
if ( err = = CANT_GET_AIRPCAP_INTERFACE_LIST & & err_str ! = NULL ) {
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " %s " , " Failed to open Airpcap Adapters! " ) ;
g_free ( err_str ) ;
}
airpcap_if_active = NULL ;
} else {
2006-11-05 00:54:17 +00:00
2007-05-18 21:06:20 +00:00
/* select the first ad default (THIS SHOULD BE CHANGED) */
airpcap_if_active = airpcap_get_default_if ( airpcap_if_list ) ;
}
break ;
2006-11-05 00:54:17 +00:00
#if 0
/*
* XXX - Maybe we need to warn the user if one of the following happens ? ? ?
*/
case AIRPCAP_DLL_OLD :
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " %s " , " AIRPCAP_DLL_OLD \n " ) ;
break ;
case AIRPCAP_DLL_ERROR :
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " %s " , " AIRPCAP_DLL_ERROR \n " ) ;
break ;
case AIRPCAP_DLL_NOT_FOUND :
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " %s " , " AIRPCAP_DDL_NOT_FOUND \n " ) ;
break ;
2006-10-19 22:43:38 +00:00
# endif
2006-11-05 00:54:17 +00:00
}
# endif /* HAVE_AIRPCAP */
2006-10-19 22:43:38 +00:00
2005-06-23 21:19:05 +00:00
/* Start windows sockets */
WSAStartup ( MAKEWORD ( 1 , 1 ) , & wsaData ) ;
# endif /* _WIN32 */
/* Assemble the compile-time version information string */
comp_info_str = g_string_new ( " Compiled " ) ;
2006-09-12 20:23:57 +00:00
2005-06-23 21:19:05 +00:00
g_string_append ( comp_info_str , " with " ) ;
g_string_sprintfa ( comp_info_str ,
# ifdef GTK_MAJOR_VERSION
" GTK+ %d.%d.%d " , GTK_MAJOR_VERSION , GTK_MINOR_VERSION ,
GTK_MICRO_VERSION ) ;
# else
" GTK+ (version unknown) " ) ;
# endif
g_string_append ( comp_info_str , " , " ) ;
2006-09-12 20:23:57 +00:00
2006-10-19 22:43:38 +00:00
get_compiled_version_info ( comp_info_str , get_gui_compiled_info ) ;
2006-10-10 19:00:50 +00:00
2005-06-23 21:19:05 +00:00
/* Assemble the run-time version information string */
runtime_info_str = g_string_new ( " Running " ) ;
2006-10-19 22:43:38 +00:00
get_runtime_version_info ( runtime_info_str , get_gui_runtime_info ) ;
2005-06-23 21:19:05 +00:00
2005-11-09 08:46:24 +00:00
/* "pre-scan" the command line parameters, if we have "console only"
parameters . We do this so we don ' t start GTK + if we ' re only showing
2005-11-17 05:59:21 +00:00
command - line help or version information .
2005-11-17 04:10:31 +00:00
XXX - this pre - scan is doen before we start GTK + , so we haven ' t
run gtk_init ( ) on the arguments . That means that GTK + arguments
have not been removed from the argument list ; those arguments
begin with " -- " , and will be treated as an error by getopt ( ) .
We thus ignore errors - * and * set " opterr " to 0 to suppress the
error messages . */
opterr = 0 ;
2005-06-23 21:19:05 +00:00
optind_initial = optind ;
while ( ( opt = getopt ( argc , argv , optstring ) ) ! = - 1 ) {
switch ( opt ) {
case ' h ' : /* Print help and exit */
print_usage ( TRUE ) ;
exit ( 0 ) ;
break ;
2007-03-14 02:55:54 +00:00
case ' P ' : /* Path settings - change these before the Preferences and alike are processed */
2007-03-14 18:19:13 +00:00
status = filesystem_opt ( opt , optarg ) ;
2007-03-14 02:55:54 +00:00
if ( status ! = 0 ) {
2007-03-14 18:19:13 +00:00
cmdarg_err ( " -P flag \" %s \" failed (hint: is it quoted and existing?) " , optarg ) ;
2007-03-14 02:55:54 +00:00
exit ( status ) ;
}
2007-03-14 18:19:13 +00:00
break ;
2005-06-23 21:19:05 +00:00
case ' v ' : /* Show version and exit */
show_version ( ) ;
exit ( 0 ) ;
break ;
2006-02-07 22:08:12 +00:00
case ' X ' :
2007-03-14 18:19:13 +00:00
/*
* Extension command line options have to be processed before
* we call epan_init ( ) as they are supposed to be used by dissectors
* or taps very early in the registration process .
*/
ex_opt_add ( optarg ) ;
break ;
2005-11-17 04:10:31 +00:00
case ' ? ' : /* Ignore errors - the "real" scan will catch them. */
2005-11-16 21:46:24 +00:00
break ;
2005-06-23 21:19:05 +00:00
}
}
2007-03-14 02:55:54 +00:00
/* Init the "Open file" dialog directory */
/* (do this after the path settings are processed) */
set_last_open_dir ( get_persdatafile_dir ( ) ) ;
2005-11-17 04:10:31 +00:00
/* Set getopt index back to initial value, so it will start with the
first command line parameter again . Also reset opterr to 1 , so that
error messages are printed by getopt ( ) .
XXX - this seems to work on most platforms , but time will tell .
The Single UNIX Specification says " The getopt() function need
not be reentrant " , so this isn't guaranteed to work. The Mac
OS X 10.4 [ . x ] getopt ( ) man page says
In order to use getopt ( ) to evaluate multiple sets of arguments , or to
evaluate a single set of arguments multiple times , the variable optreset
must be set to 1 before the second and each additional set of calls to
getopt ( ) , and the variable optind must be reinitialized .
2006-02-16 15:27:03 +00:00
. . .
2005-11-17 04:10:31 +00:00
The optreset variable was added to make it possible to call the getopt ( )
function multiple times . This is an extension to the IEEE Std 1003.2
( ` ` POSIX .2 ' ' ) specification .
which I think comes from one of the other BSDs .
XXX - if we want to control all the command - line option errors , so
that we can display them where we choose ( e . g . , in a window ) , we ' d
want to leave opterr as 0 , and produce our own messages using optopt .
We ' d have to check the value of optopt to see if it ' s a valid option
letter , in which case * presumably * the error is " this option requires
an argument but none was specified " , or not a valid option letter,
in which case * presumably * the error is " this option isn't valid " .
Some versions of getopt ( ) let you supply a option string beginning
with ' : ' , which means that getopt ( ) will return ' : ' rather than ' ? '
for " this option requires an argument but none was specified " , but
not all do . */
2005-06-23 21:19:05 +00:00
optind = optind_initial ;
2005-11-17 04:10:31 +00:00
opterr = 1 ;
2005-06-23 21:19:05 +00:00
2004-07-04 12:15:41 +00:00
/* Set the current locale according to the program environment.
* We haven ' t localized anything , but some GTK widgets are localized
* ( the file selection dialogue , for example ) .
* This also sets the C - language locale to the native environment . */
gtk_set_locale ( ) ;
2005-06-23 21:19:05 +00:00
/* Let GTK get its args (will need an X server, so do this after command line only commands handled) */
2004-07-04 12:15:41 +00:00
gtk_init ( & argc , & argv ) ;
2004-12-02 07:53:59 +00:00
2005-02-07 00:54:46 +00:00
cf_callback_add ( main_cf_callback , NULL ) ;
2004-12-02 19:17:40 +00:00
# if GTK_MAJOR_VERSION < 2 && GTK_MINOR_VERSION < 3
2004-12-02 03:12:24 +00:00
/* initialize our GTK eth_clist_type */
init_eth_clist_type ( ) ;
2004-12-02 07:53:59 +00:00
# endif
2004-07-04 12:15:41 +00:00
2001-02-20 04:09:37 +00:00
/* Arrange that if we have no console window, and a GLib message logging
routine is called to log a message , we pop up a console window .
We do that by inserting our own handler for all messages logged
to the default domain ; that handler pops up a console if necessary ,
and then calls the default handler . */
2005-05-26 17:50:27 +00:00
/* We might want to have component specific log levels later ... */
2005-05-26 21:49:48 +00:00
2006-02-16 15:27:03 +00:00
log_flags =
2001-02-20 04:09:37 +00:00
G_LOG_LEVEL_ERROR |
G_LOG_LEVEL_CRITICAL |
G_LOG_LEVEL_WARNING |
2005-05-26 21:49:48 +00:00
G_LOG_LEVEL_MESSAGE |
2001-02-20 04:09:37 +00:00
G_LOG_LEVEL_INFO |
2005-05-26 21:49:48 +00:00
G_LOG_LEVEL_DEBUG |
2005-05-26 17:50:27 +00:00
G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION ;
g_log_set_handler ( NULL ,
log_flags ,
console_log_handler , NULL /* user_data */ ) ;
2005-10-06 00:55:21 +00:00
g_log_set_handler ( LOG_DOMAIN_MAIN ,
log_flags ,
console_log_handler , NULL /* user_data */ ) ;
2001-02-20 04:09:37 +00:00
2005-01-27 10:47:27 +00:00
# ifdef HAVE_LIBPCAP
2005-05-26 17:50:27 +00:00
g_log_set_handler ( LOG_DOMAIN_CAPTURE ,
log_flags ,
2006-02-12 20:17:55 +00:00
console_log_handler , NULL /* user_data */ ) ;
g_log_set_handler ( LOG_DOMAIN_CAPTURE_CHILD ,
log_flags ,
console_log_handler , NULL /* user_data */ ) ;
2005-05-26 17:50:27 +00:00
2006-02-16 15:27:03 +00:00
/* Set the initial values in the capture_opts. This might be overwritten
2005-02-06 14:43:27 +00:00
by preference settings and then again by the command line parameters . */
capture_opts_init ( capture_opts , & cfile ) ;
2005-02-23 01:01:19 +00:00
capture_opts - > snaplen = MIN_PACKET_SIZE ;
capture_opts - > has_ring_num_files = TRUE ;
2004-12-02 00:12:54 +00:00
# endif
2005-02-06 14:43:27 +00:00
2006-02-11 23:25:11 +00:00
/* We won't come till here, if we had a "console only" command line parameter. */
2006-05-22 07:29:40 +00:00
splash_win = splash_new ( " Loading Wireshark ... " ) ;
2006-05-01 06:51:14 +00:00
if ( init_progfile_dir_error ! = NULL ) {
simple_dialog ( ESD_TYPE_WARN , ESD_BTN_OK ,
2006-05-22 07:29:40 +00:00
" Can't get pathname of Wireshark: %s. \n "
2006-05-01 06:51:14 +00:00
" It won't be possible to capture traffic. \n "
2006-05-22 07:29:40 +00:00
" Report this to the Wireshark developers. " ,
2006-05-01 06:51:14 +00:00
init_progfile_dir_error ) ;
g_free ( init_progfile_dir_error ) ;
}
1999-10-21 21:47:08 +00:00
2007-05-07 17:55:42 +00:00
splash_update ( RA_DISSECTORS , NULL , ( gpointer ) splash_win ) ;
2004-07-04 12:15:41 +00:00
Add support for a global "ethereal.conf" preferences file, stored in the
same directory as the "manuf" file ("/etc" or "/usr/local/etc", most
likely).
Add a mechanism to allow modules (e.g., dissectors) to register
preference values, which:
can be put into the global or the user's preference file;
can be set from the command line, with arguments to the "-o"
flag;
can be set from tabs in the "Preferences" dialog box.
Use that mechanism to register the "Decode IPv4 TOS field as DiffServ
field" variable for IP as a preference.
Stuff that still needs to be done:
documenting the API for registering preferences;
documenting the "-o" values in the man page (probably needs a
flag similar to "-G", and a Perl script to turn the output into
documentation as is done with the list of field);
handling error checking for numeric values (range checking,
making sure that if the user changes the variable from the GUI
they change it to a valid numeric value);
using the callbacks to, for example, update the display when
preferences are changed (could be expensive);
panic if the user specifies a numeric value with a base other
than 10, 8, or 16.
We may also want to clean up the existing wired-in preferences not to
take effect the instant you tweak the widget, and to add an "Apply"
button to the "Preferences" dialog.
svn path=/trunk/; revision=2117
2000-07-05 09:41:07 +00:00
/* Register all dissectors; we must do this before checking for the
2002-05-14 10:15:12 +00:00
" -G " flag , as the " -G " flag dumps information registered by the
dissectors , and we must do it before we read the preferences , in
case any dissectors register preferences . */
2007-05-22 23:06:22 +00:00
epan_init ( register_all_protocols , register_all_protocol_handoffs ,
2007-05-07 17:55:42 +00:00
splash_update , ( gpointer ) splash_win ,
2004-04-16 23:17:13 +00:00
failure_alert_box , open_failure_alert_box , read_failure_alert_box ) ;
2003-04-23 03:51:03 +00:00
2007-05-07 17:55:42 +00:00
splash_update ( RA_LISTENERS , NULL , ( gpointer ) splash_win ) ;
2004-07-04 12:15:41 +00:00
2003-04-23 03:51:03 +00:00
/* Register all tap listeners; we do this before we parse the arguments,
as the " -z " argument can specify a registered tap . */
2005-02-28 00:55:49 +00:00
/* we register the plugin taps before the other taps because
stats_tree taps plugins will be registered as tap listeners
by stats_tree_stat . c and need to registered before that */
2005-03-12 21:36:24 +00:00
# ifdef HAVE_PLUGINS
2005-02-27 22:04:48 +00:00
register_all_plugin_tap_listeners ( ) ;
2005-03-12 21:36:24 +00:00
# endif
Add support for a global "ethereal.conf" preferences file, stored in the
same directory as the "manuf" file ("/etc" or "/usr/local/etc", most
likely).
Add a mechanism to allow modules (e.g., dissectors) to register
preference values, which:
can be put into the global or the user's preference file;
can be set from the command line, with arguments to the "-o"
flag;
can be set from tabs in the "Preferences" dialog box.
Use that mechanism to register the "Decode IPv4 TOS field as DiffServ
field" variable for IP as a preference.
Stuff that still needs to be done:
documenting the API for registering preferences;
documenting the "-o" values in the man page (probably needs a
flag similar to "-G", and a Perl script to turn the output into
documentation as is done with the list of field);
handling error checking for numeric values (range checking,
making sure that if the user changes the variable from the GUI
they change it to a valid numeric value);
using the callbacks to, for example, update the display when
preferences are changed (could be expensive);
panic if the user specifies a numeric value with a base other
than 10, 8, or 16.
We may also want to clean up the existing wired-in preferences not to
take effect the instant you tweak the widget, and to add an "Apply"
button to the "Preferences" dialog.
svn path=/trunk/; revision=2117
2000-07-05 09:41:07 +00:00
2005-03-12 21:36:24 +00:00
register_all_tap_listeners ( ) ;
2006-02-16 15:27:03 +00:00
2007-05-07 17:55:42 +00:00
splash_update ( RA_PREFERENCES , NULL , ( gpointer ) splash_win ) ;
2004-07-04 12:15:41 +00:00
Add support for a global "ethereal.conf" preferences file, stored in the
same directory as the "manuf" file ("/etc" or "/usr/local/etc", most
likely).
Add a mechanism to allow modules (e.g., dissectors) to register
preference values, which:
can be put into the global or the user's preference file;
can be set from the command line, with arguments to the "-o"
flag;
can be set from tabs in the "Preferences" dialog box.
Use that mechanism to register the "Decode IPv4 TOS field as DiffServ
field" variable for IP as a preference.
Stuff that still needs to be done:
documenting the API for registering preferences;
documenting the "-o" values in the man page (probably needs a
flag similar to "-G", and a Perl script to turn the output into
documentation as is done with the list of field);
handling error checking for numeric values (range checking,
making sure that if the user changes the variable from the GUI
they change it to a valid numeric value);
using the callbacks to, for example, update the display when
preferences are changed (could be expensive);
panic if the user specifies a numeric value with a base other
than 10, 8, or 16.
We may also want to clean up the existing wired-in preferences not to
take effect the instant you tweak the widget, and to add an "Apply"
button to the "Preferences" dialog.
svn path=/trunk/; revision=2117
2000-07-05 09:41:07 +00:00
/* Now register the preferences for any non-dissector modules.
We must do that before we read the preferences as well . */
prefs_register_modules ( ) ;
2002-11-03 17:38:45 +00:00
/* multithread support currently doesn't seem to work in win32 gtk2.0.6 */
2004-09-11 23:03:36 +00:00
# if !defined(_WIN32) && GTK_MAJOR_VERSION >= 2 && defined(G_THREADS_ENABLED) && defined USE_THREADS
2002-11-03 17:38:45 +00:00
{
GThread * ut ;
g_thread_init ( NULL ) ;
gdk_threads_init ( ) ;
ut = g_thread_create ( update_thread , NULL , FALSE , NULL ) ;
g_thread_set_priority ( ut , G_THREAD_PRIORITY_LOW ) ;
}
2004-09-11 23:03:36 +00:00
# else /* _WIN32 || GTK1.2 || !G_THREADS_ENABLED || !USE_THREADS */
2002-09-07 10:02:36 +00:00
/* this is to keep tap extensions updating once every 3 seconds */
gtk_timeout_add ( 3000 , ( GtkFunction ) update_cb , ( gpointer ) NULL ) ;
2004-09-11 23:03:36 +00:00
# endif /* !_WIN32 && GTK2 && G_THREADS_ENABLED */
2002-09-07 10:02:36 +00:00
2003-05-04 18:50:56 +00:00
# if HAVE_GNU_ADNS
gtk_timeout_add ( 750 , ( GtkFunction ) host_name_lookup_process , NULL ) ;
# endif
2007-05-07 17:55:42 +00:00
splash_update ( RA_CONFIGURATION , NULL , ( gpointer ) splash_win ) ;
2002-08-28 21:04:11 +00:00
2001-01-28 04:52:29 +00:00
/* Read the preference files. */
2003-08-07 00:41:28 +00:00
prefs = read_prefs ( & gpf_open_errno , & gpf_read_errno , & gpf_path ,
& pf_open_errno , & pf_read_errno , & pf_path ) ;
2006-08-16 18:01:25 +00:00
2004-04-16 23:57:54 +00:00
if ( gpf_path ! = NULL ) {
if ( gpf_open_errno ! = 0 ) {
simple_dialog ( ESD_TYPE_WARN , ESD_BTN_OK ,
" Could not open global preferences file \n \" %s \" : %s. " , gpf_path ,
strerror ( gpf_open_errno ) ) ;
}
if ( gpf_read_errno ! = 0 ) {
simple_dialog ( ESD_TYPE_WARN , ESD_BTN_OK ,
" I/O error reading global preferences file \n \" %s \" : %s. " , gpf_path ,
strerror ( gpf_read_errno ) ) ;
}
}
if ( pf_path ! = NULL ) {
if ( pf_open_errno ! = 0 ) {
simple_dialog ( ESD_TYPE_WARN , ESD_BTN_OK ,
" Could not open your preferences file \n \" %s \" : %s. " , pf_path ,
strerror ( pf_open_errno ) ) ;
}
if ( pf_read_errno ! = 0 ) {
simple_dialog ( ESD_TYPE_WARN , ESD_BTN_OK ,
" I/O error reading your preferences file \n \" %s \" : %s. " , pf_path ,
strerror ( pf_read_errno ) ) ;
}
g_free ( pf_path ) ;
pf_path = NULL ;
}
1999-08-14 19:53:31 +00:00
2004-05-13 15:28:02 +00:00
# ifdef _WIN32
2005-02-06 21:20:35 +00:00
/* if the user wants a console to be always there, well, we should open one for him */
2004-05-13 15:28:02 +00:00
if ( prefs - > gui_console_open = = console_open_always ) {
create_console ( ) ;
}
# endif
2006-11-16 07:04:02 +00:00
/* Fill in capture options with values from the preferences */
prefs_to_capture_opts ( ) ;
2002-01-13 20:35:12 +00:00
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
/* Read the capture filter file. */
read_filter_list ( CFILTER_LIST , & cf_path , & cf_open_errno ) ;
2004-04-16 23:57:54 +00:00
if ( cf_path ! = NULL ) {
simple_dialog ( ESD_TYPE_WARN , ESD_BTN_OK ,
" Could not open your capture filter file \n \" %s \" : %s. " , cf_path ,
strerror ( cf_open_errno ) ) ;
g_free ( cf_path ) ;
}
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
/* Read the display filter file. */
read_filter_list ( DFILTER_LIST , & df_path , & df_open_errno ) ;
2004-04-16 23:57:54 +00:00
if ( df_path ! = NULL ) {
simple_dialog ( ESD_TYPE_WARN , ESD_BTN_OK ,
" Could not open your display filter file \n \" %s \" : %s. " , df_path ,
strerror ( df_open_errno ) ) ;
g_free ( df_path ) ;
}
2001-01-28 04:52:29 +00:00
2003-08-07 00:41:28 +00:00
/* Read the disabled protocols file. */
2004-01-03 18:40:08 +00:00
read_disabled_protos_list ( & gdp_path , & gdp_open_errno , & gdp_read_errno ,
& dp_path , & dp_open_errno , & dp_read_errno ) ;
2004-04-16 23:57:54 +00:00
if ( gdp_path ! = NULL ) {
if ( gdp_open_errno ! = 0 ) {
simple_dialog ( ESD_TYPE_WARN , ESD_BTN_OK ,
" Could not open global disabled protocols file \n \" %s \" : %s. " ,
gdp_path , strerror ( gdp_open_errno ) ) ;
}
if ( gdp_read_errno ! = 0 ) {
simple_dialog ( ESD_TYPE_WARN , ESD_BTN_OK ,
" I/O error reading global disabled protocols file \n \" %s \" : %s. " ,
gdp_path , strerror ( gdp_read_errno ) ) ;
}
g_free ( gdp_path ) ;
}
if ( dp_path ! = NULL ) {
if ( dp_open_errno ! = 0 ) {
simple_dialog ( ESD_TYPE_WARN , ESD_BTN_OK ,
" Could not open your disabled protocols file \n \" %s \" : %s. " , dp_path ,
strerror ( dp_open_errno ) ) ;
}
if ( dp_read_errno ! = 0 ) {
simple_dialog ( ESD_TYPE_WARN , ESD_BTN_OK ,
" I/O error reading your disabled protocols file \n \" %s \" : %s. " , dp_path ,
strerror ( dp_read_errno ) ) ;
}
g_free ( dp_path ) ;
}
2003-08-07 00:41:28 +00:00
2005-05-30 04:06:22 +00:00
/* Read the (static part) of the recent file. Only the static part of it will be read, */
/* as we don't have the gui now to fill the recent lists which is done in the dynamic part. */
/* We have to do this already here, so command line parameters can overwrite these values. */
recent_read_static ( & rf_path , & rf_open_errno ) ;
2002-09-06 22:45:44 +00:00
init_cap_file ( & cfile ) ;
1998-11-17 04:29:13 +00:00
1998-09-16 02:39:15 +00:00
/* Now get our args */
2002-05-22 23:22:56 +00:00
while ( ( opt = getopt ( argc , argv , optstring ) ) ! = - 1 ) {
1998-09-16 02:39:15 +00:00
switch ( opt ) {
2005-02-06 21:20:35 +00:00
/*** capture option specific ***/
2001-12-04 07:32:05 +00:00
case ' a ' : /* autostop criteria */
2005-02-06 21:20:35 +00:00
case ' b ' : /* Ringbuffer option */
case ' c ' : /* Capture xxx packets */
case ' f ' : /* capture filter */
case ' k ' : /* Start capture immediately */
case ' H ' : /* Hide capture info dialog box */
case ' i ' : /* Use interface xxx */
case ' p ' : /* Don't capture in promiscuous mode */
case ' Q ' : /* Quit after capture (just capture to file) */
case ' s ' : /* Set the snapshot (capture) length */
case ' S ' : /* "Sync" mode: used for following file ala tail -f */
case ' w ' : /* Write to capture file xxx */
case ' y ' : /* Set the pcap data link type */
# ifdef _WIN32
2005-05-30 04:46:25 +00:00
case ' B ' : /* Buffer size */
2005-02-06 21:20:35 +00:00
# endif /* _WIN32 */
2001-12-04 07:32:05 +00:00
# ifdef HAVE_LIBPCAP
2006-02-10 02:05:30 +00:00
status = capture_opts_add_opt ( capture_opts , opt , optarg , & start_capture ) ;
if ( status ! = 0 ) {
exit ( status ) ;
}
2001-12-04 07:32:05 +00:00
# else
capture_option_specified = TRUE ;
arg_error = TRUE ;
2001-12-04 08:26:00 +00:00
# endif
break ;
2005-02-06 21:20:35 +00:00
/*** all non capture option specific ***/
2005-12-13 22:48:58 +00:00
case ' D ' : /* Print a list of capture devices and exit */
# ifdef HAVE_LIBPCAP
2007-06-11 03:58:58 +00:00
capture_opts_list_interfaces ( FALSE ) ;
2005-12-13 22:48:58 +00:00
exit ( 0 ) ;
# else
capture_option_specified = TRUE ;
arg_error = TRUE ;
# endif
break ;
2005-05-31 21:30:40 +00:00
case ' g ' : /* Go to packet */
2005-11-17 05:59:21 +00:00
go_to_packet = get_positive_int ( optarg , " go to packet " ) ;
2005-05-31 21:30:40 +00:00
break ;
2001-05-01 00:41:46 +00:00
case ' l ' : /* Automatic scrolling in live capture mode */
2002-01-10 11:05:50 +00:00
# ifdef HAVE_LIBPCAP
auto_scroll_live = TRUE ;
# else
capture_option_specified = TRUE ;
arg_error = TRUE ;
2003-11-01 02:30:18 +00:00
# endif
break ;
case ' L ' : /* Print list of link-layer types and exit */
# ifdef HAVE_LIBPCAP
list_link_layer_types = TRUE ;
# else
capture_option_specified = TRUE ;
arg_error = TRUE ;
2002-01-10 11:05:50 +00:00
# endif
2001-05-01 00:41:46 +00:00
break ;
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
case ' m ' : /* Fixed-width font for the display */
2004-01-20 18:47:25 +00:00
if ( prefs - > PREFS_GUI_FONT_NAME ! = NULL )
g_free ( prefs - > PREFS_GUI_FONT_NAME ) ;
prefs - > PREFS_GUI_FONT_NAME = g_strdup ( optarg ) ;
2001-05-31 08:36:46 +00:00
break ;
1998-09-16 02:39:15 +00:00
case ' n ' : /* No name resolution */
2002-01-13 20:35:12 +00:00
g_resolv_flags = RESOLV_NONE ;
2001-05-31 08:36:46 +00:00
break ;
case ' N ' : /* Select what types of addresses/port #s to resolve */
2002-01-13 20:35:12 +00:00
if ( g_resolv_flags = = RESOLV_ALL )
g_resolv_flags = RESOLV_NONE ;
badopt = string_to_name_resolve ( optarg , & g_resolv_flags ) ;
2001-05-31 08:36:46 +00:00
if ( badopt ! = ' \0 ' ) {
2005-11-17 05:59:21 +00:00
cmdarg_err ( " -N specifies unknown resolving option '%c'; valid options are 'm', 'n', and 't' " ,
2001-05-31 08:36:46 +00:00
badopt ) ;
exit ( 1 ) ;
}
break ;
Add support for a global "ethereal.conf" preferences file, stored in the
same directory as the "manuf" file ("/etc" or "/usr/local/etc", most
likely).
Add a mechanism to allow modules (e.g., dissectors) to register
preference values, which:
can be put into the global or the user's preference file;
can be set from the command line, with arguments to the "-o"
flag;
can be set from tabs in the "Preferences" dialog box.
Use that mechanism to register the "Decode IPv4 TOS field as DiffServ
field" variable for IP as a preference.
Stuff that still needs to be done:
documenting the API for registering preferences;
documenting the "-o" values in the man page (probably needs a
flag similar to "-G", and a Perl script to turn the output into
documentation as is done with the list of field);
handling error checking for numeric values (range checking,
making sure that if the user changes the variable from the GUI
they change it to a valid numeric value);
using the callbacks to, for example, update the display when
preferences are changed (could be expensive);
panic if the user specifies a numeric value with a base other
than 10, 8, or 16.
We may also want to clean up the existing wired-in preferences not to
take effect the instant you tweak the widget, and to add an "Apply"
button to the "Preferences" dialog.
svn path=/trunk/; revision=2117
2000-07-05 09:41:07 +00:00
case ' o ' : /* Override preference from command line */
switch ( prefs_set_pref ( optarg ) ) {
2005-05-30 04:06:22 +00:00
case PREFS_SET_OK :
break ;
case PREFS_SET_SYNTAX_ERR :
2005-11-17 05:59:21 +00:00
cmdarg_err ( " Invalid -o flag \" %s \" " , optarg ) ;
Add support for a global "ethereal.conf" preferences file, stored in the
same directory as the "manuf" file ("/etc" or "/usr/local/etc", most
likely).
Add a mechanism to allow modules (e.g., dissectors) to register
preference values, which:
can be put into the global or the user's preference file;
can be set from the command line, with arguments to the "-o"
flag;
can be set from tabs in the "Preferences" dialog box.
Use that mechanism to register the "Decode IPv4 TOS field as DiffServ
field" variable for IP as a preference.
Stuff that still needs to be done:
documenting the API for registering preferences;
documenting the "-o" values in the man page (probably needs a
flag similar to "-G", and a Perl script to turn the output into
documentation as is done with the list of field);
handling error checking for numeric values (range checking,
making sure that if the user changes the variable from the GUI
they change it to a valid numeric value);
using the callbacks to, for example, update the display when
preferences are changed (could be expensive);
panic if the user specifies a numeric value with a base other
than 10, 8, or 16.
We may also want to clean up the existing wired-in preferences not to
take effect the instant you tweak the widget, and to add an "Apply"
button to the "Preferences" dialog.
svn path=/trunk/; revision=2117
2000-07-05 09:41:07 +00:00
exit ( 1 ) ;
break ;
case PREFS_SET_NO_SUCH_PREF :
2005-05-30 04:06:22 +00:00
/* not a preference, might be a recent setting */
switch ( recent_set_arg ( optarg ) ) {
case PREFS_SET_OK :
break ;
case PREFS_SET_SYNTAX_ERR :
/* shouldn't happen, checked already above */
2005-11-17 05:59:21 +00:00
cmdarg_err ( " Invalid -o flag \" %s \" " , optarg ) ;
2005-05-30 04:06:22 +00:00
exit ( 1 ) ;
break ;
case PREFS_SET_NO_SUCH_PREF :
case PREFS_SET_OBSOLETE :
2005-11-17 05:59:21 +00:00
cmdarg_err ( " -o flag \" %s \" specifies unknown preference/recent value " ,
2005-05-30 04:06:22 +00:00
optarg ) ;
exit ( 1 ) ;
break ;
default :
g_assert_not_reached ( ) ;
}
break ;
Allow a dissector to register preferences that it no longer supports as
obsolete; we silently ignore attempts to set those in a preferences
file, so that we don't spam the user with error messages caused by them
having saved preferences in an earlier release that contained those
preferences.
Make the Diameter and iSCSI dissectors register obsolete preferences.
Crash if some code tries to register a preferences module with a name
that contains something other than lower-case ASCII letters, numbers, or
underscores, or that has already been registered, or if some code tries
to register a preference with a name that contains something other than
lower-case ASCII letters, numbers, underscores, or periods, or that has
already been registered, so that we don't put code like that in a
release and have to shovel code into "prefs.c" to fix it up later. (The
problem with multiple modules or preferences with the same name should
be obvious; the problem with names with blanks, or upper-case letters,
or punctuation, is that they're a pain to type on the command line.)
svn path=/trunk/; revision=4148
2001-11-04 02:50:21 +00:00
case PREFS_SET_OBSOLETE :
2005-11-17 05:59:21 +00:00
cmdarg_err ( " -o flag \" %s \" specifies obsolete preference " ,
Add support for a global "ethereal.conf" preferences file, stored in the
same directory as the "manuf" file ("/etc" or "/usr/local/etc", most
likely).
Add a mechanism to allow modules (e.g., dissectors) to register
preference values, which:
can be put into the global or the user's preference file;
can be set from the command line, with arguments to the "-o"
flag;
can be set from tabs in the "Preferences" dialog box.
Use that mechanism to register the "Decode IPv4 TOS field as DiffServ
field" variable for IP as a preference.
Stuff that still needs to be done:
documenting the API for registering preferences;
documenting the "-o" values in the man page (probably needs a
flag similar to "-G", and a Perl script to turn the output into
documentation as is done with the list of field);
handling error checking for numeric values (range checking,
making sure that if the user changes the variable from the GUI
they change it to a valid numeric value);
using the callbacks to, for example, update the display when
preferences are changed (could be expensive);
panic if the user specifies a numeric value with a base other
than 10, 8, or 16.
We may also want to clean up the existing wired-in preferences not to
take effect the instant you tweak the widget, and to add an "Apply"
button to the "Preferences" dialog.
svn path=/trunk/; revision=2117
2000-07-05 09:41:07 +00:00
optarg ) ;
exit ( 1 ) ;
break ;
2005-05-30 04:06:22 +00:00
default :
g_assert_not_reached ( ) ;
Add support for a global "ethereal.conf" preferences file, stored in the
same directory as the "manuf" file ("/etc" or "/usr/local/etc", most
likely).
Add a mechanism to allow modules (e.g., dissectors) to register
preference values, which:
can be put into the global or the user's preference file;
can be set from the command line, with arguments to the "-o"
flag;
can be set from tabs in the "Preferences" dialog box.
Use that mechanism to register the "Decode IPv4 TOS field as DiffServ
field" variable for IP as a preference.
Stuff that still needs to be done:
documenting the API for registering preferences;
documenting the "-o" values in the man page (probably needs a
flag similar to "-G", and a Perl script to turn the output into
documentation as is done with the list of field);
handling error checking for numeric values (range checking,
making sure that if the user changes the variable from the GUI
they change it to a valid numeric value);
using the callbacks to, for example, update the display when
preferences are changed (could be expensive);
panic if the user specifies a numeric value with a base other
than 10, 8, or 16.
We may also want to clean up the existing wired-in preferences not to
take effect the instant you tweak the widget, and to add an "Apply"
button to the "Preferences" dialog.
svn path=/trunk/; revision=2117
2000-07-05 09:41:07 +00:00
}
break ;
2007-03-14 02:55:54 +00:00
case ' P ' :
/* Path settings were already processed just ignore them this time*/
break ;
1998-09-16 02:39:15 +00:00
case ' r ' : /* Read capture file xxx */
1999-12-02 08:28:34 +00:00
/* We may set "last_open_dir" to "cf_name", and if we change
" last_open_dir " later , we free the old value , so we have to
set " cf_name " to something that ' s been allocated . */
2007-01-12 03:05:28 +00:00
# if defined _WIN32 && (GLIB_MAJOR_VERSION > 2 || (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 6))
2006-01-12 22:38:37 +00:00
/* since GLib 2.6, we need to convert filenames to utf8 for Win32 */
cf_name = g_locale_to_utf8 ( optarg , - 1 , NULL , NULL , NULL ) ;
# else
Fix bug which occurs when running ethereal with "-r" to load a file, then
loading a new file from within ethereal.
In main(), cf_name was being set to optarg, without g_strdup()'ing it.
Later, in file_open_cmd_cb(), we try to g_free last_open_dir, which is
cf_name, so blammo! We try to g_free something that we can't.
So, in main(), be sure to set cf_name to a g_strdup() of optarg, not
just optarg.
(At home I'm using debug/development versions of glib/gtk, so maybe
that's why I saw the problem only now. I could have sworn that I
have done this sequence of events successfully before).
svn path=/trunk/; revision=1180
1999-12-02 05:25:59 +00:00
cf_name = g_strdup ( optarg ) ;
2006-01-12 22:38:37 +00:00
# endif
1998-09-16 02:39:15 +00:00
break ;
1999-08-08 01:29:24 +00:00
case ' R ' : /* Read file filter */
1999-08-15 19:18:46 +00:00
rfilter = optarg ;
1999-08-08 01:29:24 +00:00
break ;
1998-09-27 22:12:47 +00:00
case ' t ' : /* Time stamp type */
if ( strcmp ( optarg , " r " ) = = 0 )
2005-08-25 21:29:54 +00:00
timestamp_set_type ( TS_RELATIVE ) ;
1998-09-27 22:12:47 +00:00
else if ( strcmp ( optarg , " a " ) = = 0 )
2005-08-25 21:29:54 +00:00
timestamp_set_type ( TS_ABSOLUTE ) ;
2000-11-01 08:31:36 +00:00
else if ( strcmp ( optarg , " ad " ) = = 0 )
2005-08-25 21:29:54 +00:00
timestamp_set_type ( TS_ABSOLUTE_WITH_DATE ) ;
1998-09-27 22:12:47 +00:00
else if ( strcmp ( optarg , " d " ) = = 0 )
2005-08-25 21:29:54 +00:00
timestamp_set_type ( TS_DELTA ) ;
2007-03-23 18:08:17 +00:00
else if ( strcmp ( optarg , " dd " ) = = 0 )
timestamp_set_type ( TS_DELTA_DIS ) ;
2006-12-05 03:19:51 +00:00
else if ( strcmp ( optarg , " e " ) = = 0 )
timestamp_set_type ( TS_EPOCH ) ;
1998-09-27 22:12:47 +00:00
else {
2005-11-17 05:59:21 +00:00
cmdarg_err ( " Invalid time stamp type \" %s \" " , optarg ) ;
cmdarg_err_cont ( " It must be \" r \" for relative, \" a \" for absolute, " ) ;
cmdarg_err_cont ( " \" ad \" for absolute with date, or \" d \" for delta. " ) ;
1998-09-27 22:12:47 +00:00
exit ( 1 ) ;
}
break ;
2006-02-16 15:27:03 +00:00
case ' X ' :
2006-02-07 22:08:12 +00:00
/* ext ops were already processed just ignore them this time*/
2006-02-16 15:27:03 +00:00
break ;
2002-11-06 10:53:36 +00:00
case ' z ' :
2005-08-19 09:29:41 +00:00
/* We won't call the init function for the stat this soon
2005-04-01 09:08:27 +00:00
as it would disallow MATE ' s fields ( which are registered
by the preferences set callback ) from being used as
part of a tap filter . Instead , we just add the argument
2005-08-19 09:29:41 +00:00
to a list of stat arguments . */
if ( ! process_stat_cmd_arg ( optarg ) ) {
2005-11-17 05:59:21 +00:00
cmdarg_err ( " Invalid -z argument. " ) ;
cmdarg_err_cont ( " -z argument must be one of : " ) ;
2005-08-19 09:29:41 +00:00
list_stat_cmd_args ( ) ;
2005-04-01 09:08:27 +00:00
exit ( 1 ) ;
}
2002-11-06 10:53:36 +00:00
break ;
1999-12-07 07:12:49 +00:00
default :
1999-10-02 20:00:46 +00:00
case ' ? ' : /* Bad flag - print usage message */
1999-12-07 07:12:49 +00:00
arg_error = TRUE ;
1999-10-02 20:00:46 +00:00
break ;
1998-09-16 02:39:15 +00:00
}
}
2001-11-24 08:46:13 +00:00
argc - = optind ;
argv + = optind ;
if ( argc > = 1 ) {
if ( cf_name ! = NULL ) {
/*
* Input file name specified with " -r " * and * specified as a regular
* command - line argument .
*/
2005-11-17 05:59:21 +00:00
cmdarg_err ( " File name specified both with -r and regular argument " ) ;
2001-11-24 08:46:13 +00:00
arg_error = TRUE ;
} else {
/*
* Input file name not specified with " -r " , and a command - line argument
* was specified ; treat it as the input file name .
*
2006-05-31 17:38:42 +00:00
* Yes , this is different from tshark , where non - flag command - line
2001-11-24 08:46:13 +00:00
* arguments are a filter , but this works better on GUI desktops
* where a command can be specified to be run to open a particular
* file - yes , you could have " -r " as the last part of the command ,
* but that ' s a bit ugly .
*/
2007-01-12 03:05:28 +00:00
# if defined _WIN32 && (GLIB_MAJOR_VERSION > 2 || (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 6))
2006-01-12 22:38:37 +00:00
/* since GLib 2.6, we need to convert filenames to utf8 for Win32 */
cf_name = g_locale_to_utf8 ( argv [ 0 ] , - 1 , NULL , NULL , NULL ) ;
# else
2001-11-24 08:46:13 +00:00
cf_name = g_strdup ( argv [ 0 ] ) ;
2006-01-12 22:38:37 +00:00
# endif
2001-11-24 08:46:13 +00:00
}
argc - - ;
argv + + ;
}
2005-02-06 21:20:35 +00:00
2001-11-24 08:46:13 +00:00
if ( argc ! = 0 ) {
/*
* Extra command line arguments were specified ; complain .
*/
2005-11-17 05:59:21 +00:00
cmdarg_err ( " Invalid argument: %s " , argv [ 0 ] ) ;
2001-11-24 08:46:13 +00:00
arg_error = TRUE ;
}
2003-11-01 02:30:18 +00:00
2005-02-06 14:43:27 +00:00
if ( arg_error ) {
2003-11-01 02:30:18 +00:00
# ifndef HAVE_LIBPCAP
2005-02-06 14:43:27 +00:00
if ( capture_option_specified ) {
2006-05-22 07:29:40 +00:00
cmdarg_err ( " This version of Wireshark was not built with support for capturing packets. " ) ;
2005-02-06 14:43:27 +00:00
}
2003-11-01 02:30:18 +00:00
# endif
2002-05-22 23:22:56 +00:00
print_usage ( FALSE ) ;
exit ( 1 ) ;
}
1998-12-29 04:05:38 +00:00
2002-01-10 09:51:23 +00:00
# ifdef HAVE_LIBPCAP
2003-11-01 02:30:18 +00:00
if ( start_capture & & list_link_layer_types ) {
/* Specifying *both* is bogus. */
2005-11-17 05:59:21 +00:00
cmdarg_err ( " You can't specify both -L and a live capture. " ) ;
2003-11-01 02:30:18 +00:00
exit ( 1 ) ;
2003-08-07 00:41:28 +00:00
}
2003-11-01 02:30:18 +00:00
if ( list_link_layer_types ) {
/* We're supposed to list the link-layer types for an interface;
did the user also specify a capture file to be read ? */
if ( cf_name ) {
/* Yes - that's bogus. */
2005-11-17 05:59:21 +00:00
cmdarg_err ( " You can't specify -L and a capture file to be read. " ) ;
2003-11-01 02:30:18 +00:00
exit ( 1 ) ;
}
/* No - did they specify a ring buffer option? */
2004-12-29 09:09:35 +00:00
if ( capture_opts - > multi_files_on ) {
2005-11-17 05:59:21 +00:00
cmdarg_err ( " Ring buffer requested, but a capture isn't being done. " ) ;
2003-11-01 02:30:18 +00:00
exit ( 1 ) ;
}
} else {
2003-09-15 20:45:19 +00:00
/* We're supposed to do a live capture; did the user also specify
2003-09-15 23:20:34 +00:00
a capture file to be read ? */
2003-11-02 19:31:20 +00:00
if ( start_capture & & cf_name ) {
2003-09-15 20:45:19 +00:00
/* Yes - that's bogus. */
2005-11-17 05:59:21 +00:00
cmdarg_err ( " You can't specify both a live capture and a capture file to be read. " ) ;
2003-11-01 02:30:18 +00:00
exit ( 1 ) ;
2003-09-15 20:45:19 +00:00
}
2003-11-01 02:30:18 +00:00
/* No - was the ring buffer option specified and, if so, does it make
sense ? */
2004-12-29 09:09:35 +00:00
if ( capture_opts - > multi_files_on ) {
2003-11-01 02:30:18 +00:00
/* Ring buffer works only under certain conditions:
a ) ring buffer does not work with temporary files ;
2005-03-28 16:14:34 +00:00
b ) real_time_mode and multi_files_on are mutually exclusive -
real_time_mode takes precedence ;
2003-11-01 02:30:18 +00:00
c ) it makes no sense to enable the ring buffer if the maximum
file size is set to " infinite " . */
2005-02-06 21:20:35 +00:00
if ( capture_opts - > save_file = = NULL ) {
2005-11-17 05:59:21 +00:00
cmdarg_err ( " Ring buffer requested, but capture isn't being saved to a permanent file. " ) ;
2004-12-29 09:09:35 +00:00
capture_opts - > multi_files_on = FALSE ;
2003-11-01 02:30:18 +00:00
}
2005-03-28 16:14:34 +00:00
/* if (capture_opts->real_time_mode) {
2005-11-17 05:59:21 +00:00
cmdarg_err ( " Ring buffer requested, but an \" Update list of packets in real time \" capture is being done. " ) ;
2004-12-29 09:09:35 +00:00
capture_opts - > multi_files_on = FALSE ;
2005-03-28 00:19:02 +00:00
} */
if ( ! capture_opts - > has_autostop_filesize & & ! capture_opts - > has_file_duration ) {
2005-11-17 05:59:21 +00:00
cmdarg_err ( " Ring buffer requested, but no maximum capture file size or duration were specified. " ) ;
2005-04-12 00:54:52 +00:00
/* XXX - this must be redesigned as the conditions changed */
/* capture_opts->multi_files_on = FALSE;*/
2003-11-01 02:30:18 +00:00
}
}
}
if ( start_capture | | list_link_layer_types ) {
/* Did the user specify an interface to use? */
2006-02-16 15:27:03 +00:00
if ( ! capture_opts_trim_iface ( capture_opts ,
2005-12-13 22:48:58 +00:00
( prefs - > capture_device ) ? get_if_name ( prefs - > capture_device ) : NULL ) ) {
exit ( 2 ) ;
1999-06-15 03:46:46 +00:00
}
1999-10-02 06:00:07 +00:00
}
2003-11-01 02:30:18 +00:00
if ( list_link_layer_types ) {
2007-07-20 21:43:07 +00:00
status = capture_opts_list_link_layer_types ( capture_opts , FALSE ) ;
2006-02-10 02:05:30 +00:00
exit ( status ) ;
2003-11-01 02:30:18 +00:00
}
2003-11-18 04:16:28 +00:00
2005-12-13 22:48:58 +00:00
capture_opts_trim_snaplen ( capture_opts , MIN_PACKET_SIZE ) ;
capture_opts_trim_ring_num_files ( capture_opts ) ;
2005-02-06 21:20:35 +00:00
# endif /* HAVE_LIBPCAP */
1999-06-15 03:46:46 +00:00
2003-11-01 02:30:18 +00:00
/* Notify all registered modules that have had any of their preferences
changed either from one of the preferences file or from the command
line that their preferences have changed . */
prefs_apply_all ( ) ;
/* disabled protocols as per configuration file */
2004-01-03 18:40:08 +00:00
if ( gdp_path = = NULL & & dp_path = = NULL ) {
2003-11-01 02:30:18 +00:00
set_disabled_protos_list ( ) ;
}
2007-06-04 20:15:10 +00:00
build_column_format_array ( & cfile , TRUE ) ;
2003-12-02 23:14:32 +00:00
2004-01-20 18:47:25 +00:00
/* read in rc file from global and personal configuration paths. */
2005-07-19 20:44:45 +00:00
rc_file = get_datafile_path ( RC_FILE ) ;
gtk_rc_parse ( rc_file ) ;
2001-10-24 07:18:39 +00:00
rc_file = get_persconffile_path ( RC_FILE , FALSE ) ;
1998-09-16 02:39:15 +00:00
gtk_rc_parse ( rc_file ) ;
2006-02-11 23:35:31 +00:00
font_init ( ) ;
2001-03-02 23:10:12 +00:00
2004-07-04 12:15:41 +00:00
/* close the splash screen, as we are going to open the main window now */
2007-05-22 23:06:22 +00:00
splash_destroy ( splash_win ) ;
2004-07-04 12:15:41 +00:00
2006-02-11 23:47:03 +00:00
/************************************************************************/
/* Everything is prepared now, preferences and command line was read in */
2005-02-06 21:20:35 +00:00
2005-05-30 04:06:22 +00:00
/* Pop up the main window. */
2005-02-07 00:31:45 +00:00
create_main_window ( pl_size , tv_size , bv_size , prefs ) ;
2005-05-30 04:06:22 +00:00
/* Read the dynamic part of the recent file, as we have the gui now ready for it. */
recent_read_dynamic ( & rf_path , & rf_open_errno ) ;
2005-03-27 02:19:51 +00:00
color_filters_enable ( recent . packet_list_colorize ) ;
2005-02-07 00:31:45 +00:00
2005-05-30 04:06:22 +00:00
/* rearrange all the widgets as we now have all recent settings ready for this */
2005-02-07 00:31:45 +00:00
main_widgets_rearrange ( ) ;
/* Fill in column titles. This must be done after the top level window
is displayed .
XXX - is that still true , with fixed - width columns ? */
packet_list_set_column_titles ( ) ;
menu_recent_read_finished ( ) ;
switch ( user_font_apply ( ) ) {
case FA_SUCCESS :
break ;
case FA_FONT_NOT_RESIZEABLE :
/* "user_font_apply()" popped up an alert box. */
/* turn off zooming - font can't be resized */
case FA_FONT_NOT_AVAILABLE :
/* XXX - did we successfully load the un-zoomed version earlier?
If so , this * probably * means the font is available , but not at
this particular zoom level , but perhaps some other failure
occurred ; I ' m not sure you can determine which is the case ,
however . */
/* turn off zooming - zoom level is unavailable */
default :
/* in any other case than FA_SUCCESS, turn off zooming */
2006-02-16 15:27:03 +00:00
recent . gui_zoom_level = 0 ;
2005-02-07 00:31:45 +00:00
/* XXX: would it be a good idea to disable zooming (insensitive GUI)? */
}
2004-02-01 20:28:11 +00:00
2005-02-07 00:31:45 +00:00
dnd_init ( top_level ) ;
2004-02-01 20:28:11 +00:00
2005-02-07 00:31:45 +00:00
colors_init ( ) ;
2005-03-26 01:09:14 +00:00
color_filters_init ( ) ;
2005-02-07 00:31:45 +00:00
decode_as_init ( ) ;
2000-01-15 12:54:24 +00:00
2005-02-07 00:31:45 +00:00
/* the window can be sized only, if it's not already shown, so do it now! */
main_load_window_geometry ( top_level ) ;
2004-02-20 17:43:50 +00:00
2007-08-30 00:24:40 +00:00
/* Tell the user not to run as root. */
if ( running_with_special_privs ( ) & & recent . privs_warn_if_elevated ) {
cur_user = get_cur_username ( ) ;
cur_group = get_cur_groupname ( ) ;
priv_warning_dialog = simple_dialog ( ESD_TYPE_WARN , ESD_BTN_OK ,
" Running as user \" %s \" and group \" %s \" . \n "
" This could be dangerous. " , cur_user , cur_group ) ;
g_free ( cur_user ) ;
g_free ( cur_group ) ;
simple_dialog_check_set ( priv_warning_dialog , " Don't show this message again. " ) ;
simple_dialog_set_cb ( priv_warning_dialog , priv_warning_dialog_cb , NULL ) ;
}
2005-02-07 00:31:45 +00:00
/* If we were given the name of a capture file, read it in now;
we defer it until now , so that , if we can ' t open it , and pop
up an alert box , the alert box is more likely to come up on
top of the main window - but before the preference - file - error
alert box , so , if we get one of those , it ' s more likely to come
up on top of us . */
if ( cf_name ) {
2005-02-07 02:09:30 +00:00
show_main_window ( TRUE ) ;
2005-02-07 00:31:45 +00:00
if ( rfilter ! = NULL ) {
if ( ! dfilter_compile ( rfilter , & rfcode ) ) {
bad_dfilter_alert_box ( rfilter ) ;
rfilter_parse_failed = TRUE ;
2000-01-15 12:54:24 +00:00
}
2005-02-07 00:31:45 +00:00
}
if ( ! rfilter_parse_failed ) {
if ( cf_open ( & cfile , cf_name , FALSE , & err ) = = CF_OK ) {
/* "cf_open()" succeeded, so it closed the previous
capture file , and thus destroyed any previous read filter
attached to " cf " . */
cfile . rfcode = rfcode ;
2005-08-19 09:29:41 +00:00
/* Open stat windows; we do so after creating the main window,
2005-02-07 00:31:45 +00:00
to avoid GTK warnings , and after successfully opening the
2005-08-19 09:29:41 +00:00
capture file , so we know we have something to compute stats
on , and after registering all dissectors , so that MATE will
have registered its field array and we can have a tap filter
with one of MATE ' s late - registered fields as part of the
2005-04-01 05:45:08 +00:00
filter . */
2005-08-19 09:29:41 +00:00
start_requested_stats ( ) ;
2003-09-15 23:15:32 +00:00
2005-02-07 00:31:45 +00:00
/* Read the capture file. */
switch ( cf_read ( & cfile ) ) {
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
2005-02-07 00:31:45 +00:00
case CF_READ_OK :
case CF_READ_ERROR :
/* Just because we got an error, that doesn't mean we were unable
to read any of the file ; we handle what we could get from the
file . */
2005-05-31 21:30:40 +00:00
/* if the user told us to jump to a specific packet, do it now */
if ( go_to_packet ! = 0 ) {
cf_goto_frame ( & cfile , go_to_packet ) ;
}
2005-02-07 00:31:45 +00:00
break ;
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
2005-02-07 00:31:45 +00:00
case CF_READ_ABORTED :
/* Exit now. */
gtk_exit ( 0 ) ;
break ;
2000-01-15 12:54:24 +00:00
}
2005-02-07 00:31:45 +00:00
/* Save the name of the containing directory specified in the
path name , if any ; we can write over cf_name , which is a
good thing , given that " get_dirname() " does write over its
argument . */
s = get_dirname ( cf_name ) ;
2007-01-14 23:28:35 +00:00
set_last_open_dir ( s ) ;
2005-02-07 00:31:45 +00:00
g_free ( cf_name ) ;
cf_name = NULL ;
} else {
if ( rfcode ! = NULL )
dfilter_free ( rfcode ) ;
cfile . rfcode = NULL ;
2005-10-03 19:11:57 +00:00
show_main_window ( FALSE ) ;
2005-03-04 22:25:02 +00:00
set_menus_for_capture_in_progress ( FALSE ) ;
2000-01-15 12:54:24 +00:00
}
}
2005-02-07 02:09:30 +00:00
} else {
2000-01-15 12:54:24 +00:00
# ifdef HAVE_LIBPCAP
2005-02-07 02:09:30 +00:00
if ( start_capture ) {
if ( capture_opts - > save_file ! = NULL ) {
/* Save the directory name for future file dialogs. */
/* (get_dirname overwrites filename) */
2006-02-16 15:27:03 +00:00
s = get_dirname ( g_strdup ( capture_opts - > save_file ) ) ;
2005-02-07 02:09:30 +00:00
set_last_open_dir ( s ) ;
g_free ( s ) ;
}
/* "-k" was specified; start a capture. */
show_main_window ( TRUE ) ;
2005-03-28 18:04:09 +00:00
if ( capture_start ( capture_opts ) ) {
2005-08-19 09:29:41 +00:00
/* The capture started. Open stat windows; we do so after creating
2005-04-01 05:45:08 +00:00
the main window , to avoid GTK warnings , and after successfully
2005-08-19 09:29:41 +00:00
opening the capture file , so we know we have something to compute
stats on , and after registering all dissectors , so that MATE will
have registered its field array and we can have a tap filter with
one of MATE ' s late - registered fields as part of the filter . */
start_requested_stats ( ) ;
2005-02-07 00:31:45 +00:00
}
2000-01-25 13:44:39 +00:00
}
2005-02-07 02:09:30 +00:00
else {
show_main_window ( FALSE ) ;
set_menus_for_capture_in_progress ( FALSE ) ;
2003-11-18 04:16:28 +00:00
}
2005-02-06 21:20:35 +00:00
2005-02-07 02:09:30 +00:00
/* if the user didn't supplied a capture filter, use the one to filter out remote connections like SSH */
2006-08-26 18:36:09 +00:00
if ( ! start_capture & & strlen ( capture_opts - > cfilter ) = = 0 ) {
g_free ( capture_opts - > cfilter ) ;
2005-02-07 02:09:30 +00:00
capture_opts - > cfilter = g_strdup ( get_conn_cfilter ( ) ) ;
}
2004-04-16 23:57:54 +00:00
# else /* HAVE_LIBPCAP */
2005-02-07 02:09:30 +00:00
show_main_window ( FALSE ) ;
set_menus_for_capture_in_progress ( FALSE ) ;
2004-04-16 23:57:54 +00:00
# endif /* HAVE_LIBPCAP */
2005-02-07 02:09:30 +00:00
}
2004-01-08 20:39:51 +00:00
2006-08-26 17:55:21 +00:00
/* register our pid if we are being run from a U3 device */
u3_register_pid ( ) ;
2005-08-02 07:29:15 +00:00
/* we'll enter the GTK loop now and hand the control over to GTK ... */
2000-01-15 12:54:24 +00:00
gtk_main ( ) ;
2005-08-02 07:29:15 +00:00
/* ... back from GTK, we're going down now! */
2000-01-15 12:54:24 +00:00
2006-08-26 17:55:21 +00:00
/* deregister our pid */
u3_deregister_pid ( ) ;
2000-09-27 04:55:05 +00:00
epan_cleanup ( ) ;
2000-01-15 12:54:24 +00:00
g_free ( rc_file ) ;
2006-12-05 19:24:25 +00:00
# ifdef HAVE_AIRPDCAP
/* Davide Schiera (2006-11-18): destroy AirPDcap context */
AirPDcapDestroyContext ( & airpdcap_ctx ) ;
/* Davide Schiera (2006-11-18) ------------------------------------------- */
# endif
2004-09-11 23:03:36 +00:00
# ifdef _WIN32
2005-05-26 21:49:48 +00:00
/* hide the (unresponsive) main window, while asking the user to close the console window */
gtk_widget_hide ( top_level ) ;
2000-09-14 22:59:08 +00:00
/* Shutdown windows sockets */
WSACleanup ( ) ;
2001-02-20 04:09:37 +00:00
/* For some unknown reason, the "atexit()" call in "create_console()"
doesn ' t arrange that " destroy_console() " be called when we exit ,
so we call it here if a console was created . */
2004-05-13 15:28:02 +00:00
destroy_console ( ) ;
2000-09-14 22:59:08 +00:00
# endif
Exit from Ethereal by making the main loop exit, so that any quit
routines we register get called.
Register the "follow TCP stream" windows with "gtk_quit_add_destroy()",
so that, when Ethereal exits, they all get destroyed; this means that
their destroy callbacks get called, which means that they get to delete
their temporary files, so that, if you exit Ethereal without manually
closing the "follow TCP stream" windows, the temporary files don't get
left around.
Exit from Ethereal's "main()" function by calling "gtk_exit()", rather
than "exit()", so that we do whatever cleanup GTK+ requires. (We used
to call "gtk_exit()" in the callback for the "File:Quit" menu item and
the "delete" callback for the main window, but we now just call
"gtk_main_quit()" so that we exit from the main loop.)
svn path=/trunk/; revision=1772
2000-04-01 10:23:01 +00:00
gtk_exit ( 0 ) ;
/* This isn't reached, but we need it to keep GCC from complaining
that " main() " returns without returning a value - it knows that
" exit() " never returns , but it doesn ' t know that " gtk_exit() "
doesn ' t , as GTK + doesn ' t declare it with the attribute
" noreturn " . */
return 0 ; /* not reached */
2000-01-15 12:54:24 +00:00
}
2004-09-11 23:03:36 +00:00
# ifdef _WIN32
On Win32, build Ethereal as a Windows-subsystem program rather than a
console-subsystem program, so that when not run from a shell window it
doesn't cause a shell window to be popped up. (Yes, this means that any
messages it prints, when not popped up from a shell window, get lost,
but the same is true of Ethereal on UNIX/X.) Trick for doing this
shamelessly stolen from the Win32 port of the GIMP.
We do not want to build Tethereal or editcap as Windows-subsystem
programs, however, so we take the "/SUBSYSTEM" flag out of LDFLAGS and
put it into the link commands for Ethereal, Tethereal, and editcap.
svn path=/trunk/; revision=1857
2000-04-14 09:00:25 +00:00
/* We build this as a GUI subsystem application on Win32, so
" WinMain() " , not " main() " , gets called .
Hack shamelessly stolen from the Win32 port of the GIMP . */
# ifdef __GNUC__
# define _stdcall __attribute__((stdcall))
# endif
int _stdcall
WinMain ( struct HINSTANCE__ * hInstance ,
struct HINSTANCE__ * hPrevInstance ,
char * lpszCmdLine ,
int nCmdShow )
{
2006-02-16 15:27:03 +00:00
# if GTK_MAJOR_VERSION >= 2
INITCOMMONCONTROLSEX comm_ctrl ;
/* Initialize our controls. Required for native Windows file dialogs. */
memset ( & comm_ctrl , 0 , sizeof ( comm_ctrl ) ) ;
comm_ctrl . dwSize = sizeof ( comm_ctrl ) ;
/* Includes the animate, header, hot key, list view, progress bar,
* status bar , tab , tooltip , toolbar , trackbar , tree view , and
* up - down controls
*/
comm_ctrl . dwICC = ICC_WIN95_CLASSES ;
InitCommonControlsEx ( & comm_ctrl ) ;
/* RichEd20.DLL is needed for filter entries. */
2006-03-08 20:55:32 +00:00
LoadLibrary ( _T ( " riched20.dll " ) ) ;
2006-02-16 15:27:03 +00:00
# endif /* GTK_MAJOR_VERSION >= 2 */
2004-05-13 15:28:02 +00:00
has_console = FALSE ;
On Win32, build Ethereal as a Windows-subsystem program rather than a
console-subsystem program, so that when not run from a shell window it
doesn't cause a shell window to be popped up. (Yes, this means that any
messages it prints, when not popped up from a shell window, get lost,
but the same is true of Ethereal on UNIX/X.) Trick for doing this
shamelessly stolen from the Win32 port of the GIMP.
We do not want to build Tethereal or editcap as Windows-subsystem
programs, however, so we take the "/SUBSYSTEM" flag out of LDFLAGS and
put it into the link commands for Ethereal, Tethereal, and editcap.
svn path=/trunk/; revision=1857
2000-04-14 09:00:25 +00:00
return main ( __argc , __argv ) ;
}
2001-02-20 04:09:37 +00:00
/*
* If this application has no console window to which its standard output
* would go , create one .
*/
2004-05-13 15:28:02 +00:00
void
2001-02-20 04:09:37 +00:00
create_console ( void )
{
2005-06-23 20:18:17 +00:00
if ( ! has_console ) {
2001-02-20 04:09:37 +00:00
/* We have no console to which to print the version string, so
create one and make it the standard input , output , and error . */
if ( ! AllocConsole ( ) )
return ; /* couldn't create console */
2005-11-06 22:43:25 +00:00
eth_freopen ( " CONIN$ " , " r " , stdin ) ;
eth_freopen ( " CONOUT$ " , " w " , stdout ) ;
eth_freopen ( " CONOUT$ " , " w " , stderr ) ;
2001-02-20 04:09:37 +00:00
/* Well, we have a console now. */
2004-05-13 15:28:02 +00:00
has_console = TRUE ;
2001-02-20 04:09:37 +00:00
/* Now register "destroy_console()" as a routine to be called just
before the application exits , so that we can destroy the console
after the user has typed a key ( so that the console doesn ' t just
disappear out from under them , giving the user no chance to see
the message ( s ) we put in there ) . */
atexit ( destroy_console ) ;
2005-09-08 09:19:46 +00:00
2006-11-05 00:54:17 +00:00
SetConsoleTitle ( _T ( " Wireshark Debug Console " ) ) ;
2001-02-20 04:09:37 +00:00
}
}
static void
destroy_console ( void )
{
2006-02-11 23:25:11 +00:00
if ( has_console ) {
2004-05-13 15:28:02 +00:00
printf ( " \n \n Press any key to exit \n " ) ;
_getch ( ) ;
FreeConsole ( ) ;
}
2001-02-20 04:09:37 +00:00
}
2005-05-26 17:50:27 +00:00
# endif /* _WIN32 */
2001-02-20 04:09:37 +00:00
/* This routine should not be necessary, at least as I read the GLib
source code , as it looks as if GLib is , on Win32 , * supposed * to
create a console window into which to display its output .
That doesn ' t happen , however . I suspect there ' s something completely
broken about that code in GLib - for - Win32 , and that it may be related
to the breakage that forces us to just call " printf() " on the message
rather than passing the message on to " g_log_default_handler() "
( which is the routine that does the aforementioned non - functional
console window creation ) . */
static void
console_log_handler ( const char * log_domain , GLogLevelFlags log_level ,
2005-05-26 18:03:34 +00:00
const char * message , gpointer user_data _U_ )
2001-02-20 04:09:37 +00:00
{
2005-05-26 17:50:27 +00:00
time_t curr ;
struct tm * today ;
const char * level ;
2006-02-11 03:50:25 +00:00
/* ignore log message, if log_level isn't interesting.
If preferences aren ' t loaded yet , display message anyway */
if ( ( log_level & G_LOG_LEVEL_MASK & prefs . console_log_level ) = = 0 & &
prefs . console_log_level ! = 0 ) {
2005-05-26 21:49:48 +00:00
return ;
}
2005-05-26 17:50:27 +00:00
/* create a "timestamp" */
time ( & curr ) ;
2006-02-16 15:27:03 +00:00
today = localtime ( & curr ) ;
2005-05-26 17:50:27 +00:00
# ifdef _WIN32
2006-02-09 21:37:14 +00:00
if ( prefs . gui_console_open ! = console_open_never | | log_level & G_LOG_LEVEL_ERROR ) {
/* the user wants a console or the application will terminate immediately */
2005-06-23 20:18:17 +00:00
create_console ( ) ;
}
2004-05-13 15:28:02 +00:00
if ( has_console ) {
2001-02-20 04:09:37 +00:00
/* For some unknown reason, the above doesn't appear to actually cause
anything to be sent to the standard output , so we ' ll just splat the
message out directly , just to make sure it gets out . */
2005-05-26 17:50:27 +00:00
# endif
2005-05-26 18:29:09 +00:00
switch ( log_level & G_LOG_LEVEL_MASK ) {
2005-05-26 17:50:27 +00:00
case G_LOG_LEVEL_ERROR :
level = " Err " ;
break ;
case G_LOG_LEVEL_CRITICAL :
level = " Crit " ;
break ;
case G_LOG_LEVEL_WARNING :
level = " Warn " ;
break ;
case G_LOG_LEVEL_MESSAGE :
level = " Msg " ;
break ;
case G_LOG_LEVEL_INFO :
level = " Info " ;
break ;
case G_LOG_LEVEL_DEBUG :
level = " Dbg " ;
break ;
default :
2005-06-16 06:34:27 +00:00
fprintf ( stderr , " unknown log_level %u \n " , log_level ) ;
level = NULL ;
2005-05-26 17:50:27 +00:00
g_assert_not_reached ( ) ;
}
2005-06-16 06:41:28 +00:00
fprintf ( stderr , " %02u:%02u:%02u %8s %s %s \n " ,
today - > tm_hour , today - > tm_min , today - > tm_sec ,
log_domain ! = NULL ? log_domain : " " ,
level , message ) ;
2005-05-26 17:50:27 +00:00
# ifdef _WIN32
2006-02-09 21:37:14 +00:00
if ( log_level & G_LOG_LEVEL_ERROR ) {
2006-02-16 15:27:03 +00:00
/* wait for a key press before the following error handler will terminate the program
2006-02-09 21:37:14 +00:00
this way the user at least can read the error message */
printf ( " \n \n Press any key to exit \n " ) ;
_getch ( ) ;
}
2005-05-26 17:50:27 +00:00
} else {
2001-02-20 04:09:37 +00:00
g_log_default_handler ( log_domain , log_level , message , user_data ) ;
2005-05-26 17:50:27 +00:00
}
On Win32, build Ethereal as a Windows-subsystem program rather than a
console-subsystem program, so that when not run from a shell window it
doesn't cause a shell window to be popped up. (Yes, this means that any
messages it prints, when not popped up from a shell window, get lost,
but the same is true of Ethereal on UNIX/X.) Trick for doing this
shamelessly stolen from the Win32 port of the GIMP.
We do not want to build Tethereal or editcap as Windows-subsystem
programs, however, so we take the "/SUBSYSTEM" flag out of LDFLAGS and
put it into the link commands for Ethereal, Tethereal, and editcap.
svn path=/trunk/; revision=1857
2000-04-14 09:00:25 +00:00
# endif
2005-05-26 17:50:27 +00:00
}
On Win32, build Ethereal as a Windows-subsystem program rather than a
console-subsystem program, so that when not run from a shell window it
doesn't cause a shell window to be popped up. (Yes, this means that any
messages it prints, when not popped up from a shell window, get lost,
but the same is true of Ethereal on UNIX/X.) Trick for doing this
shamelessly stolen from the Win32 port of the GIMP.
We do not want to build Tethereal or editcap as Windows-subsystem
programs, however, so we take the "/SUBSYSTEM" flag out of LDFLAGS and
put it into the link commands for Ethereal, Tethereal, and editcap.
svn path=/trunk/; revision=1857
2000-04-14 09:00:25 +00:00
2004-01-20 18:47:25 +00:00
2005-08-02 04:47:15 +00:00
static GtkWidget * info_bar_new ( void )
2004-02-03 00:16:59 +00:00
{
/* tip: tooltips don't work on statusbars! */
info_bar = gtk_statusbar_new ( ) ;
main_ctx = gtk_statusbar_get_context_id ( GTK_STATUSBAR ( info_bar ) , " main " ) ;
file_ctx = gtk_statusbar_get_context_id ( GTK_STATUSBAR ( info_bar ) , " file " ) ;
help_ctx = gtk_statusbar_get_context_id ( GTK_STATUSBAR ( info_bar ) , " help " ) ;
# if GTK_MAJOR_VERSION >= 2
gtk_statusbar_set_has_resize_grip ( GTK_STATUSBAR ( info_bar ) , FALSE ) ;
# endif
gtk_statusbar_push ( GTK_STATUSBAR ( info_bar ) , main_ctx , DEF_READY_MESSAGE ) ;
return info_bar ;
}
2005-08-02 04:47:15 +00:00
static GtkWidget * packets_bar_new ( void )
2004-02-03 00:16:59 +00:00
{
/* tip: tooltips don't work on statusbars! */
packets_bar = gtk_statusbar_new ( ) ;
packets_ctx = gtk_statusbar_get_context_id ( GTK_STATUSBAR ( packets_bar ) , " packets " ) ;
packets_bar_update ( ) ;
2004-01-20 18:47:25 +00:00
2004-02-03 00:16:59 +00:00
return packets_bar ;
}
2004-01-20 18:47:25 +00:00
2004-01-19 00:42:12 +00:00
/*
* Helper for main_widgets_rearrange ( )
*/
2005-08-02 04:47:15 +00:00
static void foreach_remove_a_child ( GtkWidget * widget , gpointer data ) {
2004-01-19 00:42:12 +00:00
gtk_container_remove ( GTK_CONTAINER ( data ) , widget ) ;
}
2005-08-02 04:47:15 +00:00
static GtkWidget * main_widget_layout ( gint layout_content )
2004-04-29 17:03:27 +00:00
{
switch ( layout_content ) {
case ( layout_pane_content_none ) :
2004-08-31 02:49:28 +00:00
return NULL ;
2004-04-29 17:03:27 +00:00
break ;
case ( layout_pane_content_plist ) :
return pkt_scrollw ;
break ;
case ( layout_pane_content_pdetails ) :
return tv_scrollw ;
break ;
case ( layout_pane_content_pbytes ) :
return byte_nb_ptr ;
break ;
default :
g_assert_not_reached ( ) ;
return NULL ;
}
}
2004-01-19 00:42:12 +00:00
/*
* Rearrange the main window widgets
*/
void main_widgets_rearrange ( void ) {
2004-08-31 02:49:28 +00:00
GtkWidget * first_pane_widget1 , * first_pane_widget2 ;
GtkWidget * second_pane_widget1 , * second_pane_widget2 ;
gboolean split_top_left ;
2004-01-19 00:42:12 +00:00
/* be a bit faster */
gtk_widget_hide ( main_vbox ) ;
/* be sure, we don't loose a widget while rearranging */
gtk_widget_ref ( menubar ) ;
gtk_widget_ref ( main_tb ) ;
gtk_widget_ref ( filter_tb ) ;
2006-08-16 18:01:25 +00:00
# ifdef HAVE_AIRPCAP
2006-11-05 00:54:17 +00:00
gtk_widget_ref ( airpcap_tb ) ;
2006-08-16 18:01:25 +00:00
# endif
2004-01-19 00:42:12 +00:00
gtk_widget_ref ( pkt_scrollw ) ;
gtk_widget_ref ( tv_scrollw ) ;
gtk_widget_ref ( byte_nb_ptr ) ;
gtk_widget_ref ( stat_hbox ) ;
gtk_widget_ref ( info_bar ) ;
2004-02-03 00:16:59 +00:00
gtk_widget_ref ( packets_bar ) ;
2004-04-27 19:16:11 +00:00
gtk_widget_ref ( status_pane ) ;
2004-04-29 17:03:27 +00:00
gtk_widget_ref ( main_pane_v1 ) ;
gtk_widget_ref ( main_pane_v2 ) ;
gtk_widget_ref ( main_pane_h1 ) ;
gtk_widget_ref ( main_pane_h2 ) ;
2005-02-05 23:12:44 +00:00
gtk_widget_ref ( welcome_pane ) ;
2004-01-19 00:42:12 +00:00
/* empty all containers participating */
2004-04-29 17:03:27 +00:00
gtk_container_foreach ( GTK_CONTAINER ( main_vbox ) , foreach_remove_a_child , main_vbox ) ;
2004-01-19 00:42:12 +00:00
gtk_container_foreach ( GTK_CONTAINER ( stat_hbox ) , foreach_remove_a_child , stat_hbox ) ;
2004-04-29 17:03:27 +00:00
gtk_container_foreach ( GTK_CONTAINER ( status_pane ) , foreach_remove_a_child , status_pane ) ;
gtk_container_foreach ( GTK_CONTAINER ( main_pane_v1 ) , foreach_remove_a_child , main_pane_v1 ) ;
gtk_container_foreach ( GTK_CONTAINER ( main_pane_v2 ) , foreach_remove_a_child , main_pane_v2 ) ;
gtk_container_foreach ( GTK_CONTAINER ( main_pane_h1 ) , foreach_remove_a_child , main_pane_h1 ) ;
gtk_container_foreach ( GTK_CONTAINER ( main_pane_h2 ) , foreach_remove_a_child , main_pane_h2 ) ;
2004-01-19 00:42:12 +00:00
2004-01-23 16:07:37 +00:00
/* add the menubar always at the top */
2004-01-19 00:42:12 +00:00
gtk_box_pack_start ( GTK_BOX ( main_vbox ) , menubar , FALSE , TRUE , 0 ) ;
2004-01-23 16:07:37 +00:00
/* main toolbar */
2004-05-04 21:08:03 +00:00
gtk_box_pack_start ( GTK_BOX ( main_vbox ) , main_tb , FALSE , TRUE , 0 ) ;
2004-01-19 00:42:12 +00:00
2004-01-23 16:07:37 +00:00
/* filter toolbar in toolbar area */
2004-05-04 21:08:03 +00:00
if ( ! prefs . filter_toolbar_show_in_statusbar ) {
2004-01-23 16:07:37 +00:00
gtk_box_pack_start ( GTK_BOX ( main_vbox ) , filter_tb , FALSE , TRUE , 1 ) ;
}
2006-08-16 18:01:25 +00:00
# ifdef HAVE_AIRPCAP
2006-11-05 00:54:17 +00:00
/* airpcap toolbar */
gtk_box_pack_start ( GTK_BOX ( main_vbox ) , airpcap_tb , FALSE , TRUE , 1 ) ;
2006-08-16 18:01:25 +00:00
# endif
2004-04-29 17:03:27 +00:00
/* fill the main layout panes */
switch ( prefs . gui_layout_type ) {
case ( layout_type_5 ) :
main_first_pane = main_pane_v1 ;
main_second_pane = main_pane_v2 ;
2004-08-31 02:49:28 +00:00
split_top_left = FALSE ;
2004-04-29 17:03:27 +00:00
break ;
case ( layout_type_2 ) :
main_first_pane = main_pane_v1 ;
main_second_pane = main_pane_h1 ;
2004-08-31 02:49:28 +00:00
split_top_left = FALSE ;
2004-04-29 17:03:27 +00:00
break ;
case ( layout_type_1 ) :
main_first_pane = main_pane_v1 ;
main_second_pane = main_pane_h1 ;
2004-08-31 02:49:28 +00:00
split_top_left = TRUE ;
2004-04-29 17:03:27 +00:00
break ;
case ( layout_type_4 ) :
main_first_pane = main_pane_h1 ;
main_second_pane = main_pane_v1 ;
2004-08-31 02:49:28 +00:00
split_top_left = FALSE ;
2004-04-29 17:03:27 +00:00
break ;
case ( layout_type_3 ) :
main_first_pane = main_pane_h1 ;
main_second_pane = main_pane_v1 ;
2004-08-31 02:49:28 +00:00
split_top_left = TRUE ;
2004-04-29 17:03:27 +00:00
break ;
case ( layout_type_6 ) :
main_first_pane = main_pane_h1 ;
main_second_pane = main_pane_h2 ;
2004-08-31 02:49:28 +00:00
split_top_left = FALSE ;
2004-04-29 17:03:27 +00:00
break ;
default :
2004-08-31 02:49:28 +00:00
main_first_pane = NULL ;
main_second_pane = NULL ;
split_top_left = FALSE ;
2004-04-29 17:03:27 +00:00
g_assert_not_reached ( ) ;
}
2004-08-31 02:49:28 +00:00
if ( split_top_left ) {
first_pane_widget1 = main_second_pane ;
second_pane_widget1 = main_widget_layout ( prefs . gui_layout_content_1 ) ;
second_pane_widget2 = main_widget_layout ( prefs . gui_layout_content_2 ) ;
first_pane_widget2 = main_widget_layout ( prefs . gui_layout_content_3 ) ;
} else {
first_pane_widget1 = main_widget_layout ( prefs . gui_layout_content_1 ) ;
first_pane_widget2 = main_second_pane ;
second_pane_widget1 = main_widget_layout ( prefs . gui_layout_content_2 ) ;
second_pane_widget2 = main_widget_layout ( prefs . gui_layout_content_3 ) ;
}
if ( first_pane_widget1 ! = NULL )
gtk_paned_add1 ( GTK_PANED ( main_first_pane ) , first_pane_widget1 ) ;
if ( first_pane_widget2 ! = NULL )
gtk_paned_add2 ( GTK_PANED ( main_first_pane ) , first_pane_widget2 ) ;
if ( second_pane_widget1 ! = NULL )
gtk_paned_pack1 ( GTK_PANED ( main_second_pane ) , second_pane_widget1 , TRUE , TRUE ) ;
if ( second_pane_widget2 ! = NULL )
gtk_paned_pack2 ( GTK_PANED ( main_second_pane ) , second_pane_widget2 , FALSE , FALSE ) ;
2004-04-29 17:03:27 +00:00
gtk_container_add ( GTK_CONTAINER ( main_vbox ) , main_first_pane ) ;
2005-02-05 23:12:44 +00:00
/* welcome pane */
gtk_box_pack_start ( GTK_BOX ( main_vbox ) , welcome_pane , TRUE , TRUE , 0 ) ;
2004-05-04 20:49:33 +00:00
/* statusbar hbox */
2004-05-04 21:08:03 +00:00
gtk_box_pack_start ( GTK_BOX ( main_vbox ) , stat_hbox , FALSE , TRUE , 0 ) ;
2004-05-04 20:49:33 +00:00
/* filter toolbar in statusbar hbox */
2004-05-04 21:08:03 +00:00
if ( prefs . filter_toolbar_show_in_statusbar ) {
2004-05-04 20:49:33 +00:00
gtk_box_pack_start ( GTK_BOX ( stat_hbox ) , filter_tb , FALSE , TRUE , 1 ) ;
}
2006-08-16 18:01:25 +00:00
# ifdef HAVE_AIRPCAP
2006-11-05 00:54:17 +00:00
/* airpcap toolbar */
gtk_box_pack_start ( GTK_BOX ( main_vbox ) , airpcap_tb , FALSE , TRUE , 1 ) ;
2006-08-16 18:01:25 +00:00
# endif
2004-05-04 20:49:33 +00:00
/* statusbar */
2004-05-04 21:08:03 +00:00
gtk_box_pack_start ( GTK_BOX ( stat_hbox ) , status_pane , TRUE , TRUE , 0 ) ;
gtk_paned_pack1 ( GTK_PANED ( status_pane ) , info_bar , FALSE , FALSE ) ;
gtk_paned_pack2 ( GTK_PANED ( status_pane ) , packets_bar , FALSE , FALSE ) ;
/* hide widgets on users recent settings */
main_widgets_show_or_hide ( ) ;
2004-05-04 20:49:33 +00:00
gtk_widget_show ( main_vbox ) ;
}
static void
is_widget_visible ( GtkWidget * widget , gpointer data )
{
gboolean * is_visible = data ;
if ( ! * is_visible ) {
if ( GTK_WIDGET_VISIBLE ( widget ) )
* is_visible = TRUE ;
}
}
2007-01-31 03:08:39 +00:00
/*#define SHOW_WELCOME_PAGE*/
2005-12-18 11:36:06 +00:00
# ifdef SHOW_WELCOME_PAGE
2005-02-22 21:22:56 +00:00
/* XXX - There seems to be some disagreement about if and how this feature should be implemented.
As I currently don ' t have the time to continue this , it ' s temporarily disabled . - ULFL */
2005-02-05 23:12:44 +00:00
GtkWidget *
2007-05-22 23:06:22 +00:00
welcome_item ( const gchar * stock_item , const gchar * label , const gchar * message , const gchar * tooltip ,
2007-01-31 03:08:39 +00:00
GtkSignalFunc callback , void * callback_data )
2005-02-05 23:12:44 +00:00
{
GtkWidget * w , * item_hb ;
# if GTK_MAJOR_VERSION >= 2
gchar * formatted_message ;
2007-01-31 03:08:39 +00:00
GtkTooltips * tooltips ;
2005-02-05 23:12:44 +00:00
2007-01-31 03:08:39 +00:00
tooltips = gtk_tooltips_new ( ) ;
# endif
2005-02-05 23:12:44 +00:00
item_hb = gtk_hbox_new ( FALSE , 1 ) ;
w = BUTTON_NEW_FROM_STOCK ( stock_item ) ;
2007-01-31 03:08:39 +00:00
WIDGET_SET_SIZE ( w , 80 , 40 ) ;
2005-02-05 23:12:44 +00:00
# if GTK_MAJOR_VERSION >= 2
gtk_button_set_label ( GTK_BUTTON ( w ) , label ) ;
2007-01-31 03:08:39 +00:00
gtk_tooltips_set_tip ( tooltips , w , tooltip , NULL ) ;
2005-02-05 23:12:44 +00:00
# endif
gtk_box_pack_start ( GTK_BOX ( item_hb ) , w , FALSE , FALSE , 0 ) ;
SIGNAL_CONNECT ( w , " clicked " , callback , callback_data ) ;
w = gtk_label_new ( message ) ;
gtk_misc_set_alignment ( GTK_MISC ( w ) , 0.0 , 0.5 ) ;
# if GTK_MAJOR_VERSION >= 2
formatted_message = g_strdup_printf ( " <span weight= \" bold \" size= \" x-large \" >%s</span> " , message ) ;
gtk_label_set_markup ( GTK_LABEL ( w ) , formatted_message ) ;
g_free ( formatted_message ) ;
# endif
gtk_box_pack_start ( GTK_BOX ( item_hb ) , w , FALSE , FALSE , 10 ) ;
return item_hb ;
}
GtkWidget *
2007-01-31 03:08:39 +00:00
welcome_header_new ( void )
2005-02-05 23:12:44 +00:00
{
2007-01-31 03:08:39 +00:00
GtkWidget * item_vb ;
GtkWidget * item_hb ;
GtkWidget * eb ;
GdkColor bg ;
GtkWidget * icon ;
gchar * message ;
GtkWidget * w ;
2005-02-05 23:12:44 +00:00
2007-01-31 03:08:39 +00:00
/* background color of the header bar */
bg . pixel = 0 ;
bg . red = 154 * 255 ;
bg . green = 210 * 255 ;
bg . blue = 229 * 255 ;
2005-02-05 23:12:44 +00:00
2007-01-31 03:08:39 +00:00
item_vb = gtk_vbox_new ( FALSE , 0 ) ;
2005-02-05 23:12:44 +00:00
2007-01-31 03:08:39 +00:00
/* colorize vbox */
get_color ( & bg ) ;
eb = gtk_event_box_new ( ) ;
gtk_container_add ( GTK_CONTAINER ( eb ) , item_vb ) ;
# if GTK_MAJOR_VERSION >= 2
gtk_widget_modify_bg ( eb , GTK_STATE_NORMAL , & bg ) ;
# endif
2005-02-05 23:12:44 +00:00
2007-01-31 03:08:39 +00:00
item_hb = gtk_hbox_new ( FALSE , 0 ) ;
gtk_box_pack_start ( GTK_BOX ( item_vb ) , item_hb , FALSE , FALSE , 10 ) ;
2005-02-05 23:12:44 +00:00
2007-01-31 03:08:39 +00:00
icon = xpm_to_widget_from_parent ( top_level , wssplash_xpm ) ;
/*icon = xpm_to_widget_from_parent(top_level, wsicon64_xpm);*/
gtk_box_pack_start ( GTK_BOX ( item_hb ) , icon , FALSE , FALSE , 10 ) ;
2005-02-05 23:12:44 +00:00
# if GTK_MAJOR_VERSION < 2
2007-02-08 01:05:43 +00:00
message = " The World's Most Popular Network Protocol Analyzer " ;
2005-02-05 23:12:44 +00:00
# else
2007-02-08 01:05:43 +00:00
message = " <span weight= \" bold \" size= \" x-large \" > " " The World's Most Popular Network Protocol Analyzer " " </span> " ;
2005-02-05 23:12:44 +00:00
# endif
w = gtk_label_new ( message ) ;
# if GTK_MAJOR_VERSION >= 2
gtk_label_set_markup ( GTK_LABEL ( w ) , message ) ;
# endif
2005-02-07 03:35:51 +00:00
gtk_misc_set_alignment ( GTK_MISC ( w ) , 0.0 , 0.5 ) ;
2005-02-05 23:12:44 +00:00
gtk_box_pack_start ( GTK_BOX ( item_hb ) , w , TRUE , TRUE , 5 ) ;
2007-01-31 03:08:39 +00:00
gtk_widget_show_all ( eb ) ;
return eb ;
}
GtkWidget *
welcome_topic_header_new ( const char * header )
{
GtkWidget * w ;
GdkColor bg ;
GtkWidget * eb ;
# if GTK_MAJOR_VERSION >= 2
gchar * formatted_message ;
# endif
w = gtk_label_new ( header ) ;
# if GTK_MAJOR_VERSION >= 2
formatted_message = g_strdup_printf ( " <span weight= \" bold \" size= \" x-large \" >%s</span> " , header ) ;
gtk_label_set_markup ( GTK_LABEL ( w ) , formatted_message ) ;
g_free ( formatted_message ) ;
# endif
2005-02-05 23:12:44 +00:00
2007-01-31 03:08:39 +00:00
/* topic header background color */
bg . pixel = 0 ;
bg . red = 24 * 255 ;
bg . green = 151 * 255 ;
bg . blue = 192 * 255 ;
/* colorize vbox */
get_color ( & bg ) ;
eb = gtk_event_box_new ( ) ;
gtk_container_add ( GTK_CONTAINER ( eb ) , w ) ;
# if GTK_MAJOR_VERSION >= 2
gtk_widget_modify_bg ( eb , GTK_STATE_NORMAL , & bg ) ;
# endif
return eb ;
}
GtkWidget *
welcome_topic_new ( const char * header , GtkWidget * * to_fill )
{
GtkWidget * topic_vb ;
2007-02-08 01:05:43 +00:00
GtkWidget * layout_vb ;
2007-01-31 03:08:39 +00:00
GtkWidget * topic_eb ;
GtkWidget * topic_header ;
GdkColor bg ;
2007-02-08 01:05:43 +00:00
topic_vb = gtk_vbox_new ( FALSE , 0 ) ;
2007-01-31 03:08:39 +00:00
/* topic content background color */
bg . pixel = 0 ;
bg . red = 221 * 255 ;
bg . green = 226 * 255 ;
bg . blue = 228 * 255 ;
2007-02-08 01:05:43 +00:00
topic_header = welcome_topic_header_new ( header ) ;
gtk_box_pack_start ( GTK_BOX ( topic_vb ) , topic_header , FALSE , FALSE , 0 ) ;
layout_vb = gtk_vbox_new ( FALSE , 5 ) ;
gtk_container_border_width ( GTK_CONTAINER ( layout_vb ) , 10 ) ;
gtk_box_pack_start ( GTK_BOX ( topic_vb ) , layout_vb , FALSE , FALSE , 0 ) ;
2007-01-31 03:08:39 +00:00
/* colorize vbox (we need an event box for this!) */
get_color ( & bg ) ;
topic_eb = gtk_event_box_new ( ) ;
gtk_container_add ( GTK_CONTAINER ( topic_eb ) , topic_vb ) ;
# if GTK_MAJOR_VERSION >= 2
gtk_widget_modify_bg ( topic_eb , GTK_STATE_NORMAL , & bg ) ;
# endif
2007-02-08 01:05:43 +00:00
* to_fill = layout_vb ;
2007-01-31 03:08:39 +00:00
2007-02-08 01:05:43 +00:00
return topic_eb ;
}
2007-01-31 03:08:39 +00:00
2007-02-08 01:05:43 +00:00
# if GTK_MAJOR_VERSION >= 2
static gboolean
welcome_link_enter_cb ( GtkWidget * widget _U_ , GdkEventCrossing * event _U_ , gpointer user_data )
{
gchar * message ;
GtkWidget * w = user_data ;
2007-05-22 23:06:22 +00:00
2007-02-08 01:05:43 +00:00
message = g_strdup_printf ( " <span foreground='blue' underline='single'>%s</span> " , OBJECT_GET_DATA ( w , " TEXT " ) ) ;
# if GTK_MAJOR_VERSION >= 2
gtk_label_set_markup ( GTK_LABEL ( w ) , message ) ;
# endif
g_free ( message ) ;
return FALSE ;
}
static gboolean
welcome_link_leave_cb ( GtkWidget * widget _U_ , GdkEvent * event _U_ , gpointer user_data )
2007-05-22 23:06:22 +00:00
{
2007-02-08 01:05:43 +00:00
gchar * message ;
GtkWidget * w = user_data ;
2007-05-22 23:06:22 +00:00
2007-02-08 01:05:43 +00:00
message = g_strdup_printf ( " <span foreground='blue'>%s</span> " , OBJECT_GET_DATA ( w , " TEXT " ) ) ;
# if GTK_MAJOR_VERSION >= 2
gtk_label_set_markup ( GTK_LABEL ( w ) , message ) ;
# endif
g_free ( message ) ;
return FALSE ;
}
# endif
static gboolean
welcome_link_press_cb ( GtkWidget * widget _U_ , GdkEvent * event _U_ , gpointer data _U_ ) {
2007-05-22 23:06:22 +00:00
2007-02-08 01:05:43 +00:00
g_warning ( " TBD: link pressed " ) ;
return FALSE ;
}
GtkWidget *
welcome_link_new ( const gchar * text , GtkWidget * * label /*, void *callback, void *private_data */ )
{
gchar * message ;
GtkWidget * w ;
GtkWidget * eb ;
# if GTK_MAJOR_VERSION < 2
message = g_strdup ( text ) ;
# else
message = g_strdup_printf ( " <span foreground='blue'>%s</span> " , text ) ;
# endif
w = gtk_label_new ( message ) ;
* label = w ;
# if GTK_MAJOR_VERSION >= 2
gtk_label_set_markup ( GTK_LABEL ( w ) , message ) ;
# endif
g_free ( message ) ;
/* event box */
eb = gtk_event_box_new ( ) ;
gtk_container_add ( GTK_CONTAINER ( eb ) , w ) ;
# if GTK_MAJOR_VERSION >= 2
SIGNAL_CONNECT ( eb , " enter-notify-event " , welcome_link_enter_cb , w ) ;
SIGNAL_CONNECT ( eb , " leave-notify-event " , welcome_link_leave_cb , w ) ;
# endif
SIGNAL_CONNECT ( eb , " button-press-event " , welcome_link_press_cb , w ) ;
/* XXX - memleak */
OBJECT_SET_DATA ( w , " TEXT " , g_strdup ( text ) ) ;
return eb ;
}
GtkWidget *
welcome_filename_link_new ( const char * filename , GtkWidget * * label )
{
GString * str ;
GtkWidget * w ;
const unsigned int max = 60 ;
str = g_string_new ( filename ) ;
if ( str - > len > max ) {
g_string_erase ( str , 0 , str - > len - max /*cut*/ ) ;
g_string_prepend ( str , " ... " ) ;
}
w = welcome_link_new ( str - > str , label ) ;
g_string_free ( str , TRUE ) ;
return w ;
2007-01-31 03:08:39 +00:00
}
2007-02-08 01:05:43 +00:00
GtkWidget *
welcome_if_new ( const char * if_name , GdkColor * topic_bg , gboolean active )
{
GtkWidget * interface_hb ;
GtkWidget * w ;
GtkWidget * label ;
GtkTooltips * tooltips ;
GString * message ;
tooltips = gtk_tooltips_new ( ) ;
interface_hb = gtk_hbox_new ( FALSE , 5 ) ;
w = welcome_link_new ( " START " , & label ) ;
gtk_tooltips_set_tip ( tooltips , w , " Immediately start a capture on this interface " , NULL ) ;
# if GTK_MAJOR_VERSION >= 2
gtk_widget_modify_bg ( w , GTK_STATE_NORMAL , topic_bg ) ;
# endif
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0.0 , 0.0 ) ;
gtk_box_pack_start ( GTK_BOX ( interface_hb ) , w , FALSE , FALSE , 0 ) ;
w = welcome_link_new ( " OPTIONS " , & label ) ;
gtk_tooltips_set_tip ( tooltips , w , " Show the capture options of this interface " , NULL ) ;
# if GTK_MAJOR_VERSION >= 2
gtk_widget_modify_bg ( w , GTK_STATE_NORMAL , topic_bg ) ;
# endif
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0.0 , 0.0 ) ;
gtk_box_pack_start ( GTK_BOX ( interface_hb ) , w , FALSE , FALSE , 0 ) ;
w = welcome_link_new ( " DETAILS " , & label ) ;
gtk_tooltips_set_tip ( tooltips , w , " Show detailed information about this interface " , NULL ) ;
# if GTK_MAJOR_VERSION >= 2
gtk_widget_modify_bg ( w , GTK_STATE_NORMAL , topic_bg ) ;
# endif
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0.0 , 0.0 ) ;
gtk_box_pack_start ( GTK_BOX ( interface_hb ) , w , FALSE , FALSE , 0 ) ;
message = g_string_new ( if_name ) ;
/* truncate string if it's too long */
if ( message - > len > 38 ) {
g_string_truncate ( message , 35 ) ;
g_string_append ( message , " ... " ) ;
}
# if GTK_MAJOR_VERSION >= 2
/* if this is the "active" interface, display it bold */
if ( active ) {
g_string_prepend ( message , " <span weight= \" bold \" > " ) ;
g_string_append ( message , " </span> " ) ;
}
# endif
w = gtk_label_new ( message - > str ) ;
# if GTK_MAJOR_VERSION >= 2
gtk_label_set_markup ( GTK_LABEL ( w ) , message - > str ) ;
# endif
g_string_free ( message , TRUE ) ;
gtk_misc_set_alignment ( GTK_MISC ( w ) , 0.0 , 0.0 ) ;
gtk_box_pack_start ( GTK_BOX ( interface_hb ) , w , FALSE , FALSE , 0 ) ;
return interface_hb ;
}
2007-01-31 03:08:39 +00:00
/* XXX - the layout has to be improved */
GtkWidget *
welcome_new ( void )
{
GtkWidget * welcome_scrollw ;
GtkWidget * welcome_vb ;
GtkWidget * welcome_hb ;
GtkWidget * column_vb ;
GtkWidget * item_hb ;
GtkWidget * w ;
2007-02-08 01:05:43 +00:00
GtkWidget * label ;
2007-01-31 03:08:39 +00:00
GtkWidget * header ;
GtkWidget * topic_vb ;
GtkWidget * topic_to_fill ;
2007-02-08 01:05:43 +00:00
GtkWidget * interface_hb ;
GdkColor topic_bg ;
2005-02-05 23:12:44 +00:00
2007-01-31 03:08:39 +00:00
2007-02-08 01:05:43 +00:00
/* topic content background color */
topic_bg . pixel = 0 ;
topic_bg . red = 221 * 255 ;
topic_bg . green = 226 * 255 ;
topic_bg . blue = 228 * 255 ;
2007-01-31 03:08:39 +00:00
welcome_scrollw = scrolled_window_new ( NULL , NULL ) ;
welcome_vb = gtk_vbox_new ( FALSE , 0 ) ;
/* header */
header = welcome_header_new ( ) ;
gtk_box_pack_start ( GTK_BOX ( welcome_vb ) , header , FALSE , FALSE , 0 ) ;
/* content */
welcome_hb = gtk_hbox_new ( FALSE , 10 ) ;
gtk_container_border_width ( GTK_CONTAINER ( welcome_hb ) , 10 ) ;
gtk_box_pack_start ( GTK_BOX ( welcome_vb ) , welcome_hb , TRUE , TRUE , 0 ) ;
/* column capture */
column_vb = gtk_vbox_new ( FALSE , 10 ) ;
gtk_box_pack_start ( GTK_BOX ( welcome_hb ) , column_vb , TRUE , TRUE , 0 ) ;
2007-02-08 01:05:43 +00:00
/* capture topic */
2007-01-31 03:08:39 +00:00
topic_vb = welcome_topic_new ( " Capture " , & topic_to_fill ) ;
gtk_box_pack_start ( GTK_BOX ( column_vb ) , topic_vb , TRUE , TRUE , 0 ) ;
2007-02-08 01:05:43 +00:00
# ifdef HAVE_LIBPCAP
item_hb = welcome_item ( WIRESHARK_STOCK_CAPTURE_INTERFACES ,
" Interfaces... " ,
" Interface Life List " ,
" Show a life list of the available capture interfaces " ,
GTK_SIGNAL_FUNC ( capture_if_cb ) , NULL ) ;
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , item_hb , FALSE , FALSE , 5 ) ;
# endif
2007-01-31 03:08:39 +00:00
2007-02-08 01:05:43 +00:00
w = gtk_label_new ( " Available Interfaces: " ) ;
2007-01-31 03:08:39 +00:00
gtk_misc_set_alignment ( GTK_MISC ( w ) , 0.0 , 0.0 ) ;
2007-02-08 01:05:43 +00:00
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , w , FALSE , FALSE , 5 ) ;
2007-01-31 03:08:39 +00:00
2007-02-08 01:05:43 +00:00
interface_hb = welcome_if_new ( " Generic dialup adapter " , & topic_bg , FALSE ) ;
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , interface_hb , FALSE , FALSE , 0 ) ;
2007-01-31 03:08:39 +00:00
2007-02-08 01:05:43 +00:00
/* Marvell interface (currently "active") */
interface_hb = welcome_if_new ( " Marvell Gigabit Ethernet Controller " , & topic_bg , TRUE ) ;
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , interface_hb , FALSE , FALSE , 0 ) ;
2005-02-05 23:12:44 +00:00
2007-02-08 01:05:43 +00:00
/* Wireless interface */
interface_hb = welcome_if_new ( " Intel(R) PRO/Wireless 3945ABG Network Connection " , & topic_bg , FALSE ) ;
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , interface_hb , FALSE , FALSE , 0 ) ;
2005-02-05 23:12:44 +00:00
2007-01-31 03:08:39 +00:00
2007-02-08 01:05:43 +00:00
/* capture help topic */
2007-01-31 03:08:39 +00:00
topic_vb = welcome_topic_new ( " Capture Help " , & topic_to_fill ) ;
gtk_box_pack_start ( GTK_BOX ( column_vb ) , topic_vb , TRUE , TRUE , 0 ) ;
# ifdef HAVE_LIBPCAP
item_hb = welcome_item ( WIRESHARK_STOCK_CAPTURE_START ,
" Setup " ,
" How To: Setup a Capture " ,
2007-02-08 01:05:43 +00:00
" How To: Setup a Capture (online from the Wiki) " ,
GTK_SIGNAL_FUNC ( topic_cb ) , GINT_TO_POINTER ( ONLINEPAGE_USERGUIDE ) ) ;
2007-01-31 03:08:39 +00:00
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , item_hb , FALSE , FALSE , 5 ) ;
item_hb = welcome_item ( WIRESHARK_STOCK_CAPTURE_START ,
" Examples " ,
" Capture Filter Examples " ,
2007-02-08 01:05:43 +00:00
" Capture Filter Examples (online from the Wiki) " ,
GTK_SIGNAL_FUNC ( topic_cb ) , GINT_TO_POINTER ( ONLINEPAGE_USERGUIDE ) ) ;
2007-01-31 03:08:39 +00:00
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , item_hb , FALSE , FALSE , 5 ) ;
# endif
/* fill bottom space */
w = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , w , TRUE , TRUE , 0 ) ;
/* column files */
2007-02-08 01:05:43 +00:00
topic_vb = welcome_topic_new ( " Files " , & topic_to_fill ) ;
gtk_box_pack_start ( GTK_BOX ( welcome_hb ) , topic_vb , TRUE , TRUE , 0 ) ;
2007-01-31 03:08:39 +00:00
2006-02-16 15:27:03 +00:00
item_hb = welcome_item ( GTK_STOCK_OPEN ,
2007-02-08 01:05:43 +00:00
" Open... " ,
" Open a Capture File " ,
" Open a previously captured file " ,
2005-02-05 23:12:44 +00:00
GTK_SIGNAL_FUNC ( file_open_cmd_cb ) , NULL ) ;
2007-01-31 03:08:39 +00:00
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , item_hb , FALSE , FALSE , 5 ) ;
item_hb = welcome_item ( GTK_STOCK_OPEN ,
" Examples " ,
2007-02-08 01:05:43 +00:00
" Download Examples " ,
2007-01-31 03:08:39 +00:00
" Download Example Capture Files (from the Wiki) " ,
2007-02-08 01:05:43 +00:00
GTK_SIGNAL_FUNC ( topic_cb ) , GINT_TO_POINTER ( ONLINEPAGE_USERGUIDE ) ) ;
2007-01-31 03:08:39 +00:00
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , item_hb , FALSE , FALSE , 5 ) ;
2007-02-08 01:05:43 +00:00
w = gtk_label_new ( " Recent Files: " ) ;
gtk_misc_set_alignment ( GTK_MISC ( w ) , 0.0 , 0.0 ) ;
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , w , FALSE , FALSE , 5 ) ;
w = welcome_link_new ( " C: \\ Testfiles \\ hello.pcap " , & label ) ;
# if GTK_MAJOR_VERSION >= 2
gtk_widget_modify_bg ( w , GTK_STATE_NORMAL , & topic_bg ) ;
# endif
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0.0 , 0.0 ) ;
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , w , FALSE , FALSE , 0 ) ;
w = welcome_filename_link_new ( " C: \\ Testfiles \\ hello2.pcap " , & label ) ;
# if GTK_MAJOR_VERSION >= 2
gtk_widget_modify_bg ( w , GTK_STATE_NORMAL , & topic_bg ) ;
# endif
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0.0 , 0.0 ) ;
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , w , FALSE , FALSE , 0 ) ;
w = welcome_filename_link_new (
2007-05-22 23:06:22 +00:00
" C: \\ Testfiles \\ to avoid screen garbage \\ Unfortunately this is a very long filename which had to be truncated.pcap " ,
2007-02-08 01:05:43 +00:00
& label ) ;
# if GTK_MAJOR_VERSION >= 2
gtk_widget_modify_bg ( w , GTK_STATE_NORMAL , & topic_bg ) ;
# endif
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0.0 , 0.0 ) ;
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , w , FALSE , FALSE , 0 ) ;
2007-01-31 03:08:39 +00:00
w = gtk_label_new ( " " ) ;
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , w , TRUE , TRUE , 0 ) ;
2005-02-05 23:12:44 +00:00
2006-01-17 00:40:32 +00:00
2007-02-08 01:05:43 +00:00
/* column online */
column_vb = gtk_vbox_new ( FALSE , 10 ) ;
2007-01-31 03:08:39 +00:00
gtk_box_pack_start ( GTK_BOX ( welcome_hb ) , column_vb , TRUE , TRUE , 0 ) ;
2007-02-08 01:05:43 +00:00
/* topic online */
topic_vb = welcome_topic_new ( " Online " , & topic_to_fill ) ;
gtk_box_pack_start ( GTK_BOX ( column_vb ) , topic_vb , TRUE , TRUE , 0 ) ;
2007-01-31 03:08:39 +00:00
# if (GLIB_MAJOR_VERSION >= 2)
2006-05-28 17:19:08 +00:00
item_hb = welcome_item ( WIRESHARK_STOCK_WEB_SUPPORT ,
2007-02-08 01:05:43 +00:00
" Help " ,
" Show the User's Guide " ,
" Show the User's Guide (local version, if available) " ,
2006-01-17 00:40:32 +00:00
GTK_SIGNAL_FUNC ( topic_cb ) , GINT_TO_POINTER ( ONLINEPAGE_USERGUIDE ) ) ;
2007-01-31 03:08:39 +00:00
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , item_hb , FALSE , FALSE , 5 ) ;
2005-02-05 23:12:44 +00:00
2007-01-31 03:08:39 +00:00
item_hb = welcome_item ( GTK_STOCK_HOME ,
" Home " ,
2007-02-08 01:05:43 +00:00
" Projects Home Page " ,
" Visit www.wireshark.org, the project's home page " ,
2007-01-31 03:08:39 +00:00
GTK_SIGNAL_FUNC ( topic_cb ) , GINT_TO_POINTER ( ONLINEPAGE_HOME ) ) ;
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , item_hb , FALSE , FALSE , 5 ) ;
# endif
2005-02-05 23:12:44 +00:00
2007-02-08 01:05:43 +00:00
/* topic updates */
topic_vb = welcome_topic_new ( " Updates " , & topic_to_fill ) ;
gtk_box_pack_start ( GTK_BOX ( column_vb ) , topic_vb , TRUE , TRUE , 0 ) ;
w = gtk_label_new ( " No updates available! " ) ;
2007-01-31 03:08:39 +00:00
gtk_box_pack_start ( GTK_BOX ( topic_to_fill ) , w , TRUE , TRUE , 0 ) ;
2005-02-05 23:12:44 +00:00
2007-01-31 03:08:39 +00:00
/* the end */
gtk_widget_show_all ( welcome_vb ) ;
2005-02-05 23:12:44 +00:00
2005-02-07 03:35:51 +00:00
gtk_scrolled_window_add_with_viewport ( GTK_SCROLLED_WINDOW ( welcome_scrollw ) ,
2007-01-31 03:08:39 +00:00
welcome_vb ) ;
2005-02-05 23:12:44 +00:00
gtk_widget_show_all ( welcome_scrollw ) ;
2007-01-31 03:08:39 +00:00
return welcome_scrollw ;
2005-02-05 23:12:44 +00:00
}
2005-12-18 11:36:06 +00:00
# else
2005-08-02 04:47:15 +00:00
static GtkWidget *
2005-02-22 21:22:56 +00:00
welcome_new ( void )
{
/* this is just a dummy to fill up window space, simply showing nothing */
return scrolled_window_new ( NULL , NULL ) ;
}
2005-12-18 11:36:06 +00:00
# endif
2005-02-22 21:22:56 +00:00
2005-02-05 23:12:44 +00:00
2004-05-05 08:49:24 +00:00
/*
* XXX - this doesn ' t appear to work with the paned widgets in
* GTK + 1.2 [ . x ] ; if you hide one of the panes , the splitter remains
* and the other pane doesn ' t grow to take up the rest of the pane .
* It does appear to work with GTK + 2. x .
*/
2004-05-04 20:49:33 +00:00
void
main_widgets_show_or_hide ( void )
{
gboolean main_second_pane_show ;
2004-05-04 21:08:03 +00:00
if ( recent . main_toolbar_show ) {
gtk_widget_show ( main_tb ) ;
} else {
gtk_widget_hide ( main_tb ) ;
}
/*
* Show the status hbox if either :
*
* 1 ) we ' re showing the filter toolbar and we want it in the status
* line
*
* or
*
* 2 ) we ' re showing the status bar .
*/
if ( ( recent . filter_toolbar_show & & prefs . filter_toolbar_show_in_statusbar ) | |
recent . statusbar_show ) {
gtk_widget_show ( stat_hbox ) ;
} else {
gtk_widget_hide ( stat_hbox ) ;
}
if ( recent . statusbar_show ) {
gtk_widget_show ( status_pane ) ;
} else {
gtk_widget_hide ( status_pane ) ;
}
if ( recent . filter_toolbar_show ) {
gtk_widget_show ( filter_tb ) ;
} else {
gtk_widget_hide ( filter_tb ) ;
}
2006-08-16 18:01:25 +00:00
# ifdef HAVE_AIRPCAP
2006-11-05 00:54:17 +00:00
if ( recent . airpcap_toolbar_show ) {
2006-08-16 18:01:25 +00:00
gtk_widget_show ( airpcap_tb ) ;
} else {
gtk_widget_hide ( airpcap_tb ) ;
}
# endif
2005-02-05 17:53:39 +00:00
if ( recent . packet_list_show & & have_capture_file ) {
2004-04-29 17:03:27 +00:00
gtk_widget_show ( pkt_scrollw ) ;
} else {
gtk_widget_hide ( pkt_scrollw ) ;
2004-01-19 00:42:12 +00:00
}
2005-02-05 17:53:39 +00:00
if ( recent . tree_view_show & & have_capture_file ) {
2004-04-29 17:03:27 +00:00
gtk_widget_show ( tv_scrollw ) ;
} else {
gtk_widget_hide ( tv_scrollw ) ;
2004-01-19 00:42:12 +00:00
}
2005-02-05 17:53:39 +00:00
if ( recent . byte_view_show & & have_capture_file ) {
2004-04-29 17:03:27 +00:00
gtk_widget_show ( byte_nb_ptr ) ;
} else {
gtk_widget_hide ( byte_nb_ptr ) ;
2004-01-19 00:42:12 +00:00
}
2004-05-04 20:49:33 +00:00
2005-02-05 23:12:44 +00:00
if ( have_capture_file ) {
gtk_widget_show ( main_first_pane ) ;
} else {
gtk_widget_hide ( main_first_pane ) ;
}
2004-05-04 20:49:33 +00:00
/*
* Is anything in " main_second_pane " visible ?
* If so , show it , otherwise hide it .
*/
main_second_pane_show = FALSE ;
gtk_container_foreach ( GTK_CONTAINER ( main_second_pane ) , is_widget_visible ,
& main_second_pane_show ) ;
if ( main_second_pane_show ) {
2004-05-04 20:40:08 +00:00
gtk_widget_show ( main_second_pane ) ;
} else {
gtk_widget_hide ( main_second_pane ) ;
}
2005-02-05 23:12:44 +00:00
if ( ! have_capture_file ) {
if ( welcome_pane ) {
gtk_widget_show ( welcome_pane ) ;
}
} else {
gtk_widget_hide ( welcome_pane ) ;
}
2006-11-14 06:00:48 +00:00
/* workaround for bug in GtkCList to ensure packet list scrollbar is updated */
packet_list_freeze ( ) ;
packet_list_thaw ( ) ;
2004-01-19 00:42:12 +00:00
}
2004-05-17 21:15:28 +00:00
# if GTK_MAJOR_VERSION >= 2
/* called, when the window state changes (minimized, maximized, ...) */
static int
2004-05-21 00:18:46 +00:00
window_state_event_cb ( GtkWidget * widget _U_ ,
2004-05-17 21:15:28 +00:00
GdkEvent * event ,
2004-05-21 00:18:46 +00:00
gpointer data _U_ )
2004-05-17 21:15:28 +00:00
{
GdkWindowState new_window_state = ( ( GdkEventWindowState * ) event ) - > new_window_state ;
if ( ( event - > type ) = = ( GDK_WINDOW_STATE ) ) {
if ( ! ( new_window_state & GDK_WINDOW_STATE_ICONIFIED ) ) {
/* we might have dialogs popped up while we where iconified,
show em now */
display_queued_messages ( ) ;
}
}
return FALSE ;
}
# endif
2006-08-16 18:01:25 +00:00
# ifdef HAVE_AIRPCAP
/*
* Changed callback for the channel combobox
*/
static void
airpcap_toolbar_channel_changed_cb ( GtkWidget * w _U_ , gpointer data )
{
2006-11-05 00:54:17 +00:00
const gchar * s ;
2007-05-18 21:06:20 +00:00
ULONG ch_freq ;
2006-08-16 18:01:25 +00:00
2007-05-18 21:06:20 +00:00
if ( ( data ! = NULL ) & & ( w ! = NULL ) & & change_airpcap_settings ) {
s = gtk_entry_get_text ( GTK_ENTRY ( w ) ) ;
2006-11-05 00:54:17 +00:00
if ( ( g_strcasecmp ( " " , s ) ) ) {
2007-05-18 21:06:20 +00:00
ch_freq = airpcap_get_frequency_from_str ( s ) ;
2006-11-05 00:54:17 +00:00
if ( airpcap_if_active ! = NULL ) {
2007-05-18 21:06:20 +00:00
airpcap_if_active - > channelInfo . Frequency = ch_freq ;
airpcap_update_channel_offset_cb ( airpcap_if_active , ch_freq , GTK_WIDGET ( data ) ) ;
2006-11-05 00:54:17 +00:00
}
}
}
2006-08-16 18:01:25 +00:00
}
2007-05-18 21:06:20 +00:00
/*
* Changed callback for the channel offset combobox
*/
static void
on_channel_offset_cb_changed ( GtkWidget * w _U_ , gpointer data )
{
const gchar * s ;
gchar offset ;
if ( ( data ! = NULL ) & & ( w ! = NULL ) & & change_airpcap_settings )
{
s = gtk_entry_get_text ( GTK_ENTRY ( w ) ) ;
if ( ( g_strcasecmp ( " " , s ) ) )
{
if ( airpcap_if_active ! = NULL )
{
sscanf ( s , " %d " , & offset ) ;
airpcap_if_active - > channelInfo . ExtChannel = offset ;
if ( change_airpcap_settings ! = NULL )
{
airpcap_update_frequency_and_offset ( airpcap_if_active ) ;
}
}
}
}
}
2006-08-16 18:01:25 +00:00
/*
* Callback for the wrong crc combo
*/
static void
airpcap_toolbar_wrong_crc_combo_cb ( GtkWidget * entry , gpointer user_data )
{
2006-11-05 00:54:17 +00:00
gchar ebuf [ AIRPCAP_ERRBUF_SIZE ] ;
PAirpcapHandle ad ;
if ( ! block_toolbar_signals & & ( airpcap_if_active ! = NULL ) ) {
2007-05-18 21:06:20 +00:00
ad = airpcap_if_open ( airpcap_if_active - > name , ebuf ) ;
2006-11-05 00:54:17 +00:00
if ( ad ) {
airpcap_if_active - > CrcValidationOn = airpcap_get_validation_type ( gtk_entry_get_text ( GTK_ENTRY ( entry ) ) ) ;
airpcap_if_set_fcs_validation ( ad , airpcap_if_active - > CrcValidationOn ) ;
/* Save configuration */
2007-05-18 21:06:20 +00:00
airpcap_if_store_cur_config_as_adapter_default ( ad ) ;
2006-11-05 00:54:17 +00:00
airpcap_if_close ( ad ) ;
}
}
2006-08-16 18:01:25 +00:00
}
void
airpcap_toolbar_encryption_cb ( GtkWidget * entry , gpointer user_data )
{
2006-11-05 00:54:17 +00:00
/* We need to directly access the .ddl functions here... */
gchar ebuf [ AIRPCAP_ERRBUF_SIZE ] ;
PAirpcapHandle ad ;
gint n = 0 ;
gint i = 0 ;
airpcap_if_info_t * curr_if = NULL ;
/* Apply changes to the current adapter */
if ( ( airpcap_if_active ! = NULL ) ) {
2007-05-18 21:06:20 +00:00
ad = airpcap_if_open ( airpcap_if_active - > name , ebuf ) ;
2006-11-05 00:54:17 +00:00
if ( ad ) {
if ( airpcap_if_active - > DecryptionOn = = AIRPCAP_DECRYPTION_ON ) {
airpcap_if_active - > DecryptionOn = AIRPCAP_DECRYPTION_OFF ;
airpcap_if_set_decryption_state ( ad , airpcap_if_active - > DecryptionOn ) ;
/* Save configuration */
if ( ! airpcap_if_store_cur_config_as_adapter_default ( ad ) ) {
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " Cannot save configuration!!! \n Remember that in order to store the configuration in the registry you have to: \n \n - Close all the airpcap-based applications. \n - Be sure to have administrative privileges. " ) ;
2006-08-16 18:01:25 +00:00
}
2006-11-05 00:54:17 +00:00
airpcap_if_close ( ad ) ;
} else {
airpcap_if_active - > DecryptionOn = AIRPCAP_DECRYPTION_ON ;
airpcap_if_set_decryption_state ( ad , airpcap_if_active - > DecryptionOn ) ;
/* Save configuration */
if ( ! airpcap_if_store_cur_config_as_adapter_default ( ad ) ) {
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " Cannot save configuration!!! \n Remember that in order to store the configuration in the registry you have to: \n \n - Close all the airpcap-based applications. \n - Be sure to have administrative privileges. " ) ;
}
airpcap_if_close ( ad ) ;
}
2006-10-19 00:48:03 +00:00
}
2006-11-05 00:54:17 +00:00
} else {
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " No active AirPcap Adapter selected! " ) ;
return ;
}
2006-10-19 00:48:03 +00:00
2007-05-18 21:06:20 +00:00
if ( ! ( airpcap_if_list = = NULL ) ) {
2006-11-05 00:54:17 +00:00
n = g_list_length ( airpcap_if_list ) ;
2006-10-19 00:48:03 +00:00
2006-11-05 00:54:17 +00:00
/* The same kind of settings should be propagated to all the adapters */
/* Apply this change to all the adapters !!! */
for ( i = 0 ; i < n ; i + + ) {
2006-10-19 00:48:03 +00:00
curr_if = ( airpcap_if_info_t * ) g_list_nth_data ( airpcap_if_list , i ) ;
2006-11-05 00:54:17 +00:00
if ( ( curr_if ! = NULL ) & & ( curr_if ! = airpcap_if_selected ) ) {
2007-05-18 21:06:20 +00:00
ad = airpcap_if_open ( curr_if - > name , ebuf ) ;
2006-11-05 00:54:17 +00:00
if ( ad ) {
curr_if - > DecryptionOn = airpcap_if_selected - > DecryptionOn ;
airpcap_if_set_decryption_state ( ad , curr_if - > DecryptionOn ) ;
/* Save configuration for the curr_if */
if ( ! airpcap_if_store_cur_config_as_adapter_default ( ad ) ) {
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " Cannot save configuration!!! \n Remember that in order to store the configuration in the registry you have to: \n \n - Close all the airpcap-based applications. \n - Be sure to have administrative privileges. " ) ;
2007-05-18 21:06:20 +00:00
}
2006-11-05 00:54:17 +00:00
airpcap_if_close ( ad ) ;
}
2006-10-19 00:48:03 +00:00
}
2006-11-05 00:54:17 +00:00
}
2007-05-18 21:06:20 +00:00
} else {
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " AirPcap Adapter Error! " ) ;
return ;
}
2006-08-16 18:01:25 +00:00
}
/*
* Callback for the Advanced Wireless Settings button
*/
static void
toolbar_display_airpcap_advanced_cb ( GtkWidget * w , gpointer data )
{
2006-11-05 00:54:17 +00:00
int * from_widget ;
2006-08-16 18:01:25 +00:00
from_widget = ( gint * ) g_malloc ( sizeof ( gint ) ) ;
* from_widget = AIRPCAP_ADVANCED_FROM_TOOLBAR ;
OBJECT_SET_DATA ( airpcap_tb , AIRPCAP_ADVANCED_FROM_KEY , from_widget ) ;
2006-11-05 00:54:17 +00:00
display_airpcap_advanced_cb ( w , data ) ;
2006-08-16 18:01:25 +00:00
}
2004-05-17 21:15:28 +00:00
2006-10-19 00:48:03 +00:00
/*
* Callback for the Decryption Key Management button
*/
static void
toolbar_display_airpcap_key_management_cb ( GtkWidget * w , gpointer data )
{
2006-11-05 00:54:17 +00:00
int * from_widget ;
2006-10-19 00:48:03 +00:00
from_widget = ( gint * ) g_malloc ( sizeof ( gint ) ) ;
* from_widget = AIRPCAP_ADVANCED_FROM_TOOLBAR ;
OBJECT_SET_DATA ( airpcap_tb , AIRPCAP_ADVANCED_FROM_KEY , from_widget ) ;
2006-11-05 00:54:17 +00:00
display_airpcap_key_management_cb ( w , data ) ;
2006-10-19 00:48:03 +00:00
}
2006-11-05 00:54:17 +00:00
# endif /* HAVE_AIRPCAP */
2006-10-19 00:48:03 +00:00
2006-11-18 05:05:18 +00:00
# if GTK_MAJOR_VERSION >= 2
2007-05-22 23:06:22 +00:00
# define NO_SHIFT_MOD_MASK (GDK_MODIFIER_MASK & ~(GDK_SHIFT_MASK|GDK_LOCK_MASK))
2006-11-18 05:05:18 +00:00
static int
top_level_key_pressed_cb ( GtkCTree * ctree _U_ , GdkEventKey * event , gpointer user_data _U_ )
{
2006-11-18 17:17:28 +00:00
if ( event - > keyval = = GDK_F8 ) {
packet_list_next ( ) ;
return TRUE ;
} else if ( event - > keyval = = GDK_F7 ) {
packet_list_prev ( ) ;
return TRUE ;
2007-05-25 17:24:35 +00:00
} else if ( event - > state & NO_SHIFT_MOD_MASK ) {
2007-05-22 23:06:22 +00:00
return FALSE ; /* Skip control, alt, and other modifiers */
2006-11-25 06:15:51 +00:00
/*
* A comment in gdkkeysyms . h says that it ' s autogenerated from
* freedesktop . org / x . org ' s keysymdef . h . Although the GDK docs
* don ' t explicitly say so , isprint ( ) should work as expected
* for values < 127.
*/
} else if ( isascii ( event - > keyval ) & & isprint ( event - > keyval ) ) {
2006-11-18 17:17:28 +00:00
/* Forward the keypress on to the display filter entry */
if ( main_display_filter_widget & & ! gtk_widget_is_focus ( main_display_filter_widget ) ) {
gtk_window_set_focus ( GTK_WINDOW ( top_level ) , main_display_filter_widget ) ;
2006-11-21 01:27:29 +00:00
gtk_editable_set_position ( GTK_EDITABLE ( main_display_filter_widget ) , - 1 ) ;
2006-11-18 17:17:28 +00:00
}
return FALSE ;
2006-11-18 05:05:18 +00:00
}
return FALSE ;
}
# endif
2000-01-15 12:54:24 +00:00
static void
create_main_window ( gint pl_size , gint tv_size , gint bv_size , e_prefs * prefs )
{
2006-02-16 15:27:03 +00:00
GtkWidget
2002-11-03 17:38:45 +00:00
* filter_bt , * filter_cm , * filter_te ,
2004-01-25 15:10:36 +00:00
* filter_add_expr_bt ,
2002-11-03 17:38:45 +00:00
* filter_apply ,
* filter_reset ;
2005-03-25 22:52:45 +00:00
GList * dfilter_list = NULL ;
2004-01-26 18:40:44 +00:00
GtkTooltips * tooltips ;
2006-08-16 18:01:25 +00:00
2002-11-03 17:38:45 +00:00
GtkAccelGroup * accel ;
2006-05-22 07:29:40 +00:00
gchar * title ;
2006-08-16 18:01:25 +00:00
# ifdef HAVE_AIRPCAP
2007-05-18 21:06:20 +00:00
GtkWidget * key_management_bt = NULL ,
# if GTK_MAJOR_VERSION >= 2 /* For some reason this button's action crashes under GTK 1. */
* advanced_bt = NULL ,
# endif
* channel_lb = NULL ,
* channel_cm = NULL ,
* channel_offset_lb = NULL ,
* channel_offset_cb = NULL ,
* wrong_crc_lb = NULL ,
* wrong_crc_cm = NULL ;
2006-10-19 22:43:38 +00:00
2006-10-19 00:48:03 +00:00
GtkWidget * enable_decryption_lb ;
GtkWidget * enable_decryption_cb ;
GList * enable_decryption_cb_items = NULL ;
GtkWidget * enable_decryption_en ;
2006-08-16 18:01:25 +00:00
GList * channel_list = NULL ;
GList * linktype_list = NULL ;
GList * link_list = NULL ;
GtkTooltips * airpcap_tooltips ;
2007-05-18 21:06:20 +00:00
/* gchar *if_label_text; */
2006-08-16 18:01:25 +00:00
gint * from_widget = NULL ;
# endif
2002-11-03 17:38:45 +00:00
/* Display filter construct dialog has an Apply button, and "OK" not
only sets our text widget , it activates it ( i . e . , it causes us to
filter the capture ) . */
static construct_args_t args = {
2006-05-22 07:29:40 +00:00
" Wireshark: Display Filter " ,
2002-11-03 17:38:45 +00:00
TRUE ,
2005-12-31 17:09:27 +00:00
TRUE ,
FALSE
2002-11-03 17:38:45 +00:00
} ;
2004-12-02 11:30:24 +00:00
/* use user-defined title if preference is set */
2006-05-22 07:29:40 +00:00
title = create_user_window_title ( " The Wireshark Network Analyzer " ) ;
2004-12-02 11:30:24 +00:00
2002-11-03 17:38:45 +00:00
/* Main window */
2004-12-02 11:30:24 +00:00
top_level = window_new ( GTK_WINDOW_TOPLEVEL , title ) ;
g_free ( title ) ;
2004-01-20 18:47:25 +00:00
2004-01-26 18:40:44 +00:00
tooltips = gtk_tooltips_new ( ) ;
2006-08-16 18:01:25 +00:00
# ifdef HAVE_AIRPCAP
2006-11-05 00:54:17 +00:00
airpcap_tooltips = gtk_tooltips_new ( ) ;
2006-08-16 18:01:25 +00:00
# endif
2006-02-16 15:27:03 +00:00
# ifdef _WIN32
2004-01-20 18:47:25 +00:00
# if GTK_MAJOR_VERSION < 2
2004-06-17 16:35:26 +00:00
/* has to be done, after top_level window is created */
app_font_gtk1_init ( top_level ) ;
2004-01-20 18:47:25 +00:00
# endif
# endif
2006-02-16 15:27:03 +00:00
2002-11-03 17:38:45 +00:00
gtk_widget_set_name ( top_level , " main window " ) ;
2002-11-10 11:36:39 +00:00
SIGNAL_CONNECT ( top_level , " delete_event " , main_window_delete_event_cb ,
NULL ) ;
2004-05-17 21:15:28 +00:00
# if GTK_MAJOR_VERSION >= 2
SIGNAL_CONNECT ( GTK_OBJECT ( top_level ) , " window_state_event " ,
G_CALLBACK ( window_state_event_cb ) , NULL ) ;
2006-11-18 05:05:18 +00:00
SIGNAL_CONNECT ( GTK_OBJECT ( top_level ) , " key-press-event " ,
G_CALLBACK ( top_level_key_pressed_cb ) , NULL ) ;
2004-05-17 21:15:28 +00:00
# endif
2002-11-03 17:38:45 +00:00
gtk_window_set_policy ( GTK_WINDOW ( top_level ) , TRUE , TRUE , FALSE ) ;
2003-10-15 19:40:42 +00:00
/* Container for menu bar, toolbar(s), paned windows and progress/info box */
2002-11-03 17:38:45 +00:00
main_vbox = gtk_vbox_new ( FALSE , 1 ) ;
gtk_container_border_width ( GTK_CONTAINER ( main_vbox ) , 1 ) ;
gtk_container_add ( GTK_CONTAINER ( top_level ) , main_vbox ) ;
gtk_widget_show ( main_vbox ) ;
/* Menu bar */
2004-01-19 00:42:12 +00:00
menubar = main_menu_new ( & accel ) ;
2002-11-03 17:38:45 +00:00
gtk_window_add_accel_group ( GTK_WINDOW ( top_level ) , accel ) ;
gtk_widget_show ( menubar ) ;
2003-10-15 19:40:42 +00:00
/* Main Toolbar */
2004-01-19 00:42:12 +00:00
main_tb = toolbar_new ( ) ;
gtk_widget_show ( main_tb ) ;
2002-11-03 17:38:45 +00:00
/* Packet list */
2004-01-19 00:42:12 +00:00
pkt_scrollw = packet_list_new ( prefs ) ;
WIDGET_SET_SIZE ( packet_list , - 1 , pl_size ) ;
gtk_widget_show ( pkt_scrollw ) ;
2002-11-03 17:38:45 +00:00
/* Tree view */
2004-01-19 00:42:12 +00:00
tv_scrollw = main_tree_view_new ( prefs , & tree_view ) ;
WIDGET_SET_SIZE ( tv_scrollw , - 1 , tv_size ) ;
gtk_widget_show ( tv_scrollw ) ;
2002-11-03 17:38:45 +00:00
# if GTK_MAJOR_VERSION < 2
2002-11-10 11:36:39 +00:00
SIGNAL_CONNECT ( tree_view , " tree-select-row " , tree_view_select_row_cb , NULL ) ;
SIGNAL_CONNECT ( tree_view , " tree-unselect-row " , tree_view_unselect_row_cb ,
NULL ) ;
2002-11-03 17:38:45 +00:00
# else
2002-11-10 11:36:39 +00:00
SIGNAL_CONNECT ( gtk_tree_view_get_selection ( GTK_TREE_VIEW ( tree_view ) ) ,
" changed " , tree_view_selection_changed_cb , NULL ) ;
2002-11-03 17:38:45 +00:00
# endif
2002-11-10 11:36:39 +00:00
SIGNAL_CONNECT ( tree_view , " button_press_event " , popup_menu_handler ,
OBJECT_GET_DATA ( popup_menu_object , PM_TREE_VIEW_KEY ) ) ;
2002-11-03 17:38:45 +00:00
gtk_widget_show ( tree_view ) ;
1999-07-28 03:29:02 +00:00
2002-11-03 17:38:45 +00:00
/* Byte view. */
2004-01-19 00:42:12 +00:00
byte_nb_ptr = byte_view_new ( ) ;
WIDGET_SET_SIZE ( byte_nb_ptr , - 1 , bv_size ) ;
gtk_widget_show ( byte_nb_ptr ) ;
2002-11-03 17:38:45 +00:00
2002-11-10 11:36:39 +00:00
SIGNAL_CONNECT ( byte_nb_ptr , " button_press_event " , popup_menu_handler ,
OBJECT_GET_DATA ( popup_menu_object , PM_HEXDUMP_KEY ) ) ;
2002-11-03 17:38:45 +00:00
2004-01-19 00:42:12 +00:00
/* Panes for the packet list, tree, and byte view */
2004-04-29 17:03:27 +00:00
main_pane_v1 = gtk_vpaned_new ( ) ;
gtk_widget_show ( main_pane_v1 ) ;
main_pane_v2 = gtk_vpaned_new ( ) ;
gtk_widget_show ( main_pane_v2 ) ;
main_pane_h1 = gtk_hpaned_new ( ) ;
gtk_widget_show ( main_pane_h1 ) ;
main_pane_h2 = gtk_hpaned_new ( ) ;
gtk_widget_show ( main_pane_h2 ) ;
2004-01-19 00:42:12 +00:00
2006-08-16 18:01:25 +00:00
# ifdef HAVE_AIRPCAP
/* airpcap toolbar */
# if GTK_MAJOR_VERSION < 2
airpcap_tb = gtk_toolbar_new ( GTK_ORIENTATION_HORIZONTAL ,
GTK_TOOLBAR_BOTH ) ;
# else
airpcap_tb = gtk_toolbar_new ( ) ;
gtk_toolbar_set_orientation ( GTK_TOOLBAR ( airpcap_tb ) ,
GTK_ORIENTATION_HORIZONTAL ) ;
# endif /* GTK_MAJOR_VERSION */
2006-11-05 00:54:17 +00:00
gtk_widget_show ( airpcap_tb ) ;
2006-08-16 18:01:25 +00:00
2006-11-05 00:54:17 +00:00
/* Interface Label */
2007-05-18 21:06:20 +00:00
/*if(airpcap_if_active != NULL) {
2006-11-05 00:54:17 +00:00
if_label_text = g_strdup_printf ( " %s %s \t " , " Current Wireless Interface: # " , airpcap_get_if_string_number ( airpcap_if_active ) ) ;
interface_lb = gtk_label_new ( if_label_text ) ;
g_free ( if_label_text ) ;
} else {
interface_lb = gtk_label_new ( " No Wireless Interface Found " ) ;
2007-05-18 21:06:20 +00:00
} */
2006-11-05 00:54:17 +00:00
/* Add the label to the toolbar */
2007-05-18 21:06:20 +00:00
/*gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), interface_lb,
2006-11-05 00:54:17 +00:00
" Current Wireless Interface " , " Private " ) ;
OBJECT_SET_DATA ( airpcap_tb , AIRPCAP_TOOLBAR_INTERFACE_KEY , interface_lb ) ;
gtk_widget_show ( interface_lb ) ;
2007-05-18 21:06:20 +00:00
gtk_toolbar_insert_space ( GTK_TOOLBAR ( airpcap_tb ) , 1 ) ; */
2006-08-16 18:01:25 +00:00
/* Create the "802.11 Channel:" label */
2007-05-18 21:06:20 +00:00
channel_lb = gtk_label_new ( " 802.11 Channel: " ) ;
2006-12-05 19:24:25 +00:00
OBJECT_SET_DATA ( airpcap_tb , AIRPCAP_TOOLBAR_CHANNEL_LABEL_KEY , channel_lb ) ;
2006-11-05 00:54:17 +00:00
gtk_toolbar_append_widget ( GTK_TOOLBAR ( airpcap_tb ) , channel_lb ,
" Current 802.11 Channel " , " Private " ) ;
gtk_widget_show ( channel_lb ) ;
2007-05-18 21:06:20 +00:00
WIDGET_SET_SIZE ( channel_lb , 85 , 28 ) ;
2006-11-05 00:54:17 +00:00
/* Create the channel combo box */
2006-08-16 18:01:25 +00:00
channel_cm = gtk_combo_new ( ) ;
2006-11-05 00:54:17 +00:00
gtk_editable_set_editable ( GTK_EDITABLE ( GTK_COMBO ( channel_cm ) - > entry ) , FALSE ) ;
OBJECT_SET_DATA ( airpcap_tb , AIRPCAP_TOOLBAR_CHANNEL_KEY , channel_cm ) ;
2006-08-16 18:01:25 +00:00
2007-08-17 19:34:14 +00:00
if ( airpcap_if_active ! = NULL & & airpcap_if_active - > pSupportedChannels ! = NULL & & airpcap_if_active - > numSupportedChannels > 0 ) {
guint i = 0 ;
for ( ; i < airpcap_if_active - > numSupportedChannels ; i + + ) {
channel_list = g_list_append ( channel_list , ieee80211_mhz_to_str ( airpcap_if_active - > pSupportedChannels [ i ] . Frequency ) ) ;
}
gtk_combo_set_popdown_strings ( GTK_COMBO ( channel_cm ) , channel_list ) ;
}
2006-08-16 18:01:25 +00:00
2006-11-05 00:54:17 +00:00
gtk_tooltips_set_tip ( airpcap_tooltips , GTK_WIDGET ( GTK_COMBO ( channel_cm ) - > entry ) ,
" Change the 802.11 RF channel " , NULL ) ;
2006-08-16 18:01:25 +00:00
2007-05-18 21:06:20 +00:00
WIDGET_SET_SIZE ( channel_cm , 120 , 28 ) ;
2006-11-05 00:54:17 +00:00
2007-08-17 19:34:14 +00:00
if ( airpcap_if_active ! = NULL )
gtk_entry_set_text ( GTK_ENTRY ( GTK_COMBO ( channel_cm ) - > entry ) , ieee80211_mhz_to_str ( airpcap_if_active - > channelInfo . Frequency ) ) ;
else
gtk_entry_set_text ( GTK_ENTRY ( GTK_COMBO ( channel_cm ) - > entry ) , " " ) ;
2006-08-16 18:01:25 +00:00
gtk_widget_show ( channel_cm ) ;
gtk_toolbar_append_widget ( GTK_TOOLBAR ( airpcap_tb ) , channel_cm ,
2006-11-05 00:54:17 +00:00
" 802.11 Channel " , " Private " ) ;
2007-05-18 21:06:20 +00:00
/* gtk_toolbar_append_space(GTK_TOOLBAR(airpcap_tb)); */
/* Create the "Channel Offset:" label */
channel_offset_lb = gtk_label_new ( " Channel Offset: " ) ;
OBJECT_SET_DATA ( airpcap_tb , AIRPCAP_TOOLBAR_CHANNEL_OFFSET_LABEL_KEY , channel_offset_lb ) ;
gtk_toolbar_append_widget ( GTK_TOOLBAR ( airpcap_tb ) , channel_offset_lb ,
" Current 802.11 Channel Offset " , " Private " ) ;
gtk_widget_show ( channel_offset_lb ) ;
WIDGET_SET_SIZE ( channel_offset_lb , 80 , 28 ) ;
/* Start: Channel offset combo box */
channel_offset_cb = gtk_combo_new ( ) ;
gtk_editable_set_editable ( GTK_EDITABLE ( GTK_COMBO ( channel_offset_cb ) - > entry ) , FALSE ) ;
OBJECT_SET_DATA ( airpcap_tb , AIRPCAP_TOOLBAR_CHANNEL_OFFSET_KEY , channel_offset_cb ) ;
if ( airpcap_if_active ! = NULL ) {
airpcap_update_channel_offset_cb ( airpcap_if_active , airpcap_if_active - > channelInfo . Frequency , channel_offset_cb ) ;
airpcap_update_channel_offset_combo_entry ( channel_offset_cb , airpcap_if_active - > channelInfo . ExtChannel ) ;
} else {
gtk_entry_set_text ( GTK_ENTRY ( GTK_COMBO ( channel_offset_cb ) - > entry ) , " " ) ;
}
gtk_tooltips_set_tip ( airpcap_tooltips , GTK_WIDGET ( GTK_COMBO ( channel_offset_cb ) - > entry ) ,
" Change channel offset " , NULL ) ;
WIDGET_SET_SIZE ( channel_offset_cb , 50 , 28 ) ;
gtk_widget_show ( channel_offset_cb ) ;
gtk_toolbar_append_widget ( GTK_TOOLBAR ( airpcap_tb ) , channel_offset_cb ,
" 802.11 Channel Offset " , " Private " ) ;
2006-11-05 00:54:17 +00:00
gtk_toolbar_append_space ( GTK_TOOLBAR ( airpcap_tb ) ) ;
2007-05-18 21:06:20 +00:00
/* callback for channel combo box */
SIGNAL_CONNECT ( GTK_COMBO ( channel_cm ) - > entry , " changed " , airpcap_toolbar_channel_changed_cb , channel_offset_cb ) ;
/* callback for channel offset combo box */
SIGNAL_CONNECT ( GTK_COMBO ( channel_offset_cb ) - > entry , " changed " , on_channel_offset_cb_changed , channel_offset_cb ) ;
/* End: Channel offset combo box */
2006-11-05 00:54:17 +00:00
/* Wrong CRC Label */
wrong_crc_lb = gtk_label_new ( " FCS Filter: " ) ;
2006-12-05 19:24:25 +00:00
OBJECT_SET_DATA ( airpcap_tb , AIRPCAP_TOOLBAR_FCS_FILTER_LABEL_KEY , wrong_crc_lb ) ;
2006-11-05 00:54:17 +00:00
gtk_toolbar_append_widget ( GTK_TOOLBAR ( airpcap_tb ) , wrong_crc_lb ,
" " , " Private " ) ;
gtk_widget_show ( wrong_crc_lb ) ;
/* Wrong CRC combo */
wrong_crc_cm = gtk_combo_new ( ) ;
gtk_editable_set_editable ( GTK_EDITABLE ( GTK_COMBO ( wrong_crc_cm ) - > entry ) , FALSE ) ;
OBJECT_SET_DATA ( airpcap_tb , AIRPCAP_TOOLBAR_FCS_FILTER_KEY , wrong_crc_cm ) ;
gtk_toolbar_append_widget ( GTK_TOOLBAR ( airpcap_tb ) , wrong_crc_cm ,
" " , " Private " ) ;
WIDGET_SET_SIZE ( wrong_crc_cm , 100 , - 1 ) ;
linktype_list = g_list_append ( linktype_list , AIRPCAP_VALIDATION_TYPE_NAME_ALL ) ;
linktype_list = g_list_append ( linktype_list , AIRPCAP_VALIDATION_TYPE_NAME_CORRECT ) ;
2006-08-16 18:01:25 +00:00
linktype_list = g_list_append ( linktype_list , AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT ) ;
gtk_combo_set_popdown_strings ( GTK_COMBO ( wrong_crc_cm ) , linktype_list ) ;
2006-12-05 19:24:25 +00:00
gtk_tooltips_set_tip ( airpcap_tooltips , GTK_WIDGET ( GTK_COMBO ( wrong_crc_cm ) - > entry ) ,
2006-08-16 18:01:25 +00:00
" Select the 802.11 FCS filter that the wireless adapter will apply. " ,
2006-11-05 00:54:17 +00:00
NULL ) ;
2006-08-16 18:01:25 +00:00
2006-11-05 00:54:17 +00:00
if ( airpcap_if_active ! = NULL )
gtk_entry_set_text ( GTK_ENTRY ( GTK_COMBO ( wrong_crc_cm ) - > entry ) , airpcap_get_validation_name ( airpcap_if_active - > CrcValidationOn ) ) ;
else
gtk_entry_set_text ( GTK_ENTRY ( GTK_COMBO ( wrong_crc_cm ) - > entry ) , " " ) ;
2006-08-16 18:01:25 +00:00
2006-11-05 00:54:17 +00:00
SIGNAL_CONNECT ( GTK_COMBO ( wrong_crc_cm ) - > entry , " changed " , airpcap_toolbar_wrong_crc_combo_cb , airpcap_tb ) ;
gtk_widget_show ( wrong_crc_cm ) ;
2006-08-16 18:01:25 +00:00
2006-11-05 00:54:17 +00:00
gtk_toolbar_append_space ( GTK_TOOLBAR ( airpcap_tb ) ) ;
2006-08-16 18:01:25 +00:00
2006-10-19 00:48:03 +00:00
/* Decryption mode combo box */
enable_decryption_lb = gtk_label_new ( " Decryption Mode: " ) ;
2006-12-05 19:24:25 +00:00
OBJECT_SET_DATA ( airpcap_tb , AIRPCAP_TOOLBAR_DECRYPTION_LABEL_KEY , enable_decryption_lb ) ;
2006-10-19 00:48:03 +00:00
gtk_widget_set_name ( enable_decryption_lb , " enable_decryption_lb " ) ;
gtk_widget_show ( enable_decryption_lb ) ;
2006-11-05 00:54:17 +00:00
gtk_toolbar_append_widget ( GTK_TOOLBAR ( airpcap_tb ) , enable_decryption_lb ,
2006-10-19 00:48:03 +00:00
NULL , " Private " ) ;
2006-10-19 22:43:38 +00:00
2006-10-19 00:48:03 +00:00
enable_decryption_cb = gtk_combo_new ( ) ;
gtk_widget_set_name ( enable_decryption_cb , " enable_decryption_cb " ) ;
gtk_widget_show ( enable_decryption_cb ) ;
2006-11-05 00:54:17 +00:00
WIDGET_SET_SIZE ( enable_decryption_cb , 83 , - 1 ) ;
2006-12-05 19:24:25 +00:00
update_decryption_mode_list ( enable_decryption_cb ) ;
2006-10-19 22:43:38 +00:00
2006-10-19 00:48:03 +00:00
enable_decryption_en = GTK_COMBO ( enable_decryption_cb ) - > entry ;
gtk_widget_set_name ( enable_decryption_en , " enable_decryption_en " ) ;
gtk_widget_show ( enable_decryption_en ) ;
gtk_editable_set_editable ( GTK_EDITABLE ( enable_decryption_en ) , FALSE ) ;
GTK_WIDGET_UNSET_FLAGS ( enable_decryption_en , GTK_CAN_FOCUS ) ;
2006-10-19 22:43:38 +00:00
2006-11-05 00:54:17 +00:00
gtk_toolbar_append_widget ( GTK_TOOLBAR ( airpcap_tb ) , enable_decryption_cb ,
2006-10-19 00:48:03 +00:00
" Choose a Decryption Mode " , " Private " ) ;
2006-10-19 22:43:38 +00:00
2006-10-19 00:48:03 +00:00
/* Set current decryption mode!!!! */
update_decryption_mode_cm ( enable_decryption_cb ) ;
SIGNAL_CONNECT ( enable_decryption_en , " changed " , on_enable_decryption_en_changed , airpcap_tb ) ;
OBJECT_SET_DATA ( airpcap_tb , AIRPCAP_TOOLBAR_DECRYPTION_KEY , enable_decryption_cb ) ;
2006-08-16 18:01:25 +00:00
2006-11-05 00:54:17 +00:00
gtk_toolbar_append_space ( GTK_TOOLBAR ( airpcap_tb ) ) ;
2006-08-16 18:01:25 +00:00
2007-05-18 21:06:20 +00:00
# if GTK_MAJOR_VERSION >= 2 /* For some reason this button's action crashes under GTK 1. */
2006-11-05 00:54:17 +00:00
/* Advanced button */
advanced_bt = gtk_button_new_with_label ( " Wireless Settings... " ) ;
OBJECT_SET_DATA ( airpcap_tb , AIRPCAP_TOOLBAR_ADVANCED_KEY , advanced_bt ) ;
2006-08-16 18:01:25 +00:00
2006-11-05 00:54:17 +00:00
SIGNAL_CONNECT ( advanced_bt , " clicked " , toolbar_display_airpcap_advanced_cb , airpcap_tb ) ;
gtk_toolbar_append_widget ( GTK_TOOLBAR ( airpcap_tb ) , advanced_bt ,
2006-10-24 21:07:05 +00:00
" Set Advanced Wireless Settings " , " Private " ) ;
2007-05-18 21:06:20 +00:00
2006-11-05 00:54:17 +00:00
gtk_widget_show ( advanced_bt ) ;
2007-05-18 21:06:20 +00:00
# endif /* GTK_MAJOR_VERSION */
2006-11-05 00:54:17 +00:00
/* Key Management button */
key_management_bt = gtk_button_new_with_label ( " Decryption Keys... " ) ;
OBJECT_SET_DATA ( airpcap_tb , AIRPCAP_TOOLBAR_KEY_MANAGEMENT_KEY , key_management_bt ) ;
SIGNAL_CONNECT ( key_management_bt , " clicked " , toolbar_display_airpcap_key_management_cb , airpcap_tb ) ;
gtk_toolbar_append_widget ( GTK_TOOLBAR ( airpcap_tb ) , key_management_bt ,
" Manage Decryption Keys " , " Private " ) ;
gtk_widget_show ( key_management_bt ) ;
/* If no airpcap interface is present, gray everything */
if ( airpcap_if_active = = NULL ) {
2007-05-18 21:06:20 +00:00
if ( airpcap_if_list = = NULL | | g_list_length ( airpcap_if_list ) = = 0 ) {
2006-11-05 00:54:17 +00:00
/*No airpcap device found */
2006-12-05 19:24:25 +00:00
airpcap_enable_toolbar_widgets ( airpcap_tb , FALSE ) ;
2007-03-09 13:14:09 +00:00
/* recent.airpcap_toolbar_show = TRUE; */
2007-05-18 21:06:20 +00:00
} else {
/* default adapter is not airpcap... or is airpcap but is not found*/
airpcap_set_toolbar_stop_capture ( airpcap_if_active ) ;
airpcap_enable_toolbar_widgets ( airpcap_tb , FALSE ) ;
/* recent.airpcap_toolbar_show = TRUE; */
}
2006-11-05 00:54:17 +00:00
} else {
2006-08-16 18:01:25 +00:00
airpcap_set_toolbar_stop_capture ( airpcap_if_active ) ;
2007-03-09 13:14:09 +00:00
/* recent.airpcap_toolbar_show = TRUE; */
2006-11-05 00:54:17 +00:00
}
2006-08-16 18:01:25 +00:00
# endif
2004-01-19 00:42:12 +00:00
/* filter toolbar */
# if GTK_MAJOR_VERSION < 2
filter_tb = gtk_toolbar_new ( GTK_ORIENTATION_HORIZONTAL ,
GTK_TOOLBAR_BOTH ) ;
# else
filter_tb = gtk_toolbar_new ( ) ;
gtk_toolbar_set_orientation ( GTK_TOOLBAR ( filter_tb ) ,
GTK_ORIENTATION_HORIZONTAL ) ;
# endif /* GTK_MAJOR_VERSION */
gtk_widget_show ( filter_tb ) ;
2002-11-03 17:38:45 +00:00
2004-04-27 19:16:11 +00:00
/* Create the "Filter:" button */
2006-05-28 17:19:08 +00:00
filter_bt = BUTTON_NEW_FROM_STOCK ( WIRESHARK_STOCK_DISPLAY_FILTER_ENTRY ) ;
2002-11-10 11:36:39 +00:00
SIGNAL_CONNECT ( filter_bt , " clicked " , display_filter_construct_cb , & args ) ;
2002-11-03 17:38:45 +00:00
gtk_widget_show ( filter_bt ) ;
2004-01-18 00:40:39 +00:00
OBJECT_SET_DATA ( top_level , E_FILT_BT_PTR_KEY , filter_bt ) ;
2002-11-03 17:38:45 +00:00
2006-02-16 15:27:03 +00:00
gtk_toolbar_append_widget ( GTK_TOOLBAR ( filter_tb ) , filter_bt ,
2004-01-25 15:10:36 +00:00
" Open the \" Display Filter \" dialog, to edit/apply filters " , " Private " ) ;
2004-01-19 00:42:12 +00:00
2004-04-27 19:16:11 +00:00
/* Create the filter combobox */
2002-11-03 17:38:45 +00:00
filter_cm = gtk_combo_new ( ) ;
2005-03-25 22:52:45 +00:00
dfilter_list = NULL ;
2002-11-03 17:38:45 +00:00
gtk_combo_disable_activate ( GTK_COMBO ( filter_cm ) ) ;
gtk_combo_set_case_sensitive ( GTK_COMBO ( filter_cm ) , TRUE ) ;
2005-03-25 22:52:45 +00:00
OBJECT_SET_DATA ( filter_cm , E_DFILTER_FL_KEY , dfilter_list ) ;
2002-11-03 17:38:45 +00:00
filter_te = GTK_COMBO ( filter_cm ) - > entry ;
2003-08-19 10:09:20 +00:00
main_display_filter_widget = filter_te ;
2002-11-10 11:36:39 +00:00
OBJECT_SET_DATA ( filter_bt , E_FILT_TE_PTR_KEY , filter_te ) ;
OBJECT_SET_DATA ( filter_te , E_DFILTER_CM_KEY , filter_cm ) ;
2003-12-13 18:01:30 +00:00
OBJECT_SET_DATA ( top_level , E_DFILTER_CM_KEY , filter_cm ) ;
2002-11-10 11:36:39 +00:00
SIGNAL_CONNECT ( filter_te , " activate " , filter_activate_cb , filter_te ) ;
2004-01-25 15:10:36 +00:00
SIGNAL_CONNECT ( filter_te , " changed " , filter_te_syntax_check_cb , NULL ) ;
2004-01-19 00:42:12 +00:00
WIDGET_SET_SIZE ( filter_cm , 400 , - 1 ) ;
2002-11-03 17:38:45 +00:00
gtk_widget_show ( filter_cm ) ;
2006-02-16 15:27:03 +00:00
gtk_toolbar_append_widget ( GTK_TOOLBAR ( filter_tb ) , filter_cm ,
2004-01-26 18:40:44 +00:00
NULL , NULL ) ;
/* setting a tooltip for a combobox will do nothing, so add it to the corresponding text entry */
2006-02-16 15:27:03 +00:00
gtk_tooltips_set_tip ( tooltips , filter_te ,
2004-01-26 18:40:44 +00:00
" Enter a display filter, or choose one of your recently used filters. "
2006-02-16 15:27:03 +00:00
" The background color of this field is changed by a continuous syntax check (green is valid, red is invalid). " ,
2004-01-26 18:40:44 +00:00
NULL ) ;
2004-01-25 15:10:36 +00:00
/* Create the "Add Expression..." button, to pop up a dialog
for constructing filter comparison expressions . */
2006-05-28 17:19:08 +00:00
filter_add_expr_bt = BUTTON_NEW_FROM_STOCK ( WIRESHARK_STOCK_ADD_EXPRESSION ) ;
2004-01-25 15:10:36 +00:00
OBJECT_SET_DATA ( filter_tb , E_FILT_FILTER_TE_KEY , filter_te ) ;
SIGNAL_CONNECT ( filter_add_expr_bt , " clicked " , filter_add_expr_bt_cb , filter_tb ) ;
gtk_widget_show ( filter_add_expr_bt ) ;
2006-02-16 15:27:03 +00:00
gtk_toolbar_append_widget ( GTK_TOOLBAR ( filter_tb ) , filter_add_expr_bt ,
2004-01-25 15:10:36 +00:00
" Add an expression to this filter string " , " Private " ) ;
2002-11-03 17:38:45 +00:00
2004-04-27 19:16:11 +00:00
/* Create the "Clear" button */
2004-01-10 16:27:43 +00:00
filter_reset = BUTTON_NEW_FROM_STOCK ( GTK_STOCK_CLEAR ) ;
2002-11-10 11:36:39 +00:00
OBJECT_SET_DATA ( filter_reset , E_DFILTER_TE_KEY , filter_te ) ;
SIGNAL_CONNECT ( filter_reset , " clicked " , filter_reset_cb , NULL ) ;
2002-11-03 17:38:45 +00:00
gtk_widget_show ( filter_reset ) ;
2006-02-16 15:27:03 +00:00
gtk_toolbar_append_widget ( GTK_TOOLBAR ( filter_tb ) , filter_reset ,
2004-01-25 15:10:36 +00:00
" Clear this filter string and update the display " , " Private " ) ;
2002-11-03 17:38:45 +00:00
2004-04-27 19:16:11 +00:00
/* Create the "Apply" button */
2004-01-10 16:27:43 +00:00
filter_apply = BUTTON_NEW_FROM_STOCK ( GTK_STOCK_APPLY ) ;
2002-11-10 11:36:39 +00:00
OBJECT_SET_DATA ( filter_apply , E_DFILTER_CM_KEY , filter_cm ) ;
SIGNAL_CONNECT ( filter_apply , " clicked " , filter_activate_cb , filter_te ) ;
2002-11-03 17:38:45 +00:00
gtk_widget_show ( filter_apply ) ;
2006-02-16 15:27:03 +00:00
gtk_toolbar_append_widget ( GTK_TOOLBAR ( filter_tb ) , filter_apply ,
2004-01-25 15:10:36 +00:00
" Apply this filter string to the display " , " Private " ) ;
2002-11-03 17:38:45 +00:00
/* Sets the text entry widget pointer as the E_DILTER_TE_KEY data
* of any widget that ends up calling a callback which needs
* that text entry pointer */
set_menu_object_data ( " /File/Open... " , E_DFILTER_TE_KEY , filter_te ) ;
2007-03-08 23:37:55 +00:00
set_menu_object_data ( " /Edit/Copy/As Filter " , E_DFILTER_TE_KEY ,
filter_te ) ;
2003-12-07 09:43:53 +00:00
set_menu_object_data ( " /Analyze/Display Filters... " , E_FILT_TE_PTR_KEY ,
2002-11-03 17:38:45 +00:00
filter_te ) ;
2004-02-23 19:19:39 +00:00
set_menu_object_data ( " /Analyze/Follow TCP Stream " , E_DFILTER_TE_KEY ,
2002-11-03 17:38:45 +00:00
filter_te ) ;
2006-02-04 23:44:05 +00:00
set_menu_object_data ( " /Analyze/Follow SSL Stream " , E_DFILTER_TE_KEY ,
2006-02-16 15:27:03 +00:00
filter_te ) ;
2004-05-07 12:15:24 +00:00
set_menu_object_data ( " /Analyze/Apply as Filter/Selected " , E_DFILTER_TE_KEY ,
2002-11-03 17:38:45 +00:00
filter_te ) ;
2004-05-07 12:15:24 +00:00
set_menu_object_data ( " /Analyze/Apply as Filter/Not Selected " , E_DFILTER_TE_KEY ,
2002-11-03 17:38:45 +00:00
filter_te ) ;
2004-05-07 12:15:24 +00:00
set_menu_object_data ( " /Analyze/Apply as Filter/... and Selected " , E_DFILTER_TE_KEY ,
2002-11-03 17:38:45 +00:00
filter_te ) ;
2004-05-07 12:15:24 +00:00
set_menu_object_data ( " /Analyze/Apply as Filter/... or Selected " , E_DFILTER_TE_KEY ,
2002-11-03 17:38:45 +00:00
filter_te ) ;
2004-05-07 12:15:24 +00:00
set_menu_object_data ( " /Analyze/Apply as Filter/... and not Selected " , E_DFILTER_TE_KEY ,
2002-11-03 17:38:45 +00:00
filter_te ) ;
2004-05-07 12:15:24 +00:00
set_menu_object_data ( " /Analyze/Apply as Filter/... or not Selected " , E_DFILTER_TE_KEY ,
2002-11-03 17:38:45 +00:00
filter_te ) ;
2004-05-07 12:15:24 +00:00
set_menu_object_data ( " /Analyze/Prepare a Filter/Selected " , E_DFILTER_TE_KEY ,
2002-11-03 17:38:45 +00:00
filter_te ) ;
2004-05-07 12:15:24 +00:00
set_menu_object_data ( " /Analyze/Prepare a Filter/Not Selected " , E_DFILTER_TE_KEY ,
2002-11-03 17:38:45 +00:00
filter_te ) ;
2004-05-07 12:15:24 +00:00
set_menu_object_data ( " /Analyze/Prepare a Filter/... and Selected " , E_DFILTER_TE_KEY ,
2002-11-03 17:38:45 +00:00
filter_te ) ;
2004-05-07 12:15:24 +00:00
set_menu_object_data ( " /Analyze/Prepare a Filter/... or Selected " , E_DFILTER_TE_KEY ,
2002-11-03 17:38:45 +00:00
filter_te ) ;
2004-05-07 12:15:24 +00:00
set_menu_object_data ( " /Analyze/Prepare a Filter/... and not Selected " , E_DFILTER_TE_KEY ,
2003-12-07 09:43:53 +00:00
filter_te ) ;
2004-05-07 12:15:24 +00:00
set_menu_object_data ( " /Analyze/Prepare a Filter/... or not Selected " , E_DFILTER_TE_KEY ,
2002-11-03 17:38:45 +00:00
filter_te ) ;
2006-08-12 22:38:08 +00:00
set_menu_object_data ( " /Conversation Filter/Ethernet " , E_DFILTER_TE_KEY ,
filter_te ) ;
set_menu_object_data ( " /Conversation Filter/IP " , E_DFILTER_TE_KEY ,
filter_te ) ;
set_menu_object_data ( " /Conversation Filter/TCP " , E_DFILTER_TE_KEY ,
filter_te ) ;
set_menu_object_data ( " /Conversation Filter/UDP " , E_DFILTER_TE_KEY ,
filter_te ) ;
set_menu_object_data ( " /Conversation Filter/PN-CBA Server " , E_DFILTER_TE_KEY ,
filter_te ) ;
2003-10-16 20:56:07 +00:00
set_toolbar_object_data ( E_DFILTER_TE_KEY , filter_te ) ;
2002-11-10 11:36:39 +00:00
OBJECT_SET_DATA ( popup_menu_object , E_DFILTER_TE_KEY , filter_te ) ;
OBJECT_SET_DATA ( popup_menu_object , E_MPACKET_LIST_KEY , packet_list ) ;
2002-11-03 17:38:45 +00:00
2004-02-03 00:16:59 +00:00
/* info (main) statusbar */
info_bar = info_bar_new ( ) ;
2002-11-03 17:38:45 +00:00
gtk_widget_show ( info_bar ) ;
2004-02-03 00:16:59 +00:00
/* packets statusbar */
packets_bar = packets_bar_new ( ) ;
gtk_widget_show ( packets_bar ) ;
2004-01-23 16:07:37 +00:00
/* Filter/status hbox */
2004-01-19 00:42:12 +00:00
stat_hbox = gtk_hbox_new ( FALSE , 1 ) ;
gtk_container_border_width ( GTK_CONTAINER ( stat_hbox ) , 0 ) ;
gtk_widget_show ( stat_hbox ) ;
2004-04-27 19:16:11 +00:00
/* Pane for the statusbar */
status_pane = gtk_hpaned_new ( ) ;
gtk_widget_show ( status_pane ) ;
2005-02-05 23:12:44 +00:00
/* Pane for the welcome screen */
welcome_pane = welcome_new ( ) ;
gtk_widget_show ( welcome_pane ) ;
1998-09-16 02:39:15 +00:00
}
2005-02-07 02:09:30 +00:00
2006-11-05 00:54:17 +00:00
# ifdef HAVE_AIRPCAP
static void
driver_warning_dialog_cb ( gpointer dialog , gint btn _U_ , gpointer data _U_ )
2006-10-31 01:44:11 +00:00
{
2006-11-05 00:54:17 +00:00
gboolean r ;
2006-11-18 05:05:18 +00:00
2006-11-05 00:54:17 +00:00
r = simple_dialog_check_get ( dialog ) ;
2006-10-31 01:44:11 +00:00
recent . airpcap_driver_check_show = ! r ;
}
2006-11-05 00:54:17 +00:00
# endif
2006-10-31 01:44:11 +00:00
2005-02-07 02:09:30 +00:00
static void
show_main_window ( gboolean doing_work )
{
main_set_for_capture_file ( doing_work ) ;
/*** we have finished all init things, show the main window ***/
gtk_widget_show ( top_level ) ;
2006-10-19 22:43:38 +00:00
2005-02-07 02:09:30 +00:00
/* the window can be maximized only, if it's visible, so do it after show! */
main_load_window_geometry ( top_level ) ;
/* process all pending GUI events before continue */
while ( gtk_events_pending ( ) ) gtk_main_iteration ( ) ;
/* Pop up any queued-up alert boxes. */
display_queued_messages ( ) ;
2006-10-19 00:48:03 +00:00
2006-10-19 22:43:38 +00:00
# ifdef HAVE_AIRPCAP
2006-11-05 00:54:17 +00:00
/*
* This will read the decryption keys from the preferences file , and will
* store them into the registry . . .
*/
2007-05-18 21:06:20 +00:00
if ( airpcap_if_list ! = NULL & & g_list_length ( airpcap_if_list ) > 0 ) {
if ( ! airpcap_check_decryption_keys ( airpcap_if_list ) ) {
/* Ask the user what to do ...*/
airpcap_keys_check_w ( NULL , NULL ) ;
} else {
/* Keys from lists are equals, or wireshark has got no keys */
airpcap_load_decryption_keys ( airpcap_if_list ) ;
}
2006-11-05 00:54:17 +00:00
}
2006-10-31 01:44:11 +00:00
2006-11-05 00:54:17 +00:00
switch ( airpcap_dll_ret_val ) {
case AIRPCAP_DLL_OK :
break ;
case AIRPCAP_DLL_OLD :
if ( recent . airpcap_driver_check_show ) {
driver_warning_dialog = simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " %s " ,
2006-10-31 01:44:11 +00:00
" WARNING: The version of AirPcap on this system \n "
" does not support driver-level decryption. Please \n "
" download a more recent version from \n " " http://www.cacetech.com/support/downloads.htm \n " ) ;
2006-11-05 00:54:17 +00:00
simple_dialog_check_set ( driver_warning_dialog , " Don't show this message again. " ) ;
2007-08-30 00:24:40 +00:00
simple_dialog_set_cb ( driver_warning_dialog , driver_warning_dialog_cb , NULL ) ;
2006-11-05 00:54:17 +00:00
}
break ;
#if 0
/*
* XXX - Maybe we need to warn the user if one of the following happens ? ? ?
*/
case AIRPCAP_DLL_ERROR :
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " %s " , " AIRPCAP_DLL_ERROR \n " ) ;
break ;
case AIRPCAP_DLL_NOT_FOUND :
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " %s " , " AIRPCAP_DDL_NOT_FOUND \n " ) ;
break ;
2006-10-19 00:48:03 +00:00
# endif
2006-11-05 00:54:17 +00:00
}
# endif /* HAVE_AIRPCAP */
2005-02-07 02:09:30 +00:00
}
2006-11-16 07:04:02 +00:00
/* Fill in capture options with values from the preferences */
void
prefs_to_capture_opts ( void )
{
# ifdef HAVE_LIBPCAP
/* Set promiscuous mode from the preferences setting. */
/* the same applies to other preferences settings as well. */
capture_opts - > promisc_mode = prefs . capture_prom_mode ;
capture_opts - > show_info = prefs . capture_show_info ;
capture_opts - > real_time_mode = prefs . capture_real_time ;
auto_scroll_live = prefs . capture_auto_scroll ;
# endif /* HAVE_LIBPCAP */
/* Set the name resolution code's flags from the preferences. */
g_resolv_flags = prefs . name_resolve ;
}