1999-09-11 12:38:18 +00:00
|
|
|
/* main.c
|
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
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
1998-09-16 02:39:15 +00:00
|
|
|
*/
|
|
|
|
|
2016-03-14 19:03:11 +00:00
|
|
|
#include <config.h>
|
1998-09-16 02:39:15 +00:00
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
2006-11-18 05:05:18 +00:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2011-06-20 00:48:05 +00:00
|
|
|
#if GTK_CHECK_VERSION(3,0,0)
|
|
|
|
# include <gdk/gdkkeysyms-compat.h>
|
|
|
|
#endif
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2009-08-27 02:53:13 +00:00
|
|
|
#include <stdio.h>
|
1998-09-16 02:39:15 +00:00
|
|
|
#include <string.h>
|
2011-06-24 02:35:46 +00:00
|
|
|
#include <locale.h>
|
1999-07-13 02:53:26 +00:00
|
|
|
|
2014-12-26 22:37:31 +00:00
|
|
|
#ifdef HAVE_GETOPT_H
|
|
|
|
#include <getopt.h>
|
|
|
|
#endif
|
|
|
|
|
2015-12-29 06:57:36 +00:00
|
|
|
#ifdef HAVE_EXTCAP
|
|
|
|
#include <extcap.h>
|
|
|
|
#endif
|
|
|
|
|
2006-09-12 20:23:57 +00:00
|
|
|
#ifdef HAVE_LIBPORTAUDIO
|
|
|
|
#include <portaudio.h>
|
|
|
|
#endif /* HAVE_LIBPORTAUDIO */
|
|
|
|
|
2015-02-20 00:05:49 +00:00
|
|
|
#include <wsutil/copyright_info.h>
|
2013-01-16 00:12:27 +00:00
|
|
|
#include <wsutil/crash_info.h>
|
2013-11-19 19:45:38 +00:00
|
|
|
#include <wsutil/filesystem.h>
|
2013-07-16 02:04:55 +00:00
|
|
|
#include <wsutil/file_util.h>
|
2013-11-19 19:45:38 +00:00
|
|
|
#include <wsutil/privileges.h>
|
2017-04-08 19:45:19 +00:00
|
|
|
#include <wsutil/report_message.h>
|
2017-09-26 14:04:56 +00:00
|
|
|
#include <version_info.h>
|
2013-01-16 00:12:27 +00:00
|
|
|
|
2013-07-16 02:35:33 +00:00
|
|
|
#include <wiretap/merge.h>
|
|
|
|
|
2013-11-22 00:20:23 +00:00
|
|
|
#include <epan/addr_resolv.h>
|
|
|
|
#include <epan/column.h>
|
|
|
|
#include <epan/disabled_protos.h>
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/epan.h>
|
2016-10-07 20:25:01 +00:00
|
|
|
#include <epan/decode_as.h>
|
2014-11-06 10:19:25 +00:00
|
|
|
#include <epan/proto.h>
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/epan_dissect.h>
|
2004-05-20 12:01:13 +00:00
|
|
|
#include <epan/dfilter/dfilter.h>
|
|
|
|
#include <epan/strutil.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>
|
2004-09-27 22:55:15 +00:00
|
|
|
#include <epan/prefs.h>
|
2004-10-01 08:33:53 +00:00
|
|
|
#include <epan/prefs-int.h>
|
2004-09-29 00:06:36 +00:00
|
|
|
#include <epan/tap.h>
|
2014-11-14 18:51:40 +00:00
|
|
|
#include <epan/stat_tap_ui.h>
|
2008-04-12 23:34:44 +00:00
|
|
|
#include <epan/uat.h>
|
2013-07-12 03:50:50 +00:00
|
|
|
#include <epan/print.h>
|
2013-11-22 00:20:23 +00:00
|
|
|
#include <epan/timestamp.h>
|
2014-07-23 17:38:55 +00:00
|
|
|
#include <epan/conversation_table.h>
|
2008-04-12 23:34:44 +00:00
|
|
|
|
2015-01-01 23:05:25 +00:00
|
|
|
#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
|
|
|
|
#include <epan/asn1.h>
|
|
|
|
#include <epan/dissectors/packet-kerberos.h>
|
|
|
|
#endif
|
|
|
|
|
2014-06-29 21:37:21 +00:00
|
|
|
#include <wsutil/cmdarg_err.h>
|
2013-12-02 08:30:29 +00:00
|
|
|
#include <wsutil/plugins.h>
|
|
|
|
|
2008-04-12 23:34:44 +00:00
|
|
|
/* general (not GTK specific) */
|
2016-02-18 12:06:13 +00:00
|
|
|
#include "../../file.h"
|
|
|
|
#include "../../frame_tvbuff.h"
|
|
|
|
#include "../../summary.h"
|
2015-12-22 20:07:00 +00:00
|
|
|
#include <epan/color_filters.h>
|
2016-02-18 12:06:13 +00:00
|
|
|
#include "../../register.h"
|
|
|
|
#include "../../ringbuffer.h"
|
|
|
|
#include "../../log.h"
|
2012-01-18 19:38:34 +00:00
|
|
|
|
2012-06-28 16:21:51 +00:00
|
|
|
#include "gtk_iface_monitor.h"
|
|
|
|
|
2012-01-18 19:38:34 +00:00
|
|
|
#include "ui/alert_box.h"
|
2014-09-25 23:21:02 +00:00
|
|
|
#include "ui/console.h"
|
2013-12-10 19:23:26 +00:00
|
|
|
#include "ui/decode_as_utils.h"
|
2017-04-09 04:24:45 +00:00
|
|
|
#include "ui/filter_files.h"
|
2012-01-18 19:38:34 +00:00
|
|
|
#include "ui/main_statusbar.h"
|
2013-11-19 19:45:38 +00:00
|
|
|
#include "ui/persfilepath_opt.h"
|
2013-01-18 00:50:14 +00:00
|
|
|
#include "ui/preference_utils.h"
|
2012-01-18 19:38:34 +00:00
|
|
|
#include "ui/recent.h"
|
|
|
|
#include "ui/recent_utils.h"
|
2013-02-19 22:21:17 +00:00
|
|
|
#include "ui/software_update.h"
|
2017-10-14 20:14:14 +00:00
|
|
|
#include "ui/ws_ui_util.h"
|
2014-06-30 21:47:22 +00:00
|
|
|
#include "ui/util.h"
|
2016-10-30 21:07:33 +00:00
|
|
|
#include "ui/dissect_opts.h"
|
2016-06-18 20:49:23 +00:00
|
|
|
#include "ui/commandline.h"
|
2012-01-18 19:38:34 +00:00
|
|
|
|
2012-08-01 22:32:14 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2014-06-30 01:36:22 +00:00
|
|
|
#include "ui/capture_ui_utils.h"
|
2012-08-03 23:30:47 +00:00
|
|
|
#include "ui/capture_globals.h"
|
2012-08-01 22:32:14 +00:00
|
|
|
#include "ui/iface_lists.h"
|
|
|
|
#endif
|
|
|
|
|
2013-12-02 08:30:29 +00:00
|
|
|
#include "codecs/codecs.h"
|
|
|
|
|
2014-07-04 07:24:02 +00:00
|
|
|
#include "caputils/capture-pcap-util.h"
|
2014-07-03 09:16:12 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBPCAP
|
2014-07-04 07:24:02 +00:00
|
|
|
#include "caputils/capture_ifinfo.h"
|
2014-06-30 05:38:29 +00:00
|
|
|
#include "ui/capture.h"
|
2014-06-24 00:27:28 +00:00
|
|
|
#include <capchild/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
|
2014-07-04 07:24:02 +00:00
|
|
|
#include "caputils/capture-wpcap.h"
|
|
|
|
#include "caputils/capture_wpcap_packet.h"
|
2006-03-08 20:55:32 +00:00
|
|
|
#include <tchar.h> /* Needed for Unicode */
|
2014-12-25 21:03:09 +00:00
|
|
|
#include <wsutil/os_version_info.h>
|
2011-05-24 00:07:56 +00:00
|
|
|
#include <wsutil/unicode-utils.h>
|
2006-02-16 15:27:03 +00:00
|
|
|
#include <commctrl.h>
|
2010-08-13 21:21:28 +00:00
|
|
|
#include <shellapi.h>
|
2006-02-16 15:27:03 +00:00
|
|
|
#endif /* _WIN32 */
|
2005-03-07 10:19:33 +00:00
|
|
|
|
2004-05-20 12:01:13 +00:00
|
|
|
/* GTK related */
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/file_dlg.h"
|
|
|
|
#include "ui/gtk/gtkglobals.h"
|
|
|
|
#include "ui/gtk/color_utils.h"
|
|
|
|
#include "ui/gtk/gui_utils.h"
|
|
|
|
#include "ui/gtk/color_dlg.h"
|
|
|
|
#include "ui/gtk/filter_dlg.h"
|
2012-09-26 23:33:11 +00:00
|
|
|
#include "ui/gtk/fileset_dlg.h"
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/uat_gui.h"
|
|
|
|
#include "ui/gtk/main.h"
|
2012-06-24 19:43:09 +00:00
|
|
|
#include "ui/gtk/main_80211_toolbar.h"
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/main_airpcap_toolbar.h"
|
|
|
|
#include "ui/gtk/main_filter_toolbar.h"
|
2012-06-03 18:35:34 +00:00
|
|
|
#include "ui/gtk/main_titlebar.h"
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/menus.h"
|
2012-06-04 02:24:42 +00:00
|
|
|
#include "ui/gtk/main_menubar_private.h"
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/macros_dlg.h"
|
|
|
|
#include "ui/gtk/main_statusbar_private.h"
|
|
|
|
#include "ui/gtk/main_toolbar.h"
|
2012-06-04 03:15:05 +00:00
|
|
|
#include "ui/gtk/main_toolbar_private.h"
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/main_welcome.h"
|
2015-04-05 20:01:45 +00:00
|
|
|
#include "ui/gtk/main_welcome_private.h"
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/drag_and_drop.h"
|
|
|
|
#include "ui/gtk/capture_file_dlg.h"
|
2012-06-16 20:52:04 +00:00
|
|
|
#include "ui/gtk/packet_panes.h"
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/keys.h"
|
|
|
|
#include "ui/gtk/packet_win.h"
|
|
|
|
#include "ui/gtk/stock_icons.h"
|
|
|
|
#include "ui/gtk/find_dlg.h"
|
|
|
|
#include "ui/gtk/font_utils.h"
|
|
|
|
#include "ui/gtk/about_dlg.h"
|
|
|
|
#include "ui/gtk/help_dlg.h"
|
|
|
|
#include "ui/gtk/decode_as_dlg.h"
|
|
|
|
#include "ui/gtk/webbrowser.h"
|
|
|
|
#include "ui/gtk/capture_dlg.h"
|
|
|
|
#include "ui/gtk/capture_if_dlg.h"
|
|
|
|
#include "ui/gtk/tap_param_dlg.h"
|
|
|
|
#include "ui/gtk/prefs_column.h"
|
|
|
|
#include "ui/gtk/prefs_dlg.h"
|
2012-09-04 01:57:36 +00:00
|
|
|
#include "ui/gtk/packet_list.h"
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/filter_expression_save_dlg.h"
|
2014-07-23 17:38:55 +00:00
|
|
|
#include "ui/gtk/conversations_table.h"
|
2014-07-25 15:34:51 +00:00
|
|
|
#include "ui/gtk/hostlist_table.h"
|
Further refactor SRT stats.
Create "common" SRT tap data collection intended for all GUIs. Refactor/merge functionality of existing dissectors that have SRT support (AFP, DCERPC, Diameter, FC, GTP, LDAP, NCP, RPC, SCIS, SMB, and SMB2) for both TShark and GTK.
SMB and DCERPC "tap packet filtering" were different between TShark and GTK, so I went with GTK filter logic.
CAMEL "tap packet filtering" was different between TShark and GTK, so GTK filtering logic was pushed to the dissector and the TShark tap was left alone.
Change-Id: I7d6eaad0673fe628ef337f9165d7ed94f4a5e1cc
Reviewed-on: https://code.wireshark.org/review/8894
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-06-16 21:07:04 +00:00
|
|
|
#include "ui/gtk/service_response_time_table.h"
|
2015-06-20 16:22:22 +00:00
|
|
|
#include "ui/gtk/response_time_delay_table.h"
|
2015-06-23 12:53:17 +00:00
|
|
|
#include "ui/gtk/simple_stattable.h"
|
2014-09-24 21:06:23 +00:00
|
|
|
#include "simple_dialog.h"
|
2016-02-21 17:10:03 +00:00
|
|
|
#ifdef HAVE_GDK_GRESOURCE
|
2015-10-17 12:47:17 +00:00
|
|
|
#include "wireshark-gresources.h"
|
|
|
|
#else
|
|
|
|
#include "ui/gtk/pixbuf-csource.h"
|
|
|
|
#endif
|
2012-01-15 21:59:11 +00:00
|
|
|
|
|
|
|
#include "ui/gtk/old-gtk-compat.h"
|
2011-07-21 17:44:02 +00:00
|
|
|
|
2006-08-16 18:01:25 +00:00
|
|
|
#ifdef HAVE_AIRPCAP
|
2014-08-01 00:29:36 +00:00
|
|
|
#include <caputils/airpcap.h>
|
|
|
|
#include <caputils/airpcap_loader.h>
|
2006-08-16 18:01:25 +00:00
|
|
|
#include "airpcap_dlg.h"
|
|
|
|
#include "airpcap_gui_utils.h"
|
|
|
|
#endif
|
2001-04-03 05:26:27 +00:00
|
|
|
|
2006-12-28 17:22:12 +00:00
|
|
|
#include <epan/crypt/airpdcap_ws.h>
|
2006-12-05 19:24:25 +00:00
|
|
|
|
2009-06-30 18:05:04 +00:00
|
|
|
|
2010-05-25 00:35:44 +00:00
|
|
|
#ifdef HAVE_GTKOSXAPPLICATION
|
2012-11-02 09:58:43 +00:00
|
|
|
#include <gtkmacintegration/gtkosxapplication.h>
|
2010-05-25 00:35:44 +00:00
|
|
|
#endif
|
|
|
|
|
2017-04-08 19:45:19 +00:00
|
|
|
#define INVALID_OPTION 1
|
2017-01-25 09:16:35 +00:00
|
|
|
#define INIT_FAILED 2
|
|
|
|
#define INVALID_CAPABILITY 2
|
|
|
|
#define INVALID_LINK_TYPE 2
|
|
|
|
|
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"
|
|
|
|
|
2013-05-22 10:21:52 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
capture_session global_capture_session;
|
2015-12-17 04:15:03 +00:00
|
|
|
info_data_t global_info_data;
|
2013-05-22 09:59:58 +00:00
|
|
|
#endif
|
2013-05-22 07:44:28 +00:00
|
|
|
|
2000-06-27 04:36:03 +00:00
|
|
|
capture_file cfile;
|
2008-04-12 23:34:44 +00:00
|
|
|
|
2012-06-14 03:50:39 +00:00
|
|
|
static gboolean capture_stopping;
|
|
|
|
|
2008-04-12 23:34:44 +00:00
|
|
|
/* "exported" main widgets */
|
2010-01-29 19:09:01 +00:00
|
|
|
GtkWidget *top_level = NULL, *pkt_scrollw, *tree_view_gbl, *byte_nb_ptr_gbl;
|
2008-04-12 23:34:44 +00:00
|
|
|
|
|
|
|
/* placement widgets (can be a bit confusing, because of the many layout possibilities */
|
|
|
|
static GtkWidget *main_vbox, *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;
|
2008-04-12 21:44:50 +00:00
|
|
|
|
2008-04-12 23:34:44 +00:00
|
|
|
/* internally used widgets */
|
|
|
|
static GtkWidget *menubar, *main_tb, *filter_tb, *tv_scrollw, *statusbar, *welcome_pane;
|
2006-08-16 18:01:25 +00:00
|
|
|
|
2012-06-19 14:37:46 +00:00
|
|
|
GtkWidget *wireless_tb;
|
2012-06-19 16:13:11 +00:00
|
|
|
#ifdef HAVE_AIRPCAP
|
2008-04-12 22:14:42 +00:00
|
|
|
int airpcap_dll_ret_val = -1;
|
2006-08-16 18:01:25 +00:00
|
|
|
#endif
|
|
|
|
|
2010-10-12 17:39:44 +00:00
|
|
|
static gboolean have_capture_file = FALSE; /* XXX - is there an equivalent in cfile? */
|
|
|
|
|
|
|
|
static guint tap_update_timer_id;
|
2008-04-21 10:57:32 +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);
|
2004-02-01 20:28:11 +00:00
|
|
|
static void main_save_window_geometry(GtkWidget *widget);
|
1998-10-12 01:40:57 +00:00
|
|
|
|
2008-04-12 23:34:44 +00:00
|
|
|
|
1999-06-24 16:25:59 +00:00
|
|
|
/* Match selected byte pattern */
|
2002-04-08 20:30:56 +00:00
|
|
|
static void
|
2012-12-05 01:02:40 +00:00
|
|
|
match_selected_cb_do(GtkWidget *filter_te, int action, gchar *text)
|
1999-06-24 16:25:59 +00:00
|
|
|
{
|
2007-11-24 11:38:16 +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))) {
|
2017-02-19 18:58:47 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not acquire information to build a filter.\nTry expanding or choosing another item.");
|
2007-11-24 11:38:16 +00:00
|
|
|
return;
|
2007-03-08 23:37:55 +00:00
|
|
|
}
|
|
|
|
|
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:
|
2007-11-24 11:38:16 +00:00
|
|
|
new_filter = g_strdup(text);
|
|
|
|
break;
|
2002-01-11 08:21:02 +00:00
|
|
|
|
|
|
|
case MATCH_SELECTED_AND:
|
2007-11-24 11:38:16 +00:00
|
|
|
if ((!cur_filter) || (0 == strlen(cur_filter)))
|
|
|
|
new_filter = g_strdup(text);
|
|
|
|
else
|
|
|
|
new_filter = g_strconcat("(", cur_filter, ") && (", text, ")", NULL);
|
|
|
|
break;
|
2002-01-11 08:21:02 +00:00
|
|
|
|
|
|
|
case MATCH_SELECTED_OR:
|
2007-11-24 11:38:16 +00:00
|
|
|
if ((!cur_filter) || (0 == strlen(cur_filter)))
|
|
|
|
new_filter = g_strdup(text);
|
|
|
|
else
|
|
|
|
new_filter = g_strconcat("(", cur_filter, ") || (", text, ")", NULL);
|
|
|
|
break;
|
2002-01-11 08:21:02 +00:00
|
|
|
|
|
|
|
case MATCH_SELECTED_NOT:
|
2007-11-24 11:38:16 +00:00
|
|
|
new_filter = g_strconcat("!(", text, ")", NULL);
|
|
|
|
break;
|
2002-01-11 08:21:02 +00:00
|
|
|
|
|
|
|
case MATCH_SELECTED_AND_NOT:
|
2007-11-24 11:38:16 +00:00
|
|
|
if ((!cur_filter) || (0 == strlen(cur_filter)))
|
|
|
|
new_filter = g_strconcat("!(", text, ")", NULL);
|
|
|
|
else
|
|
|
|
new_filter = g_strconcat("(", cur_filter, ") && !(", text, ")", NULL);
|
|
|
|
break;
|
2002-01-11 08:21:02 +00:00
|
|
|
|
|
|
|
case MATCH_SELECTED_OR_NOT:
|
2007-11-24 11:38:16 +00:00
|
|
|
if ((!cur_filter) || (0 == strlen(cur_filter)))
|
|
|
|
new_filter = g_strconcat("!(", text, ")", NULL);
|
|
|
|
else
|
|
|
|
new_filter = g_strconcat("(", cur_filter, ") || !(", text, ")", NULL);
|
|
|
|
break;
|
2002-01-11 08:21:02 +00:00
|
|
|
|
|
|
|
default:
|
2007-11-24 11:38:16 +00:00
|
|
|
g_assert_not_reached();
|
|
|
|
new_filter = NULL;
|
|
|
|
break;
|
2002-01-11 08:21:02 +00:00
|
|
|
}
|
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) {
|
2007-11-24 11:38:16 +00:00
|
|
|
GString *gtk_text_str = g_string_new("");
|
2009-03-12 07:56:42 +00:00
|
|
|
g_string_append(gtk_text_str, new_filter);
|
2007-11-24 11:38:16 +00:00
|
|
|
copy_to_clipboard(gtk_text_str);
|
|
|
|
g_string_free(gtk_text_str, TRUE);
|
2007-03-08 23:37:55 +00:00
|
|
|
} else {
|
2007-11-24 11:38:16 +00:00
|
|
|
/* 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-11-24 11:38:16 +00:00
|
|
|
/* Run the display filter so it goes in effect. */
|
|
|
|
if (action&MATCH_SELECTED_APPLY_NOW)
|
|
|
|
main_filter_packets(&cfile, new_filter, FALSE);
|
2007-03-08 23:37:55 +00:00
|
|
|
}
|
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
|
2012-07-24 15:03:59 +00:00
|
|
|
match_selected_ptree_cb(gpointer data, MATCH_SELECTED_E action)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
2007-11-24 11:38:16 +00:00
|
|
|
char *filter = NULL;
|
2006-11-23 21:16:46 +00:00
|
|
|
|
|
|
|
if (cfile.finfo_selected) {
|
2006-11-24 18:25:23 +00:00
|
|
|
filter = proto_construct_match_selected_string(cfile.finfo_selected,
|
|
|
|
cfile.edt);
|
2013-03-11 06:47:34 +00:00
|
|
|
match_selected_cb_do((GtkWidget *)g_object_get_data(G_OBJECT(data), E_DFILTER_TE_KEY), action, filter);
|
2015-01-17 02:47:48 +00:00
|
|
|
wmem_free(NULL, filter);
|
2006-11-23 21:16:46 +00:00
|
|
|
}
|
2002-01-11 08:21:02 +00:00
|
|
|
}
|
|
|
|
|
2007-11-24 11:38:16 +00:00
|
|
|
void
|
|
|
|
colorize_selected_ptree_cb(GtkWidget *w _U_, gpointer data _U_, guint8 filt_nr)
|
|
|
|
{
|
|
|
|
char *filter = NULL;
|
2015-12-22 20:07:00 +00:00
|
|
|
gchar *err_msg = NULL;
|
2007-11-24 11:38:16 +00:00
|
|
|
|
|
|
|
if (cfile.finfo_selected) {
|
|
|
|
filter = proto_construct_match_selected_string(cfile.finfo_selected,
|
|
|
|
cfile.edt);
|
|
|
|
if ((!filter) || (0 == strlen(filter))) {
|
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
2017-02-19 18:58:47 +00:00
|
|
|
"Could not acquire information to build a filter.\n"
|
2007-11-24 11:38:16 +00:00
|
|
|
"Try expanding or choosing another item.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filt_nr==0) {
|
|
|
|
color_display_with_filter(filter);
|
|
|
|
} else {
|
|
|
|
if (filt_nr==255) {
|
2015-12-22 20:07:00 +00:00
|
|
|
if (!color_filters_reset_tmp(&err_msg)) {
|
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
|
|
|
g_free(err_msg);
|
|
|
|
}
|
2007-11-24 11:38:16 +00:00
|
|
|
} else {
|
2015-12-22 20:07:00 +00:00
|
|
|
if (!color_filters_set_tmp(filt_nr,filter, FALSE, &err_msg)) {
|
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
|
|
|
g_free(err_msg);
|
|
|
|
}
|
|
|
|
|
2007-11-24 11:38:16 +00:00
|
|
|
}
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_colorize_packets();
|
2007-11-24 11:38:16 +00:00
|
|
|
}
|
2015-01-17 02:47:48 +00:00
|
|
|
wmem_free(NULL, filter);
|
2007-11-24 11:38:16 +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;
|
2013-03-11 06:47:34 +00:00
|
|
|
gchar *proto_abbrev = (gchar *)data;
|
2005-01-18 22:24:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
switch(btn) {
|
|
|
|
case(ESD_BTN_OK):
|
|
|
|
if (cfile.finfo_selected) {
|
|
|
|
/* open wiki page using the protocol abbreviation */
|
2015-03-10 17:46:50 +00:00
|
|
|
selected_proto_url = g_strdup_printf("https://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;
|
2013-02-25 23:35:13 +00:00
|
|
|
/* if the selected field isn't a protocol, get its parent */
|
2005-01-17 21:48:51 +00:00
|
|
|
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);
|
|
|
|
|
2015-10-14 00:34:43 +00:00
|
|
|
/* ask the user if the wiki page really should be opened */
|
|
|
|
dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_OK_CANCEL,
|
|
|
|
"%sOpen Wireshark Wiki page of protocol \"%s\"?%s\n"
|
|
|
|
"\n"
|
|
|
|
"This will open the \"%s\" related Wireshark Wiki page in your Web browser.\n"
|
|
|
|
"\n"
|
|
|
|
"The Wireshark Wiki is a collaborative approach to provide information "
|
|
|
|
"about Wireshark in several ways (not limited to protocol specifics).\n"
|
|
|
|
"\n"
|
|
|
|
"This Wiki is new, so the page of the selected protocol "
|
|
|
|
"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), "
|
|
|
|
"you are encouraged to add information if you can.\n"
|
|
|
|
"\n"
|
2017-02-19 18:58:47 +00:00
|
|
|
"Hint 1: If you are new to wiki editing, try out editing the Sandbox first.\n"
|
2015-10-14 00:34:43 +00:00
|
|
|
"\n"
|
|
|
|
"Hint 2: If you want to add a new protocol page, you should use the ProtocolTemplate, "
|
|
|
|
"which will save you a lot of editing and will give a consistent look over the pages.",
|
|
|
|
simple_dialog_primary_start(), proto_abbrev, simple_dialog_primary_end(), proto_abbrev);
|
|
|
|
simple_dialog_set_cb(dialog, selected_ptree_info_answered_cb, (gpointer)proto_abbrev);
|
2005-01-17 21:48:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-24 17:24:03 +00:00
|
|
|
static void selected_ptree_ref_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
|
|
|
|
{
|
|
|
|
gchar *selected_proto_url;
|
2013-03-11 06:47:34 +00:00
|
|
|
gchar *proto_abbrev = (gchar *)data;
|
2009-02-24 17:24:03 +00:00
|
|
|
|
|
|
|
switch(btn) {
|
|
|
|
case(ESD_BTN_OK):
|
|
|
|
if (cfile.finfo_selected) {
|
|
|
|
/* open reference page using the protocol abbreviation */
|
2015-03-10 17:46:50 +00:00
|
|
|
selected_proto_url = g_strdup_printf("https://www.wireshark.org/docs/dfref/%c/%s", proto_abbrev[0], proto_abbrev);
|
2009-02-24 17:24:03 +00:00
|
|
|
browser_open_url(selected_proto_url);
|
|
|
|
g_free(selected_proto_url);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case(ESD_BTN_CANCEL):
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
}
|
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;
|
2009-02-24 17:24:03 +00:00
|
|
|
gpointer dialog;
|
2005-01-19 01:12:45 +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;
|
2013-02-25 23:35:13 +00:00
|
|
|
/* if the selected field isn't a protocol, get its parent */
|
2005-01-19 01:12:45 +00:00
|
|
|
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);
|
|
|
|
|
2015-10-14 00:34:43 +00:00
|
|
|
/* ask the user if the wiki page really should be opened */
|
|
|
|
dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_OK_CANCEL,
|
|
|
|
"%sOpen Wireshark filter reference page of protocol \"%s\"?%s\n"
|
|
|
|
"\n"
|
|
|
|
"This will open the \"%s\" related Wireshark filter reference page in your Web browser.\n"
|
|
|
|
"\n",
|
|
|
|
simple_dialog_primary_start(), proto_abbrev, simple_dialog_primary_end(), proto_abbrev);
|
|
|
|
simple_dialog_set_cb(dialog, selected_ptree_ref_answered_cb, (gpointer)proto_abbrev);
|
2005-01-19 01:12:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-27 06:51:16 +00:00
|
|
|
static gboolean
|
|
|
|
is_address_column (gint column)
|
|
|
|
{
|
2015-06-27 03:00:33 +00:00
|
|
|
if (((cfile.cinfo.columns[column].col_fmt == COL_DEF_SRC) ||
|
|
|
|
(cfile.cinfo.columns[column].col_fmt == COL_RES_SRC) ||
|
|
|
|
(cfile.cinfo.columns[column].col_fmt == COL_DEF_DST) ||
|
|
|
|
(cfile.cinfo.columns[column].col_fmt == COL_RES_DST)) &&
|
2012-01-25 13:04:32 +00:00
|
|
|
strlen(cfile.cinfo.col_expr.col_expr_val[column]))
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
2010-04-27 06:51:16 +00:00
|
|
|
|
2012-01-25 13:04:32 +00:00
|
|
|
return FALSE;
|
2010-04-27 06:51:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GList *
|
|
|
|
get_ip_address_list_from_packet_list_row(gpointer data)
|
|
|
|
{
|
|
|
|
gint row = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_ROW_KEY));
|
2012-09-04 02:35:25 +00:00
|
|
|
gint column = packet_list_get_column_id (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_COL_KEY)));
|
2010-04-27 06:51:16 +00:00
|
|
|
gint col;
|
|
|
|
frame_data *fdata;
|
|
|
|
GList *addr_list = NULL;
|
|
|
|
|
2012-09-04 02:35:25 +00:00
|
|
|
fdata = (frame_data *) packet_list_get_row_data(row);
|
2010-04-27 06:51:16 +00:00
|
|
|
|
|
|
|
if (fdata != NULL) {
|
|
|
|
epan_dissect_t edt;
|
|
|
|
|
2014-05-24 18:28:30 +00:00
|
|
|
if (!cf_read_record(&cfile, fdata))
|
Instead of using a Boolean for the search direction, use an enum, so
that you can tell from examination whether the search is forward or
backward.
Make the cf_find_packet routines take the direction as an explicit
argument, rather than, in the cases where you don't want to permanently
set the direction, saving the direction in the capture_file structure,
changing it, doing the search, and restoring the saved direction. Give
more information in the Doxygen comments for those routines.
Add a cf_find_packet_dfilter_string() routine, which takes a filter
string rather than a compiled filter as an argument. Replace
find_previous_next_frame_with_filter() with it.
Have cf_read_frame_r() and cf_read_frame() pop up the error dialog if
the read fails, rather than leaving that up to its caller. That lets us
eliminate cf_read_error_message(), by swallowing its code into
cf_read_frame_r(). Add Doxygen comments for cf_read_frame_r() and
cf_read_frame().
Don't have find_packet() read the packet before calling the callback
routine; leave that up to the callback routine.
Add cf_find_packet_marked(), to find the next or previous marked packet,
and cf_find_packet_time_reference(), to find the next or previous time
reference packet. Those routines do *not* need to read the packet data
to see if it matches; that lets them run much faster.
Clean up indentation.
svn path=/trunk/; revision=33791
2010-08-13 07:39:46 +00:00
|
|
|
return NULL; /* error reading the frame */
|
2010-04-27 06:51:16 +00:00
|
|
|
|
2013-07-21 18:38:03 +00:00
|
|
|
epan_dissect_init(&edt, cfile.epan, FALSE, FALSE);
|
2010-04-27 06:51:16 +00:00
|
|
|
col_custom_prime_edt(&edt, &cfile.cinfo);
|
|
|
|
|
2014-05-25 00:04:44 +00:00
|
|
|
epan_dissect_run(&edt, cfile.cd_t, &cfile.phdr,
|
|
|
|
frame_tvbuff_new_buffer(fdata, &cfile.buf), fdata, &cfile.cinfo);
|
2010-04-27 06:51:16 +00:00
|
|
|
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
|
|
|
|
|
2012-01-25 13:04:32 +00:00
|
|
|
/* First check selected column */
|
|
|
|
if (is_address_column (column)) {
|
2016-06-06 02:24:47 +00:00
|
|
|
addr_list = g_list_append (addr_list, g_strdup(cfile.cinfo.col_expr.col_expr_val[column]));
|
2010-04-27 06:51:16 +00:00
|
|
|
}
|
|
|
|
|
2012-01-25 13:04:32 +00:00
|
|
|
for (col = 0; col < cfile.cinfo.num_cols; col++) {
|
|
|
|
/* Then check all columns except the selected */
|
|
|
|
if ((col != column) && (is_address_column (col))) {
|
2016-06-06 02:24:47 +00:00
|
|
|
addr_list = g_list_append (addr_list, g_strdup(cfile.cinfo.col_expr.col_expr_val[col]));
|
2012-01-25 13:04:32 +00:00
|
|
|
}
|
|
|
|
}
|
2010-04-27 06:51:16 +00:00
|
|
|
|
|
|
|
epan_dissect_cleanup(&edt);
|
|
|
|
}
|
|
|
|
|
|
|
|
return addr_list;
|
|
|
|
}
|
|
|
|
|
2002-01-11 08:21:02 +00:00
|
|
|
static gchar *
|
2009-06-06 00:21:40 +00:00
|
|
|
get_filter_from_packet_list_row_and_column(gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
2009-08-14 19:35:01 +00:00
|
|
|
gint row = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_ROW_KEY));
|
2012-09-04 02:35:25 +00:00
|
|
|
gint column = packet_list_get_column_id (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_COL_KEY)));
|
2009-08-14 19:35:01 +00:00
|
|
|
frame_data *fdata;
|
2009-07-21 16:48:16 +00:00
|
|
|
gchar *buf=NULL;
|
|
|
|
|
2012-09-04 02:35:25 +00:00
|
|
|
fdata = (frame_data *) packet_list_get_row_data(row);
|
2009-08-14 19:35:01 +00:00
|
|
|
|
2009-07-21 16:48:16 +00:00
|
|
|
if (fdata != NULL) {
|
2009-08-14 19:35:01 +00:00
|
|
|
epan_dissect_t edt;
|
|
|
|
|
2014-05-24 18:28:30 +00:00
|
|
|
if (!cf_read_record(&cfile, fdata))
|
|
|
|
return NULL; /* error reading the record */
|
2009-08-14 19:35:01 +00:00
|
|
|
/* proto tree, visible. We need a proto tree if there's custom columns */
|
2013-07-21 18:38:03 +00:00
|
|
|
epan_dissect_init(&edt, cfile.epan, have_custom_cols(&cfile.cinfo), FALSE);
|
2009-08-14 19:35:01 +00:00
|
|
|
col_custom_prime_edt(&edt, &cfile.cinfo);
|
|
|
|
|
2014-05-25 00:04:44 +00:00
|
|
|
epan_dissect_run(&edt, cfile.cd_t, &cfile.phdr,
|
|
|
|
frame_tvbuff_new_buffer(fdata, &cfile.buf),
|
2013-06-16 00:20:00 +00:00
|
|
|
fdata, &cfile.cinfo);
|
2009-09-08 19:00:54 +00:00
|
|
|
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
|
2009-08-14 19:35:01 +00:00
|
|
|
|
2015-06-27 03:00:33 +00:00
|
|
|
if ((cfile.cinfo.columns[column].col_custom_occurrence) ||
|
2010-09-26 10:54:12 +00:00
|
|
|
(strchr (cfile.cinfo.col_expr.col_expr_val[column], ',') == NULL))
|
|
|
|
{
|
2010-09-25 09:33:29 +00:00
|
|
|
/* Only construct the filter when a single occurrence is displayed
|
|
|
|
* otherwise we might end up with a filter like "ip.proto==1,6".
|
|
|
|
*
|
2010-10-12 13:15:08 +00:00
|
|
|
* Or do we want to be able to filter on multiple occurrences so that
|
2010-09-25 09:33:29 +00:00
|
|
|
* the filter might be calculated as "ip.proto==1 && ip.proto==6"
|
|
|
|
* instead?
|
|
|
|
*/
|
|
|
|
if (strlen(cfile.cinfo.col_expr.col_expr[column]) != 0 &&
|
|
|
|
strlen(cfile.cinfo.col_expr.col_expr_val[column]) != 0) {
|
2015-01-18 19:46:28 +00:00
|
|
|
/* leak a little; is there a safe wmem_ scope here? */
|
2015-06-27 03:00:33 +00:00
|
|
|
if (cfile.cinfo.columns[column].col_fmt == COL_CUSTOM) {
|
2015-12-11 08:34:08 +00:00
|
|
|
header_field_info *hfi = proto_registrar_get_byname(cfile.cinfo.columns[column].col_custom_fields);
|
2013-02-08 16:23:02 +00:00
|
|
|
if (hfi && hfi->parent == -1) {
|
2010-09-25 09:33:29 +00:00
|
|
|
/* Protocol only */
|
2014-06-15 16:07:10 +00:00
|
|
|
buf = g_strdup(cfile.cinfo.col_expr.col_expr[column]);
|
2014-04-12 22:26:34 +00:00
|
|
|
} else if (hfi && IS_FT_STRING(hfi->type)) {
|
2010-09-25 09:33:29 +00:00
|
|
|
/* Custom string, add quotes */
|
2014-06-15 16:07:10 +00:00
|
|
|
buf = g_strdup_printf("%s == \"%s\"", cfile.cinfo.col_expr.col_expr[column],
|
2010-09-25 09:33:29 +00:00
|
|
|
cfile.cinfo.col_expr.col_expr_val[column]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (buf == NULL) {
|
2014-06-15 16:07:10 +00:00
|
|
|
buf = g_strdup_printf("%s == %s", cfile.cinfo.col_expr.col_expr[column],
|
2009-12-03 14:01:18 +00:00
|
|
|
cfile.cinfo.col_expr.col_expr_val[column]);
|
|
|
|
}
|
|
|
|
}
|
2009-08-14 19:35:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
epan_dissect_cleanup(&edt);
|
2009-07-21 16:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return buf;
|
2002-01-11 08:21:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-07-24 15:03:59 +00:00
|
|
|
match_selected_plist_cb(gpointer data, MATCH_SELECTED_E action)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
2014-06-15 16:07:10 +00:00
|
|
|
char *filter;
|
|
|
|
|
|
|
|
filter = get_filter_from_packet_list_row_and_column((GtkWidget *)data);
|
|
|
|
|
2013-03-21 02:29:09 +00:00
|
|
|
match_selected_cb_do((GtkWidget *)g_object_get_data(G_OBJECT(data), E_DFILTER_TE_KEY),
|
2014-06-15 16:07:10 +00:00
|
|
|
action, filter);
|
|
|
|
|
|
|
|
g_free(filter);
|
2002-01-11 08:21:02 +00:00
|
|
|
}
|
|
|
|
|
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
|
2009-04-08 18:32:11 +00:00
|
|
|
copy_selected_plist_cb(GtkWidget *w _U_, gpointer data _U_, COPY_SELECTED_E action)
|
2006-05-11 05:08:00 +00:00
|
|
|
{
|
2008-02-04 00:21:20 +00:00
|
|
|
GString *gtk_text_str = g_string_new("");
|
2012-12-05 01:02:40 +00:00
|
|
|
char labelstring[ITEM_LABEL_LENGTH];
|
2006-05-11 05:08:00 +00:00
|
|
|
char *stringpointer = labelstring;
|
|
|
|
|
2009-04-08 18:32:11 +00:00
|
|
|
switch(action)
|
|
|
|
{
|
|
|
|
case COPY_SELECTED_DESCRIPTION:
|
2011-03-23 07:29:19 +00:00
|
|
|
if (cfile.finfo_selected->rep &&
|
2015-12-17 04:15:03 +00:00
|
|
|
strlen(cfile.finfo_selected->rep->representation) > 0) {
|
2009-04-08 18:32:11 +00:00
|
|
|
g_string_append(gtk_text_str, cfile.finfo_selected->rep->representation);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case COPY_SELECTED_FIELDNAME:
|
|
|
|
if (cfile.finfo_selected->hfinfo->abbrev != 0) {
|
|
|
|
g_string_append(gtk_text_str, cfile.finfo_selected->hfinfo->abbrev);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case COPY_SELECTED_VALUE:
|
|
|
|
if (cfile.edt !=0 ) {
|
2014-05-18 18:21:31 +00:00
|
|
|
gchar* field_str = get_node_field_value(cfile.finfo_selected, cfile.edt);
|
|
|
|
g_string_append(gtk_text_str, field_str);
|
|
|
|
g_free(field_str);
|
2009-04-08 18:32:11 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2006-05-11 05:08:00 +00:00
|
|
|
}
|
2009-04-08 18:32:11 +00:00
|
|
|
|
|
|
|
if (gtk_text_str->len == 0) {
|
|
|
|
/* If no representation then... Try to read the value */
|
|
|
|
proto_item_fill_label(cfile.finfo_selected, stringpointer);
|
2009-03-12 07:56:42 +00:00
|
|
|
g_string_append(gtk_text_str, stringpointer);
|
2006-05-11 05:08:00 +00:00
|
|
|
}
|
2009-04-08 18:32:11 +00:00
|
|
|
|
|
|
|
if (gtk_text_str->len == 0) {
|
|
|
|
/* Could not get item so display error msg */
|
2006-05-11 05:08:00 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not acquire information to copy, try expanding or choosing another item");
|
2009-04-08 18:32:11 +00:00
|
|
|
} else {
|
|
|
|
/* Copy string to clipboard */
|
|
|
|
copy_to_clipboard(gtk_text_str);
|
2006-05-11 05:08:00 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
|
2003-09-12 02:48:23 +00:00
|
|
|
/* mark as reference time frame */
|
2010-08-16 18:17:45 +00:00
|
|
|
void
|
2003-09-12 02:48:23 +00:00
|
|
|
set_frame_reftime(gboolean set, frame_data *frame, gint row) {
|
2012-01-25 13:04:32 +00:00
|
|
|
if (row == -1)
|
|
|
|
return;
|
|
|
|
if (set) {
|
|
|
|
frame->flags.ref_time=1;
|
|
|
|
cfile.ref_time_count++;
|
|
|
|
} else {
|
|
|
|
frame->flags.ref_time=0;
|
|
|
|
cfile.ref_time_count--;
|
|
|
|
}
|
|
|
|
cf_reftime_packets(&cfile);
|
|
|
|
if (!frame->flags.ref_time && !frame->flags.passed_dfilter) {
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_freeze();
|
2012-01-25 13:04:32 +00:00
|
|
|
cfile.displayed_count--;
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_recreate_visible_rows();
|
|
|
|
packet_list_thaw();
|
2012-01-25 13:04:32 +00:00
|
|
|
}
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_queue_draw();
|
2003-09-12 02:48:23 +00:00
|
|
|
}
|
|
|
|
|
2006-06-29 19:04:33 +00:00
|
|
|
|
|
|
|
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;
|
2012-01-25 13:04:32 +00:00
|
|
|
cf_timestamp_auto_precision(&cfile);
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_queue_draw();
|
2006-06-29 19:04:33 +00:00
|
|
|
break;
|
|
|
|
case(ESD_BTN_NO):
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cfile.current_frame) {
|
|
|
|
set_frame_reftime(!cfile.current_frame->flags.ref_time,
|
2012-01-25 13:04:32 +00:00
|
|
|
cfile.current_frame, cfile.current_row);
|
2006-06-29 19:04:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2012-01-25 13:04:32 +00:00
|
|
|
static GtkWidget *reftime_dialog = NULL;
|
|
|
|
|
|
|
|
switch(action){
|
|
|
|
case REFTIME_TOGGLE:
|
|
|
|
if (cfile.current_frame) {
|
|
|
|
if(recent.gui_time_format != TS_RELATIVE && cfile.current_frame->flags.ref_time==0) {
|
2013-03-11 06:47:34 +00:00
|
|
|
reftime_dialog = (GtkWidget *)simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_YES_NO,
|
2012-01-25 13:04:32 +00:00
|
|
|
"%sSwitch to the appropriate Time Display Format?%s\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_primary_start(), simple_dialog_primary_end());
|
|
|
|
simple_dialog_set_cb(reftime_dialog, reftime_answered_cb, NULL);
|
|
|
|
} else {
|
|
|
|
set_frame_reftime(!cfile.current_frame->flags.ref_time,
|
|
|
|
cfile.current_frame, cfile.current_row);
|
|
|
|
}
|
2006-11-05 00:54:17 +00:00
|
|
|
}
|
2012-01-25 13:04:32 +00:00
|
|
|
break;
|
|
|
|
case REFTIME_FIND_NEXT:
|
|
|
|
cf_find_packet_time_reference(&cfile, SD_FORWARD);
|
|
|
|
break;
|
|
|
|
case REFTIME_FIND_PREV:
|
|
|
|
cf_find_packet_time_reference(&cfile, SD_BACKWARD);
|
|
|
|
break;
|
2006-06-29 19:04:33 +00:00
|
|
|
}
|
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
|
|
|
{
|
Instead of using a Boolean for the search direction, use an enum, so
that you can tell from examination whether the search is forward or
backward.
Make the cf_find_packet routines take the direction as an explicit
argument, rather than, in the cases where you don't want to permanently
set the direction, saving the direction in the capture_file structure,
changing it, doing the search, and restoring the saved direction. Give
more information in the Doxygen comments for those routines.
Add a cf_find_packet_dfilter_string() routine, which takes a filter
string rather than a compiled filter as an argument. Replace
find_previous_next_frame_with_filter() with it.
Have cf_read_frame_r() and cf_read_frame() pop up the error dialog if
the read fails, rather than leaving that up to its caller. That lets us
eliminate cf_read_error_message(), by swallowing its code into
cf_read_frame_r(). Add Doxygen comments for cf_read_frame_r() and
cf_read_frame().
Don't have find_packet() read the packet before calling the callback
routine; leave that up to the callback routine.
Add cf_find_packet_marked(), to find the next or previous marked packet,
and cf_find_packet_time_reference(), to find the next or previous time
reference packet. Those routines do *not* need to read the packet data
to see if it matches; that lets them run much faster.
Clean up indentation.
svn path=/trunk/; revision=33791
2010-08-13 07:39:46 +00:00
|
|
|
cf_find_packet_marked(&cfile, SD_FORWARD);
|
2006-06-12 19:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
Instead of using a Boolean for the search direction, use an enum, so
that you can tell from examination whether the search is forward or
backward.
Make the cf_find_packet routines take the direction as an explicit
argument, rather than, in the cases where you don't want to permanently
set the direction, saving the direction in the capture_file structure,
changing it, doing the search, and restoring the saved direction. Give
more information in the Doxygen comments for those routines.
Add a cf_find_packet_dfilter_string() routine, which takes a filter
string rather than a compiled filter as an argument. Replace
find_previous_next_frame_with_filter() with it.
Have cf_read_frame_r() and cf_read_frame() pop up the error dialog if
the read fails, rather than leaving that up to its caller. That lets us
eliminate cf_read_error_message(), by swallowing its code into
cf_read_frame_r(). Add Doxygen comments for cf_read_frame_r() and
cf_read_frame().
Don't have find_packet() read the packet before calling the callback
routine; leave that up to the callback routine.
Add cf_find_packet_marked(), to find the next or previous marked packet,
and cf_find_packet_time_reference(), to find the next or previous time
reference packet. Those routines do *not* need to read the packet data
to see if it matches; that lets them run much faster.
Clean up indentation.
svn path=/trunk/; revision=33791
2010-08-13 07:39:46 +00:00
|
|
|
cf_find_packet_marked(&cfile, SD_BACKWARD);
|
2006-06-12 19:35:26 +00:00
|
|
|
}
|
|
|
|
|
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_)
|
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 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;
|
2007-09-17 12:12:02 +00:00
|
|
|
gint finfo_length;
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
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 nothing is selected */
|
|
|
|
if (!gtk_tree_selection_get_selected(sel, &model, &iter))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Which byte view is displaying the current protocol tree
|
|
|
|
* row's data?
|
|
|
|
*/
|
2010-01-29 19:09:01 +00:00
|
|
|
byte_view = get_notebook_bv_ptr(byte_nb_ptr_gbl);
|
2002-11-03 17:38:45 +00:00
|
|
|
if (byte_view == NULL)
|
2013-12-17 13:06:11 +00:00
|
|
|
return; /* none */
|
2002-11-03 17:38:45 +00:00
|
|
|
|
|
|
|
byte_data = get_byte_view_data_and_length(byte_view, &byte_len);
|
|
|
|
if (byte_data == NULL)
|
2013-12-17 13:06:11 +00:00
|
|
|
return; /* none */
|
2002-11-03 17:38:45 +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, 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);
|
|
|
|
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
|
|
|
|
2010-01-29 19:09:01 +00:00
|
|
|
set_notebook_page(byte_nb_ptr_gbl, finfo->ds_tvb);
|
2001-03-23 14:44:04 +00:00
|
|
|
|
2010-01-29 19:09:01 +00:00
|
|
|
byte_view = get_notebook_bv_ptr(byte_nb_ptr_gbl);
|
2002-11-03 17:38:45 +00:00
|
|
|
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;
|
2009-04-16 00:45:26 +00:00
|
|
|
length = (guint) strlen(finfo->hfinfo->blurb);
|
2002-11-03 17:38:45 +00:00
|
|
|
} else {
|
2009-04-16 00:45:26 +00:00
|
|
|
length = (guint) strlen(finfo->hfinfo->name);
|
2002-11-03 17:38:45 +00:00
|
|
|
}
|
2007-09-17 12:12:02 +00:00
|
|
|
finfo_length = finfo->length + finfo->appendix_length;
|
2008-04-12 15:55:27 +00:00
|
|
|
|
2007-09-17 12:12:02 +00:00
|
|
|
if (finfo_length == 0) {
|
2002-11-03 17:38:45 +00:00
|
|
|
len_str[0] = '\0';
|
2007-09-17 12:12:02 +00:00
|
|
|
} else if (finfo_length == 1) {
|
2008-02-29 13:33:37 +00:00
|
|
|
g_strlcpy (len_str, ", 1 byte", sizeof len_str);
|
2002-11-03 17:38:45 +00:00
|
|
|
} else {
|
2007-09-17 12:12:02 +00:00
|
|
|
g_snprintf (len_str, sizeof len_str, ", %d bytes", finfo_length);
|
2002-11-03 17:38:45 +00:00
|
|
|
}
|
2013-12-17 13:06:11 +00:00
|
|
|
statusbar_pop_field_msg(); /* get rid of current help msg */
|
2002-11-03 17:38:45 +00:00
|
|
|
if (length) {
|
2010-11-27 23:06:14 +00:00
|
|
|
statusbar_push_field_msg(" %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
|
|
|
} 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;
|
2015-09-11 21:41:13 +00:00
|
|
|
* the pseudo-field for text-only items is such
|
2002-11-03 17:38:45 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2015-09-11 21:41:13 +00:00
|
|
|
* Or perhaps text-only items 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.
|
2002-11-03 17:38:45 +00:00
|
|
|
*/
|
2010-11-28 00:02:39 +00:00
|
|
|
statusbar_push_field_msg("%s", "");
|
2002-11-03 17:38:45 +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
|
|
|
}
|
|
|
|
|
2013-10-23 14:24:17 +00:00
|
|
|
void collapse_all_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|
|
|
{
|
2012-01-25 13:04:32 +00:00
|
|
|
if (cfile.edt->tree)
|
|
|
|
collapse_all_tree(cfile.edt->tree, tree_view_gbl);
|
1999-09-11 12:38:18 +00:00
|
|
|
}
|
|
|
|
|
2013-10-23 14:24:17 +00:00
|
|
|
void expand_all_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|
|
|
{
|
2012-01-25 13:04:32 +00:00
|
|
|
if (cfile.edt->tree)
|
|
|
|
expand_all_tree(cfile.edt->tree, tree_view_gbl);
|
1999-09-11 12:38:18 +00:00
|
|
|
}
|
|
|
|
|
2009-11-19 18:22:26 +00:00
|
|
|
void apply_as_custom_column_cb (GtkWidget *widget _U_, gpointer data _U_)
|
|
|
|
{
|
2012-01-25 13:04:32 +00:00
|
|
|
if (cfile.finfo_selected) {
|
|
|
|
column_prefs_add_custom(COL_CUSTOM, cfile.finfo_selected->hfinfo->name,
|
|
|
|
cfile.finfo_selected->hfinfo->abbrev,0);
|
|
|
|
/* Recreate the packet list according to new preferences */
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_recreate ();
|
2012-01-25 13:04:32 +00:00
|
|
|
if (!prefs.gui_use_pref_save) {
|
|
|
|
prefs_main_write();
|
|
|
|
}
|
2012-09-03 15:12:49 +00:00
|
|
|
cfile.columns_changed = FALSE; /* Reset value */
|
2009-11-26 09:11:55 +00:00
|
|
|
}
|
2009-11-19 18:22:26 +00:00
|
|
|
}
|
|
|
|
|
2013-10-23 14:24:17 +00:00
|
|
|
void expand_tree_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|
|
|
{
|
2012-01-25 13:04:32 +00:00
|
|
|
GtkTreePath *path;
|
2004-03-19 06:23:38 +00:00
|
|
|
|
2012-01-25 13:04:32 +00:00
|
|
|
path = tree_find_by_field_info(GTK_TREE_VIEW(tree_view_gbl), cfile.finfo_selected);
|
|
|
|
if(path) {
|
|
|
|
/* the mouse position is at an entry, expand that one */
|
|
|
|
gtk_tree_view_expand_row(GTK_TREE_VIEW(tree_view_gbl), path, TRUE);
|
|
|
|
gtk_tree_path_free(path);
|
|
|
|
}
|
2004-03-19 06:23:38 +00:00
|
|
|
}
|
|
|
|
|
2013-10-23 14:24:17 +00:00
|
|
|
void collapse_tree_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|
|
|
{
|
|
|
|
GtkTreePath *path;
|
|
|
|
|
|
|
|
path = tree_find_by_field_info(GTK_TREE_VIEW(tree_view_gbl), cfile.finfo_selected);
|
|
|
|
if(path) {
|
|
|
|
/* the mouse position is at an entry, expand that one */
|
|
|
|
|
|
|
|
tree_collapse_path_all(GTK_TREE_VIEW(tree_view_gbl), path);
|
|
|
|
gtk_tree_path_free(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void resolve_name_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|
|
|
{
|
2015-07-25 13:24:48 +00:00
|
|
|
static const e_addr_resolve resolv_flags = {
|
|
|
|
TRUE, /* mac_name */
|
|
|
|
TRUE, /* network_name */
|
|
|
|
TRUE, /* transport_name */
|
|
|
|
TRUE, /* dns_pkt_addr_resolution */
|
|
|
|
TRUE, /* use_external_net_name_resolver */
|
2016-03-13 22:16:20 +00:00
|
|
|
FALSE, /* load_hosts_file_from_profile_only */
|
2016-09-13 04:46:06 +00:00
|
|
|
FALSE, /* vlan_name */
|
|
|
|
FALSE, /* ss7pc_name */
|
2015-07-25 13:24:48 +00:00
|
|
|
};
|
2012-07-06 04:48:36 +00:00
|
|
|
|
|
|
|
if (cfile.edt->tree) {
|
2012-07-06 07:34:08 +00:00
|
|
|
proto_tree_draw_resolve(cfile.edt->tree, tree_view_gbl, &resolv_flags);
|
2012-07-06 04:48:36 +00:00
|
|
|
}
|
2000-02-20 14:52:28 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 00:00:25 +00:00
|
|
|
/* Update main window items based on whether there's a capture in progress. */
|
|
|
|
static void
|
|
|
|
main_set_for_capture_in_progress(gboolean capture_in_progress)
|
|
|
|
{
|
|
|
|
set_menus_for_capture_in_progress(capture_in_progress);
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
set_toolbar_for_capture_in_progress(capture_in_progress);
|
|
|
|
|
|
|
|
set_capture_if_dialog_for_capture_in_progress(capture_in_progress);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update main window items based on whether we have a capture file. */
|
2009-10-06 13:26:00 +00:00
|
|
|
static void
|
2005-02-05 17:53:39 +00:00
|
|
|
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
|
|
|
|
2012-06-17 00:00:25 +00:00
|
|
|
/* Update main window items based on whether we have captured packets. */
|
|
|
|
static void
|
|
|
|
main_set_for_captured_packets(gboolean have_captured_packets)
|
|
|
|
{
|
|
|
|
set_menus_for_captured_packets(have_captured_packets);
|
|
|
|
set_toolbar_for_captured_packets(have_captured_packets);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update main window items based on whether we have a packet history. */
|
|
|
|
void
|
|
|
|
main_set_for_packet_history(gboolean back_history, gboolean forward_history)
|
|
|
|
{
|
|
|
|
set_menus_for_packet_history(back_history, forward_history);
|
|
|
|
set_toolbar_for_packet_history(back_history, forward_history);
|
|
|
|
}
|
|
|
|
|
2004-01-29 23:11:38 +00:00
|
|
|
gboolean
|
|
|
|
main_do_quit(void)
|
2000-02-13 10:36:06 +00:00
|
|
|
{
|
2012-01-25 13:04:32 +00:00
|
|
|
/* get the current geometry, before writing it to disk */
|
|
|
|
main_save_window_geometry(top_level);
|
|
|
|
|
|
|
|
/* write user's recent file to disk
|
|
|
|
* It is no problem to write this file, even if we do not quit */
|
|
|
|
write_profile_recent();
|
|
|
|
write_recent();
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
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. */
|
2012-01-24 17:12:56 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBPCAP
|
2012-01-25 13:04:32 +00:00
|
|
|
/* Nuke any child capture in progress. */
|
2013-05-22 07:44:28 +00:00
|
|
|
capture_kill_child(&global_capture_session);
|
2012-01-25 13:04:32 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
/* Say that the window should *not* be deleted;
|
|
|
|
that'll be done by the code that cleans up. */
|
|
|
|
return TRUE;
|
|
|
|
} else {
|
|
|
|
/* Close any capture file we have open; on some OSes, you
|
|
|
|
can't unlink a temporary capture file if you have it
|
|
|
|
open.
|
|
|
|
"cf_close()" will unlink it after closing it if
|
|
|
|
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
|
|
|
|
or other problem when "cf_close()" tries to
|
|
|
|
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? */
|
|
|
|
cf_close(&cfile);
|
|
|
|
|
|
|
|
/* Exit by leaving the main loop, so that any quit functions
|
|
|
|
we registered get called. */
|
|
|
|
gtk_main_quit();
|
|
|
|
|
|
|
|
/* Say that the window should be deleted. */
|
|
|
|
return FALSE;
|
|
|
|
}
|
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
|
|
|
{
|
2012-06-14 03:50:39 +00:00
|
|
|
/* If we're in the middle of stopping a capture, don't do anything;
|
|
|
|
the user can try deleting the window after the capture stops. */
|
|
|
|
if (capture_stopping)
|
|
|
|
return TRUE;
|
|
|
|
|
2012-05-25 21:25:55 +00:00
|
|
|
/* If there's unsaved data, let the user save it first.
|
|
|
|
If they cancel out of it, don't quit. */
|
|
|
|
if (do_file_close(&cfile, TRUE, " before quitting"))
|
2012-01-25 13:04:32 +00:00
|
|
|
return main_do_quit();
|
2012-05-25 21:25:55 +00:00
|
|
|
else
|
|
|
|
return TRUE; /* will this keep the window from being deleted? */
|
2003-10-07 04:36:36 +00:00
|
|
|
}
|
|
|
|
|
2004-05-23 17:37:36 +00:00
|
|
|
|
2008-04-28 12:35:03 +00:00
|
|
|
static void
|
|
|
|
main_pane_load_window_geometry(void)
|
|
|
|
{
|
|
|
|
if (recent.has_gui_geometry_main_upper_pane && recent.gui_geometry_main_upper_pane)
|
|
|
|
gtk_paned_set_position(GTK_PANED(main_first_pane), recent.gui_geometry_main_upper_pane);
|
|
|
|
if (recent.has_gui_geometry_main_lower_pane && recent.gui_geometry_main_lower_pane) {
|
|
|
|
gtk_paned_set_position(GTK_PANED(main_second_pane), recent.gui_geometry_main_lower_pane);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2016-06-07 22:26:03 +00:00
|
|
|
geom.x = recent.gui_gtk_geometry_main_x;
|
|
|
|
geom.y = recent.gui_gtk_geometry_main_y;
|
2004-05-23 17:37:36 +00:00
|
|
|
geom.set_size = prefs.gui_geometry_save_size;
|
2016-06-16 00:34:27 +00:00
|
|
|
geom.set_maximized = FALSE;
|
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
|
|
|
|
2008-04-28 12:35:03 +00:00
|
|
|
main_pane_load_window_geometry();
|
2008-04-12 15:55:27 +00:00
|
|
|
statusbar_load_window_geometry();
|
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) {
|
2016-06-07 22:26:03 +00:00
|
|
|
recent.gui_gtk_geometry_main_x = geom.x;
|
|
|
|
recent.gui_gtk_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) {
|
2008-02-04 00:11:59 +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(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));
|
2008-04-12 15:55:27 +00:00
|
|
|
statusbar_save_window_geometry();
|
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
|
|
|
{
|
2012-05-25 21:25:55 +00:00
|
|
|
/* If there's unsaved data, let the user save it first. */
|
|
|
|
if (do_file_close(&cfile, TRUE, " before quitting"))
|
2012-01-25 13:04:32 +00:00
|
|
|
main_do_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
|
|
|
}
|
|
|
|
|
2010-05-07 08:40:02 +00:00
|
|
|
/*
|
|
|
|
* Report an error in command-line arguments.
|
|
|
|
* Creates a console on Windows.
|
2014-06-29 21:37:21 +00:00
|
|
|
* XXX - pop this up in a window of some sort on UNIX+X11 if the controlling
|
|
|
|
* terminal isn't the standard error?
|
2010-05-07 08:40:02 +00:00
|
|
|
*/
|
2014-06-29 21:37:21 +00:00
|
|
|
static void
|
|
|
|
wireshark_cmdarg_err(const char *fmt, va_list ap)
|
2010-05-07 08:40:02 +00:00
|
|
|
{
|
2013-04-25 05:47:11 +00:00
|
|
|
#ifdef _WIN32
|
2013-12-17 13:06:11 +00:00
|
|
|
create_console();
|
2013-04-25 05:47:11 +00:00
|
|
|
#endif
|
2013-12-17 13:06:11 +00:00
|
|
|
fprintf(stderr, "wireshark: ");
|
|
|
|
vfprintf(stderr, fmt, ap);
|
|
|
|
fprintf(stderr, "\n");
|
2005-11-17 05:59:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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?
|
|
|
|
*/
|
2014-06-29 21:37:21 +00:00
|
|
|
static void
|
|
|
|
wireshark_cmdarg_err_cont(const char *fmt, va_list ap)
|
2005-11-17 05:59:21 +00:00
|
|
|
{
|
2013-04-25 05:47:11 +00:00
|
|
|
#ifdef _WIN32
|
2013-12-17 13:06:11 +00:00
|
|
|
create_console();
|
2013-04-25 05:47:11 +00:00
|
|
|
#endif
|
2013-12-17 13:06:11 +00:00
|
|
|
vfprintf(stderr, fmt, ap);
|
|
|
|
fprintf(stderr, "\n");
|
2005-11-17 05:59:21 +00:00
|
|
|
}
|
|
|
|
|
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
|
2011-05-15 02:42:52 +00:00
|
|
|
the tap extensions.
|
2002-09-07 10:02:36 +00:00
|
|
|
*/
|
2008-07-08 02:25:30 +00:00
|
|
|
static gboolean
|
2009-12-22 20:01:06 +00:00
|
|
|
tap_update_cb(gpointer data _U_)
|
2002-09-07 10:02:36 +00:00
|
|
|
{
|
2012-01-25 13:04:32 +00:00
|
|
|
draw_tap_listeners(FALSE);
|
|
|
|
return TRUE;
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
2008-04-21 10:57:32 +00:00
|
|
|
|
2009-12-22 20:01:06 +00:00
|
|
|
/*
|
|
|
|
* Periodically process outstanding hostname lookups. If we have new items,
|
|
|
|
* redraw the packet list and tree view.
|
|
|
|
*/
|
2010-04-29 00:09:01 +00:00
|
|
|
|
2009-12-22 20:01:06 +00:00
|
|
|
static gboolean
|
|
|
|
resolv_update_cb(gpointer data _U_)
|
|
|
|
{
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Anything new show up? */
|
|
|
|
if (host_name_lookup_process()) {
|
|
|
|
if (gtk_widget_get_window(pkt_scrollw))
|
|
|
|
gdk_window_invalidate_rect(gtk_widget_get_window(pkt_scrollw), NULL, TRUE);
|
|
|
|
if (gtk_widget_get_window(tv_scrollw))
|
|
|
|
gdk_window_invalidate_rect(gtk_widget_get_window(tv_scrollw), NULL, TRUE);
|
|
|
|
}
|
2009-12-22 20:01:06 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Always check. Even if we don't do async lookups we could still get
|
|
|
|
passive updates, e.g. from DNS packets. */
|
|
|
|
return TRUE;
|
2009-12-22 20:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-04 02:24:42 +00:00
|
|
|
/* Update various parts of the main window for a capture file "unsaved
|
|
|
|
changes" change - update the title to reflect whether there are
|
|
|
|
unsaved changes or not, and update the menus and toolbar to
|
|
|
|
enable or disable the "Save" operation. */
|
|
|
|
void
|
|
|
|
main_update_for_unsaved_changes(capture_file *cf)
|
|
|
|
{
|
2013-12-17 13:06:11 +00:00
|
|
|
set_titlebar_for_capture_file(cf);
|
|
|
|
set_menus_for_capture_file(cf);
|
|
|
|
set_toolbar_for_capture_file(cf);
|
2012-06-04 02:24:42 +00:00
|
|
|
}
|
|
|
|
|
2012-06-04 03:15:05 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
void
|
|
|
|
main_auto_scroll_live_changed(gboolean auto_scroll_live_in)
|
|
|
|
{
|
2014-09-22 23:33:05 +00:00
|
|
|
/* Update menubar and toolbar */
|
|
|
|
menu_auto_scroll_live_changed(auto_scroll_live_in);
|
2013-12-17 13:06:11 +00:00
|
|
|
toolbar_auto_scroll_live_changed(auto_scroll_live_in);
|
2012-06-04 03:15:05 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* change auto scroll state */
|
|
|
|
auto_scroll_live = auto_scroll_live_in;
|
2012-06-04 03:15:05 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
|
|
|
main_colorize_changed(gboolean packet_list_colorize)
|
|
|
|
{
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Update menubar and toolbar */
|
|
|
|
menu_colorize_changed(packet_list_colorize);
|
|
|
|
toolbar_colorize_changed(packet_list_colorize);
|
|
|
|
|
|
|
|
/* change colorization */
|
|
|
|
if(packet_list_colorize != recent.packet_list_colorize) {
|
|
|
|
recent.packet_list_colorize = packet_list_colorize;
|
2015-12-22 20:07:00 +00:00
|
|
|
packet_list_enable_color(packet_list_colorize);
|
2013-12-17 13:06:11 +00:00
|
|
|
packet_list_colorize_packets();
|
|
|
|
}
|
2012-06-04 03:15:05 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 17:39:44 +00:00
|
|
|
static 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);
|
|
|
|
}
|
|
|
|
|
2007-09-15 00:18:17 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
static void
|
|
|
|
npf_warning_dialog_cb(gpointer dialog, gint btn _U_, gpointer data _U_)
|
|
|
|
{
|
|
|
|
recent.privs_warn_if_no_npf = !simple_dialog_check_get(dialog);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
{
|
2006-11-05 00:54:17 +00:00
|
|
|
/* if we have more than 10000 packets, show a splash screen while closing */
|
2009-04-08 13:41:30 +00:00
|
|
|
/* XXX - don't know a better way to decide whether to show or not,
|
2012-06-13 21:08:18 +00:00
|
|
|
* as most of the time is spend in various calls that destroy various
|
|
|
|
* data structures, so it wouldn't be easy to use a progress bar,
|
|
|
|
* rather than, say, a progress spinner, here! */
|
2006-11-05 00:54:17 +00:00
|
|
|
if(cf->count > 10000) {
|
2013-03-12 06:41:00 +00:00
|
|
|
close_dlg = (GtkWidget *)simple_dialog(ESD_TYPE_STOP, ESD_BTN_NONE,
|
2017-01-23 15:43:59 +00:00
|
|
|
"%sClosing file.%s\n\nPlease wait ...",
|
2006-11-05 00:54:17 +00:00
|
|
|
simple_dialog_primary_start(),
|
|
|
|
simple_dialog_primary_end());
|
|
|
|
gtk_window_set_position(GTK_WINDOW(close_dlg), GTK_WIN_POS_CENTER_ON_PARENT);
|
|
|
|
}
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Clear maunally resolved addresses */
|
|
|
|
manually_resolve_cleanup();
|
"Save As" always saves everything and, when the save is done, makes the
new file the current file, as is the case in most if not all other GUI
applications.
A new "Export Specified Packets" menu option allows you to specify which
packets to write out, with the default being the displayed packets (and
those on which the displayed packets depend for, e.g. reassembly), and
never makes the resulting file the current file.
The two operations are conceptually distinct. Lumping them into one
menu item, with the default for "Save As" being "displayed packets only"
and thus making it behave like the latter operation, was causing some
confusion; see, for example, bug 6640.
Make the dialog popped up if you try to "Save As" or "Export Specified
Packets" on top of an existing file ask the "do you want to do this?"
question in the main part of the message, and note in the secondary text
that doing that will overwrite what's in the file; that matches what
TextEdit on OS X and the GNOME text editor say.
svn path=/trunk/; revision=42792
2012-05-22 22:17:57 +00:00
|
|
|
/* Destroy all windows that refer to the
|
2005-02-07 00:54:46 +00:00
|
|
|
capture file we're closing. */
|
2005-12-05 22:45:54 +00:00
|
|
|
destroy_packet_wins();
|
2005-02-07 00:54:46 +00:00
|
|
|
|
2013-04-01 00:21:44 +00:00
|
|
|
/* Update the titlebar to reflect the lack of a capture file. */
|
|
|
|
set_titlebar_for_capture_file(NULL);
|
2005-02-07 00:54:46 +00:00
|
|
|
|
2013-04-01 00:21:44 +00:00
|
|
|
/* Disable all menu and toolbar items that make sense only if
|
|
|
|
you have a capture. */
|
2007-03-14 19:30:19 +00:00
|
|
|
set_menus_for_capture_file(NULL);
|
2012-06-04 02:24:42 +00:00
|
|
|
set_toolbar_for_capture_file(NULL);
|
2012-06-17 00:00:25 +00:00
|
|
|
main_set_for_captured_packets(FALSE);
|
2005-02-07 00:54:46 +00:00
|
|
|
set_menus_for_selected_packet(cf);
|
2012-06-17 00:00:25 +00:00
|
|
|
main_set_for_capture_in_progress(FALSE);
|
2008-04-12 17:04:21 +00:00
|
|
|
set_capture_if_dialog_for_capture_in_progress(FALSE);
|
2005-02-07 00:54:46 +00:00
|
|
|
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();
|
2013-10-23 12:02:15 +00:00
|
|
|
|
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
|
|
|
{
|
2013-12-17 13:06:11 +00:00
|
|
|
if(close_dlg != NULL) {
|
|
|
|
splash_destroy(close_dlg);
|
|
|
|
close_dlg = NULL;
|
|
|
|
}
|
2005-02-07 00:54:46 +00:00
|
|
|
}
|
|
|
|
|
2008-04-12 15:55:27 +00:00
|
|
|
|
2005-02-07 02:09:30 +00:00
|
|
|
static void
|
2009-12-14 22:05:29 +00:00
|
|
|
main_cf_cb_file_read_started(capture_file *cf _U_)
|
2005-02-07 00:54:46 +00:00
|
|
|
{
|
2013-12-17 13:06:11 +00:00
|
|
|
tap_param_dlg_update();
|
2008-04-12 20:31:18 +00:00
|
|
|
|
2013-12-17 13:06:11 +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)
|
|
|
|
{
|
2010-08-18 19:11:07 +00:00
|
|
|
gchar *dir_path;
|
2010-08-10 11:36:18 +00:00
|
|
|
|
2010-08-08 21:26:39 +00:00
|
|
|
if (!cf->is_tempfile && cf->filename) {
|
|
|
|
/* Add this filename to the list of recent files in the "Recent Files" submenu */
|
|
|
|
add_menu_recent_capture_file(cf->filename);
|
2010-08-10 11:36:18 +00:00
|
|
|
|
2010-08-10 21:16:41 +00:00
|
|
|
/* Remember folder for next Open dialog and save it in recent */
|
2016-02-03 17:28:46 +00:00
|
|
|
dir_path = g_strdup(cf->filename);
|
|
|
|
set_last_open_dir(get_dirname(dir_path));
|
2010-08-10 21:16:41 +00:00
|
|
|
g_free(dir_path);
|
2010-08-08 21:26:39 +00:00
|
|
|
}
|
2005-02-07 00:54:46 +00:00
|
|
|
|
2012-06-04 02:24:42 +00:00
|
|
|
/* Update the appropriate parts of the main window. */
|
|
|
|
main_update_for_unsaved_changes(cf);
|
2005-02-07 00:54:46 +00:00
|
|
|
|
|
|
|
/* Enable menu items that make sense if you have some captured packets. */
|
2012-06-17 00:00:25 +00:00
|
|
|
main_set_for_captured_packets(TRUE);
|
2005-02-07 00:54:46 +00:00
|
|
|
}
|
|
|
|
|
If we do a Save or Save As with a move, don't reread the capture file,
just tweak the elements in the capture_file structure as necessary and
poke the UI to update stuff such as the windows title.
If we do a Save or Save As with a copy, don't reread the capture file,
just close the old wtap, open a wtap for the copy, and tweak the
elements in the capture_file structure as necessary and poke the UI to
update stuff such as the windows title.
Otherwise, don't do a full read-and-dissect pass on the capture file,
just close the old wtap, open a wtap for the new file, tweak the
elements in the capture_file structure as necessary and poke the UI to
update stuff such as the windows title, and rescan the file to update
the packet offsets (and cause Wiretap to regenerate, for a gzipped file,
the information needed to support fast random access to the gzipped
file).
This should speed up Save and Save As a bit, as well as removing some
glitches in the UI (e.g., you won't see the packet list disappear and
reappear).
svn path=/trunk/; revision=43101
2012-06-05 06:52:18 +00:00
|
|
|
static void
|
|
|
|
main_cf_cb_file_rescan_finished(capture_file *cf)
|
|
|
|
{
|
|
|
|
gchar *dir_path;
|
|
|
|
|
|
|
|
if (!cf->is_tempfile && cf->filename) {
|
|
|
|
/* Add this filename to the list of recent files in the "Recent Files" submenu */
|
|
|
|
add_menu_recent_capture_file(cf->filename);
|
|
|
|
|
|
|
|
/* Remember folder for next Open dialog and save it in recent */
|
2016-02-03 17:28:46 +00:00
|
|
|
dir_path = g_strdup(cf->filename);
|
|
|
|
set_last_open_dir(get_dirname(dir_path));
|
If we do a Save or Save As with a move, don't reread the capture file,
just tweak the elements in the capture_file structure as necessary and
poke the UI to update stuff such as the windows title.
If we do a Save or Save As with a copy, don't reread the capture file,
just close the old wtap, open a wtap for the copy, and tweak the
elements in the capture_file structure as necessary and poke the UI to
update stuff such as the windows title.
Otherwise, don't do a full read-and-dissect pass on the capture file,
just close the old wtap, open a wtap for the new file, tweak the
elements in the capture_file structure as necessary and poke the UI to
update stuff such as the windows title, and rescan the file to update
the packet offsets (and cause Wiretap to regenerate, for a gzipped file,
the information needed to support fast random access to the gzipped
file).
This should speed up Save and Save As a bit, as well as removing some
glitches in the UI (e.g., you won't see the packet list disappear and
reappear).
svn path=/trunk/; revision=43101
2012-06-05 06:52:18 +00:00
|
|
|
g_free(dir_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update the appropriate parts of the main window. */
|
|
|
|
main_update_for_unsaved_changes(cf);
|
|
|
|
}
|
|
|
|
|
2009-10-06 13:51:56 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2009-10-06 13:26:00 +00:00
|
|
|
static GList *icon_list_create(
|
2016-02-21 17:10:03 +00:00
|
|
|
#ifdef HAVE_GDK_GRESOURCE
|
2015-10-17 12:47:17 +00:00
|
|
|
const gchar *icon16_path,
|
|
|
|
const gchar *icon32_path,
|
|
|
|
const gchar *icon48_path,
|
|
|
|
const gchar *icon64_path)
|
|
|
|
#else
|
2013-03-26 19:51:33 +00:00
|
|
|
const guint8 *icon16_pb,
|
|
|
|
const guint8 *icon32_pb,
|
|
|
|
const guint8 *icon48_pb,
|
|
|
|
const guint8 *icon64_pb)
|
2015-10-17 12:47:17 +00:00
|
|
|
#endif
|
2006-01-17 00:40:32 +00:00
|
|
|
{
|
2013-12-17 13:06:11 +00:00
|
|
|
GList *icon_list = NULL;
|
2015-10-17 12:47:17 +00:00
|
|
|
GdkPixbuf *pixbuf16 = NULL;
|
|
|
|
GdkPixbuf *pixbuf32 = NULL;
|
|
|
|
GdkPixbuf *pixbuf48 = NULL;
|
|
|
|
GdkPixbuf *pixbuf64 = NULL;
|
|
|
|
|
2016-02-21 17:10:03 +00:00
|
|
|
#ifdef HAVE_GDK_GRESOURCE
|
2015-10-17 12:47:17 +00:00
|
|
|
if (icon16_path != NULL)
|
|
|
|
pixbuf16 = ws_gdk_pixbuf_new_from_resource(icon16_path);
|
|
|
|
if (icon32_path != NULL)
|
|
|
|
pixbuf32 = ws_gdk_pixbuf_new_from_resource(icon32_path);
|
|
|
|
if (icon48_path != NULL)
|
|
|
|
pixbuf48 = ws_gdk_pixbuf_new_from_resource(icon48_path);
|
|
|
|
if (icon64_path != NULL)
|
|
|
|
pixbuf64 = ws_gdk_pixbuf_new_from_resource(icon64_path);
|
|
|
|
#else
|
|
|
|
if (icon16_pb != NULL)
|
2013-12-17 13:06:11 +00:00
|
|
|
pixbuf16 = gdk_pixbuf_new_from_inline(-1, icon16_pb, FALSE, NULL);
|
2015-10-17 12:47:17 +00:00
|
|
|
if (icon32_pb != NULL)
|
2013-12-17 13:06:11 +00:00
|
|
|
pixbuf32 = gdk_pixbuf_new_from_inline(-1, icon32_pb, FALSE, NULL);
|
2015-10-17 12:47:17 +00:00
|
|
|
if (icon48_pb != NULL)
|
2013-12-17 13:06:11 +00:00
|
|
|
pixbuf48 = gdk_pixbuf_new_from_inline(-1, icon48_pb, FALSE, NULL);
|
2015-10-17 12:47:17 +00:00
|
|
|
if (icon64_pb != NULL)
|
2013-12-17 13:06:11 +00:00
|
|
|
pixbuf64 = gdk_pixbuf_new_from_inline(-1, icon64_pb, FALSE, NULL);
|
2015-10-17 12:47:17 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (pixbuf16 != NULL)
|
|
|
|
icon_list = g_list_append(icon_list, pixbuf16);
|
|
|
|
if (pixbuf32 != NULL)
|
|
|
|
icon_list = g_list_append(icon_list, pixbuf32);
|
|
|
|
if (pixbuf48 != NULL)
|
|
|
|
icon_list = g_list_append(icon_list, pixbuf48);
|
|
|
|
if (pixbuf64 != NULL)
|
2013-12-17 13:06:11 +00:00
|
|
|
icon_list = g_list_append(icon_list, pixbuf64);
|
2006-01-17 00:40:32 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
return icon_list;
|
2006-01-17 00:40:32 +00:00
|
|
|
}
|
|
|
|
|
2010-01-13 10:21:25 +00:00
|
|
|
static void
|
2013-05-22 07:44:28 +00:00
|
|
|
main_capture_cb_capture_prepared(capture_session *cap_session)
|
2010-01-13 10:21:25 +00:00
|
|
|
{
|
|
|
|
static GList *icon_list = NULL;
|
|
|
|
|
2013-05-22 07:44:28 +00:00
|
|
|
set_titlebar_for_capture_in_progress((capture_file *)cap_session->cf);
|
2005-02-07 00:54:46 +00:00
|
|
|
|
2006-01-17 00:40:32 +00:00
|
|
|
if(icon_list == NULL) {
|
2016-02-21 17:10:03 +00:00
|
|
|
#ifdef HAVE_GDK_GRESOURCE
|
2015-10-17 12:47:17 +00:00
|
|
|
icon_list = icon_list_create("/org/wireshark/image/wsiconcap16.png",
|
|
|
|
"/org/wireshark/image/wsiconcap32.png",
|
|
|
|
"/org/wireshark/image/wsiconcap48.png",
|
|
|
|
"/org/wireshark/image/wsiconcap64.png");
|
|
|
|
#else
|
|
|
|
icon_list = icon_list_create(wsiconcap_16_pb_data,
|
|
|
|
wsiconcap_32_pb_data,
|
|
|
|
wsiconcap_48_pb_data,
|
|
|
|
wsiconcap_64_pb_data);
|
|
|
|
#endif
|
2006-01-17 00:40:32 +00:00
|
|
|
}
|
|
|
|
gtk_window_set_icon_list(GTK_WINDOW(top_level), icon_list);
|
|
|
|
|
2005-02-07 00:54:46 +00:00
|
|
|
/* Disable menu items that make no sense if you're currently running
|
|
|
|
a capture. */
|
2012-06-17 00:00:25 +00:00
|
|
|
main_set_for_capture_in_progress(TRUE);
|
2008-04-12 17:04:21 +00:00
|
|
|
set_capture_if_dialog_for_capture_in_progress(TRUE);
|
2005-02-07 00:54:46 +00:00
|
|
|
|
2005-05-25 23:28:59 +00:00
|
|
|
/* Don't set up main window for a capture file. */
|
|
|
|
main_set_for_capture_file(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-05-22 07:44:28 +00:00
|
|
|
main_capture_cb_capture_update_started(capture_session *cap_session)
|
2005-05-25 23:28:59 +00:00
|
|
|
{
|
2005-10-05 23:56:36 +00:00
|
|
|
/* We've done this in "prepared" above, but it will be cleared while
|
|
|
|
switching to the next multiple file. */
|
2013-05-22 07:44:28 +00:00
|
|
|
set_titlebar_for_capture_in_progress((capture_file *)cap_session->cf);
|
2005-05-25 23:28:59 +00:00
|
|
|
|
2012-06-17 00:00:25 +00:00
|
|
|
main_set_for_capture_in_progress(TRUE);
|
2008-04-12 17:04:21 +00:00
|
|
|
set_capture_if_dialog_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*). */
|
2012-06-17 00:00:25 +00:00
|
|
|
main_set_for_captured_packets(TRUE);
|
2005-02-07 00:54:46 +00:00
|
|
|
|
|
|
|
/* Set up main window for a capture file. */
|
|
|
|
main_set_for_capture_file(TRUE);
|
|
|
|
}
|
|
|
|
|
2005-04-16 19:29:48 +00:00
|
|
|
static void
|
2013-05-22 07:44:28 +00:00
|
|
|
main_capture_cb_capture_update_finished(capture_session *cap_session)
|
2005-04-16 19:29:48 +00:00
|
|
|
{
|
2013-05-22 07:44:28 +00:00
|
|
|
capture_file *cf = (capture_file *)cap_session->cf;
|
2006-02-11 17:08:32 +00:00
|
|
|
static GList *icon_list = NULL;
|
|
|
|
|
2012-06-14 03:50:39 +00:00
|
|
|
/* The capture isn't stopping any more - it's stopped. */
|
|
|
|
capture_stopping = FALSE;
|
|
|
|
|
2010-08-08 21:26:39 +00:00
|
|
|
if (!cf->is_tempfile && cf->filename) {
|
|
|
|
/* Add this filename to the list of recent files in the "Recent Files" submenu */
|
|
|
|
add_menu_recent_capture_file(cf->filename);
|
|
|
|
}
|
2012-06-04 02:24:42 +00:00
|
|
|
|
2005-04-16 19:29:48 +00:00
|
|
|
/* Enable menu items that make sense if you're not currently running
|
|
|
|
a capture. */
|
2012-06-17 00:00:25 +00:00
|
|
|
main_set_for_capture_in_progress(FALSE);
|
2008-04-12 17:04:21 +00:00
|
|
|
set_capture_if_dialog_for_capture_in_progress(FALSE);
|
2005-04-16 19:29:48 +00:00
|
|
|
|
2012-12-20 04:06:44 +00:00
|
|
|
/* Update the main window as appropriate. This has to occur AFTER
|
|
|
|
* main_set_for_capture_in_progress() or else some of the menus are
|
|
|
|
* incorrectly disabled (see bug
|
|
|
|
* https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8108) */
|
|
|
|
main_update_for_unsaved_changes(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(icon_list == NULL) {
|
2016-02-21 17:10:03 +00:00
|
|
|
#ifdef HAVE_GDK_GRESOURCE
|
2015-10-17 12:47:17 +00:00
|
|
|
icon_list = icon_list_create("/org/wireshark/image/wsicon16.png",
|
|
|
|
"/org/wireshark/image/wsicon32.png",
|
|
|
|
"/org/wireshark/image/wsicon48.png",
|
|
|
|
"/org/wireshark/image/wsicon64.png");
|
|
|
|
#else
|
|
|
|
icon_list = icon_list_create(wsicon_16_pb_data,
|
|
|
|
wsicon_32_pb_data,
|
|
|
|
wsicon_48_pb_data,
|
|
|
|
wsicon_64_pb_data);
|
|
|
|
#endif
|
2006-02-11 17:08:32 +00:00
|
|
|
}
|
|
|
|
gtk_window_set_icon_list(GTK_WINDOW(top_level), icon_list);
|
|
|
|
|
2016-06-28 01:40:09 +00:00
|
|
|
if(global_commandline_info.quit_after_cap) {
|
2005-12-13 02:09:14 +00:00
|
|
|
/* 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
|
2013-05-22 07:44:28 +00:00
|
|
|
main_capture_cb_capture_fixed_started(capture_session *cap_session _U_)
|
2005-04-10 19:36:56 +00:00
|
|
|
{
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-05-22 07:44:28 +00:00
|
|
|
main_capture_cb_capture_fixed_finished(capture_session *cap_session _U_)
|
2005-04-10 19:36:56 +00:00
|
|
|
{
|
2008-06-24 08:05:45 +00:00
|
|
|
#if 0
|
2013-05-22 07:44:28 +00:00
|
|
|
capture_file *cf = (capture_file *)cap_session->cf;
|
2008-06-24 08:05:45 +00:00
|
|
|
#endif
|
2006-02-11 17:08:32 +00:00
|
|
|
static GList *icon_list = NULL;
|
|
|
|
|
2012-06-14 03:50:39 +00:00
|
|
|
/* The capture isn't stopping any more - it's stopped. */
|
|
|
|
capture_stopping = FALSE;
|
|
|
|
|
2013-03-31 22:17:43 +00:00
|
|
|
/*set_titlebar_for_capture_file(cf);*/
|
2005-04-10 19:36:56 +00:00
|
|
|
|
|
|
|
/* Enable menu items that make sense if you're not currently running
|
|
|
|
a capture. */
|
2012-06-17 00:00:25 +00:00
|
|
|
main_set_for_capture_in_progress(FALSE);
|
2008-04-12 17:04:21 +00:00
|
|
|
set_capture_if_dialog_for_capture_in_progress(FALSE);
|
2005-04-10 19:36:56 +00:00
|
|
|
|
2005-12-13 02:09:14 +00:00
|
|
|
/* Restore the standard title bar message */
|
|
|
|
/* (just in case we have trouble opening the capture file). */
|
2013-04-01 00:21:44 +00:00
|
|
|
set_titlebar_for_capture_file(NULL);
|
2005-12-13 02:09:14 +00:00
|
|
|
|
2006-02-11 17:08:32 +00:00
|
|
|
if(icon_list == NULL) {
|
2016-02-21 17:10:03 +00:00
|
|
|
#ifdef HAVE_GDK_GRESOURCE
|
2015-10-17 12:47:17 +00:00
|
|
|
icon_list = icon_list_create("/org/wireshark/image/wsicon16.png",
|
|
|
|
"/org/wireshark/image/wsicon32.png",
|
|
|
|
"/org/wireshark/image/wsicon48.png",
|
|
|
|
"/org/wireshark/image/wsicon64.png");
|
|
|
|
#else
|
|
|
|
icon_list = icon_list_create(wsicon_16_pb_data,
|
|
|
|
wsicon_32_pb_data,
|
|
|
|
wsicon_48_pb_data,
|
|
|
|
wsicon_64_pb_data);
|
|
|
|
#endif
|
2006-02-11 17:08:32 +00:00
|
|
|
}
|
|
|
|
gtk_window_set_icon_list(GTK_WINDOW(top_level), icon_list);
|
|
|
|
|
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
|
|
|
|
2016-06-28 01:40:09 +00:00
|
|
|
if(global_commandline_info.quit_after_cap) {
|
2005-12-13 02:09:14 +00:00
|
|
|
/* 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
|
|
|
}
|
2012-04-20 05:20:04 +00:00
|
|
|
|
2012-06-14 02:19:46 +00:00
|
|
|
static void
|
2013-05-22 07:44:28 +00:00
|
|
|
main_capture_cb_capture_stopping(capture_session *cap_session _U_)
|
2012-06-14 02:19:46 +00:00
|
|
|
{
|
2012-06-14 03:50:39 +00:00
|
|
|
capture_stopping = TRUE;
|
2012-06-14 02:19:46 +00:00
|
|
|
set_menus_for_capture_stopping();
|
2012-06-17 00:00:25 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
set_toolbar_for_capture_stopping();
|
|
|
|
|
|
|
|
set_capture_if_dialog_for_capture_stopping();
|
|
|
|
#endif
|
2012-06-14 02:19:46 +00:00
|
|
|
}
|
|
|
|
|
2012-04-20 05:20:04 +00:00
|
|
|
static void
|
2013-05-22 07:44:28 +00:00
|
|
|
main_capture_cb_capture_failed(capture_session *cap_session _U_)
|
2012-04-20 05:20:04 +00:00
|
|
|
{
|
|
|
|
static GList *icon_list = NULL;
|
|
|
|
|
2012-06-14 03:50:39 +00:00
|
|
|
/* Capture isn't stopping any more. */
|
|
|
|
capture_stopping = FALSE;
|
|
|
|
|
2012-04-20 05:20:04 +00:00
|
|
|
/* the capture failed before the first packet was captured
|
|
|
|
reset title, menus and icon */
|
2013-04-01 00:21:44 +00:00
|
|
|
set_titlebar_for_capture_file(NULL);
|
2012-04-20 05:20:04 +00:00
|
|
|
|
2012-06-17 00:00:25 +00:00
|
|
|
main_set_for_capture_in_progress(FALSE);
|
2012-04-20 05:20:04 +00:00
|
|
|
set_capture_if_dialog_for_capture_in_progress(FALSE);
|
|
|
|
|
|
|
|
main_set_for_capture_file(FALSE);
|
|
|
|
|
|
|
|
if(icon_list == NULL) {
|
2016-02-21 17:10:03 +00:00
|
|
|
#ifdef HAVE_GDK_GRESOURCE
|
2015-10-17 12:47:17 +00:00
|
|
|
icon_list = icon_list_create("/org/wireshark/image/wsicon16.png",
|
|
|
|
"/org/wireshark/image/wsicon32.png",
|
|
|
|
"/org/wireshark/image/wsicon48.png",
|
|
|
|
"/org/wireshark/image/wsicon64.png");
|
|
|
|
#else
|
|
|
|
icon_list = icon_list_create(wsicon_16_pb_data,
|
|
|
|
wsicon_32_pb_data,
|
|
|
|
wsicon_48_pb_data,
|
|
|
|
wsicon_64_pb_data);
|
|
|
|
#endif
|
2012-04-20 05:20:04 +00:00
|
|
|
}
|
|
|
|
gtk_window_set_icon_list(GTK_WINDOW(top_level), icon_list);
|
|
|
|
|
|
|
|
|
2016-06-28 01:40:09 +00:00
|
|
|
if(global_commandline_info.quit_after_cap) {
|
2012-04-20 05:20:04 +00:00
|
|
|
/* command line asked us to quit after the capture */
|
|
|
|
/* don't pop up a dialog to ask for unsaved files etc. */
|
|
|
|
main_do_quit();
|
|
|
|
}
|
|
|
|
}
|
2008-04-12 23:34:44 +00:00
|
|
|
#endif /* HAVE_LIBPCAP */
|
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)
|
|
|
|
{
|
2013-03-11 06:47:34 +00:00
|
|
|
capture_file *cf = (capture_file *)data;
|
2005-02-07 00:54:46 +00:00
|
|
|
|
2009-11-05 10:16:49 +00:00
|
|
|
/* Display the GUI protocol tree and packet bytes.
|
2005-02-07 00:54:46 +00:00
|
|
|
XXX - why do we dump core if we call "proto_tree_draw()"
|
|
|
|
before calling "add_byte_views()"? */
|
2012-06-16 23:10:06 +00:00
|
|
|
add_byte_views(cf->edt, tree_view_gbl, byte_nb_ptr_gbl);
|
|
|
|
proto_tree_draw(cf->edt->tree, tree_view_gbl);
|
2005-02-07 00:54:46 +00:00
|
|
|
|
2011-05-15 02:42:52 +00:00
|
|
|
/* Note: Both string and hex value searches in the packet data produce a non-zero
|
2011-01-19 18:21:21 +00:00
|
|
|
search_pos if successful */
|
2011-05-15 02:42:52 +00:00
|
|
|
if(cf->search_in_progress &&
|
2011-01-31 12:19:15 +00:00
|
|
|
(cf->search_pos != 0 || (cf->string && cf->decode_data))) {
|
2011-01-19 18:21:21 +00:00
|
|
|
highlight_field(cf->edt->tvb, cf->search_pos,
|
2010-01-29 19:09:01 +00:00
|
|
|
(GtkTreeView *)tree_view_gbl, cf->edt->tree);
|
2011-05-15 02:42:52 +00:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2012-06-16 23:10:06 +00:00
|
|
|
/* No packet is being displayed; clear the hex dump pane by getting
|
|
|
|
rid of all the byte views. */
|
|
|
|
while (gtk_notebook_get_nth_page(GTK_NOTEBOOK(byte_nb_ptr_gbl), 0) != NULL)
|
|
|
|
gtk_notebook_remove_page(GTK_NOTEBOOK(byte_nb_ptr_gbl), 0);
|
|
|
|
|
|
|
|
/* Add a placeholder byte view so that there's at least something
|
|
|
|
displayed in the byte view notebook. */
|
|
|
|
add_byte_tab(byte_nb_ptr_gbl, "", NULL, NULL, tree_view_gbl);
|
|
|
|
|
|
|
|
/* And clear the protocol tree display as well. */
|
|
|
|
proto_tree_draw(NULL, tree_view_gbl);
|
2005-02-07 00:54:46 +00:00
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
|
|
|
set_menus_for_selected_tree_row(cf);
|
|
|
|
}
|
|
|
|
|
2008-05-22 15:46:27 +00:00
|
|
|
static void
|
2008-04-12 23:34:44 +00:00
|
|
|
main_cf_callback(gint event, gpointer data, gpointer user_data _U_)
|
2005-02-07 00:54:46 +00:00
|
|
|
{
|
2013-03-11 06:47:34 +00:00
|
|
|
capture_file *cf = (capture_file *)data;
|
2005-02-07 00:54:46 +00:00
|
|
|
switch(event) {
|
2012-09-26 23:33:11 +00:00
|
|
|
case(cf_cb_file_opened):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Opened");
|
2013-03-11 06:47:34 +00:00
|
|
|
fileset_file_opened(cf);
|
2012-09-26 23:33:11 +00:00
|
|
|
break;
|
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");
|
2013-03-11 06:47:34 +00:00
|
|
|
main_cf_cb_file_closing(cf);
|
2005-09-20 08:42:35 +00:00
|
|
|
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");
|
2013-03-11 06:47:34 +00:00
|
|
|
main_cf_cb_file_closed(cf);
|
2012-09-26 23:40:56 +00:00
|
|
|
fileset_file_closed();
|
2005-02-07 00:54:46 +00:00
|
|
|
break;
|
2009-12-14 22:05:29 +00:00
|
|
|
case(cf_cb_file_read_started):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Read started");
|
2013-03-11 06:47:34 +00:00
|
|
|
main_cf_cb_file_read_started(cf);
|
2005-02-07 00:54:46 +00:00
|
|
|
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");
|
2013-03-11 06:47:34 +00:00
|
|
|
main_cf_cb_file_read_finished(cf);
|
2005-02-07 00:54:46 +00:00
|
|
|
break;
|
2012-05-22 03:52:12 +00:00
|
|
|
case(cf_cb_file_reload_started):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Reload started");
|
2013-03-11 06:47:34 +00:00
|
|
|
main_cf_cb_file_read_started(cf);
|
2012-05-22 03:52:12 +00:00
|
|
|
break;
|
|
|
|
case(cf_cb_file_reload_finished):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Reload finished");
|
2013-03-11 06:47:34 +00:00
|
|
|
main_cf_cb_file_read_finished(cf);
|
2012-05-22 03:52:12 +00:00
|
|
|
break;
|
If we do a Save or Save As with a move, don't reread the capture file,
just tweak the elements in the capture_file structure as necessary and
poke the UI to update stuff such as the windows title.
If we do a Save or Save As with a copy, don't reread the capture file,
just close the old wtap, open a wtap for the copy, and tweak the
elements in the capture_file structure as necessary and poke the UI to
update stuff such as the windows title.
Otherwise, don't do a full read-and-dissect pass on the capture file,
just close the old wtap, open a wtap for the new file, tweak the
elements in the capture_file structure as necessary and poke the UI to
update stuff such as the windows title, and rescan the file to update
the packet offsets (and cause Wiretap to regenerate, for a gzipped file,
the information needed to support fast random access to the gzipped
file).
This should speed up Save and Save As a bit, as well as removing some
glitches in the UI (e.g., you won't see the packet list disappear and
reappear).
svn path=/trunk/; revision=43101
2012-06-05 06:52:18 +00:00
|
|
|
case(cf_cb_file_rescan_started):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Rescan started");
|
|
|
|
break;
|
|
|
|
case(cf_cb_file_rescan_finished):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Rescan finished");
|
2013-03-11 06:47:34 +00:00
|
|
|
main_cf_cb_file_rescan_finished(cf);
|
If we do a Save or Save As with a move, don't reread the capture file,
just tweak the elements in the capture_file structure as necessary and
poke the UI to update stuff such as the windows title.
If we do a Save or Save As with a copy, don't reread the capture file,
just close the old wtap, open a wtap for the copy, and tweak the
elements in the capture_file structure as necessary and poke the UI to
update stuff such as the windows title.
Otherwise, don't do a full read-and-dissect pass on the capture file,
just close the old wtap, open a wtap for the new file, tweak the
elements in the capture_file structure as necessary and poke the UI to
update stuff such as the windows title, and rescan the file to update
the packet offsets (and cause Wiretap to regenerate, for a gzipped file,
the information needed to support fast random access to the gzipped
file).
This should speed up Save and Save As a bit, as well as removing some
glitches in the UI (e.g., you won't see the packet list disappear and
reappear).
svn path=/trunk/; revision=43101
2012-06-05 06:52:18 +00:00
|
|
|
break;
|
2015-08-26 15:41:50 +00:00
|
|
|
case(cf_cb_file_retap_started):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Retap started");
|
|
|
|
break;
|
|
|
|
case(cf_cb_file_retap_finished):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Retap finished");
|
|
|
|
break;
|
If we do a Save or Save As with a move, don't reread the capture file,
just tweak the elements in the capture_file structure as necessary and
poke the UI to update stuff such as the windows title.
If we do a Save or Save As with a copy, don't reread the capture file,
just close the old wtap, open a wtap for the copy, and tweak the
elements in the capture_file structure as necessary and poke the UI to
update stuff such as the windows title.
Otherwise, don't do a full read-and-dissect pass on the capture file,
just close the old wtap, open a wtap for the new file, tweak the
elements in the capture_file structure as necessary and poke the UI to
update stuff such as the windows title, and rescan the file to update
the packet offsets (and cause Wiretap to regenerate, for a gzipped file,
the information needed to support fast random access to the gzipped
file).
This should speed up Save and Save As a bit, as well as removing some
glitches in the UI (e.g., you won't see the packet list disappear and
reappear).
svn path=/trunk/; revision=43101
2012-06-05 06:52:18 +00:00
|
|
|
case(cf_cb_file_fast_save_finished):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Fast save finished");
|
2013-03-11 06:47:34 +00:00
|
|
|
main_cf_cb_file_rescan_finished(cf);
|
If we do a Save or Save As with a move, don't reread the capture file,
just tweak the elements in the capture_file structure as necessary and
poke the UI to update stuff such as the windows title.
If we do a Save or Save As with a copy, don't reread the capture file,
just close the old wtap, open a wtap for the copy, and tweak the
elements in the capture_file structure as necessary and poke the UI to
update stuff such as the windows title.
Otherwise, don't do a full read-and-dissect pass on the capture file,
just close the old wtap, open a wtap for the new file, tweak the
elements in the capture_file structure as necessary and poke the UI to
update stuff such as the windows title, and rescan the file to update
the packet offsets (and cause Wiretap to regenerate, for a gzipped file,
the information needed to support fast random access to the gzipped
file).
This should speed up Save and Save As a bit, as well as removing some
glitches in the UI (e.g., you won't see the packet list disappear and
reappear).
svn path=/trunk/; revision=43101
2012-06-05 06:52:18 +00:00
|
|
|
break;
|
2005-02-07 00:54:46 +00:00
|
|
|
case(cf_cb_packet_selected):
|
2013-03-11 06:47:34 +00:00
|
|
|
main_cf_cb_packet_selected(cf);
|
2005-02-07 00:54:46 +00:00
|
|
|
break;
|
|
|
|
case(cf_cb_packet_unselected):
|
2013-03-11 06:47:34 +00:00
|
|
|
main_cf_cb_packet_unselected(cf);
|
2005-02-07 00:54:46 +00:00
|
|
|
break;
|
|
|
|
case(cf_cb_field_unselected):
|
2013-03-11 06:47:34 +00:00
|
|
|
main_cf_cb_field_unselected(cf);
|
2005-02-07 00:54:46 +00:00
|
|
|
break;
|
2009-12-14 22:05:29 +00:00
|
|
|
case(cf_cb_file_save_started):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Save started");
|
2005-02-07 00:54:46 +00:00
|
|
|
break;
|
2009-12-14 22:05:29 +00:00
|
|
|
case(cf_cb_file_save_finished):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Save finished");
|
2005-02-07 00:54:46 +00:00
|
|
|
break;
|
2009-12-14 22:05:29 +00:00
|
|
|
case(cf_cb_file_save_failed):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Save failed");
|
2005-02-07 00:54:46 +00:00
|
|
|
break;
|
Distinguish between "failed" and "user stopped it" for "save as" and
"export specified packets". For "failed", let the user try again with a
different file, in case it failed due to, for example, running out of
space or quota (probably the most likely failure mode for writing, and
trying to a different volume might be the best workaround). For "user
stopped it", presumably they don't want to try again (the most likely
reason is "it was taking too damn long").
Put "Exporting to: ...", not "Saving: ..." in the statusbar if we're
doing "export specified packets".
In process_specified_packets(), allow a null range pointer to be
specified, meaning "save 'em all"; that avoids the possibly-expensive
(with a large capture) operation of initializing the range.
If a "safe save" atop an existing file fails or is stopped, get rid of
the temporary file we created.
svn path=/trunk/; revision=43095
2012-06-05 02:46:54 +00:00
|
|
|
case(cf_cb_file_save_stopped):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Save stopped");
|
|
|
|
break;
|
|
|
|
case(cf_cb_file_export_specified_packets_started):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Export specified packets started");
|
|
|
|
break;
|
|
|
|
case(cf_cb_file_export_specified_packets_finished):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Export specified packets finished");
|
|
|
|
break;
|
|
|
|
case(cf_cb_file_export_specified_packets_failed):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Export specified packets failed");
|
|
|
|
break;
|
|
|
|
case(cf_cb_file_export_specified_packets_stopped):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Export specified packets stopped");
|
|
|
|
break;
|
2005-02-07 00:54:46 +00:00
|
|
|
default:
|
|
|
|
g_warning("main_cf_callback: event %u unknown", event);
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
}
|
2004-01-31 18:32:37 +00:00
|
|
|
|
2008-06-24 08:05:45 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
static void
|
2013-05-22 07:44:28 +00:00
|
|
|
main_capture_callback(gint event, capture_session *cap_session, gpointer user_data _U_)
|
2008-06-24 08:05:45 +00:00
|
|
|
{
|
2010-05-25 00:35:44 +00:00
|
|
|
#ifdef HAVE_GTKOSXAPPLICATION
|
2012-11-02 09:58:43 +00:00
|
|
|
GtkosxApplication *theApp;
|
2010-05-28 20:19:55 +00:00
|
|
|
#endif
|
2008-06-24 08:05:45 +00:00
|
|
|
switch(event) {
|
|
|
|
case(capture_cb_capture_prepared):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture prepared");
|
2013-05-22 07:44:28 +00:00
|
|
|
main_capture_cb_capture_prepared(cap_session);
|
2008-06-24 08:05:45 +00:00
|
|
|
break;
|
|
|
|
case(capture_cb_capture_update_started):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update started");
|
2013-05-22 07:44:28 +00:00
|
|
|
main_capture_cb_capture_update_started(cap_session);
|
2010-05-25 00:35:44 +00:00
|
|
|
#ifdef HAVE_GTKOSXAPPLICATION
|
2013-03-26 05:02:05 +00:00
|
|
|
theApp = (GtkosxApplication *)g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
|
2016-02-21 17:10:03 +00:00
|
|
|
#ifdef HAVE_GDK_GRESOURCE
|
2015-10-17 12:47:17 +00:00
|
|
|
gtkosx_application_set_dock_icon_pixbuf(theApp, ws_gdk_pixbuf_new_from_resource("/org/wireshark/image/wsicon48.png"));
|
|
|
|
#else
|
|
|
|
gtkosx_application_set_dock_icon_pixbuf(theApp, gdk_pixbuf_new_from_inline(-1, wsicon_48_pb_data, FALSE, NULL));
|
|
|
|
#endif
|
2010-05-25 00:35:44 +00:00
|
|
|
#endif
|
2008-06-24 08:05:45 +00:00
|
|
|
break;
|
|
|
|
case(capture_cb_capture_update_continue):
|
|
|
|
/*g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update continue");*/
|
|
|
|
break;
|
|
|
|
case(capture_cb_capture_update_finished):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update finished");
|
2013-05-22 07:44:28 +00:00
|
|
|
main_capture_cb_capture_update_finished(cap_session);
|
2008-06-24 08:05:45 +00:00
|
|
|
break;
|
|
|
|
case(capture_cb_capture_fixed_started):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed started");
|
2013-05-22 07:44:28 +00:00
|
|
|
main_capture_cb_capture_fixed_started(cap_session);
|
2008-06-24 08:05:45 +00:00
|
|
|
break;
|
|
|
|
case(capture_cb_capture_fixed_continue):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed continue");
|
|
|
|
break;
|
|
|
|
case(capture_cb_capture_fixed_finished):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed finished");
|
2013-05-22 07:44:28 +00:00
|
|
|
main_capture_cb_capture_fixed_finished(cap_session);
|
2008-06-24 08:05:45 +00:00
|
|
|
break;
|
|
|
|
case(capture_cb_capture_stopping):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture stopping");
|
|
|
|
/* Beware: this state won't be called, if the capture child
|
2013-02-25 23:35:13 +00:00
|
|
|
* closes the capturing on its own! */
|
2010-05-25 00:35:44 +00:00
|
|
|
#ifdef HAVE_GTKOSXAPPLICATION
|
2013-03-26 05:02:05 +00:00
|
|
|
theApp = (GtkosxApplication *)g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
|
2016-02-21 17:10:03 +00:00
|
|
|
#ifdef HAVE_GDK_GRESOURCE
|
2015-10-17 12:47:17 +00:00
|
|
|
gtkosx_application_set_dock_icon_pixbuf(theApp, ws_gdk_pixbuf_new_from_resource("/org/wireshark/image/wsicon64.png"));
|
|
|
|
#else
|
2013-03-27 12:29:44 +00:00
|
|
|
gtkosx_application_set_dock_icon_pixbuf(theApp, gdk_pixbuf_new_from_inline(-1, wsicon_64_pb_data, FALSE, NULL));
|
2015-10-17 12:47:17 +00:00
|
|
|
#endif
|
2010-05-25 00:35:44 +00:00
|
|
|
#endif
|
2013-05-22 07:44:28 +00:00
|
|
|
main_capture_cb_capture_stopping(cap_session);
|
2008-06-24 08:05:45 +00:00
|
|
|
break;
|
2012-03-13 08:36:25 +00:00
|
|
|
case(capture_cb_capture_failed):
|
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture failed");
|
2013-05-22 07:44:28 +00:00
|
|
|
main_capture_cb_capture_failed(cap_session);
|
2012-03-13 08:36:25 +00:00
|
|
|
break;
|
2008-06-24 08:05:45 +00:00
|
|
|
default:
|
|
|
|
g_warning("main_capture_callback: event %u unknown", event);
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-06-18 20:49:23 +00:00
|
|
|
void
|
2014-07-03 08:45:32 +00:00
|
|
|
get_wireshark_gtk_compiled_info(GString *str)
|
2010-10-21 07:13:43 +00:00
|
|
|
{
|
2013-12-17 13:06:11 +00:00
|
|
|
g_string_append(str, "with ");
|
|
|
|
g_string_append_printf(str,
|
2010-10-21 07:13:43 +00:00
|
|
|
#ifdef GTK_MAJOR_VERSION
|
2013-12-17 13:06:11 +00:00
|
|
|
"GTK+ %d.%d.%d", GTK_MAJOR_VERSION, GTK_MINOR_VERSION,
|
|
|
|
GTK_MICRO_VERSION);
|
2010-10-21 07:13:43 +00:00
|
|
|
#else
|
2013-12-17 13:06:11 +00:00
|
|
|
"GTK+ (version unknown)");
|
2010-10-21 07:13:43 +00:00
|
|
|
#endif
|
2014-07-03 08:45:32 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Cairo */
|
2014-07-03 08:45:32 +00:00
|
|
|
g_string_append(str, ", with Cairo ");
|
2013-12-17 13:06:11 +00:00
|
|
|
g_string_append(str, CAIRO_VERSION_STRING);
|
2011-08-08 06:08:27 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Pango */
|
2014-07-03 08:45:32 +00:00
|
|
|
g_string_append(str, ", with Pango ");
|
2013-12-17 13:06:11 +00:00
|
|
|
g_string_append(str, PANGO_VERSION_STRING);
|
2014-07-03 08:45:32 +00:00
|
|
|
|
2014-07-04 07:24:02 +00:00
|
|
|
/* Capture libraries */
|
2014-07-03 08:45:32 +00:00
|
|
|
g_string_append(str, ", ");
|
2014-07-04 07:24:02 +00:00
|
|
|
get_compiled_caplibs_version(str);
|
2010-10-21 07:13:43 +00:00
|
|
|
}
|
|
|
|
|
2016-06-18 20:49:23 +00:00
|
|
|
void
|
2006-10-19 22:43:38 +00:00
|
|
|
get_gui_compiled_info(GString *str)
|
2006-10-19 18:43:12 +00:00
|
|
|
{
|
2013-12-17 13:06:11 +00:00
|
|
|
epan_get_compiled_version_info(str);
|
2006-10-19 21:17:23 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
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
|
2013-12-17 13:06:11 +00:00
|
|
|
g_string_append(str, "with PortAudio <= V18");
|
2006-10-19 18:43:12 +00:00
|
|
|
#else /* PORTAUDIO_API_1 */
|
2013-12-17 13:06:11 +00:00
|
|
|
g_string_append(str, "with ");
|
|
|
|
g_string_append(str, Pa_GetVersionText());
|
2006-10-19 18:43:12 +00:00
|
|
|
#endif /* PORTAUDIO_API_1 */
|
|
|
|
#else /* HAVE_LIBPORTAUDIO */
|
2013-12-17 13:06:11 +00:00
|
|
|
g_string_append(str, "without PortAudio");
|
2006-10-19 18:43:12 +00:00
|
|
|
#endif /* HAVE_LIBPORTAUDIO */
|
2006-10-19 22:43:38 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
g_string_append(str, ", ");
|
2006-10-19 22:43:38 +00:00
|
|
|
#ifdef HAVE_AIRPCAP
|
2013-12-17 13:06:11 +00:00
|
|
|
get_compiled_airpcap_version(str);
|
2013-12-17 13:21:26 +00:00
|
|
|
#else
|
|
|
|
g_string_append(str, "without AirPcap");
|
2006-10-19 22:43:38 +00:00
|
|
|
#endif
|
2016-11-28 23:58:40 +00:00
|
|
|
|
|
|
|
codec_get_compiled_version_info(str);
|
2006-10-19 22:43:38 +00:00
|
|
|
}
|
|
|
|
|
2016-06-18 20:49:23 +00:00
|
|
|
void
|
2014-06-23 21:55:56 +00:00
|
|
|
get_wireshark_runtime_info(GString *str)
|
2006-10-19 22:43:38 +00:00
|
|
|
{
|
2014-06-23 21:55:56 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2014-07-04 07:24:02 +00:00
|
|
|
/* Capture libraries */
|
2014-06-23 21:55:56 +00:00
|
|
|
g_string_append(str, ", ");
|
2014-07-04 07:24:02 +00:00
|
|
|
get_runtime_caplibs_version(str);
|
2014-06-23 21:55:56 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* stuff used by libwireshark */
|
2013-12-17 13:06:11 +00:00
|
|
|
epan_get_runtime_version_info(str);
|
2010-07-15 02:07:16 +00:00
|
|
|
|
2006-10-19 22:43:38 +00:00
|
|
|
#ifdef HAVE_AIRPCAP
|
2013-12-17 13:06:11 +00:00
|
|
|
g_string_append(str, ", ");
|
|
|
|
get_runtime_airpcap_version(str);
|
2006-10-19 22:43:38 +00:00
|
|
|
#endif
|
2006-10-19 18:43:12 +00:00
|
|
|
}
|
|
|
|
|
2008-01-14 16:40:23 +00:00
|
|
|
static e_prefs *
|
2017-04-08 19:45:19 +00:00
|
|
|
read_configuration_files(void)
|
2008-01-14 16:40:23 +00:00
|
|
|
{
|
2013-12-17 13:06:11 +00:00
|
|
|
e_prefs *prefs_p;
|
|
|
|
|
2017-04-09 19:27:57 +00:00
|
|
|
/* Load libwireshark settings from the current profile. */
|
|
|
|
prefs_p = epan_load_settings();
|
2008-01-14 16:40:23 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2013-12-17 13:06:11 +00:00
|
|
|
/* if the user wants a console to be always there, well, we should open one for him */
|
|
|
|
if (prefs_p->gui_console_open == console_open_always) {
|
|
|
|
create_console();
|
|
|
|
}
|
2008-01-14 16:40:23 +00:00
|
|
|
#endif
|
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Read the capture filter file. */
|
2017-04-09 09:01:05 +00:00
|
|
|
read_filter_list(CFILTER_LIST);
|
2008-01-14 16:40:23 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Read the display filter file. */
|
2017-04-09 09:01:05 +00:00
|
|
|
read_filter_list(DFILTER_LIST);
|
2008-01-14 16:40:23 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
return prefs_p;
|
2008-01-14 16:40:23 +00:00
|
|
|
}
|
|
|
|
|
2010-04-29 19:30:54 +00:00
|
|
|
/* Check if there's something important to tell the user during startup.
|
|
|
|
* We want to do this *after* showing the main window so that any windows
|
|
|
|
* we pop up will be above the main window.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
#ifdef _WIN32
|
|
|
|
check_and_warn_user_startup(gchar *cf_name)
|
|
|
|
#else
|
|
|
|
check_and_warn_user_startup(gchar *cf_name _U_)
|
|
|
|
#endif
|
|
|
|
{
|
2013-12-17 13:06:11 +00:00
|
|
|
gchar *cur_user, *cur_group;
|
|
|
|
gpointer priv_warning_dialog;
|
|
|
|
|
|
|
|
/* 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.\n\n"
|
|
|
|
"If you're running Wireshark this way in order to perform live capture, "
|
|
|
|
"you may want to be aware that there is a better way documented at\n"
|
2015-03-10 17:46:50 +00:00
|
|
|
"https://wiki.wireshark.org/CaptureSetup/CapturePrivileges", cur_user, cur_group);
|
2013-12-17 13:06:11 +00:00
|
|
|
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);
|
|
|
|
}
|
2010-04-29 19:30:54 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Warn the user if npf.sys isn't loaded. */
|
2014-06-21 21:32:45 +00:00
|
|
|
if (!get_stdin_capture() && !cf_name && !npf_sys_is_running() && recent.privs_warn_if_no_npf && get_windows_major_version() >= 6) {
|
2013-12-17 13:06:11 +00:00
|
|
|
priv_warning_dialog = simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
|
|
|
|
"The NPF driver isn't running. You may have trouble\n"
|
|
|
|
"capturing or listing interfaces.");
|
|
|
|
simple_dialog_check_set(priv_warning_dialog, "Don't show this message again.");
|
|
|
|
simple_dialog_set_cb(priv_warning_dialog, npf_warning_dialog_cb, NULL);
|
|
|
|
}
|
2010-04-29 19:30:54 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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[])
|
|
|
|
{
|
2013-12-17 13:06:11 +00:00
|
|
|
char *init_progfile_dir_error;
|
|
|
|
char *s;
|
2017-01-25 09:16:35 +00:00
|
|
|
int ret = EXIT_SUCCESS;
|
2013-12-17 13:06:11 +00:00
|
|
|
extern int info_update_freq; /* Found in about_dlg.c. */
|
|
|
|
const gchar *filter;
|
2009-05-27 14:13:55 +00:00
|
|
|
|
2004-09-11 23:03:36 +00:00
|
|
|
#ifdef _WIN32
|
2013-12-17 13:06:11 +00:00
|
|
|
WSADATA wsaData;
|
2017-03-26 22:46:13 +00:00
|
|
|
int result;
|
2004-09-11 23:03:36 +00:00
|
|
|
#endif /* _WIN32 */
|
2000-10-27 17:19:23 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
char *rf_path;
|
|
|
|
int rf_open_errno;
|
|
|
|
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
|
2013-12-17 13:06:11 +00:00
|
|
|
gchar *err_str;
|
2017-09-14 00:22:49 +00:00
|
|
|
int caps_queries = 0;
|
1999-12-07 07:12:49 +00:00
|
|
|
#else
|
2010-05-08 00:17:06 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#ifdef HAVE_AIRPCAP
|
2013-12-17 13:06:11 +00:00
|
|
|
gchar *err_str;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
gint pl_size = 280, tv_size = 95, bv_size = 75;
|
2016-06-18 20:49:23 +00:00
|
|
|
gchar *rc_file;
|
2013-12-17 13:06:11 +00:00
|
|
|
dfilter_t *rfcode = NULL;
|
2015-12-22 20:07:00 +00:00
|
|
|
gchar *err_msg = NULL;
|
2013-12-17 13:06:11 +00:00
|
|
|
gboolean rfilter_parse_failed = FALSE;
|
|
|
|
GtkWidget *splash_win = NULL;
|
|
|
|
dfilter_t *jump_to_filter = NULL;
|
2014-03-04 11:19:01 +00:00
|
|
|
unsigned int in_file_type = WTAP_TYPE_AUTO;
|
2010-05-25 00:35:44 +00:00
|
|
|
#ifdef HAVE_GTKOSXAPPLICATION
|
2013-12-17 13:06:11 +00:00
|
|
|
GtkosxApplication *theApp;
|
2010-05-25 00:35:44 +00:00
|
|
|
#endif
|
2016-06-19 21:12:30 +00:00
|
|
|
GString *comp_info_str = NULL;
|
|
|
|
GString *runtime_info_str = NULL;
|
2016-06-18 20:49:23 +00:00
|
|
|
|
2016-02-21 17:10:03 +00:00
|
|
|
#ifdef HAVE_GDK_GRESOURCE
|
2015-10-17 12:47:17 +00:00
|
|
|
main_register_resource();
|
|
|
|
#endif
|
|
|
|
|
2014-06-29 21:37:21 +00:00
|
|
|
cmdarg_err_init(wireshark_cmdarg_err, wireshark_cmdarg_err_cont);
|
2013-01-16 00:12:27 +00:00
|
|
|
|
2016-06-24 23:01:51 +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. */
|
2013-12-17 13:06:11 +00:00
|
|
|
setlocale(LC_ALL, "");
|
2010-08-13 21:21:28 +00:00
|
|
|
#ifdef _WIN32
|
2013-12-17 13:06:11 +00:00
|
|
|
arg_list_utf_16to8(argc, argv);
|
|
|
|
create_app_running_mutex();
|
2010-08-13 21:21:28 +00:00
|
|
|
#endif /* _WIN32 */
|
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/*
|
|
|
|
* Get credential information for later use, and drop privileges
|
|
|
|
* before doing anything else.
|
|
|
|
* Let the user know if anything happened.
|
|
|
|
*/
|
|
|
|
init_process_policies();
|
|
|
|
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
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/*
|
2016-12-05 04:25:51 +00:00
|
|
|
* Attempt to get the pathname of the directory containing the
|
|
|
|
* executable file.
|
2013-12-17 13:06:11 +00:00
|
|
|
*/
|
2015-12-12 02:34:47 +00:00
|
|
|
init_progfile_dir_error = init_progfile_dir(argv[0], main);
|
2006-02-06 03:11:34 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* initialize the funnel mini-api */
|
|
|
|
initialize_funnel_ops();
|
2006-02-16 15:27:03 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
AirPDcapInitContext(&airpdcap_ctx);
|
2007-08-30 00:24:40 +00:00
|
|
|
|
2005-06-23 21:19:05 +00:00
|
|
|
#ifdef _WIN32
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Load wpcap if possible. Do this before collecting the run-time version information */
|
|
|
|
load_wpcap();
|
2005-06-23 21:19:05 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* ... and also load the packet.dll from wpcap */
|
|
|
|
wpcap_packet_load();
|
2005-06-23 21:19:05 +00:00
|
|
|
|
2006-10-19 22:43:38 +00:00
|
|
|
#ifdef HAVE_AIRPCAP
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Load the airpcap.dll. This must also be done before collecting
|
|
|
|
* run-time version information. */
|
|
|
|
airpcap_dll_ret_val = load_airpcap();
|
|
|
|
|
|
|
|
switch (airpcap_dll_ret_val) {
|
|
|
|
case AIRPCAP_DLL_OK:
|
|
|
|
/* load the airpcap interfaces */
|
2015-07-02 10:19:02 +00:00
|
|
|
g_airpcap_if_list = get_airpcap_interface_list(&err, &err_str);
|
2013-12-17 13:06:11 +00:00
|
|
|
|
2015-07-02 10:19:02 +00:00
|
|
|
if (g_airpcap_if_list == NULL || g_list_length(g_airpcap_if_list) == 0){
|
2013-12-17 13:06:11 +00:00
|
|
|
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;
|
2007-05-18 21:06:20 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
} else {
|
2006-11-05 00:54:17 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* select the first ad default (THIS SHOULD BE CHANGED) */
|
2015-07-02 10:19:02 +00:00
|
|
|
airpcap_if_active = airpcap_get_default_if(g_airpcap_if_list);
|
2013-12-17 13:06:11 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-11-05 00:54:17 +00:00
|
|
|
#if 0
|
2013-12-17 13:06:11 +00:00
|
|
|
/*
|
|
|
|
* 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;
|
2006-11-05 00:54:17 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
case AIRPCAP_DLL_ERROR:
|
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s","AIRPCAP_DLL_ERROR\n");
|
|
|
|
break;
|
2006-11-05 00:54:17 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
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
|
2013-12-17 13:06:11 +00:00
|
|
|
}
|
2006-11-05 00:54:17 +00:00
|
|
|
#endif /* HAVE_AIRPCAP */
|
2013-02-03 18:31:23 +00:00
|
|
|
#endif /* _WIN32 */
|
2006-10-19 22:43:38 +00:00
|
|
|
|
2014-12-31 06:28:25 +00:00
|
|
|
/* Get the compile-time version information string */
|
2016-06-19 21:12:30 +00:00
|
|
|
comp_info_str = get_compiled_version_info(get_wireshark_gtk_compiled_info,
|
2014-12-31 06:28:25 +00:00
|
|
|
get_gui_compiled_info);
|
2013-02-03 15:11:53 +00:00
|
|
|
|
2014-12-31 06:28:25 +00:00
|
|
|
/* Get the run-time version information string */
|
2016-06-19 21:12:30 +00:00
|
|
|
runtime_info_str = get_runtime_version_info(get_wireshark_runtime_info);
|
2013-02-03 15:11:53 +00:00
|
|
|
|
2014-07-01 10:05:38 +00:00
|
|
|
/* Add it to the information to be reported on a crash. */
|
2014-07-03 02:03:07 +00:00
|
|
|
ws_add_crash_info("Wireshark %s\n"
|
2013-12-17 13:06:11 +00:00
|
|
|
"\n"
|
|
|
|
"%s"
|
|
|
|
"\n"
|
|
|
|
"%s",
|
2016-06-19 21:12:30 +00:00
|
|
|
get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str);
|
2005-06-23 21:19:05 +00:00
|
|
|
|
2014-06-30 22:27:39 +00:00
|
|
|
#ifdef _WIN32
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Start windows sockets */
|
2017-03-26 22:46:13 +00:00
|
|
|
result = WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
|
|
|
|
if (result != 0) {
|
|
|
|
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
|
|
|
|
"Error: WSAStartup failed with error: %d", result);
|
|
|
|
ret = INIT_FAILED;
|
|
|
|
goto clean_exit;
|
|
|
|
}
|
2013-12-17 13:06:11 +00:00
|
|
|
#endif /* _WIN32 */
|
2009-12-21 12:32:31 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
profile_store_persconffiles (TRUE);
|
2005-06-23 21:19:05 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Read the profile independent recent file. We have to do this here so we can */
|
2014-04-23 17:22:21 +00:00
|
|
|
/* set the profile before it can be set from the command line parameter */
|
2013-12-17 13:06:11 +00:00
|
|
|
recent_read_static(&rf_path, &rf_open_errno);
|
|
|
|
if (rf_path != NULL && rf_open_errno != 0) {
|
|
|
|
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
|
|
|
|
"Could not open common recent file\n\"%s\": %s.",
|
|
|
|
rf_path, g_strerror(rf_open_errno));
|
|
|
|
}
|
|
|
|
|
2016-06-19 21:12:30 +00:00
|
|
|
commandline_early_options(argc, argv, comp_info_str, runtime_info_str);
|
2005-06-23 21:19:05 +00:00
|
|
|
|
2014-01-05 18:39:43 +00:00
|
|
|
/* Init the "Open file" dialog directory */
|
|
|
|
/* (do this after the path settings are processed) */
|
|
|
|
|
|
|
|
/* Read the profile dependent (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. */
|
2015-10-04 09:31:19 +00:00
|
|
|
if (!recent_read_profile_static(&rf_path, &rf_open_errno)) {
|
2014-01-05 18:39:43 +00:00
|
|
|
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
|
|
|
|
"Could not open recent file\n\"%s\": %s.",
|
|
|
|
rf_path, g_strerror(rf_open_errno));
|
2015-10-04 09:31:19 +00:00
|
|
|
g_free(rf_path);
|
2014-01-05 18:39:43 +00:00
|
|
|
}
|
2010-06-25 19:22:32 +00:00
|
|
|
|
2014-01-05 18:39:43 +00:00
|
|
|
if (recent.gui_fileopen_remembered_dir &&
|
|
|
|
test_for_directory(recent.gui_fileopen_remembered_dir) == EISDIR) {
|
|
|
|
set_last_open_dir(recent.gui_fileopen_remembered_dir);
|
|
|
|
} else {
|
|
|
|
set_last_open_dir(get_persdatafile_dir());
|
|
|
|
}
|
2007-03-14 02:55:54 +00:00
|
|
|
|
2011-11-09 23:43:50 +00:00
|
|
|
#if !GLIB_CHECK_VERSION(2,31,0)
|
2013-12-17 13:06:11 +00:00
|
|
|
g_thread_init(NULL);
|
2011-11-09 23:43:50 +00:00
|
|
|
#endif
|
2011-07-14 23:18:02 +00:00
|
|
|
|
2016-06-14 03:01:08 +00:00
|
|
|
/* Disable liboverlay scrollbar which broke Wireshark on Ubuntu */
|
|
|
|
#if !GTK_CHECK_VERSION(3,16,0)
|
|
|
|
if (NULL == g_getenv("LIBOVERLAY_SCROLLBAR")) {
|
|
|
|
g_setenv("LIBOVERLAY_SCROLLBAR", "0", FALSE);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Let GTK get its args (will need an X server, so do this after command line only commands handled) */
|
|
|
|
gtk_init (&argc, &argv);
|
2004-12-02 07:53:59 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
cf_callback_add(main_cf_callback, NULL);
|
2008-06-24 08:05:45 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2013-12-17 13:06:11 +00:00
|
|
|
capture_callback_add(main_capture_callback, NULL);
|
2008-06-24 08:05:45 +00:00
|
|
|
#endif
|
2015-04-05 20:01:45 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
cf_callback_add(statusbar_cf_callback, NULL);
|
2008-06-24 08:05:45 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2013-12-17 13:06:11 +00:00
|
|
|
capture_callback_add(statusbar_capture_callback, NULL);
|
2008-06-24 08:05:45 +00:00
|
|
|
#endif
|
2005-02-07 00:54:46 +00:00
|
|
|
|
2015-04-05 20:01:45 +00:00
|
|
|
cf_callback_add(welcome_cf_callback, NULL);
|
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
capture_callback_add(welcome_capture_callback, NULL);
|
|
|
|
#endif
|
|
|
|
|
2014-09-25 23:21:02 +00:00
|
|
|
set_console_log_handler();
|
2001-02-20 04:09:37 +00:00
|
|
|
|
2005-01-27 10:47:27 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Set the initial values in the capture options. This might be overwritten
|
|
|
|
by preference settings and then again by the command line parameters. */
|
|
|
|
capture_opts_init(&global_capture_opts);
|
2013-05-22 07:44:28 +00:00
|
|
|
|
2014-09-09 20:42:58 +00:00
|
|
|
capture_session_init(&global_capture_session, &cfile);
|
2004-12-02 00:12:54 +00:00
|
|
|
#endif
|
2005-02-06 14:43:27 +00:00
|
|
|
|
2017-04-08 19:45:19 +00:00
|
|
|
init_report_message(vfailure_alert_box, vwarning_alert_box,
|
|
|
|
open_failure_alert_box, read_failure_alert_box,
|
|
|
|
write_failure_alert_box);
|
2013-12-05 09:30:22 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Non-blank filter means we're remote. Throttle splash screen and resolution updates. */
|
|
|
|
filter = get_conn_cfilter();
|
|
|
|
if ( *filter != '\0' ) {
|
|
|
|
info_update_freq = 1000; /* Milliseconds */
|
|
|
|
}
|
2009-05-27 14:13:55 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* We won't come till here, if we had a "console only" command line parameter. */
|
|
|
|
splash_win = splash_new("Loading Wireshark ...");
|
|
|
|
if (init_progfile_dir_error != NULL) {
|
|
|
|
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
|
2016-12-05 04:25:51 +00:00
|
|
|
"Can't get pathname of directory containing Wireshark: %s.\n"
|
2013-12-17 13:06:11 +00:00
|
|
|
"It won't be possible to capture traffic.\n"
|
|
|
|
"Report this to the Wireshark developers.",
|
|
|
|
init_progfile_dir_error);
|
|
|
|
g_free(init_progfile_dir_error);
|
|
|
|
}
|
1999-10-21 21:47:08 +00:00
|
|
|
|
2016-12-04 21:42:07 +00:00
|
|
|
wtap_init();
|
2014-01-18 14:20:02 +00:00
|
|
|
|
2013-12-02 08:30:29 +00:00
|
|
|
#ifdef HAVE_PLUGINS
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Register all the plugin types we have. */
|
2016-06-19 09:01:56 +00:00
|
|
|
epan_register_plugin_types(); /* Types known to libwireshark */
|
2015-12-04 00:09:57 +00:00
|
|
|
codec_register_plugin_types(); /* Types known to libwscodecs */
|
2013-12-02 08:30:29 +00:00
|
|
|
|
2016-06-19 09:01:56 +00:00
|
|
|
/* Scan for plugins. This does *not* call their registration routines;
|
|
|
|
that's done later. */
|
2016-09-05 23:26:29 +00:00
|
|
|
scan_plugins(REPORT_LOAD_FAILURE);
|
2016-06-19 09:01:56 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Register all libwiretap plugin modules. */
|
|
|
|
register_all_wiretap_modules();
|
2016-11-28 23:53:23 +00:00
|
|
|
#endif
|
2013-12-02 08:30:29 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Register all audio codec plugins. */
|
|
|
|
register_all_codecs();
|
2013-12-02 08:30:29 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
splash_update(RA_DISSECTORS, NULL, (gpointer)splash_win);
|
2004-07-04 12:15:41 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Register all dissectors; we must do this before checking for the
|
|
|
|
"-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. */
|
2015-10-28 00:41:23 +00:00
|
|
|
if (!epan_init(register_all_protocols,register_all_protocol_handoffs,
|
2017-01-25 09:16:35 +00:00
|
|
|
splash_update, (gpointer) splash_win)) {
|
|
|
|
ret = INIT_FAILED;
|
|
|
|
goto clean_exit;
|
|
|
|
}
|
2003-04-23 03:51:03 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
splash_update(RA_LISTENERS, NULL, (gpointer)splash_win);
|
2004-07-04 12:15:41 +00:00
|
|
|
|
2013-12-17 13:06:11 +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
|
|
|
|
2013-12-17 13:06:11 +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
|
2013-12-17 13:06:11 +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
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
register_all_tap_listeners();
|
2014-07-23 17:38:55 +00:00
|
|
|
conversation_table_set_gui_info(init_conversation_table);
|
2014-07-25 15:34:51 +00:00
|
|
|
hostlist_table_set_gui_info(init_hostlist_table);
|
Further refactor SRT stats.
Create "common" SRT tap data collection intended for all GUIs. Refactor/merge functionality of existing dissectors that have SRT support (AFP, DCERPC, Diameter, FC, GTP, LDAP, NCP, RPC, SCIS, SMB, and SMB2) for both TShark and GTK.
SMB and DCERPC "tap packet filtering" were different between TShark and GTK, so I went with GTK filter logic.
CAMEL "tap packet filtering" was different between TShark and GTK, so GTK filtering logic was pushed to the dissector and the TShark tap was left alone.
Change-Id: I7d6eaad0673fe628ef337f9165d7ed94f4a5e1cc
Reviewed-on: https://code.wireshark.org/review/8894
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-06-16 21:07:04 +00:00
|
|
|
srt_table_iterate_tables(register_service_response_tables, NULL);
|
2015-06-20 16:22:22 +00:00
|
|
|
rtd_table_iterate_tables(register_response_time_delay_tables, NULL);
|
2015-06-23 12:53:17 +00:00
|
|
|
new_stat_tap_iterate_tables(register_simple_stat_tables, NULL);
|
2006-02-16 15:27:03 +00:00
|
|
|
|
2017-01-04 09:53:29 +00:00
|
|
|
#ifdef HAVE_EXTCAP
|
|
|
|
splash_update(RA_EXTCAP, NULL, (gpointer)splash_win);
|
|
|
|
extcap_register_preferences();
|
|
|
|
#endif
|
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
splash_update(RA_PREFERENCES, NULL, (gpointer)splash_win);
|
2004-07-04 12:15:41 +00:00
|
|
|
|
2017-04-08 19:45:19 +00:00
|
|
|
global_commandline_info.prefs_p = read_configuration_files();
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Removed thread code:
|
2014-02-07 19:14:52 +00:00
|
|
|
* https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=9e277ae6154fd04bf6a0a34ec5655a73e5a736a3
|
2013-12-17 13:06:11 +00:00
|
|
|
*/
|
2008-04-21 10:57:32 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
cap_file_init(&cfile);
|
1998-11-17 04:29:13 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Fill in capture options with values from the preferences */
|
|
|
|
prefs_to_capture_opts();
|
2008-09-25 06:21:02 +00:00
|
|
|
|
2012-01-25 13:04:32 +00:00
|
|
|
/*#ifdef HAVE_LIBPCAP
|
2013-12-17 13:06:11 +00:00
|
|
|
fill_in_local_interfaces();
|
2012-01-25 13:04:32 +00:00
|
|
|
#endif*/
|
2014-12-26 22:37:31 +00:00
|
|
|
|
2016-06-18 20:49:23 +00:00
|
|
|
/* Now get our args */
|
2016-06-28 02:54:42 +00:00
|
|
|
commandline_other_options(argc, argv, TRUE);
|
2012-08-01 22:32:14 +00:00
|
|
|
|
2012-01-25 13:04:32 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2016-06-24 23:48:23 +00:00
|
|
|
splash_update(RA_INTERFACES, NULL, (gpointer)splash_win);
|
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
fill_in_local_interfaces(main_window_update);
|
2003-11-01 02:30:18 +00:00
|
|
|
|
2017-08-07 14:38:52 +00:00
|
|
|
if (global_commandline_info.list_link_layer_types)
|
|
|
|
caps_queries |= CAPS_QUERY_LINK_TYPES;
|
|
|
|
if (global_commandline_info.list_timestamp_types)
|
|
|
|
caps_queries |= CAPS_QUERY_TIMESTAMP_TYPES;
|
|
|
|
|
|
|
|
if (global_commandline_info.start_capture || caps_queries) {
|
|
|
|
/* We're supposed to do a live capture or get a list of link-layer/timestamp
|
2013-12-17 13:06:11 +00:00
|
|
|
types for a live capture device; if the user didn't specify an
|
|
|
|
interface to use, pick a default. */
|
2017-01-25 09:16:35 +00:00
|
|
|
ret = capture_opts_default_iface_if_necessary(&global_capture_opts,
|
2016-06-28 01:40:09 +00:00
|
|
|
((global_commandline_info.prefs_p->capture_device) && (*global_commandline_info.prefs_p->capture_device != '\0')) ? get_if_name(global_commandline_info.prefs_p->capture_device) : NULL);
|
2017-01-25 09:16:35 +00:00
|
|
|
if (ret != 0) {
|
|
|
|
goto clean_exit;
|
2013-12-17 13:06:11 +00:00
|
|
|
}
|
1999-06-15 03:46:46 +00:00
|
|
|
}
|
2003-11-01 02:30:18 +00:00
|
|
|
|
2017-08-07 14:38:52 +00:00
|
|
|
if (caps_queries) {
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Get the list of link-layer types for the capture devices. */
|
|
|
|
if_capabilities_t *caps;
|
|
|
|
guint i;
|
|
|
|
interface_t device;
|
|
|
|
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
2017-08-07 14:38:52 +00:00
|
|
|
int if_caps_queries = caps_queries;
|
2013-12-17 13:06:11 +00:00
|
|
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
|
|
|
if (device.selected) {
|
2015-07-17 15:01:27 +00:00
|
|
|
gchar* auth_str = NULL;
|
|
|
|
#ifdef HAVE_PCAP_REMOTE
|
|
|
|
if (device.remote_opts.remote_host_opts.auth_type == CAPTURE_AUTH_PWD) {
|
|
|
|
auth_str = g_strdup_printf("%s:%s", device.remote_opts.remote_host_opts.auth_username,
|
|
|
|
device.remote_opts.remote_host_opts.auth_password);
|
|
|
|
}
|
|
|
|
#endif
|
2012-01-25 20:26:34 +00:00
|
|
|
#if defined(HAVE_PCAP_CREATE)
|
2015-07-17 15:01:27 +00:00
|
|
|
caps = capture_get_if_capabilities(device.name, device.monitor_mode_supported, auth_str, &err_str, main_window_update);
|
2012-01-25 13:04:32 +00:00
|
|
|
#else
|
2015-07-17 15:01:27 +00:00
|
|
|
caps = capture_get_if_capabilities(device.name, FALSE, auth_str, &err_str,main_window_update);
|
2012-01-25 13:04:32 +00:00
|
|
|
#endif
|
2015-07-17 15:01:27 +00:00
|
|
|
g_free(auth_str);
|
2013-12-17 13:06:11 +00:00
|
|
|
if (caps == NULL) {
|
|
|
|
cmdarg_err("%s", err_str);
|
|
|
|
g_free(err_str);
|
2017-01-25 09:16:35 +00:00
|
|
|
ret = INVALID_CAPABILITY;
|
|
|
|
goto clean_exit;
|
2013-12-17 13:06:11 +00:00
|
|
|
}
|
2017-01-04 22:14:21 +00:00
|
|
|
if (caps->data_link_types == NULL) {
|
|
|
|
cmdarg_err("The capture device \"%s\" has no data link types.", device.name);
|
2017-01-25 09:16:35 +00:00
|
|
|
ret = INVALID_LINK_TYPE;
|
|
|
|
goto clean_exit;
|
2017-01-04 22:14:21 +00:00
|
|
|
}
|
2013-04-25 05:47:11 +00:00
|
|
|
#ifdef _WIN32
|
2017-01-04 22:14:21 +00:00
|
|
|
create_console();
|
2013-04-25 05:47:11 +00:00
|
|
|
#endif /* _WIN32 */
|
2012-01-25 20:26:34 +00:00
|
|
|
#if defined(HAVE_PCAP_CREATE)
|
2017-08-07 14:38:52 +00:00
|
|
|
if (device.monitor_mode_supported)
|
|
|
|
if_caps_queries |= CAPS_MONITOR_MODE;
|
2012-01-25 13:04:32 +00:00
|
|
|
#endif
|
2017-08-07 14:38:52 +00:00
|
|
|
capture_opts_print_if_capabilities(caps, device.name, if_caps_queries);
|
2013-04-25 05:47:11 +00:00
|
|
|
#ifdef _WIN32
|
2017-01-04 22:14:21 +00:00
|
|
|
destroy_console();
|
2013-04-25 05:47:11 +00:00
|
|
|
#endif /* _WIN32 */
|
2017-01-04 22:14:21 +00:00
|
|
|
free_if_capabilities(caps);
|
2013-12-17 13:06:11 +00:00
|
|
|
}
|
|
|
|
}
|
2017-01-25 09:16:35 +00:00
|
|
|
ret = EXIT_SUCCESS;
|
|
|
|
goto clean_exit;
|
2010-05-13 17:37:39 +00:00
|
|
|
}
|
2017-01-04 22:14:21 +00:00
|
|
|
capture_opts_trim_snaplen(&global_capture_opts, MIN_PACKET_SIZE);
|
|
|
|
capture_opts_trim_ring_num_files(&global_capture_opts);
|
2005-02-06 21:20:35 +00:00
|
|
|
#endif /* HAVE_LIBPCAP */
|
1999-06-15 03:46:46 +00:00
|
|
|
|
2013-12-17 13:06:11 +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();
|
2003-11-01 02:30:18 +00:00
|
|
|
|
2011-07-08 13:47:16 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2013-12-17 13:06:11 +00:00
|
|
|
if ((global_capture_opts.num_selected == 0) &&
|
2016-06-19 22:28:39 +00:00
|
|
|
((prefs.capture_device != NULL) &&
|
2016-06-28 01:40:09 +00:00
|
|
|
(global_commandline_info.prefs_p != NULL) &&
|
|
|
|
(*global_commandline_info.prefs_p->capture_device != '\0'))) {
|
2013-12-17 13:06:11 +00:00
|
|
|
guint i;
|
|
|
|
interface_t device;
|
|
|
|
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
|
|
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
|
|
|
if (!device.hidden && strstr(prefs.capture_device, device.name) != NULL) {
|
|
|
|
device.selected = TRUE;
|
|
|
|
global_capture_opts.num_selected++;
|
|
|
|
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
|
|
|
|
g_array_insert_val(global_capture_opts.all_ifaces, i, device);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (global_capture_opts.num_selected == 0 && global_capture_opts.all_ifaces->len == 1) {
|
|
|
|
interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, 0);
|
2012-01-25 13:04:32 +00:00
|
|
|
device.selected = TRUE;
|
|
|
|
global_capture_opts.num_selected++;
|
2013-12-17 13:06:11 +00:00
|
|
|
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, 0);
|
|
|
|
g_array_insert_val(global_capture_opts.all_ifaces, 0, device);
|
2011-07-21 15:23:46 +00:00
|
|
|
}
|
2011-07-08 13:47:16 +00:00
|
|
|
#endif
|
|
|
|
|
2017-04-08 19:45:19 +00:00
|
|
|
/*
|
|
|
|
* Enabled and disabled protocols and heuristic dissectors as per
|
|
|
|
* command-line options.
|
|
|
|
*/
|
|
|
|
if (!setup_enabled_and_disabled_protocols()) {
|
|
|
|
ret = INVALID_OPTION;
|
|
|
|
goto clean_exit;
|
2015-07-14 04:28:49 +00:00
|
|
|
}
|
|
|
|
|
2016-06-28 01:40:09 +00:00
|
|
|
build_column_format_array(&cfile.cinfo, global_commandline_info.prefs_p->num_cols, TRUE);
|
2003-12-02 23:14:32 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* read in rc file from global and personal configuration paths. */
|
|
|
|
rc_file = get_datafile_path(RC_FILE);
|
2011-08-17 15:29:15 +00:00
|
|
|
#if GTK_CHECK_VERSION(3,0,0)
|
2013-12-17 13:06:11 +00:00
|
|
|
/* XXX resolve later */
|
2011-08-17 15:29:15 +00:00
|
|
|
#else
|
2013-12-17 13:06:11 +00:00
|
|
|
gtk_rc_parse(rc_file);
|
|
|
|
g_free(rc_file);
|
|
|
|
rc_file = get_persconffile_path(RC_FILE, FALSE);
|
|
|
|
gtk_rc_parse(rc_file);
|
2011-08-17 15:29:15 +00:00
|
|
|
#endif
|
2013-12-17 13:06:11 +00:00
|
|
|
g_free(rc_file);
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
font_init();
|
2001-03-02 23:10:12 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
macros_init();
|
2010-08-30 08:47:26 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
stock_icons_init();
|
2008-04-12 00:49:20 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* close the splash screen, as we are going to open the main window now */
|
|
|
|
splash_destroy(splash_win);
|
2004-07-04 12:15:41 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/************************************************************************/
|
|
|
|
/* Everything is prepared now, preferences and command line was read in */
|
2005-02-06 21:20:35 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Pop up the main window. */
|
2016-06-28 01:40:09 +00:00
|
|
|
create_main_window(pl_size, tv_size, bv_size, global_commandline_info.prefs_p);
|
2005-02-07 00:31:45 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Read the dynamic part of the recent file, as we have the gui now ready for it. */
|
2015-10-04 09:31:19 +00:00
|
|
|
if (!recent_read_dynamic(&rf_path, &rf_open_errno)) {
|
2013-12-17 13:06:11 +00:00
|
|
|
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
|
|
|
|
"Could not open recent file\n\"%s\": %s.",
|
|
|
|
rf_path, g_strerror(rf_open_errno));
|
2015-10-04 09:31:19 +00:00
|
|
|
g_free(rf_path);
|
2013-12-17 13:06:11 +00:00
|
|
|
}
|
2008-04-28 12:35:03 +00:00
|
|
|
|
2015-12-22 20:07:00 +00:00
|
|
|
packet_list_enable_color(recent.packet_list_colorize);
|
2005-02-07 00:31:45 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* rearrange all the widgets as we now have all recent settings ready for this */
|
|
|
|
main_widgets_rearrange();
|
2005-02-07 00:31:45 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Fill in column titles. This must be done after the top level window
|
2005-02-07 00:31:45 +00:00
|
|
|
is displayed.
|
|
|
|
|
|
|
|
XXX - is that still true, with fixed-width columns? */
|
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
menu_recent_read_finished();
|
2008-02-22 04:56:26 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2013-12-17 13:06:11 +00:00
|
|
|
main_auto_scroll_live_changed(auto_scroll_live);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
switch (user_font_apply()) {
|
|
|
|
case FA_SUCCESS:
|
|
|
|
break;
|
2015-12-12 01:00:05 +00:00
|
|
|
case FA_ZOOMED_TOO_FAR:
|
|
|
|
/* The zoom level is too big for this font; turn off zooming. */
|
|
|
|
recent.gui_zoom_level = 0;
|
|
|
|
break;
|
2013-12-17 13:06:11 +00:00
|
|
|
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 */
|
|
|
|
recent.gui_zoom_level = 0;
|
|
|
|
/* XXX: would it be a good idea to disable zooming (insensitive GUI)? */
|
2015-12-12 01:00:05 +00:00
|
|
|
break;
|
2013-12-17 13:06:11 +00:00
|
|
|
}
|
2004-02-01 20:28:11 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
dnd_init(top_level);
|
2004-02-01 20:28:11 +00:00
|
|
|
|
2016-01-01 04:14:08 +00:00
|
|
|
if (!color_filters_init(&err_msg, color_filter_add_cb)) {
|
2015-12-22 20:07:00 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
|
|
|
g_free(err_msg);
|
|
|
|
}
|
2011-10-11 01:25:54 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2013-12-17 13:06:11 +00:00
|
|
|
capture_filter_init();
|
2011-10-11 01:25:54 +00:00
|
|
|
#endif
|
2000-01-15 12:54:24 +00:00
|
|
|
|
2013-12-17 13:06:11 +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
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
g_timeout_add(info_update_freq, resolv_update_cb, NULL);
|
2010-04-29 00:09:01 +00:00
|
|
|
|
2016-01-09 18:52:19 +00:00
|
|
|
/* this is to keep tap extensions updating once every 3 seconds */
|
2016-06-28 01:40:09 +00:00
|
|
|
tap_update_timer_id = g_timeout_add(global_commandline_info.prefs_p->tap_update_interval, tap_update_cb, NULL);
|
2016-01-09 18:52:19 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* If we were given the name of a capture file, read it in now;
|
2005-02-07 00:31:45 +00:00
|
|
|
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. */
|
2016-06-28 01:40:09 +00:00
|
|
|
if (global_commandline_info.cf_name) {
|
2013-12-17 13:06:11 +00:00
|
|
|
show_main_window(TRUE);
|
2016-06-28 01:40:09 +00:00
|
|
|
check_and_warn_user_startup(global_commandline_info.cf_name);
|
|
|
|
if (global_commandline_info.rfilter != NULL) {
|
|
|
|
if (!dfilter_compile(global_commandline_info.rfilter, &rfcode, &err_msg)) {
|
|
|
|
bad_dfilter_alert_box(top_level, global_commandline_info.rfilter, err_msg);
|
2015-01-18 10:22:19 +00:00
|
|
|
g_free(err_msg);
|
2013-12-17 13:06:11 +00:00
|
|
|
rfilter_parse_failed = TRUE;
|
2009-11-20 18:52:01 +00:00
|
|
|
}
|
2000-01-15 12:54:24 +00:00
|
|
|
}
|
2014-03-04 11:19:01 +00:00
|
|
|
if (ex_opt_count("read_format") > 0) {
|
|
|
|
in_file_type = open_info_name_to_type(ex_opt_get_next("read_format"));
|
|
|
|
}
|
2013-12-17 13:06:11 +00:00
|
|
|
if (!rfilter_parse_failed) {
|
2016-06-28 01:40:09 +00:00
|
|
|
if (cf_open(&cfile, global_commandline_info.cf_name, in_file_type, FALSE, &err) == CF_OK) {
|
2013-12-17 13:06:11 +00:00
|
|
|
/* "cf_open()" succeeded, so it closed the previous
|
|
|
|
capture file, and thus destroyed any previous read filter
|
|
|
|
attached to "cf". */
|
|
|
|
|
|
|
|
cfile.rfcode = rfcode;
|
|
|
|
/* Open stat windows; we do so after creating the main window,
|
|
|
|
to avoid GTK warnings, and after successfully 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();
|
|
|
|
|
|
|
|
/* Read the capture file. */
|
|
|
|
switch (cf_read(&cfile, FALSE)) {
|
|
|
|
|
|
|
|
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. */
|
|
|
|
/* if the user told us to jump to a specific packet, do it now */
|
2016-06-28 01:40:09 +00:00
|
|
|
if(global_commandline_info.go_to_packet != 0) {
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Jump to the specified frame number, kept for backward
|
|
|
|
compatibility. */
|
2016-06-28 01:40:09 +00:00
|
|
|
cf_goto_frame(&cfile, global_commandline_info.go_to_packet);
|
|
|
|
} else if (global_commandline_info.jfilter != NULL) {
|
2013-12-17 13:06:11 +00:00
|
|
|
/* try to compile given filter */
|
2016-06-28 01:40:09 +00:00
|
|
|
if (!dfilter_compile(global_commandline_info.jfilter, &jump_to_filter, &err_msg)) {
|
|
|
|
bad_dfilter_alert_box(top_level, global_commandline_info.jfilter, err_msg);
|
2015-01-18 10:22:19 +00:00
|
|
|
g_free(err_msg);
|
2013-12-17 13:06:11 +00:00
|
|
|
} else {
|
|
|
|
/* Filter ok, jump to the first packet matching the filter
|
|
|
|
conditions. Default search direction is forward, but if
|
|
|
|
option d was given, search backwards */
|
2016-06-28 01:40:09 +00:00
|
|
|
cf_find_packet_dfilter(&cfile, jump_to_filter, global_commandline_info.jump_backwards);
|
2013-12-17 13:06:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CF_READ_ABORTED:
|
|
|
|
/* Exit now. */
|
|
|
|
exit(0);
|
|
|
|
break;
|
|
|
|
}
|
2010-08-20 21:56:52 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* If the filename is not the absolute path, prepend the current dir. This happens
|
|
|
|
when wireshark is invoked from a cmd shell (e.g.,'wireshark -r file.pcap'). */
|
2016-06-28 01:40:09 +00:00
|
|
|
if (!g_path_is_absolute(global_commandline_info.cf_name)) {
|
|
|
|
char *old_cf_name = global_commandline_info.cf_name;
|
2013-12-17 13:06:11 +00:00
|
|
|
char *pwd = g_get_current_dir();
|
2016-06-28 01:40:09 +00:00
|
|
|
global_commandline_info.cf_name = g_strdup_printf("%s%s%s", pwd, G_DIR_SEPARATOR_S, global_commandline_info.cf_name);
|
2013-12-17 13:06:11 +00:00
|
|
|
g_free(old_cf_name);
|
|
|
|
g_free(pwd);
|
|
|
|
}
|
2010-08-20 21:56:52 +00:00
|
|
|
|
2013-12-17 13:06:11 +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. */
|
2016-06-28 01:40:09 +00:00
|
|
|
s = get_dirname(global_commandline_info.cf_name);
|
2013-12-17 13:06:11 +00:00
|
|
|
set_last_open_dir(s);
|
2016-06-28 01:40:09 +00:00
|
|
|
g_free(global_commandline_info.cf_name);
|
|
|
|
global_commandline_info.cf_name = NULL;
|
2013-12-17 13:06:11 +00:00
|
|
|
} else {
|
2017-08-26 08:30:47 +00:00
|
|
|
dfilter_free(rfcode);
|
2013-12-17 13:06:11 +00:00
|
|
|
cfile.rfcode = NULL;
|
|
|
|
show_main_window(FALSE);
|
|
|
|
/* Don't call check_and_warn_user_startup(): we did it above */
|
|
|
|
main_set_for_capture_in_progress(FALSE);
|
|
|
|
set_capture_if_dialog_for_capture_in_progress(FALSE);
|
|
|
|
}
|
|
|
|
}
|
2011-07-16 11:07:32 +00:00
|
|
|
} else {
|
2013-12-17 13:06:11 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2016-06-28 01:40:09 +00:00
|
|
|
if (global_commandline_info.start_capture) {
|
2013-12-17 13:06:11 +00:00
|
|
|
if (global_capture_opts.save_file != NULL) {
|
|
|
|
/* Save the directory name for future file dialogs. */
|
|
|
|
/* (get_dirname overwrites filename) */
|
2016-02-03 17:28:46 +00:00
|
|
|
s = g_strdup(global_capture_opts.save_file);
|
|
|
|
set_last_open_dir(get_dirname(s));
|
2013-12-17 13:06:11 +00:00
|
|
|
g_free(s);
|
|
|
|
}
|
|
|
|
/* "-k" was specified; start a capture. */
|
|
|
|
show_main_window(FALSE);
|
2016-06-28 01:40:09 +00:00
|
|
|
check_and_warn_user_startup(global_commandline_info.cf_name);
|
2013-12-17 13:06:11 +00:00
|
|
|
|
|
|
|
/* If no user interfaces were specified on the command line,
|
|
|
|
copy the list of selected interfaces to the set of interfaces
|
|
|
|
to use for this capture. */
|
|
|
|
if (global_capture_opts.ifaces->len == 0)
|
|
|
|
collect_ifaces(&global_capture_opts);
|
2015-12-17 04:15:03 +00:00
|
|
|
if (capture_start(&global_capture_opts, &global_capture_session, &global_info_data,main_window_update)) {
|
2013-12-17 13:06:11 +00:00
|
|
|
/* The capture started. Open stat windows; we do so after creating
|
|
|
|
the main window, to avoid GTK warnings, and after successfully
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
show_main_window(FALSE);
|
2016-06-28 01:40:09 +00:00
|
|
|
check_and_warn_user_startup(global_commandline_info.cf_name);
|
2013-12-17 13:06:11 +00:00
|
|
|
main_set_for_capture_in_progress(FALSE);
|
|
|
|
set_capture_if_dialog_for_capture_in_progress(FALSE);
|
|
|
|
}
|
2011-06-27 00:09:03 +00:00
|
|
|
/* if the user didn't supply a capture filter, use the one to filter out remote connections like SSH */
|
2016-06-28 01:40:09 +00:00
|
|
|
if (!global_commandline_info.start_capture && !global_capture_opts.default_options.cfilter) {
|
2013-12-17 13:06:11 +00:00
|
|
|
global_capture_opts.default_options.cfilter = g_strdup(get_conn_cfilter());
|
|
|
|
}
|
2004-04-16 23:57:54 +00:00
|
|
|
#else /* HAVE_LIBPCAP */
|
2013-12-17 13:06:11 +00:00
|
|
|
show_main_window(FALSE);
|
2016-06-28 01:40:09 +00:00
|
|
|
check_and_warn_user_startup(global_commandline_info.cf_name);
|
2013-12-17 13:06:11 +00:00
|
|
|
main_set_for_capture_in_progress(FALSE);
|
|
|
|
set_capture_if_dialog_for_capture_in_progress(FALSE);
|
2004-04-16 23:57:54 +00:00
|
|
|
#endif /* HAVE_LIBPCAP */
|
2013-12-17 13:06:11 +00:00
|
|
|
}
|
2004-01-08 20:39:51 +00:00
|
|
|
|
2016-06-28 01:40:09 +00:00
|
|
|
if (global_commandline_info.dfilter) {
|
2013-12-17 13:06:11 +00:00
|
|
|
GtkWidget *filter_te;
|
|
|
|
filter_te = gtk_bin_get_child(GTK_BIN(g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY)));
|
2016-06-28 01:40:09 +00:00
|
|
|
gtk_entry_set_text(GTK_ENTRY(filter_te), global_commandline_info.dfilter);
|
2013-03-28 14:54:33 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Run the display filter so it goes in effect. */
|
2016-06-28 01:40:09 +00:00
|
|
|
main_filter_packets(&cfile, global_commandline_info.dfilter, FALSE);
|
2013-12-17 13:06:11 +00:00
|
|
|
}
|
2013-03-28 14:54:33 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
profile_store_persconffiles (FALSE);
|
2009-12-21 12:32:31 +00:00
|
|
|
|
2010-05-25 00:35:44 +00:00
|
|
|
#ifdef HAVE_GTKOSXAPPLICATION
|
2013-12-17 13:06:11 +00:00
|
|
|
theApp = (GtkosxApplication *)g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
|
2016-02-21 17:10:03 +00:00
|
|
|
#ifdef HAVE_GDK_GRESOURCE
|
2015-10-17 12:47:17 +00:00
|
|
|
gtkosx_application_set_dock_icon_pixbuf(theApp, ws_gdk_pixbuf_new_from_resource("/org/wireshark/image/wsicon64.png"));
|
|
|
|
#else
|
2013-12-17 13:06:11 +00:00
|
|
|
gtkosx_application_set_dock_icon_pixbuf(theApp, gdk_pixbuf_new_from_inline(-1, wsicon_64_pb_data, FALSE, NULL));
|
2015-10-17 12:47:17 +00:00
|
|
|
#endif
|
2013-12-17 13:06:11 +00:00
|
|
|
gtkosx_application_ready(theApp);
|
2010-05-25 00:35:44 +00:00
|
|
|
#endif
|
2010-05-28 20:19:55 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "Wireshark is up and ready to go");
|
2007-11-26 18:38:03 +00:00
|
|
|
|
2012-06-28 19:10:40 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2013-12-17 13:06:11 +00:00
|
|
|
gtk_iface_mon_start();
|
2012-06-28 19:10:40 +00:00
|
|
|
#endif
|
2012-06-28 16:21:51 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
software_update_init();
|
2013-02-20 01:19:42 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* we'll enter the GTK loop now and hand the control over to GTK ... */
|
|
|
|
gtk_main();
|
|
|
|
/* ... back from GTK, we're going down now! */
|
2000-01-15 12:54:24 +00:00
|
|
|
|
2012-06-28 19:10:40 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2013-12-17 13:06:11 +00:00
|
|
|
gtk_iface_mon_stop();
|
2012-06-28 19:10:40 +00:00
|
|
|
#endif
|
2012-06-28 16:21:51 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
epan_cleanup();
|
2000-01-15 12:54:24 +00:00
|
|
|
|
2016-09-12 13:07:36 +00:00
|
|
|
#ifdef HAVE_EXTCAP
|
2016-09-10 23:16:24 +00:00
|
|
|
extcap_cleanup();
|
2016-09-12 13:07:36 +00:00
|
|
|
#endif
|
2016-09-10 23:16:24 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
AirPDcapDestroyContext(&airpdcap_ctx);
|
2006-12-05 19:24:25 +00:00
|
|
|
|
2010-05-25 00:35:44 +00:00
|
|
|
#ifdef HAVE_GTKOSXAPPLICATION
|
2013-12-17 13:06:11 +00:00
|
|
|
g_object_unref(theApp);
|
2010-05-25 00:35:44 +00:00
|
|
|
#endif
|
2010-05-28 20:19:55 +00:00
|
|
|
|
2014-05-01 12:29:52 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
/* hide the (unresponsive) main window, while asking the user to close the console window */
|
2014-06-27 12:11:14 +00:00
|
|
|
if (G_IS_OBJECT(top_level))
|
|
|
|
gtk_widget_hide(top_level);
|
2014-05-01 12:29:52 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
software_update_cleanup();
|
2013-02-19 22:21:17 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Shutdown windows sockets */
|
|
|
|
WSACleanup();
|
2001-02-20 04:09:37 +00:00
|
|
|
|
2013-12-17 13:06:11 +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. */
|
|
|
|
destroy_console();
|
2000-09-14 22:59:08 +00:00
|
|
|
#endif
|
|
|
|
|
2016-02-21 17:10:03 +00:00
|
|
|
#ifdef HAVE_GDK_GRESOURCE
|
2015-10-17 12:47:17 +00:00
|
|
|
main_unregister_resource();
|
|
|
|
#endif
|
|
|
|
|
2017-01-25 09:16:35 +00:00
|
|
|
clean_exit:
|
2017-02-03 00:12:23 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2017-01-25 09:16:35 +00:00
|
|
|
capture_opts_cleanup(&global_capture_opts);
|
2017-02-03 00:12:23 +00:00
|
|
|
#endif
|
2017-02-03 21:41:31 +00:00
|
|
|
col_cleanup(&cfile.cinfo);
|
2017-02-03 22:15:56 +00:00
|
|
|
free_filter_lists();
|
2017-02-04 15:26:34 +00:00
|
|
|
wtap_cleanup();
|
2017-02-08 13:25:57 +00:00
|
|
|
free_progdirs();
|
|
|
|
#ifdef HAVE_PLUGINS
|
|
|
|
plugins_cleanup();
|
|
|
|
#endif
|
2017-01-25 09:16:35 +00:00
|
|
|
return ret;
|
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,
|
2012-01-25 13:04:32 +00:00
|
|
|
struct HINSTANCE__ *hPrevInstance,
|
|
|
|
char *lpszCmdLine,
|
|
|
|
int nCmdShow)
|
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
|
|
|
{
|
2013-12-17 13:06:11 +00:00
|
|
|
INITCOMMONCONTROLSEX comm_ctrl;
|
2006-02-16 15:27:03 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/*
|
|
|
|
* Initialize our DLL search path. MUST be called before LoadLibrary
|
|
|
|
* or g_module_open.
|
|
|
|
*/
|
|
|
|
ws_init_dll_search_path();
|
|
|
|
|
|
|
|
/* 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);
|
2006-02-16 15:27:03 +00:00
|
|
|
|
2016-01-29 18:26:28 +00:00
|
|
|
/* RichEd20.DLL is needed for native file dialog filter entries. */
|
2013-12-17 13:06:11 +00:00
|
|
|
ws_load_library("riched20.dll");
|
2006-02-16 15:27:03 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
set_has_console(FALSE);
|
|
|
|
set_console_wait(FALSE);
|
|
|
|
return main (__argc, __argv);
|
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
|
|
|
}
|
|
|
|
|
2005-05-26 17:50:27 +00:00
|
|
|
#endif /* _WIN32 */
|
|
|
|
|
2001-02-20 04:09:37 +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
|
|
|
|
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
|
|
|
case(layout_pane_content_plist):
|
|
|
|
return pkt_scrollw;
|
|
|
|
case(layout_pane_content_pdetails):
|
|
|
|
return tv_scrollw;
|
|
|
|
case(layout_pane_content_pbytes):
|
2010-01-29 19:09:01 +00:00
|
|
|
return byte_nb_ptr_gbl;
|
2004-04-29 17:03:27 +00:00
|
|
|
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;
|
2012-02-07 11:12:17 +00:00
|
|
|
gboolean split_top_left = FALSE;
|
2004-01-19 00:42:12 +00:00
|
|
|
|
|
|
|
/* be a bit faster */
|
|
|
|
gtk_widget_hide(main_vbox);
|
|
|
|
|
2008-08-20 19:27:07 +00:00
|
|
|
/* be sure we don't lose a widget while rearranging */
|
2009-04-10 14:10:49 +00:00
|
|
|
g_object_ref(G_OBJECT(menubar));
|
|
|
|
g_object_ref(G_OBJECT(main_tb));
|
|
|
|
g_object_ref(G_OBJECT(filter_tb));
|
2012-06-19 14:37:46 +00:00
|
|
|
g_object_ref(G_OBJECT(wireless_tb));
|
2009-04-10 14:10:49 +00:00
|
|
|
g_object_ref(G_OBJECT(pkt_scrollw));
|
|
|
|
g_object_ref(G_OBJECT(tv_scrollw));
|
2010-01-29 19:09:01 +00:00
|
|
|
g_object_ref(G_OBJECT(byte_nb_ptr_gbl));
|
2009-04-10 14:10:49 +00:00
|
|
|
g_object_ref(G_OBJECT(statusbar));
|
|
|
|
g_object_ref(G_OBJECT(main_pane_v1));
|
|
|
|
g_object_ref(G_OBJECT(main_pane_v2));
|
|
|
|
g_object_ref(G_OBJECT(main_pane_h1));
|
|
|
|
g_object_ref(G_OBJECT(main_pane_h2));
|
|
|
|
g_object_ref(G_OBJECT(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);
|
|
|
|
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
|
|
|
|
2008-04-12 15:55:27 +00:00
|
|
|
statusbar_widgets_emptying(statusbar);
|
|
|
|
|
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-11-05 00:54:17 +00:00
|
|
|
/* airpcap toolbar */
|
2012-06-19 14:37:46 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(main_vbox), wireless_tb, FALSE, TRUE, 1);
|
2006-08-16 18:01:25 +00:00
|
|
|
|
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;
|
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
|
|
|
|
2012-07-18 19:44:54 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(main_vbox), main_first_pane, TRUE, TRUE, 0);
|
2004-04-29 17:03:27 +00:00
|
|
|
|
2005-02-05 23:12:44 +00:00
|
|
|
/* welcome pane */
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vbox), welcome_pane, TRUE, TRUE, 0);
|
|
|
|
|
2008-04-12 15:55:27 +00:00
|
|
|
/* statusbar */
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vbox), statusbar, 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) {
|
2008-04-12 15:55:27 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(statusbar), filter_tb, FALSE, TRUE, 1);
|
2004-05-04 20:49:33 +00:00
|
|
|
}
|
|
|
|
|
2008-04-12 15:55:27 +00:00
|
|
|
/* statusbar widgets */
|
|
|
|
statusbar_widgets_pack(statusbar);
|
2004-05-04 21:08:03 +00:00
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
2013-03-11 06:47:34 +00:00
|
|
|
gboolean *is_visible = ( gboolean *)data;
|
2004-05-04 20:49:33 +00:00
|
|
|
|
|
|
|
if (!*is_visible) {
|
2011-02-01 07:15:14 +00:00
|
|
|
if (gtk_widget_get_visible(widget))
|
2004-05-04 20:49:33 +00:00
|
|
|
*is_visible = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-22 21:22:56 +00:00
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2008-04-12 15:55:27 +00:00
|
|
|
statusbar_widgets_show_or_hide(statusbar);
|
2004-05-04 21:08:03 +00:00
|
|
|
|
|
|
|
if (recent.filter_toolbar_show) {
|
|
|
|
gtk_widget_show(filter_tb);
|
|
|
|
} else {
|
|
|
|
gtk_widget_hide(filter_tb);
|
|
|
|
}
|
|
|
|
|
2012-06-19 12:42:06 +00:00
|
|
|
if (recent.wireless_toolbar_show) {
|
2012-06-19 14:37:46 +00:00
|
|
|
gtk_widget_show(wireless_tb);
|
2006-08-16 18:01:25 +00:00
|
|
|
} else {
|
2012-06-19 14:37:46 +00:00
|
|
|
gtk_widget_hide(wireless_tb);
|
2006-08-16 18:01:25 +00:00
|
|
|
}
|
|
|
|
|
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) {
|
2010-01-29 19:09:01 +00:00
|
|
|
gtk_widget_show(byte_nb_ptr_gbl);
|
2004-04-29 17:03:27 +00:00
|
|
|
} else {
|
2010-01-29 19:09:01 +00:00
|
|
|
gtk_widget_hide(byte_nb_ptr_gbl);
|
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);
|
|
|
|
}
|
2004-01-19 00:42:12 +00:00
|
|
|
}
|
|
|
|
|
2004-05-17 21:15:28 +00:00
|
|
|
|
|
|
|
/* called, when the window state changes (minimized, maximized, ...) */
|
2010-07-30 12:41:56 +00:00
|
|
|
static gboolean
|
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;
|
|
|
|
}
|
|
|
|
|
2008-04-04 23:14:27 +00:00
|
|
|
|
2006-10-19 00:48:03 +00:00
|
|
|
|
2008-06-29 12:55:14 +00:00
|
|
|
#define NO_SHIFT_MOD_MASK (GDK_MODIFIER_MASK & ~(GDK_SHIFT_MASK|GDK_MOD2_MASK|GDK_LOCK_MASK))
|
2010-07-30 12:41:56 +00:00
|
|
|
static gboolean
|
2009-03-16 19:43:45 +00:00
|
|
|
top_level_key_pressed_cb(GtkWidget *w _U_, GdkEventKey *event, gpointer user_data _U_)
|
2006-11-18 05:05:18 +00:00
|
|
|
{
|
2006-11-18 17:17:28 +00:00
|
|
|
if (event->keyval == GDK_F8) {
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_next();
|
2012-01-25 13:04:32 +00:00
|
|
|
return TRUE;
|
2006-11-18 17:17:28 +00:00
|
|
|
} else if (event->keyval == GDK_F7) {
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_prev();
|
2012-01-25 13:04:32 +00:00
|
|
|
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
|
2013-12-21 15:12:11 +00:00
|
|
|
* don't explicitly say so, g_ascii_isprint() should work as expected
|
2006-11-25 06:15:51 +00:00
|
|
|
* for values < 127.
|
|
|
|
*/
|
2013-12-29 23:29:03 +00:00
|
|
|
} else if (event->keyval < 256 && g_ascii_isprint(event->keyval)) {
|
2012-01-25 13:04:32 +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);
|
2012-01-25 13:04:32 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
2006-11-18 05:05:18 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-01-15 12:54:24 +00:00
|
|
|
static void
|
2013-01-22 18:27:18 +00:00
|
|
|
create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs_p
|
|
|
|
#if !defined(HAVE_IGE_MAC_INTEGRATION) && !defined (HAVE_GTKOSXAPPLICATION)
|
|
|
|
_U_
|
|
|
|
#endif
|
|
|
|
)
|
2000-01-15 12:54:24 +00:00
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkAccelGroup *accel;
|
2006-08-16 18:01:25 +00:00
|
|
|
|
2010-08-08 21:26:39 +00:00
|
|
|
/* Main window */
|
2010-08-07 14:37:37 +00:00
|
|
|
top_level = window_new(GTK_WINDOW_TOPLEVEL, "");
|
2013-04-01 00:21:44 +00:00
|
|
|
set_titlebar_for_capture_file(NULL);
|
2004-01-20 18:47:25 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_widget_set_name(top_level, "main window");
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(top_level, "delete_event", G_CALLBACK(main_window_delete_event_cb),
|
2002-11-10 11:36:39 +00:00
|
|
|
NULL);
|
2011-08-12 17:26:20 +00:00
|
|
|
g_signal_connect(G_OBJECT(top_level), "window_state_event",
|
2008-04-11 23:16:06 +00:00
|
|
|
G_CALLBACK(window_state_event_cb), NULL);
|
2011-08-12 17:26:20 +00:00
|
|
|
g_signal_connect(G_OBJECT(top_level), "key-press-event",
|
2008-04-11 23:16:06 +00:00
|
|
|
G_CALLBACK(top_level_key_pressed_cb), NULL );
|
2004-05-17 21:15:28 +00:00
|
|
|
|
2008-04-12 21:44:50 +00:00
|
|
|
/* Vertical container for menu bar, toolbar(s), paned windows and progress/info box */
|
2012-06-02 23:53:04 +00:00
|
|
|
main_vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 1, FALSE);
|
2012-07-18 19:44:54 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 0);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(top_level), main_vbox);
|
|
|
|
gtk_widget_show(main_vbox);
|
|
|
|
|
|
|
|
/* Menu bar */
|
2012-06-28 08:25:17 +00:00
|
|
|
menubar = main_menu_new(&accel);
|
2012-01-25 13:04:32 +00:00
|
|
|
|
2012-06-28 08:25:17 +00:00
|
|
|
#if defined(HAVE_IGE_MAC_INTEGRATION) || defined (HAVE_GTKOSXAPPLICATION)
|
2017-04-05 19:15:27 +00:00
|
|
|
/* macOS native menus are created and displayed by main_menu_new() */
|
2012-06-28 08:25:17 +00:00
|
|
|
if(!prefs_p->gui_macosx_style) {
|
|
|
|
#endif
|
|
|
|
gtk_window_add_accel_group(GTK_WINDOW(top_level), accel);
|
|
|
|
gtk_widget_show(menubar);
|
|
|
|
#if defined(HAVE_IGE_MAC_INTEGRATION) || defined(HAVE_GTKOSXAPPLICATION)
|
2012-11-02 09:58:43 +00:00
|
|
|
} else {
|
|
|
|
gtk_widget_hide(menubar);
|
2012-01-25 13:04:32 +00:00
|
|
|
}
|
2012-06-28 08:25:17 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Main Toolbar */
|
|
|
|
main_tb = toolbar_new();
|
|
|
|
gtk_widget_show (main_tb);
|
|
|
|
|
|
|
|
/* Filter toolbar */
|
|
|
|
filter_tb = filter_toolbar_new();
|
|
|
|
|
|
|
|
/* Packet list */
|
2012-09-04 02:35:25 +00:00
|
|
|
pkt_scrollw = packet_list_create();
|
2012-06-28 08:25:17 +00:00
|
|
|
gtk_widget_set_size_request(pkt_scrollw, -1, pl_size);
|
|
|
|
gtk_widget_show_all(pkt_scrollw);
|
|
|
|
|
|
|
|
/* Tree view */
|
2013-01-22 18:27:18 +00:00
|
|
|
tv_scrollw = proto_tree_view_new(&tree_view_gbl);
|
2012-06-28 08:25:17 +00:00
|
|
|
gtk_widget_set_size_request(tv_scrollw, -1, tv_size);
|
|
|
|
gtk_widget_show(tv_scrollw);
|
|
|
|
|
|
|
|
g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view_gbl)),
|
|
|
|
"changed", G_CALLBACK(tree_view_selection_changed_cb), NULL);
|
|
|
|
g_signal_connect(tree_view_gbl, "button_press_event", G_CALLBACK(popup_menu_handler),
|
|
|
|
g_object_get_data(G_OBJECT(popup_menu_object), PM_TREE_VIEW_KEY));
|
|
|
|
gtk_widget_show(tree_view_gbl);
|
|
|
|
|
|
|
|
/* Byte view. */
|
|
|
|
byte_nb_ptr_gbl = byte_view_new();
|
|
|
|
gtk_widget_set_size_request(byte_nb_ptr_gbl, -1, bv_size);
|
|
|
|
gtk_widget_show(byte_nb_ptr_gbl);
|
|
|
|
|
|
|
|
g_signal_connect(byte_nb_ptr_gbl, "button_press_event", G_CALLBACK(popup_menu_handler),
|
|
|
|
g_object_get_data(G_OBJECT(popup_menu_object), PM_BYTES_VIEW_KEY));
|
|
|
|
|
|
|
|
/* Panes for the packet list, tree, and byte view */
|
|
|
|
main_pane_v1 = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
|
|
|
|
gtk_widget_show(main_pane_v1);
|
|
|
|
main_pane_v2 = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
|
|
|
|
gtk_widget_show(main_pane_v2);
|
|
|
|
main_pane_h1 = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
gtk_widget_show(main_pane_h1);
|
|
|
|
main_pane_h2 = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
gtk_widget_show(main_pane_h2);
|
|
|
|
#ifdef HAVE_AIRPCAP
|
|
|
|
wireless_tb = airpcap_toolbar_new();
|
|
|
|
#else
|
|
|
|
wireless_tb = ws80211_toolbar_new();
|
2012-07-06 17:02:08 +00:00
|
|
|
#endif
|
|
|
|
gtk_widget_show(wireless_tb);
|
2012-06-28 08:25:17 +00:00
|
|
|
|
|
|
|
/* status bar */
|
|
|
|
statusbar = statusbar_new();
|
|
|
|
gtk_widget_show(statusbar);
|
|
|
|
|
|
|
|
/* Pane for the welcome screen */
|
|
|
|
welcome_pane = welcome_new();
|
|
|
|
gtk_widget_show(welcome_pane);
|
2012-01-25 13:04:32 +00:00
|
|
|
}
|
|
|
|
|
2012-06-28 08:25:17 +00:00
|
|
|
static void
|
|
|
|
show_main_window(gboolean doing_work)
|
|
|
|
{
|
2013-12-17 13:06:11 +00:00
|
|
|
main_set_for_capture_file(doing_work);
|
2012-06-28 08:25:17 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/*** we have finished all init things, show the main window ***/
|
|
|
|
gtk_widget_show(top_level);
|
2012-06-28 08:25:17 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* the window can be maximized only, if it's visible, so do it after show! */
|
|
|
|
main_load_window_geometry(top_level);
|
2012-06-28 08:25:17 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* process all pending GUI events before continue */
|
|
|
|
while (gtk_events_pending()) gtk_main_iteration();
|
2012-06-28 08:25:17 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Pop up any queued-up alert boxes. */
|
|
|
|
display_queued_messages();
|
2012-06-28 08:25:17 +00:00
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/* Move the main window to the front, in case it isn't already there */
|
|
|
|
gdk_window_raise(gtk_widget_get_window(top_level));
|
2012-06-28 08:25:17 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_AIRPCAP
|
2013-12-17 13:06:11 +00:00
|
|
|
airpcap_toolbar_show(wireless_tb);
|
2012-06-28 08:25:17 +00:00
|
|
|
#endif /* HAVE_AIRPCAP */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void copy_global_profile (const gchar *profile_name)
|
|
|
|
{
|
|
|
|
char *pf_dir_path, *pf_dir_path2, *pf_filename;
|
|
|
|
|
|
|
|
if (create_persconffile_profile(profile_name, &pf_dir_path) == -1) {
|
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
|
|
|
"Can't create directory\n\"%s\":\n%s.",
|
|
|
|
pf_dir_path, g_strerror(errno));
|
|
|
|
|
|
|
|
g_free(pf_dir_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (copy_persconffile_profile(profile_name, profile_name, TRUE, &pf_filename,
|
|
|
|
&pf_dir_path, &pf_dir_path2) == -1) {
|
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
|
|
|
"Can't copy file \"%s\" in directory\n\"%s\" to\n\"%s\":\n%s.",
|
|
|
|
pf_filename, pf_dir_path2, pf_dir_path, g_strerror(errno));
|
|
|
|
|
|
|
|
g_free(pf_filename);
|
|
|
|
g_free(pf_dir_path);
|
|
|
|
g_free(pf_dir_path2);
|
Detangle the code that manages the interface list on the welcome screen:
fill_capture_box():
if there are interfaces on which to capture, constructs the
interface list, otherwise destroys the interface list and puts
up a message.
update_capture_box():
updates the interface list to reflect current reality.
welcome_if_panel_reload():
if there is an interface list, and if there are interfaces on
which to capture (so that we still want that list), updates the
list by calling update_capture_box(), otherwise creates or
destroys it by calling fill_capture_box() (as either it doesn't
exist but now needs to or does exist but needs to go away).
Have refresh_local_interface_lists(), which re-fetches the list of local
interfaces and updates every interface list that includes local
interfaces, and refresh_non_local_interface_lists(), which only updates
interface lists that (also) include interfaces other than local
interfaces (such as pipes and remote interfaces). Call them in the
apprpriate places (if we know the list of local interfaces has been
updated, call refresh_local_interface_lists(), otherwise, if we know
interfaces other than local interfaces have been added or removed, call
refresh_non_local_interface_lists()).
Don't have any routine that updates the interface list for one widget
update the interface list for any other widget; leave the global
updating of interface lists up to refresh_local_interface_lists() and
refresh_non_local_interface_lists() - only call one of them if any
interface lists are to be updated.
svn path=/trunk/; revision=43517
2012-06-28 08:13:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-28 08:25:17 +00:00
|
|
|
/* Change configuration profile */
|
|
|
|
void change_configuration_profile (const gchar *profile_name)
|
2012-01-25 13:04:32 +00:00
|
|
|
{
|
2012-06-28 08:25:17 +00:00
|
|
|
char *rf_path;
|
|
|
|
int rf_open_errno;
|
2015-12-22 20:07:00 +00:00
|
|
|
gchar* err_msg = NULL;
|
2012-06-28 08:25:17 +00:00
|
|
|
|
|
|
|
/* First check if profile exists */
|
|
|
|
if (!profile_exists(profile_name, FALSE)) {
|
|
|
|
if (profile_exists(profile_name, TRUE)) {
|
|
|
|
/* Copy from global profile */
|
|
|
|
copy_global_profile (profile_name);
|
|
|
|
} else {
|
|
|
|
/* No personal and no global profile exists */
|
|
|
|
return;
|
2012-01-25 13:04:32 +00:00
|
|
|
}
|
|
|
|
}
|
2012-06-28 08:25:17 +00:00
|
|
|
|
|
|
|
/* Then check if changing to another profile */
|
|
|
|
if (profile_name && strcmp (profile_name, get_profile_name()) == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the current geometry, before writing it to disk */
|
|
|
|
main_save_window_geometry(top_level);
|
|
|
|
|
|
|
|
if (profile_exists(get_profile_name(), FALSE)) {
|
|
|
|
/* Write recent file for profile we are leaving, if it still exists */
|
|
|
|
write_profile_recent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set profile name and update the status bar */
|
|
|
|
set_profile_name (profile_name);
|
|
|
|
profile_bar_update ();
|
|
|
|
|
2017-04-08 19:45:19 +00:00
|
|
|
/*
|
|
|
|
* Reset current preferences and enabled/disabled protocols and
|
|
|
|
* heuristic dissectors.
|
|
|
|
*/
|
2012-06-28 08:25:17 +00:00
|
|
|
prefs_reset();
|
|
|
|
menu_prefs_reset();
|
2017-04-08 19:45:19 +00:00
|
|
|
proto_reenable_all();
|
2012-06-28 08:25:17 +00:00
|
|
|
|
2017-04-08 19:45:19 +00:00
|
|
|
/*
|
|
|
|
* Read the configuration files for the new profile.
|
|
|
|
*/
|
|
|
|
(void) read_configuration_files();
|
2012-06-28 08:25:17 +00:00
|
|
|
|
2015-10-04 09:31:19 +00:00
|
|
|
if (!recent_read_profile_static(&rf_path, &rf_open_errno)) {
|
2012-06-28 08:25:17 +00:00
|
|
|
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
|
|
|
|
"Could not open common recent file\n\"%s\": %s.",
|
|
|
|
rf_path, g_strerror(rf_open_errno));
|
2015-10-04 09:31:19 +00:00
|
|
|
g_free(rf_path);
|
2012-06-28 08:25:17 +00:00
|
|
|
}
|
|
|
|
if (recent.gui_fileopen_remembered_dir &&
|
|
|
|
test_for_directory(recent.gui_fileopen_remembered_dir) == EISDIR) {
|
|
|
|
set_last_open_dir(recent.gui_fileopen_remembered_dir);
|
|
|
|
}
|
|
|
|
timestamp_set_type (recent.gui_time_format);
|
|
|
|
timestamp_set_seconds_type (recent.gui_seconds_format);
|
2015-12-22 20:07:00 +00:00
|
|
|
packet_list_enable_color(recent.packet_list_colorize);
|
2012-06-28 08:25:17 +00:00
|
|
|
|
|
|
|
prefs_to_capture_opts();
|
|
|
|
prefs_apply_all();
|
2015-12-02 12:21:05 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2015-12-02 08:13:40 +00:00
|
|
|
update_local_interfaces();
|
2015-12-02 12:21:05 +00:00
|
|
|
#endif
|
2012-06-28 08:25:17 +00:00
|
|
|
macros_post_update();
|
|
|
|
|
|
|
|
/* Update window view and redraw the toolbar */
|
|
|
|
main_titlebar_update();
|
|
|
|
filter_expression_reinit(FILTER_EXPRESSION_REINIT_CREATE);
|
|
|
|
toolbar_redraw_all();
|
|
|
|
|
|
|
|
/* Reload color filters */
|
2016-01-01 04:14:08 +00:00
|
|
|
if (!color_filters_reload(&err_msg, color_filter_add_cb)) {
|
2015-12-22 20:07:00 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
|
|
|
g_free(err_msg);
|
|
|
|
}
|
2012-06-28 08:25:17 +00:00
|
|
|
|
|
|
|
/* Reload list of interfaces on welcome page */
|
|
|
|
welcome_if_panel_reload();
|
|
|
|
|
|
|
|
/* Recreate the packet list according to new preferences */
|
2012-09-04 02:35:25 +00:00
|
|
|
packet_list_recreate ();
|
2012-09-03 15:12:49 +00:00
|
|
|
cfile.columns_changed = FALSE; /* Reset value */
|
2012-06-28 08:25:17 +00:00
|
|
|
user_font_apply();
|
|
|
|
|
|
|
|
/* Update menus with new recent values */
|
|
|
|
menu_recent_read_finished();
|
|
|
|
|
|
|
|
/* Reload pane geometry, must be done after recreating the list */
|
|
|
|
main_pane_load_window_geometry();
|
|
|
|
}
|
|
|
|
|
2014-11-06 10:19:25 +00:00
|
|
|
void
|
|
|
|
main_fields_changed (void)
|
|
|
|
{
|
2015-12-22 20:07:00 +00:00
|
|
|
gchar* err_msg = NULL;
|
|
|
|
|
2014-11-06 10:19:25 +00:00
|
|
|
/* Reload color filters */
|
2016-01-01 04:14:08 +00:00
|
|
|
if (!color_filters_reload(&err_msg, color_filter_add_cb)) {
|
2015-12-22 20:07:00 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
|
|
|
g_free(err_msg);
|
|
|
|
}
|
2014-11-06 10:19:25 +00:00
|
|
|
|
|
|
|
/* Syntax check filter */
|
|
|
|
filter_te_syntax_check_cb(main_display_filter_widget, NULL);
|
|
|
|
if (cfile.dfilter) {
|
|
|
|
/* Check if filter is still valid */
|
|
|
|
dfilter_t *dfp = NULL;
|
2015-01-18 10:22:19 +00:00
|
|
|
if (!dfilter_compile(cfile.dfilter, &dfp, NULL)) {
|
2014-11-06 10:19:25 +00:00
|
|
|
/* Not valid. Enable 'Apply' button and remove dfilter. */
|
|
|
|
g_signal_emit_by_name(G_OBJECT(main_display_filter_widget), "changed");
|
|
|
|
g_free(cfile.dfilter);
|
|
|
|
cfile.dfilter = NULL;
|
|
|
|
}
|
|
|
|
dfilter_free(dfp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (have_custom_cols(&cfile.cinfo)) {
|
|
|
|
/* Recreate packet list according to new/changed/deleted fields */
|
|
|
|
packet_list_recreate();
|
|
|
|
} else if (cfile.state != FILE_CLOSED) {
|
|
|
|
/* Redissect packets if we have any */
|
|
|
|
redissect_packets();
|
|
|
|
}
|
|
|
|
destroy_packet_wins(); /* TODO: close windows until we can recreate */
|
|
|
|
|
|
|
|
proto_free_deregistered_fields();
|
|
|
|
}
|
|
|
|
|
2012-06-28 08:25:17 +00:00
|
|
|
/** redissect packets and update UI */
|
|
|
|
void redissect_packets(void)
|
|
|
|
{
|
|
|
|
cf_redissect_packets(&cfile);
|
|
|
|
status_expert_update();
|
2012-01-25 13:04:32 +00:00
|
|
|
}
|
2013-12-17 13:06:11 +00:00
|
|
|
|
2016-12-13 18:33:02 +00:00
|
|
|
#ifdef HAVE_SOFTWARE_UPDATE
|
|
|
|
/** Check to see if Wireshark can shut down safely (e.g. offer to save the
|
|
|
|
* current capture).
|
|
|
|
* Dummy.
|
|
|
|
*/
|
|
|
|
int software_update_can_shutdown_callback(void) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Shut down Wireshark in preparation for an upgrade.
|
|
|
|
* Dummy.
|
|
|
|
*/
|
|
|
|
void software_update_shutdown_request_callback(void) {
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-12-17 13:06:11 +00:00
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|