2018-06-07 20:04:38 +00:00
/* main.cpp
2012-01-04 22:13:01 +00:00
*
* Wireshark - Network traffic analyzer
* By Gerald Combs < gerald @ wireshark . org >
* Copyright 1998 Gerald Combs
*
2018-02-07 11:26:45 +00:00
* SPDX - License - Identifier : GPL - 2.0 - or - later
2012-01-04 22:13:01 +00:00
*/
2015-01-03 20:52:54 +00:00
# include <config.h>
2014-01-07 21:09:03 +00:00
2012-01-04 22:13:01 +00:00
# include <glib.h>
2016-06-24 23:01:51 +00:00
# include <locale.h>
2018-10-07 17:06:00 +00:00
# ifdef _WIN32
# include <windows.h>
# include <tchar.h>
# include <wchar.h>
# include <shellapi.h>
2020-09-09 02:59:02 +00:00
# include "ui/win32/console_win32.h"
2018-10-07 17:06:00 +00:00
# endif
2021-02-14 20:54:42 +00:00
/*
* If we have getopt_long ( ) in the system library , include < getopt . h > .
* Otherwise , we ' re using our own getopt_long ( ) ( either because the
* system has getopt ( ) but not getopt_long ( ) , as with some UN * Xes ,
* or because it doesn ' t even have getopt ( ) , as with Windows ) , so
* include our getopt_long ( ) ' s header .
*/
# ifdef HAVE_GETOPT_LONG
2014-12-25 01:10:40 +00:00
# include <getopt.h>
2021-02-14 20:54:42 +00:00
# else
# include <wsutil/wsgetopt.h>
2012-01-04 22:13:01 +00:00
# endif
2019-01-01 00:55:23 +00:00
# include <ui/clopts_common.h>
# include <ui/cmdarg_err.h>
2021-04-13 08:23:21 +00:00
# include <ui/exit_codes.h>
2020-10-03 02:17:00 +00:00
# include <ui/urls.h>
2013-11-19 19:45:38 +00:00
# include <wsutil/filesystem.h>
# include <wsutil/privileges.h>
2019-05-02 01:46:23 +00:00
# include <wsutil/socket.h>
2021-06-08 01:46:52 +00:00
# include <wsutil/wslog.h>
2013-12-02 08:30:29 +00:00
# ifdef HAVE_PLUGINS
# include <wsutil/plugins.h>
# endif
2017-04-08 19:45:19 +00:00
# include <wsutil/report_message.h>
2019-05-02 01:46:23 +00:00
# include <wsutil/please_report_bug.h>
2015-06-16 18:55:09 +00:00
# include <wsutil/unicode-utils.h>
2021-07-03 11:58:30 +00:00
# include <ui/version_info.h>
2013-01-16 00:13:33 +00:00
2012-01-04 22:13:01 +00:00
# include <epan/addr_resolv.h>
# include <epan/ex-opt.h>
# include <epan/tap.h>
2014-11-14 18:51:40 +00:00
# include <epan/stat_tap_ui.h>
2012-01-04 22:13:01 +00:00
# include <epan/column.h>
2013-07-12 01:40:06 +00:00
# include <epan/disabled_protos.h>
2016-06-18 20:49:23 +00:00
# include <epan/prefs.h>
2012-01-04 22:13:01 +00:00
2015-01-03 00:27:24 +00:00
# ifdef HAVE_KERBEROS
2015-01-01 23:05:25 +00:00
# include <epan/packet.h>
# include <epan/asn1.h>
# include <epan/dissectors/packet-kerberos.h>
# endif
2019-02-03 02:15:13 +00:00
# include <wsutil/codecs.h>
2013-12-02 08:30:29 +00:00
2015-12-29 06:57:36 +00:00
# include <extcap.h>
2012-01-04 22:13:01 +00:00
/* general (not Qt specific) */
2015-01-01 12:16:05 +00:00
# include "file.h"
2015-12-22 20:07:00 +00:00
# include "epan/color_filters.h"
2012-01-04 22:13:01 +00:00
2015-07-07 19:04:48 +00:00
# include "epan/rtd_table.h"
# include "epan/srt_table.h"
2012-01-16 01:18:56 +00:00
# include "ui/alert_box.h"
2014-09-25 23:21:02 +00:00
# include "ui/console.h"
2012-08-03 23:30:47 +00:00
# include "ui/iface_lists.h"
2013-12-21 16:55:43 +00:00
# include "ui/language.h"
2013-11-19 19:45:38 +00:00
# include "ui/persfilepath_opt.h"
2012-01-18 19:59:13 +00:00
# include "ui/recent.h"
2012-01-16 01:18:56 +00:00
# include "ui/simple_dialog.h"
2015-07-07 19:04:48 +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"
2016-08-01 15:33:05 +00:00
# include "ui/capture_ui_utils.h"
2018-01-08 23:40:50 +00:00
# include "ui/preference_utils.h"
2020-02-13 23:18:14 +00:00
# include "ui/software_update.h"
2017-12-10 17:29:40 +00:00
# include "ui/taps.h"
2012-01-16 01:18:56 +00:00
2015-07-07 19:04:48 +00:00
# include "ui/qt/conversation_dialog.h"
2017-07-25 14:15:18 +00:00
# include "ui/qt/utils/color_utils.h"
2015-12-22 20:07:00 +00:00
# include "ui/qt/coloring_rules_dialog.h"
2015-07-07 19:04:48 +00:00
# include "ui/qt/endpoint_dialog.h"
2015-01-01 09:19:57 +00:00
# include "ui/qt/main_window.h"
2015-07-07 19:04:48 +00:00
# include "ui/qt/response_time_delay_dialog.h"
# include "ui/qt/service_response_time_dialog.h"
# include "ui/qt/simple_dialog.h"
2015-07-07 23:18:00 +00:00
# include "ui/qt/simple_statistics_dialog.h"
2019-06-29 12:30:51 +00:00
# include <ui/qt/widgets/splash_overlay.h>
2015-01-01 09:19:57 +00:00
# include "ui/qt/wireshark_application.h"
2021-03-24 22:09:19 +00:00
# include "capture/capture-pcap-util.h"
2014-07-03 09:16:12 +00:00
2017-07-24 17:55:56 +00:00
# include <QMessageBox>
2019-02-20 01:08:05 +00:00
# include <QScreen>
2017-07-24 17:55:56 +00:00
2012-01-04 22:13:01 +00:00
# ifdef _WIN32
2021-03-24 22:09:19 +00:00
# include "capture / capture-wpcap.h"
2015-01-01 00:10:02 +00:00
# include <wsutil / file_util.h>
2012-01-04 22:13:01 +00:00
# endif /* _WIN32 */
# ifdef HAVE_AIRPCAP
2021-03-24 22:09:19 +00:00
# include <capture / airpcap.h>
# include <capture / airpcap_loader.h>
2012-03-30 14:55:00 +00:00
//# include "airpcap_dlg.h"
//# include "airpcap_gui_utils.h"
2012-01-04 22:13:01 +00:00
# endif
2018-02-23 17:43:29 +00:00
# include "epan/crypt/dot11decrypt_ws.h"
2012-01-04 22:13:01 +00:00
2018-04-09 09:39:49 +00:00
/* Handle the addition of View menu items without request */
# if defined(Q_OS_MAC)
# include <ui/macosx/cocoa_bridge.h>
# endif
2017-12-17 09:47:30 +00:00
# include <ui/qt/utils/qt_ui_utils.h>
2017-01-04 16:20:19 +00:00
//#define DEBUG_STARTUP_TIME 1
2012-01-04 22:13:01 +00:00
/* update the main window */
void main_window_update ( void )
{
WiresharkApplication : : processEvents ( ) ;
}
# ifdef HAVE_LIBPCAP
/* quit the main window */
void main_window_quit ( void )
{
2013-10-30 22:39:52 +00:00
wsApp - > quit ( ) ;
2012-01-04 22:13:01 +00:00
}
2018-03-01 17:19:57 +00:00
# endif /* HAVE_LIBPCAP */
2018-02-26 18:39:27 +00:00
void exit_application ( int status ) {
if ( wsApp ) {
wsApp - > quit ( ) ;
}
exit ( status ) ;
}
2012-01-04 22:13:01 +00:00
/*
* Report an error in command - line arguments .
2021-03-16 01:40:19 +00:00
*
* On Windows , Wireshark is built for the Windows subsystem , and runs
* without a console , so we create a console on Windows to receive the
* output .
*
* See create_console ( ) , in ui / win32 / console_win32 . c , for an example
* of code to check whether we need to create a console .
*
* On UN * Xes :
*
* If Wireshark is run from the command line , its output either goes
* to the terminal or to wherever the standard error was redirected .
*
* If Wireshark is run by executing it as a remote command , e . g . with
* ssh , its output either goes to whatever socket was set up for the
* remote command ' s standard error or to wherever the standard error
* was redirected .
*
* If Wireshark was run from the GUI , e . g . by double - clicking on its
* icon or on a file that it opens , there are no guarantees as to
* where the standard error went . It could be going to / dev / null
* ( current macOS ) , or to a socket to systemd for the journal , or
* to a log file in the user ' s home directory , or to the " console
* device " ( " workstation console " ), or....
*
* Part of determining that , at least for locally - run Wireshark ,
* is to try to open / dev / tty to determine whether the process
* has a controlling terminal . ( It fails , at a minimum , for
* Wireshark launched from the GUI under macOS , Ubuntu with GNOME ,
* and Ubuntu with KDE ; in all cases , an attempt to open / dev / tty
* fails with ENXIO . ) If it does have a controlling terminal ,
* write to the standard error , otherwise assume that the standard
* error might not go anywhere that the user will be able to see .
* That doesn ' t handle the " run by ssh " case , however ; that will
* not have a controlling terminal . ( This means running it by
* remote execution , not by remote login . ) Perhaps there ' s an
* environment variable to check there .
2012-01-04 22:13:01 +00:00
*/
// xxx copied from ../gtk/main.c
2014-06-29 21:37:21 +00:00
static void
wireshark_cmdarg_err ( const char * fmt , va_list ap )
2012-01-04 22:13:01 +00:00
{
2013-04-25 05:47:11 +00:00
# ifdef _WIN32
create_console ( ) ;
# endif
fprintf ( stderr , " wireshark: " ) ;
vfprintf ( stderr , fmt , ap ) ;
fprintf ( stderr , " \n " ) ;
2012-01-04 22:13:01 +00:00
}
/*
* Report additional information for an error in command - line arguments .
* Creates a console on Windows .
*/
// xxx copied from ../gtk/main.c
2014-06-29 21:37:21 +00:00
static void
wireshark_cmdarg_err_cont ( const char * fmt , va_list ap )
2012-01-04 22:13:01 +00:00
{
2013-04-25 05:47:11 +00:00
# ifdef _WIN32
create_console ( ) ;
# endif
vfprintf ( stderr , fmt , ap ) ;
fprintf ( stderr , " \n " ) ;
2012-01-04 22:13:01 +00:00
}
Fix -v for QtShark
./Wireshark -v
wireshark 1.7.1 (SVN Rev Unknown from unknown)
Copyright 1998-2012 Gerald Combs <gerald@wireshark.org> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiled (64-bit) with Qt 4.7.4 with GLib 2.30.0, with libpcap (version
unknown), with libz 1.2.3.4, with POSIX capabilities (Linux), with SMI 0.4.8,
with c-ares 1.7.4, with Lua 5.1, without Python, with GnuTLS 2.10.5, with Gcrypt
1.5.0, with MIT Kerberos, with GeoIP, with PortAudio V19-devel (built Jul 27
2011 11:52:20), without AirPcap.
Running on Linux 3.0.0-13-generic, with locale fr_FR.UTF-8, with libpcap version
1.1.1, with libz 1.2.3.4, GnuTLS 2.10.5, Gcrypt 1.5.0.
Built using gcc 4.6.1.
get_gui_compiled_info & get_gui_runtime_info copied from ../gtk/main.c
the function is common to GTK and Qt need to put in version_info.[ch] ?
svn path=/trunk/; revision=40633
2012-01-21 18:56:01 +00:00
// xxx based from ../gtk/main.c:get_gtk_compiled_info
2016-06-18 20:49:23 +00:00
void
2014-07-03 08:45:32 +00:00
get_wireshark_qt_compiled_info ( GString * str )
Fix -v for QtShark
./Wireshark -v
wireshark 1.7.1 (SVN Rev Unknown from unknown)
Copyright 1998-2012 Gerald Combs <gerald@wireshark.org> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiled (64-bit) with Qt 4.7.4 with GLib 2.30.0, with libpcap (version
unknown), with libz 1.2.3.4, with POSIX capabilities (Linux), with SMI 0.4.8,
with c-ares 1.7.4, with Lua 5.1, without Python, with GnuTLS 2.10.5, with Gcrypt
1.5.0, with MIT Kerberos, with GeoIP, with PortAudio V19-devel (built Jul 27
2011 11:52:20), without AirPcap.
Running on Linux 3.0.0-13-generic, with locale fr_FR.UTF-8, with libpcap version
1.1.1, with libz 1.2.3.4, GnuTLS 2.10.5, Gcrypt 1.5.0.
Built using gcc 4.6.1.
get_gui_compiled_info & get_gui_runtime_info copied from ../gtk/main.c
the function is common to GTK and Qt need to put in version_info.[ch] ?
svn path=/trunk/; revision=40633
2012-01-21 18:56:01 +00:00
{
2014-01-05 18:40:07 +00:00
g_string_append ( str , " with " ) ;
g_string_append_printf ( str ,
Fix -v for QtShark
./Wireshark -v
wireshark 1.7.1 (SVN Rev Unknown from unknown)
Copyright 1998-2012 Gerald Combs <gerald@wireshark.org> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiled (64-bit) with Qt 4.7.4 with GLib 2.30.0, with libpcap (version
unknown), with libz 1.2.3.4, with POSIX capabilities (Linux), with SMI 0.4.8,
with c-ares 1.7.4, with Lua 5.1, without Python, with GnuTLS 2.10.5, with Gcrypt
1.5.0, with MIT Kerberos, with GeoIP, with PortAudio V19-devel (built Jul 27
2011 11:52:20), without AirPcap.
Running on Linux 3.0.0-13-generic, with locale fr_FR.UTF-8, with libpcap version
1.1.1, with libz 1.2.3.4, GnuTLS 2.10.5, Gcrypt 1.5.0.
Built using gcc 4.6.1.
get_gui_compiled_info & get_gui_runtime_info copied from ../gtk/main.c
the function is common to GTK and Qt need to put in version_info.[ch] ?
svn path=/trunk/; revision=40633
2012-01-21 18:56:01 +00:00
# ifdef QT_VERSION
2014-07-03 08:45:32 +00:00
" Qt %s " , QT_VERSION_STR ) ;
Fix -v for QtShark
./Wireshark -v
wireshark 1.7.1 (SVN Rev Unknown from unknown)
Copyright 1998-2012 Gerald Combs <gerald@wireshark.org> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiled (64-bit) with Qt 4.7.4 with GLib 2.30.0, with libpcap (version
unknown), with libz 1.2.3.4, with POSIX capabilities (Linux), with SMI 0.4.8,
with c-ares 1.7.4, with Lua 5.1, without Python, with GnuTLS 2.10.5, with Gcrypt
1.5.0, with MIT Kerberos, with GeoIP, with PortAudio V19-devel (built Jul 27
2011 11:52:20), without AirPcap.
Running on Linux 3.0.0-13-generic, with locale fr_FR.UTF-8, with libpcap version
1.1.1, with libz 1.2.3.4, GnuTLS 2.10.5, Gcrypt 1.5.0.
Built using gcc 4.6.1.
get_gui_compiled_info & get_gui_runtime_info copied from ../gtk/main.c
the function is common to GTK and Qt need to put in version_info.[ch] ?
svn path=/trunk/; revision=40633
2012-01-21 18:56:01 +00:00
# else
2014-07-03 08:45:32 +00:00
" Qt (version unknown) " ) ;
Fix -v for QtShark
./Wireshark -v
wireshark 1.7.1 (SVN Rev Unknown from unknown)
Copyright 1998-2012 Gerald Combs <gerald@wireshark.org> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiled (64-bit) with Qt 4.7.4 with GLib 2.30.0, with libpcap (version
unknown), with libz 1.2.3.4, with POSIX capabilities (Linux), with SMI 0.4.8,
with c-ares 1.7.4, with Lua 5.1, without Python, with GnuTLS 2.10.5, with Gcrypt
1.5.0, with MIT Kerberos, with GeoIP, with PortAudio V19-devel (built Jul 27
2011 11:52:20), without AirPcap.
Running on Linux 3.0.0-13-generic, with locale fr_FR.UTF-8, with libpcap version
1.1.1, with libz 1.2.3.4, GnuTLS 2.10.5, Gcrypt 1.5.0.
Built using gcc 4.6.1.
get_gui_compiled_info & get_gui_runtime_info copied from ../gtk/main.c
the function is common to GTK and Qt need to put in version_info.[ch] ?
svn path=/trunk/; revision=40633
2012-01-21 18:56:01 +00:00
# endif
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 ) ;
Fix -v for QtShark
./Wireshark -v
wireshark 1.7.1 (SVN Rev Unknown from unknown)
Copyright 1998-2012 Gerald Combs <gerald@wireshark.org> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiled (64-bit) with Qt 4.7.4 with GLib 2.30.0, with libpcap (version
unknown), with libz 1.2.3.4, with POSIX capabilities (Linux), with SMI 0.4.8,
with c-ares 1.7.4, with Lua 5.1, without Python, with GnuTLS 2.10.5, with Gcrypt
1.5.0, with MIT Kerberos, with GeoIP, with PortAudio V19-devel (built Jul 27
2011 11:52:20), without AirPcap.
Running on Linux 3.0.0-13-generic, with locale fr_FR.UTF-8, with libpcap version
1.1.1, with libz 1.2.3.4, GnuTLS 2.10.5, Gcrypt 1.5.0.
Built using gcc 4.6.1.
get_gui_compiled_info & get_gui_runtime_info copied from ../gtk/main.c
the function is common to GTK and Qt need to put in version_info.[ch] ?
svn path=/trunk/; revision=40633
2012-01-21 18:56:01 +00:00
}
// xxx copied from ../gtk/main.c
2016-06-18 20:49:23 +00:00
void
Fix -v for QtShark
./Wireshark -v
wireshark 1.7.1 (SVN Rev Unknown from unknown)
Copyright 1998-2012 Gerald Combs <gerald@wireshark.org> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiled (64-bit) with Qt 4.7.4 with GLib 2.30.0, with libpcap (version
unknown), with libz 1.2.3.4, with POSIX capabilities (Linux), with SMI 0.4.8,
with c-ares 1.7.4, with Lua 5.1, without Python, with GnuTLS 2.10.5, with Gcrypt
1.5.0, with MIT Kerberos, with GeoIP, with PortAudio V19-devel (built Jul 27
2011 11:52:20), without AirPcap.
Running on Linux 3.0.0-13-generic, with locale fr_FR.UTF-8, with libpcap version
1.1.1, with libz 1.2.3.4, GnuTLS 2.10.5, Gcrypt 1.5.0.
Built using gcc 4.6.1.
get_gui_compiled_info & get_gui_runtime_info copied from ../gtk/main.c
the function is common to GTK and Qt need to put in version_info.[ch] ?
svn path=/trunk/; revision=40633
2012-01-21 18:56:01 +00:00
get_gui_compiled_info ( GString * str )
{
2014-01-05 18:40:07 +00:00
epan_get_compiled_version_info ( str ) ;
Fix -v for QtShark
./Wireshark -v
wireshark 1.7.1 (SVN Rev Unknown from unknown)
Copyright 1998-2012 Gerald Combs <gerald@wireshark.org> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiled (64-bit) with Qt 4.7.4 with GLib 2.30.0, with libpcap (version
unknown), with libz 1.2.3.4, with POSIX capabilities (Linux), with SMI 0.4.8,
with c-ares 1.7.4, with Lua 5.1, without Python, with GnuTLS 2.10.5, with Gcrypt
1.5.0, with MIT Kerberos, with GeoIP, with PortAudio V19-devel (built Jul 27
2011 11:52:20), without AirPcap.
Running on Linux 3.0.0-13-generic, with locale fr_FR.UTF-8, with libpcap version
1.1.1, with libz 1.2.3.4, GnuTLS 2.10.5, Gcrypt 1.5.0.
Built using gcc 4.6.1.
get_gui_compiled_info & get_gui_runtime_info copied from ../gtk/main.c
the function is common to GTK and Qt need to put in version_info.[ch] ?
svn path=/trunk/; revision=40633
2012-01-21 18:56:01 +00:00
2014-01-05 18:40:07 +00:00
g_string_append ( str , " , " ) ;
2015-10-01 22:51:34 +00:00
# ifdef QT_MULTIMEDIA_LIB
g_string_append ( str , " with QtMultimedia " ) ;
# else
g_string_append ( str , " without QtMultimedia " ) ;
# endif
Fix -v for QtShark
./Wireshark -v
wireshark 1.7.1 (SVN Rev Unknown from unknown)
Copyright 1998-2012 Gerald Combs <gerald@wireshark.org> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiled (64-bit) with Qt 4.7.4 with GLib 2.30.0, with libpcap (version
unknown), with libz 1.2.3.4, with POSIX capabilities (Linux), with SMI 0.4.8,
with c-ares 1.7.4, with Lua 5.1, without Python, with GnuTLS 2.10.5, with Gcrypt
1.5.0, with MIT Kerberos, with GeoIP, with PortAudio V19-devel (built Jul 27
2011 11:52:20), without AirPcap.
Running on Linux 3.0.0-13-generic, with locale fr_FR.UTF-8, with libpcap version
1.1.1, with libz 1.2.3.4, GnuTLS 2.10.5, Gcrypt 1.5.0.
Built using gcc 4.6.1.
get_gui_compiled_info & get_gui_runtime_info copied from ../gtk/main.c
the function is common to GTK and Qt need to put in version_info.[ch] ?
svn path=/trunk/; revision=40633
2012-01-21 18:56:01 +00:00
2020-02-13 23:18:14 +00:00
g_string_append ( str , " , " ) ;
const char * update_info = software_update_info ( ) ;
if ( update_info ) {
g_string_append_printf ( str , " with automatic updates using %s " , update_info ) ;
} else {
g_string_append_printf ( str , " without automatic updates " ) ;
}
2017-10-22 13:16:53 +00:00
# ifdef _WIN32
2014-06-23 21:55:56 +00:00
g_string_append ( str , " , " ) ;
Fix -v for QtShark
./Wireshark -v
wireshark 1.7.1 (SVN Rev Unknown from unknown)
Copyright 1998-2012 Gerald Combs <gerald@wireshark.org> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiled (64-bit) with Qt 4.7.4 with GLib 2.30.0, with libpcap (version
unknown), with libz 1.2.3.4, with POSIX capabilities (Linux), with SMI 0.4.8,
with c-ares 1.7.4, with Lua 5.1, without Python, with GnuTLS 2.10.5, with Gcrypt
1.5.0, with MIT Kerberos, with GeoIP, with PortAudio V19-devel (built Jul 27
2011 11:52:20), without AirPcap.
Running on Linux 3.0.0-13-generic, with locale fr_FR.UTF-8, with libpcap version
1.1.1, with libz 1.2.3.4, GnuTLS 2.10.5, Gcrypt 1.5.0.
Built using gcc 4.6.1.
get_gui_compiled_info & get_gui_runtime_info copied from ../gtk/main.c
the function is common to GTK and Qt need to put in version_info.[ch] ?
svn path=/trunk/; revision=40633
2012-01-21 18:56:01 +00:00
# ifdef HAVE_AIRPCAP
2014-01-05 18:40:07 +00:00
get_compiled_airpcap_version ( str ) ;
Fix -v for QtShark
./Wireshark -v
wireshark 1.7.1 (SVN Rev Unknown from unknown)
Copyright 1998-2012 Gerald Combs <gerald@wireshark.org> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiled (64-bit) with Qt 4.7.4 with GLib 2.30.0, with libpcap (version
unknown), with libz 1.2.3.4, with POSIX capabilities (Linux), with SMI 0.4.8,
with c-ares 1.7.4, with Lua 5.1, without Python, with GnuTLS 2.10.5, with Gcrypt
1.5.0, with MIT Kerberos, with GeoIP, with PortAudio V19-devel (built Jul 27
2011 11:52:20), without AirPcap.
Running on Linux 3.0.0-13-generic, with locale fr_FR.UTF-8, with libpcap version
1.1.1, with libz 1.2.3.4, GnuTLS 2.10.5, Gcrypt 1.5.0.
Built using gcc 4.6.1.
get_gui_compiled_info & get_gui_runtime_info copied from ../gtk/main.c
the function is common to GTK and Qt need to put in version_info.[ch] ?
svn path=/trunk/; revision=40633
2012-01-21 18:56:01 +00:00
# else
2014-01-05 18:40:07 +00:00
g_string_append ( str , " without AirPcap " ) ;
Fix -v for QtShark
./Wireshark -v
wireshark 1.7.1 (SVN Rev Unknown from unknown)
Copyright 1998-2012 Gerald Combs <gerald@wireshark.org> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiled (64-bit) with Qt 4.7.4 with GLib 2.30.0, with libpcap (version
unknown), with libz 1.2.3.4, with POSIX capabilities (Linux), with SMI 0.4.8,
with c-ares 1.7.4, with Lua 5.1, without Python, with GnuTLS 2.10.5, with Gcrypt
1.5.0, with MIT Kerberos, with GeoIP, with PortAudio V19-devel (built Jul 27
2011 11:52:20), without AirPcap.
Running on Linux 3.0.0-13-generic, with locale fr_FR.UTF-8, with libpcap version
1.1.1, with libz 1.2.3.4, GnuTLS 2.10.5, Gcrypt 1.5.0.
Built using gcc 4.6.1.
get_gui_compiled_info & get_gui_runtime_info copied from ../gtk/main.c
the function is common to GTK and Qt need to put in version_info.[ch] ?
svn path=/trunk/; revision=40633
2012-01-21 18:56:01 +00:00
# endif
2017-10-22 13:16:53 +00:00
# endif /* _WIN32 */
2016-11-28 23:58:40 +00:00
2019-02-02 14:52:07 +00:00
# ifdef HAVE_SPEEXDSP
g_string_append ( str , " , with SpeexDSP (using system library) " ) ;
# else
g_string_append ( str , " , with SpeexDSP (using bundled resampler) " ) ;
# endif
2020-12-19 06:16:04 +00:00
# ifdef HAVE_MINIZIP
g_string_append ( str , " , with Minizip " ) ;
# else
g_string_append ( str , " , without Minizip " ) ;
# endif
Fix -v for QtShark
./Wireshark -v
wireshark 1.7.1 (SVN Rev Unknown from unknown)
Copyright 1998-2012 Gerald Combs <gerald@wireshark.org> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiled (64-bit) with Qt 4.7.4 with GLib 2.30.0, with libpcap (version
unknown), with libz 1.2.3.4, with POSIX capabilities (Linux), with SMI 0.4.8,
with c-ares 1.7.4, with Lua 5.1, without Python, with GnuTLS 2.10.5, with Gcrypt
1.5.0, with MIT Kerberos, with GeoIP, with PortAudio V19-devel (built Jul 27
2011 11:52:20), without AirPcap.
Running on Linux 3.0.0-13-generic, with locale fr_FR.UTF-8, with libpcap version
1.1.1, with libz 1.2.3.4, GnuTLS 2.10.5, Gcrypt 1.5.0.
Built using gcc 4.6.1.
get_gui_compiled_info & get_gui_runtime_info copied from ../gtk/main.c
the function is common to GTK and Qt need to put in version_info.[ch] ?
svn path=/trunk/; revision=40633
2012-01-21 18:56:01 +00:00
}
// xxx copied from ../gtk/main.c
2016-06-18 20:49:23 +00:00
void
2014-06-23 21:55:56 +00:00
get_wireshark_runtime_info ( GString * str )
Fix -v for QtShark
./Wireshark -v
wireshark 1.7.1 (SVN Rev Unknown from unknown)
Copyright 1998-2012 Gerald Combs <gerald@wireshark.org> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiled (64-bit) with Qt 4.7.4 with GLib 2.30.0, with libpcap (version
unknown), with libz 1.2.3.4, with POSIX capabilities (Linux), with SMI 0.4.8,
with c-ares 1.7.4, with Lua 5.1, without Python, with GnuTLS 2.10.5, with Gcrypt
1.5.0, with MIT Kerberos, with GeoIP, with PortAudio V19-devel (built Jul 27
2011 11:52:20), without AirPcap.
Running on Linux 3.0.0-13-generic, with locale fr_FR.UTF-8, with libpcap version
1.1.1, with libz 1.2.3.4, GnuTLS 2.10.5, Gcrypt 1.5.0.
Built using gcc 4.6.1.
get_gui_compiled_info & get_gui_runtime_info copied from ../gtk/main.c
the function is common to GTK and Qt need to put in version_info.[ch] ?
svn path=/trunk/; revision=40633
2012-01-21 18:56:01 +00:00
{
2021-05-28 10:26:44 +00:00
g_string_append_printf ( str , " , with Qt %s " , qVersion ( ) ) ;
2021-05-24 15:14:51 +00:00
# ifdef HAVE_LIBPCAP
/* Capture libraries */
g_string_append ( str , " , " ) ;
get_runtime_caplibs_version ( str ) ;
# endif
/* stuff used by libwireshark */
epan_get_runtime_version_info ( str ) ;
# ifdef HAVE_AIRPCAP
g_string_append ( str , " , " ) ;
get_runtime_airpcap_version ( str ) ;
# endif
2019-02-20 01:08:05 +00:00
if ( wsApp ) {
// Display information
const char * display_mode = ColorUtils : : themeIsDark ( ) ? " dark " : " light " ;
g_string_append_printf ( str , " , with %s display mode " , display_mode ) ;
int hidpi_count = 0 ;
foreach ( QScreen * screen , wsApp - > screens ( ) ) {
if ( screen - > devicePixelRatio ( ) > 1.0 ) {
hidpi_count + + ;
}
}
if ( hidpi_count = = wsApp - > screens ( ) . count ( ) ) {
g_string_append ( str , " , with HiDPI " ) ;
} else if ( hidpi_count ) {
g_string_append ( str , " , with mixed DPI " ) ;
} else {
g_string_append ( str , " , without HiDPI " ) ;
}
}
Fix -v for QtShark
./Wireshark -v
wireshark 1.7.1 (SVN Rev Unknown from unknown)
Copyright 1998-2012 Gerald Combs <gerald@wireshark.org> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiled (64-bit) with Qt 4.7.4 with GLib 2.30.0, with libpcap (version
unknown), with libz 1.2.3.4, with POSIX capabilities (Linux), with SMI 0.4.8,
with c-ares 1.7.4, with Lua 5.1, without Python, with GnuTLS 2.10.5, with Gcrypt
1.5.0, with MIT Kerberos, with GeoIP, with PortAudio V19-devel (built Jul 27
2011 11:52:20), without AirPcap.
Running on Linux 3.0.0-13-generic, with locale fr_FR.UTF-8, with libpcap version
1.1.1, with libz 1.2.3.4, GnuTLS 2.10.5, Gcrypt 1.5.0.
Built using gcc 4.6.1.
get_gui_compiled_info & get_gui_runtime_info copied from ../gtk/main.c
the function is common to GTK and Qt need to put in version_info.[ch] ?
svn path=/trunk/; revision=40633
2012-01-21 18:56:01 +00:00
}
2012-01-04 22:13:01 +00:00
2018-01-03 09:57:19 +00:00
static void
2021-06-08 01:46:52 +00:00
qt_log_message_handler ( QtMsgType type , const QMessageLogContext & , const QString & msg )
2017-12-16 22:15:28 +00:00
{
2021-06-08 01:46:52 +00:00
enum ws_log_level log_level = LOG_LEVEL_DEBUG ;
2017-12-16 22:15:28 +00:00
switch ( type ) {
case QtInfoMsg :
2021-06-08 01:46:52 +00:00
log_level = LOG_LEVEL_INFO ;
2017-12-16 22:15:28 +00:00
break ;
2019-11-03 16:47:18 +00:00
// We want qDebug() messages to show up at our default log level.
case QtDebugMsg :
2017-12-16 22:15:28 +00:00
case QtWarningMsg :
2021-06-08 01:46:52 +00:00
log_level = LOG_LEVEL_WARNING ;
2017-12-16 22:15:28 +00:00
break ;
case QtCriticalMsg :
2021-06-08 01:46:52 +00:00
log_level = LOG_LEVEL_CRITICAL ;
2017-12-16 22:15:28 +00:00
break ;
case QtFatalMsg :
2021-06-08 01:46:52 +00:00
log_level = LOG_LEVEL_ERROR ;
2017-12-16 22:15:28 +00:00
break ;
2019-11-03 16:47:18 +00:00
default :
break ;
2017-12-16 22:15:28 +00:00
}
2021-06-23 22:39:00 +00:00
ws_log ( LOG_DOMAIN_QTUI , log_level , " %s " , qUtf8Printable ( msg ) ) ;
2017-12-16 22:15:28 +00:00
}
2014-09-30 19:15:17 +00:00
# ifdef HAVE_LIBPCAP
2014-09-29 23:27:11 +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
2020-02-03 17:18:29 +00:00
check_and_warn_user_startup ( )
2014-09-29 23:27:11 +00:00
{
gchar * cur_user , * cur_group ;
/* 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 ( ) ;
simple_message_box ( ESD_TYPE_WARN , & recent . privs_warn_if_elevated ,
2020-10-25 21:42:47 +00:00
" 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 "
WS_WIKI_URL ( " CaptureSetup/CapturePrivileges " ) , cur_user , cur_group ) ;
2014-09-29 23:27:11 +00:00
g_free ( cur_user ) ;
g_free ( cur_group ) ;
}
}
2014-09-30 19:15:17 +00:00
# endif
2014-09-29 23:27:11 +00:00
2015-01-30 23:34:18 +00:00
# ifdef _WIN32
// Try to avoid library search path collisions. QCoreApplication will
// search QT_INSTALL_PREFIX/plugins for platform DLLs before searching
// the application directory. If
//
// - You have Qt version 5.x.y installed in the default location
// (C:\Qt\5.x) on your machine.
//
// and
//
// - You install Wireshark that was built on a machine with Qt version
// 5.x.z installed in the default location.
//
// Qt5Core.dll will load qwindows.dll from your local C:\Qt\5.x\...\plugins
// directory. This may not be compatible with qwindows.dll from that
// same path on the build machine. At any rate, loading DLLs from paths
// you don't control is ill-advised. We work around this by removing every
// path except our application directory.
static inline void
2020-12-15 19:14:17 +00:00
win32_reset_library_path ( void )
2015-01-30 23:34:18 +00:00
{
QString app_path = QDir ( get_progfile_dir ( ) ) . path ( ) ;
foreach ( QString path , QCoreApplication : : libraryPaths ( ) ) {
QCoreApplication : : removeLibraryPath ( path ) ;
}
QCoreApplication : : addLibraryPath ( app_path ) ;
}
# endif
2020-12-15 19:14:17 +00:00
# ifdef Q_OS_MAC
// Try to work around
//
// https://gitlab.com/wireshark/wireshark/-/issues/17075
//
// aka
//
// https://bugreports.qt.io/browse/QTBUG-87014
//
// The fix at
//
// https://codereview.qt-project.org/c/qt/qtbase/+/322228/3/src/plugins/platforms/cocoa/qnsview_drawing.mm
//
// enables layer backing if we're running on Big Sur OR we're running on
// Catalina AND we were built with the Catalina SDK. Enable layer backing
// here by setting QT_MAC_WANTS_LAYER=1, but only if we're running on Big
// Sur and our version of Qt doesn't have a fix for QTBUG-87014.
# include <QOperatingSystemVersion>
static inline void
macos_enable_layer_backing ( void )
{
// At the time of this writing, the QTBUG-87014 for layerEnabledByMacOS is...
//
// ...in https://github.com/qt/qtbase/blob/5.12/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...not in https://github.com/qt/qtbase/blob/5.12.10/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...in https://github.com/qt/qtbase/blob/5.15/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...not in https://github.com/qt/qtbase/blob/5.15.2/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...not in https://github.com/qt/qtbase/blob/6.0/src/plugins/platforms/cocoa/qnsview_drawing.mm
// ...not in https://github.com/qt/qtbase/blob/6.0.0/src/plugins/platforms/cocoa/qnsview_drawing.mm
//
// We'll assume that it will be fixed in 5.12.11, 5.15.3, and 6.0.1.
// Note that we only ship LTS versions of Qt with our macOS packages.
// Feel free to add other versions if needed.
# if \
( QT_VERSION > = QT_VERSION_CHECK ( 5 , 12 , 0 ) & & QT_VERSION < QT_VERSION_CHECK ( 5 , 12 , 11 ) \
| | ( QT_VERSION > = QT_VERSION_CHECK ( 5 , 15 , 0 ) & & QT_VERSION < QT_VERSION_CHECK ( 5 , 15 , 3 ) ) \
| | ( QT_VERSION > = QT_VERSION_CHECK ( 6 , 0 , 0 ) & & QT_VERSION < QT_VERSION_CHECK ( 6 , 0 , 1 ) ) \
)
QOperatingSystemVersion os_ver = QOperatingSystemVersion : : current ( ) ;
int major_ver = os_ver . majorVersion ( ) ;
int minor_ver = os_ver . minorVersion ( ) ;
if ( ( major_ver = = 10 & & minor_ver > = 16 ) | | major_ver > = 11 ) {
if ( qgetenv ( " QT_MAC_WANTS_LAYER " ) . isEmpty ( ) ) {
qputenv ( " QT_MAC_WANTS_LAYER " , " 1 " ) ;
}
}
# endif
}
# endif
2012-01-04 22:13:01 +00:00
/* And now our feature presentation... [ fade to music ] */
2016-09-16 01:20:05 +00:00
int main ( int argc , char * qt_argv [ ] )
2012-01-04 22:13:01 +00:00
{
2012-12-29 01:39:02 +00:00
MainWindow * main_w ;
2012-01-04 22:13:01 +00:00
2016-06-19 07:38:41 +00:00
# ifdef _WIN32
2018-10-07 17:06:00 +00:00
LPWSTR * wc_argv ;
int wc_argc ;
2016-06-19 07:38:41 +00:00
# endif
2017-01-25 09:16:35 +00:00
int ret_val = EXIT_SUCCESS ;
2016-09-16 01:20:05 +00:00
char * * argv = qt_argv ;
2012-01-04 22:13:01 +00:00
char * rf_path ;
int rf_open_errno ;
# ifdef HAVE_LIBPCAP
2021-03-05 04:09:47 +00:00
gchar * err_str , * err_str_secondary ; ;
2012-01-04 22:13:01 +00:00
# else
# ifdef _WIN32
# ifdef HAVE_AIRPCAP
gchar * err_str ;
# endif
# endif
# endif
2017-01-25 09:16:35 +00:00
gchar * err_msg = NULL ;
2012-01-04 22:13:01 +00:00
2014-11-22 11:58:43 +00:00
QString dfilter , read_filter ;
2017-08-22 14:10:06 +00:00
# ifdef HAVE_LIBPCAP
2017-08-07 14:38:52 +00:00
int caps_queries = 0 ;
2017-08-22 14:10:06 +00:00
# endif
2018-01-13 12:21:09 +00:00
/* Start time in microseconds */
guint64 start_time = g_get_monotonic_time ( ) ;
2021-03-15 18:29:43 +00:00
static const struct report_message_routines wireshark_report_routines = {
vfailure_alert_box ,
vwarning_alert_box ,
open_failure_alert_box ,
read_failure_alert_box ,
write_failure_alert_box ,
cfile_open_failure_alert_box ,
cfile_dump_open_failure_alert_box ,
cfile_read_failure_alert_box ,
cfile_write_failure_alert_box ,
cfile_close_failure_alert_box
} ;
2020-09-09 02:59:02 +00:00
2020-10-26 23:00:40 +00:00
# if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
/*
* See :
*
* issue # 16908 ;
*
* https : //doc.qt.io/qt-5/qvector.html#maximum-size-and-out-of-memory-conditions
*
* https : //forum.qt.io/topic/114950/qvector-realloc-throwing-sigsegv-when-very-large-surface3d-is-rendered
*
* for why we ' re doing this ; the widget we use for the packet list
* uses QVector , so those limitations apply to it .
*
* Apparently , this will be fixed in Qt 6 :
*
* https : //github.com/qt/qtbase/commit/215ca735341b9487826023a7983382851ce8bf26
*
* https : //github.com/qt/qtbase/commit/2a6cdec718934ca2cc7f6f9c616ebe62f6912123#diff-724f419b0bb0487c2629bb16cf534c4b268ddcee89b5177189b607f940cfd83dR192
*
* Hopefully QList won ' t cause any performance hits relative to
* QVector .
*
* We pick 53 million records as a value that should avoid the problem ;
* see the Wireshark issue for why that value was chosen .
*/
cf_set_max_records ( 53000000 ) ;
# endif
2020-12-15 19:14:17 +00:00
# ifdef Q_OS_MAC
macos_enable_layer_backing ( ) ;
# endif
2021-06-24 20:20:25 +00:00
cmdarg_err_init ( wireshark_cmdarg_err , wireshark_cmdarg_err_cont ) ;
2021-06-08 01:46:52 +00:00
/* Initialize log handler early so we can have proper logging during startup. */
2021-06-24 20:20:25 +00:00
ws_log_init_with_writer ( " wireshark " , console_log_writer , vcmdarg_err ) ;
2021-06-08 01:46:52 +00:00
qInstallMessageHandler ( qt_log_message_handler ) ;
2020-09-09 02:59:02 +00:00
# ifdef _WIN32
restore_pipes ( ) ;
# endif
2018-01-24 01:17:11 +00:00
# ifdef DEBUG_STARTUP_TIME
2017-01-04 16:20:19 +00:00
prefs . gui_console_open = console_open_always ;
# endif /* DEBUG_STARTUP_TIME */
2014-06-29 21:37:21 +00:00
2018-04-09 09:39:49 +00:00
# if defined(Q_OS_MAC)
/* Disable automatic addition of tab menu entries in view menu */
CocoaBridge : : cleanOSGeneratedMenuItems ( ) ;
# endif
2020-06-24 23:02:39 +00:00
/*
* Set the C - language locale to the native environment and set the
* code page to UTF - 8 on Windows .
*/
# ifdef _WIN32
setlocale ( LC_ALL , " .UTF-8 " ) ;
# else
2016-06-24 23:01:51 +00:00
setlocale ( LC_ALL , " " ) ;
2020-06-24 23:02:39 +00:00
# endif
2016-06-24 23:01:51 +00:00
2013-02-20 05:04:57 +00:00
# ifdef _WIN32
2018-10-07 17:06:00 +00:00
//
// On Windows, QCoreApplication has its own WinMain(), which gets the
// command line using GetCommandLineW(), breaks it into individual
// arguments using CommandLineToArgvW(), and then "helpfully"
// converts those UTF-16LE arguments into strings in the local code
// page.
//
// We don't want that, because not all file names can be represented
// in the local code page, so we do the same, but we convert the
// strings into UTF-8.
//
wc_argv = CommandLineToArgvW ( GetCommandLineW ( ) , & wc_argc ) ;
2018-10-08 02:04:50 +00:00
if ( wc_argv ) {
argc = wc_argc ;
argv = arg_list_utf_16to8 ( wc_argc , wc_argv ) ;
LocalFree ( wc_argv ) ;
2018-10-07 17:06:00 +00:00
} /* XXX else bail because something is horribly, horribly wrong? */
2013-02-20 01:19:42 +00:00
create_app_running_mutex ( ) ;
2015-06-16 18:55:09 +00:00
# endif /* _WIN32 */
2013-09-09 19:30:02 +00:00
2021-06-19 18:44:58 +00:00
/* Early logging command-line initialization. */
ws_log_parse_args ( & argc , argv , vcmdarg_err , INVALID_OPTION ) ;
2021-06-08 01:46:52 +00:00
2012-01-04 22:13:01 +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 ( ) ;
2015-01-31 04:06:49 +00:00
/*
2016-12-05 04:25:51 +00:00
* Attempt to get the pathname of the directory containing the
* executable file .
2015-01-31 04:06:49 +00:00
*/
2018-05-05 07:19:09 +00:00
/* init_progfile_dir_error = */ init_progfile_dir ( argv [ 0 ] ) ;
2021-06-08 01:46:52 +00:00
/* ws_log(NULL, LOG_LEVEL_DEBUG, "progfile_dir: %s", get_progfile_dir()); */
2015-01-31 04:06:49 +00:00
2015-07-14 21:23:15 +00:00
# ifdef _WIN32
2016-06-16 03:39:32 +00:00
ws_init_dll_search_path ( ) ;
2015-07-14 21:23:15 +00:00
/* Load wpcap if possible. Do this before collecting the run-time version information */
load_wpcap ( ) ;
# ifdef HAVE_AIRPCAP
/* Load the airpcap.dll. This must also be done before collecting
* run - time version information . */
load_airpcap ( ) ;
#if 0
airpcap_dll_ret_val = load_airpcap ( ) ;
switch ( airpcap_dll_ret_val ) {
case AIRPCAP_DLL_OK :
/* load the airpcap interfaces */
g_airpcap_if_list = get_airpcap_interface_list ( & err , & err_str ) ;
2019-11-17 19:02:20 +00:00
if ( g_airpcap_if_list = = NULL | | g_list_length ( g_airpcap_if_list ) = = 0 ) {
2015-07-14 21:23:15 +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 ;
} else {
2020-12-06 15:01:04 +00:00
/* select the first as default (THIS SHOULD BE CHANGED) */
2015-07-14 21:23:15 +00:00
airpcap_if_active = airpcap_get_default_if ( airpcap_if_list ) ;
}
break ;
/*
* XXX - Maybe we need to warn the user if one of the following happens ? ? ?
*/
case AIRPCAP_DLL_OLD :
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " %s " , " AIRPCAP_DLL_OLD \n " ) ;
break ;
case AIRPCAP_DLL_ERROR :
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " %s " , " AIRPCAP_DLL_ERROR \n " ) ;
break ;
case AIRPCAP_DLL_NOT_FOUND :
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " %s " , " AIRPCAP_DDL_NOT_FOUND \n " ) ;
break ;
}
# endif
# endif /* HAVE_AIRPCAP */
# endif /* _WIN32 */
2015-01-29 12:24:54 +00:00
/* Get the compile-time version information string */
2018-12-13 02:16:15 +00:00
ws_init_version_info ( " Wireshark " , get_wireshark_qt_compiled_info ,
get_gui_compiled_info , get_wireshark_runtime_info ) ;
2015-01-29 12:24:54 +00:00
2017-06-20 19:12:48 +00:00
/* Create the user profiles directory */
if ( create_profiles_dir ( & rf_path ) = = - 1 ) {
simple_dialog ( ESD_TYPE_WARN , ESD_BTN_OK ,
2020-01-12 19:51:13 +00:00
" Could not create profiles directory \n \" %s \" : %s. " ,
2020-09-04 22:15:05 +00:00
rf_path , g_strerror ( errno ) ) ;
2017-06-20 19:12:48 +00:00
g_free ( rf_path ) ;
}
2016-05-11 12:31:59 +00:00
profile_store_persconffiles ( TRUE ) ;
2017-09-14 12:53:18 +00:00
recent_init ( ) ;
2016-05-11 12:31:59 +00:00
/* Read the profile independent recent file. We have to do this here so we can */
/* set the profile before it can be set from the command line parameter */
if ( ! recent_read_static ( & rf_path , & rf_open_errno ) ) {
simple_dialog ( ESD_TYPE_WARN , ESD_BTN_OK ,
" Could not open common recent file \n \" %s \" : %s. " ,
2020-09-04 22:15:05 +00:00
rf_path , g_strerror ( rf_open_errno ) ) ;
2016-05-11 12:31:59 +00:00
g_free ( rf_path ) ;
}
2018-12-13 02:16:15 +00:00
commandline_early_options ( argc , argv ) ;
2015-01-29 12:24:54 +00:00
2015-01-30 23:34:18 +00:00
# ifdef _WIN32
2020-12-15 19:14:17 +00:00
win32_reset_library_path ( ) ;
2015-01-30 23:34:18 +00:00
# endif
2017-08-07 15:42:37 +00:00
// Handle DPI scaling on Windows. This causes problems in at least
// one case on X11 and we don't yet support Android.
// We do the equivalent on macOS by setting NSHighResolutionCapable
// in Info.plist.
2018-05-09 18:46:56 +00:00
// Note that this enables Windows 8.1-style Per-monitor DPI
// awareness but not Windows 10-style Per-monitor v2 awareness.
2019-07-27 07:54:44 +00:00
// https://doc.qt.io/qt-5/scalability.html
// https://doc.qt.io/qt-5/highdpi.html
2017-07-27 23:42:25 +00:00
// https://bugreports.qt.io/browse/QTBUG-53022 - The device pixel ratio is pretty much bogus on Windows.
// https://bugreports.qt.io/browse/QTBUG-55510 - Windows have wrong size
2021-02-19 21:31:04 +00:00
# if defined(Q_OS_WIN)
2018-02-26 18:39:27 +00:00
QApplication : : setAttribute ( Qt : : AA_EnableHighDpiScaling ) ;
2017-07-27 23:42:25 +00:00
# endif
2015-01-30 23:34:18 +00:00
/* Create The Wireshark app */
2021-04-03 16:29:11 +00:00
wsApp = new WiresharkApplication ( argc , qt_argv ) ;
2015-01-30 23:34:18 +00:00
2012-01-04 22:13:01 +00:00
/* initialize the funnel mini-api */
// xxx qtshark
//initialize_funnel_ops();
2018-02-23 17:43:29 +00:00
Dot11DecryptInitContext ( & dot11decrypt_ctx ) ;
2012-01-04 22:13:01 +00:00
2014-09-29 23:27:11 +00:00
QString cf_name ;
2014-06-30 22:51:20 +00:00
unsigned int in_file_type = WTAP_TYPE_AUTO ;
2019-05-02 01:46:23 +00:00
err_msg = ws_init_sockets ( ) ;
if ( err_msg ! = NULL )
2017-03-26 22:46:13 +00:00
{
2019-05-02 01:46:23 +00:00
cmdarg_err ( " %s " , err_msg ) ;
g_free ( err_msg ) ;
cmdarg_err_cont ( " %s " , please_report_bug ( ) ) ;
2017-03-26 22:46:13 +00:00
ret_val = INIT_FAILED ;
goto clean_exit ;
}
2012-01-04 22:13:01 +00:00
2014-04-23 17:59:03 +00:00
/* 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-04-23 17:59:03 +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-04-23 17:59:03 +00:00
}
2015-12-15 18:47:02 +00:00
wsApp - > applyCustomColorsFromRecent ( ) ;
2014-04-23 17:59:03 +00:00
2013-12-21 16:55:43 +00:00
// Initialize our language
read_language_prefs ( ) ;
2016-06-24 23:01:51 +00:00
wsApp - > loadLanguage ( language ) ;
2013-12-21 16:55:43 +00:00
2021-06-08 01:46:52 +00:00
/* ws_log(LOG_DOMAIN_MAIN, LOG_LEVEL_DEBUG, "Translator %s", language); */
2013-12-21 16:55:43 +00:00
2014-04-23 17:59:03 +00:00
// Init the main window (and splash)
main_w = new ( MainWindow ) ;
main_w - > show ( ) ;
// We may not need a queued connection here but it would seem to make sense
// to force the issue.
2021-04-03 16:29:11 +00:00
main_w - > connect ( wsApp , SIGNAL ( openCaptureFile ( QString , QString , unsigned int ) ) ,
2015-09-11 18:13:23 +00:00
main_w , SLOT ( openCaptureFile ( QString , QString , unsigned int ) ) ) ;
2021-04-03 16:29:11 +00:00
main_w - > connect ( wsApp , SIGNAL ( openCaptureOptions ( ) ) ,
2016-10-19 08:19:28 +00:00
main_w , SLOT ( on_actionCaptureOptions_triggered ( ) ) ) ;
2014-04-23 17:59:03 +00:00
2012-09-17 23:40:53 +00:00
/* Init the "Open file" dialog directory */
/* (do this after the path settings are processed) */
if ( recent . gui_fileopen_remembered_dir & &
test_for_directory ( recent . gui_fileopen_remembered_dir ) = = EISDIR ) {
wsApp - > setLastOpenDir ( recent . gui_fileopen_remembered_dir ) ;
} else {
wsApp - > setLastOpenDir ( get_persdatafile_dir ( ) ) ;
}
2017-01-04 16:20:19 +00:00
# ifdef DEBUG_STARTUP_TIME
2021-06-08 01:46:52 +00:00
ws_log ( LOG_DOMAIN_MAIN , LOG_LEVEL_INFO , " set_console_log_handler, elapsed time % " G_GUINT64_FORMAT " us \n " , g_get_monotonic_time ( ) - start_time ) ;
2017-01-04 16:20:19 +00:00
# endif
2012-01-04 22:13:01 +00:00
2017-12-11 22:41:58 +00:00
# ifdef HAVE_LIBPCAP
/* 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 ) ;
# endif
2021-03-15 18:29:43 +00:00
init_report_message ( " Wireshark " , & wireshark_report_routines ) ;
2013-12-05 09:30:22 +00:00
2021-02-19 22:46:42 +00:00
/*
* Libwiretap must be initialized before libwireshark is , so that
* dissection - time handlers for file - type - dependent blocks can
* register using the file type / subtype value for the file type .
*/
2018-01-09 08:55:37 +00:00
wtap_init ( TRUE ) ;
2014-01-18 14:20:02 +00:00
2017-01-05 04:03:35 +00:00
splash_update ( RA_DISSECTORS , NULL , NULL ) ;
2017-01-04 16:20:19 +00:00
# ifdef DEBUG_STARTUP_TIME
2021-06-08 01:46:52 +00:00
ws_log ( LOG_DOMAIN_MAIN , LOG_LEVEL_INFO , " Calling epan init, elapsed time % " G_GUINT64_FORMAT " us \n " , g_get_monotonic_time ( ) - start_time ) ;
2017-01-04 16:20:19 +00:00
# endif
2016-06-19 09:01:56 +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 . */
2018-09-08 15:02:06 +00:00
if ( ! epan_init ( splash_update , NULL , TRUE ) ) {
2016-06-19 09:01:56 +00:00
SimpleDialog : : displayQueuedMessages ( main_w ) ;
2017-01-25 09:16:35 +00:00
ret_val = INIT_FAILED ;
goto clean_exit ;
2016-06-19 09:01:56 +00:00
}
2017-01-04 16:20:19 +00:00
# ifdef DEBUG_STARTUP_TIME
/* epan_init resets the preferences */
prefs . gui_console_open = console_open_always ;
2021-06-08 01:46:52 +00:00
ws_log ( LOG_DOMAIN_MAIN , LOG_LEVEL_INFO , " epan done, elapsed time % " G_GUINT64_FORMAT " us \n " , g_get_monotonic_time ( ) - start_time ) ;
2017-01-04 16:20:19 +00:00
# endif
2016-06-19 09:01:56 +00:00
2017-09-30 23:56:03 +00:00
/* Register all audio codecs. */
codecs_init ( ) ;
2016-10-17 09:55:56 +00:00
// Read the dynamic part of the recent file. This determines whether or
// not the recent list appears in the main window so the earlier we can
// call this the better.
if ( ! recent_read_dynamic ( & rf_path , & rf_open_errno ) ) {
simple_dialog ( ESD_TYPE_WARN , ESD_BTN_OK ,
" Could not open recent file \n \" %s \" : %s. " ,
rf_path , g_strerror ( rf_open_errno ) ) ;
g_free ( rf_path ) ;
}
2017-12-16 22:24:24 +00:00
wsApp - > refreshRecentCaptures ( ) ;
2016-10-17 09:55:56 +00:00
2013-11-21 20:24:01 +00:00
splash_update ( RA_LISTENERS , NULL , NULL ) ;
2017-01-04 16:20:19 +00:00
# ifdef DEBUG_STARTUP_TIME
2021-06-08 01:46:52 +00:00
ws_log ( LOG_DOMAIN_MAIN , LOG_LEVEL_INFO , " Register all tap listeners, elapsed time % " G_GUINT64_FORMAT " us \n " , g_get_monotonic_time ( ) - start_time ) ;
2017-01-04 16:20:19 +00:00
# endif
2013-11-21 20:24:01 +00:00
/* Register all tap listeners; we do this before we parse the arguments,
as the " -z " argument can specify a registered tap . */
2021-01-31 05:08:59 +00:00
register_all_tap_listeners ( tap_reg_listener ) ;
2013-11-21 20:24:01 +00:00
2014-07-23 17:38:55 +00:00
conversation_table_set_gui_info ( init_conversation_table ) ;
2014-08-06 17:07:42 +00:00
hostlist_table_set_gui_info ( init_endpoint_table ) ;
2015-06-05 20:17:13 +00:00
srt_table_iterate_tables ( register_service_response_tables , NULL ) ;
2015-07-07 19:04:48 +00:00
rtd_table_iterate_tables ( register_response_time_delay_tables , NULL ) ;
2018-02-18 22:39:49 +00:00
stat_tap_iterate_tables ( register_simple_stat_tables , NULL ) ;
2013-11-21 20:24:01 +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 " ) ) ;
}
2017-01-04 16:20:19 +00:00
# ifdef DEBUG_STARTUP_TIME
2021-06-08 01:46:52 +00:00
ws_log ( LOG_DOMAIN_MAIN , LOG_LEVEL_INFO , " Calling extcap_register_preferences, elapsed time % " G_GUINT64_FORMAT " us \n " , g_get_monotonic_time ( ) - start_time ) ;
2017-01-04 16:20:19 +00:00
# endif
2017-01-04 09:53:29 +00:00
splash_update ( RA_EXTCAP , NULL , NULL ) ;
extcap_register_preferences ( ) ;
2013-09-02 16:03:13 +00:00
splash_update ( RA_PREFERENCES , NULL , NULL ) ;
2018-01-13 12:21:09 +00:00
# ifdef DEBUG_STARTUP_TIME
2021-06-08 01:46:52 +00:00
ws_log ( LOG_DOMAIN_MAIN , LOG_LEVEL_INFO , " Calling module preferences, elapsed time % " G_GUINT64_FORMAT " us \n " , g_get_monotonic_time ( ) - start_time ) ;
2018-01-13 12:21:09 +00:00
# endif
2013-09-02 16:03:13 +00:00
2021-04-03 16:29:11 +00:00
global_commandline_info . prefs_p = wsApp - > readConfigurationFiles ( false ) ;
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 ) ;
2014-07-09 17:50:51 +00:00
2016-06-18 20:49:23 +00:00
/* Convert some command-line parameters to QStrings */
2016-06-28 01:40:09 +00:00
if ( global_commandline_info . cf_name ! = NULL )
cf_name = QString ( global_commandline_info . cf_name ) ;
if ( global_commandline_info . rfilter ! = NULL )
read_filter = QString ( global_commandline_info . rfilter ) ;
if ( global_commandline_info . dfilter ! = NULL )
dfilter = QString ( global_commandline_info . dfilter ) ;
2014-07-09 17:50:51 +00:00
2014-10-21 20:36:10 +00:00
timestamp_set_type ( recent . gui_time_format ) ;
timestamp_set_precision ( recent . gui_time_precision ) ;
2015-12-13 11:41:59 +00:00
timestamp_set_seconds_type ( recent . gui_seconds_format ) ;
2012-01-04 22:13:01 +00:00
2012-08-03 23:30:47 +00:00
# ifdef HAVE_LIBPCAP
2017-01-04 16:20:19 +00:00
# ifdef DEBUG_STARTUP_TIME
2021-06-08 01:46:52 +00:00
ws_log ( LOG_DOMAIN_MAIN , LOG_LEVEL_INFO , " Calling fill_in_local_interfaces, elapsed time % " G_GUINT64_FORMAT " us \n " , g_get_monotonic_time ( ) - start_time ) ;
2017-01-04 16:20:19 +00:00
# endif
2016-06-24 23:48:23 +00:00
splash_update ( RA_INTERFACES , NULL , NULL ) ;
2018-09-26 13:19:08 +00:00
if ( ! global_commandline_info . cf_name & & ! prefs . capture_no_interface_load )
2018-09-10 10:39:34 +00:00
fill_in_local_interfaces ( main_window_update ) ;
2012-08-03 23:30:47 +00:00
2017-08-07 14:38:52 +00:00
if ( global_commandline_info . list_link_layer_types )
caps_queries | = CAPS_QUERY_LINK_TYPES ;
2017-12-11 22:41:58 +00:00
if ( global_commandline_info . list_timestamp_types )
2017-08-07 14:38:52 +00:00
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
2014-09-29 23:27: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_val = 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_val ! = 0 ) {
goto clean_exit ;
2014-09-29 23:27:11 +00:00
}
}
2021-04-14 00:00:38 +00:00
/*
* If requested , list the link layer types and / or time stamp types
* and exit .
*/
2017-08-07 14:38:52 +00:00
if ( caps_queries ) {
2014-09-29 23:27:11 +00:00
guint i ;
2021-04-14 00:00:38 +00:00
2021-04-15 05:51:21 +00:00
# ifdef _WIN32
create_console ( ) ;
# endif /* _WIN32 */
2021-04-14 00:00:38 +00:00
/* Get the list of link-layer types for the capture devices. */
2021-04-15 06:36:07 +00:00
ret_val = EXIT_SUCCESS ;
2021-04-14 00:00:38 +00:00
for ( i = 0 ; i < global_capture_opts . ifaces - > len ; i + + ) {
interface_options * interface_opts ;
if_capabilities_t * caps ;
char * auth_str = NULL ;
interface_opts = & g_array_index ( global_capture_opts . ifaces , interface_options , i ) ;
# ifdef HAVE_PCAP_REMOTE
if ( interface_opts - > auth_type = = CAPTURE_AUTH_PWD ) {
auth_str = g_strdup_printf ( " %s:%s " , interface_opts - > auth_username , interface_opts - > auth_password ) ;
}
# endif
caps = capture_get_if_capabilities ( interface_opts - > name , interface_opts - > monitor_mode ,
auth_str , & err_str , & err_str_secondary , NULL ) ;
g_free ( auth_str ) ;
if ( caps = = NULL ) {
cmdarg_err ( " %s%s%s " , err_str , err_str_secondary ? " \n " : " " , err_str_secondary ? err_str_secondary : " " ) ;
g_free ( err_str ) ;
g_free ( err_str_secondary ) ;
ret_val = INVALID_CAPABILITY ;
2021-04-15 06:36:07 +00:00
break ;
2021-04-14 00:00:38 +00:00
}
2021-04-14 06:14:09 +00:00
ret_val = capture_opts_print_if_capabilities ( caps , interface_opts ,
caps_queries ) ;
2021-04-15 05:51:21 +00:00
free_if_capabilities ( caps ) ;
if ( ret_val ! = EXIT_SUCCESS ) {
2021-04-15 06:36:07 +00:00
break ;
2021-04-15 05:51:21 +00:00
}
2014-09-29 23:27:11 +00:00
}
2021-04-15 05:51:21 +00:00
# ifdef _WIN32
destroy_console ( ) ;
# endif /* _WIN32 */
2017-01-25 09:16:35 +00:00
goto clean_exit ;
2014-09-29 23:27:11 +00:00
}
2012-08-03 23:30:47 +00:00
capture_opts_trim_snaplen ( & global_capture_opts , MIN_PACKET_SIZE ) ;
capture_opts_trim_ring_num_files ( & global_capture_opts ) ;
# endif /* HAVE_LIBPCAP */
2012-12-07 01:46:20 +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 . */
2017-01-04 16:20:19 +00:00
# ifdef DEBUG_STARTUP_TIME
2021-06-08 01:46:52 +00:00
ws_log ( LOG_DOMAIN_MAIN , LOG_LEVEL_INFO , " Calling prefs_apply_all, elapsed time % " G_GUINT64_FORMAT " us \n " , g_get_monotonic_time ( ) - start_time ) ;
2017-01-04 16:20:19 +00:00
# endif
2013-01-18 00:50:14 +00:00
prefs_apply_all ( ) ;
2018-01-08 23:40:50 +00:00
prefs_to_capture_opts ( ) ;
2013-01-18 00:50:14 +00:00
wsApp - > emitAppSignal ( WiresharkApplication : : PreferencesChanged ) ;
2012-08-03 23:30:47 +00:00
# ifdef HAVE_LIBPCAP
if ( ( global_capture_opts . num_selected = = 0 ) & &
( prefs . capture_device ! = NULL ) ) {
guint i ;
2017-08-24 14:16:34 +00:00
interface_t * device ;
2012-08-03 23:30:47 +00:00
for ( i = 0 ; i < global_capture_opts . all_ifaces - > len ; i + + ) {
2017-08-24 14:16:34 +00:00
device = & g_array_index ( global_capture_opts . all_ifaces , interface_t , i ) ;
if ( ! device - > hidden & & strcmp ( device - > display_name , prefs . capture_device ) = = 0 ) {
device - > selected = TRUE ;
2012-08-03 23:30:47 +00:00
global_capture_opts . num_selected + + ;
break ;
}
}
}
# 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_val = 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 ( & CaptureFile : : globalCapFile ( ) - > cinfo , global_commandline_info . prefs_p - > num_cols , TRUE ) ;
2015-02-19 01:18:27 +00:00
wsApp - > emitAppSignal ( WiresharkApplication : : ColumnsChanged ) ; // We read "recent" widths above.
2015-07-08 23:48:58 +00:00
wsApp - > emitAppSignal ( WiresharkApplication : : RecentPreferencesRead ) ; // Must be emitted after PreferencesChanged.
2012-01-04 22:13:01 +00:00
2013-01-24 01:10:12 +00:00
wsApp - > setMonospaceFont ( prefs . gui_qt_font_name ) ;
2012-01-04 22:13:01 +00:00
2015-12-15 11:12:27 +00:00
/* For update of WindowTitle (When use gui.window_title preference) */
main_w - > setWSWindowTitle ( ) ;
2012-01-04 22:13:01 +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 ) ;
}
2012-01-04 22:13:01 +00:00
2012-11-03 22:48:29 +00:00
wsApp - > allSystemsGo ( ) ;
2021-06-16 00:07:37 +00:00
ws_log ( LOG_DOMAIN_MAIN , LOG_LEVEL_MESSAGE , " Wireshark is up and ready to go, elapsed time %.3fs " , ( float ) ( g_get_monotonic_time ( ) - start_time ) / 1000000 ) ;
2014-12-14 17:49:02 +00:00
SimpleDialog : : displayQueuedMessages ( main_w ) ;
2012-01-04 22:13:01 +00:00
2015-06-05 20:17:13 +00:00
/* User could specify filename, or display filter, or both */
2015-12-15 08:15:51 +00:00
if ( ! dfilter . isEmpty ( ) )
main_w - > filterPackets ( dfilter , false ) ;
2014-09-29 23:27:11 +00:00
if ( ! cf_name . isEmpty ( ) ) {
2015-06-05 20:17:13 +00:00
if ( main_w - > openCaptureFile ( cf_name , read_filter , in_file_type ) ) {
/* Open stat windows; we do so after creating the main window,
to avoid Qt 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 ( ) ;
2019-11-17 19:02:20 +00:00
if ( global_commandline_info . go_to_packet ! = 0 ) {
2015-06-05 20:17:13 +00:00
/* Jump to the specified frame number, kept for backward
compatibility . */
2016-06-28 01:40:09 +00:00
cf_goto_frame ( CaptureFile : : globalCapFile ( ) , global_commandline_info . go_to_packet ) ;
} else if ( global_commandline_info . jfilter ! = NULL ) {
2016-06-22 21:41:16 +00:00
dfilter_t * jump_to_filter = NULL ;
/* 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 ) ) {
2016-06-22 21:41:16 +00:00
// Similar code in MainWindow::mergeCaptureFile().
QMessageBox : : warning ( main_w , QObject : : tr ( " Invalid Display Filter " ) ,
QObject : : tr ( " The filter expression %1 isn't a valid display filter. (%2). " )
2016-06-28 01:40:09 +00:00
. arg ( global_commandline_info . jfilter , err_msg ) ,
2016-06-22 21:41:16 +00:00
QMessageBox : : Ok ) ;
g_free ( err_msg ) ;
} 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 ( CaptureFile : : globalCapFile ( ) , jump_to_filter , global_commandline_info . jump_backwards ) ;
2016-06-22 21:41:16 +00:00
}
2015-06-05 20:17:13 +00:00
}
2014-09-30 19:59:51 +00:00
}
2013-09-02 14:15:23 +00:00
}
2014-09-29 23:27:11 +00:00
# ifdef HAVE_LIBPCAP
else {
2016-06-28 01:40:09 +00:00
if ( global_commandline_info . start_capture ) {
2014-09-29 23:27: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
gchar * s = g_strdup ( global_capture_opts . save_file ) ;
set_last_open_dir ( get_dirname ( s ) ) ;
2014-09-29 23:27:11 +00:00
g_free ( s ) ;
}
/* "-k" was specified; start a capture. */
2020-02-03 17:18:29 +00:00
check_and_warn_user_startup ( ) ;
2014-09-29 23:27: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 ) ;
2014-09-09 20:42:58 +00:00
CaptureFile : : globalCapFile ( ) - > window = main_w ;
Clean up handling of --capture-comment.
Don't store the comments in a capture_options structure, because that's
available only if we're being built with capture support, and
--capture-comment can be used in TShark when reading a capture file and
writing another capture file, with no live capture taking place.
This means we don't handle that option in capture_opts_add_opt(); handle
it in the programs that support it.
Support writing multiple comments in dumpcap when capturing.
These changes also fix builds without pcap, and makes --capture-comment
work in Wireshark when a capture is started from the command line with
-k.
Update the help messages to indicate that --capture-comment adds a
capture comment, it doesn't change any comment (much less "the" comment,
as there isn't necessarily a single comment).
Update the man pages:
- not to presume that only pcapng files support file comments (even if
that's true now, it might not be true in the future);
- to note that multiple instances of --capture-comment are supported,
and that multiple comments will be written, whether capturing or reading
one file and writing another;
- clarify that Wireshark doesn't *discard* SHB comments other than the
first one, even though it only displays the first one;
2021-07-15 05:16:30 +00:00
if ( capture_start ( & global_capture_opts , global_commandline_info . capture_comments ,
main_w - > captureSession ( ) , main_w - > captureInfoData ( ) ,
main_window_update ) ) {
2014-09-29 23:27: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 ( ) ;
}
}
2018-01-24 23:52:49 +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 ) {
2014-09-29 23:27:11 +00:00
global_capture_opts . default_options . cfilter = g_strdup ( get_conn_cfilter ( ) ) ;
}
}
# endif /* HAVE_LIBPCAP */
2013-09-02 14:15:23 +00:00
2017-03-22 09:52:16 +00:00
// UAT files used in configuration profiles which are used in Qt dialogs
// are not registered during startup because they only get loaded when
// the dialog is shown. Register them here.
g_free ( get_persconffile_path ( " io_graphs " , TRUE ) ) ;
2016-05-11 12:31:59 +00:00
profile_store_persconffiles ( FALSE ) ;
2016-05-11 13:16:44 +00:00
ret_val = wsApp - > exec ( ) ;
2017-09-14 12:53:18 +00:00
recent_cleanup ( ) ;
2016-05-11 13:16:44 +00:00
epan_cleanup ( ) ;
2021-04-03 16:29:11 +00:00
delete main_w ;
delete wsApp ;
wsApp = NULL ;
2016-09-10 23:16:24 +00:00
extcap_cleanup ( ) ;
2018-02-23 17:43:29 +00:00
Dot11DecryptDestroyContext ( & dot11decrypt_ctx ) ;
2016-05-11 13:16:44 +00:00
2019-05-02 01:46:23 +00:00
ws_cleanup_sockets ( ) ;
2016-05-11 13:16:44 +00:00
2019-05-02 01:46:23 +00:00
# ifdef _WIN32
2016-05-11 13:16:44 +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 ( ) ;
# endif /* _WIN32 */
2017-01-25 09:16:35 +00:00
clean_exit :
2017-02-03 00:00:49 +00:00
# ifdef HAVE_LIBPCAP
2017-01-25 09:16:35 +00:00
capture_opts_cleanup ( & global_capture_opts ) ;
2017-02-03 00:00:49 +00:00
# endif
2017-02-03 21:41:31 +00:00
col_cleanup ( & CaptureFile : : globalCapFile ( ) - > cinfo ) ;
2017-09-30 23:56:03 +00:00
codecs_cleanup ( ) ;
2017-02-04 15:26:34 +00:00
wtap_cleanup ( ) ;
2017-02-08 13:25:57 +00:00
free_progdirs ( ) ;
2018-02-26 18:39:27 +00:00
exit_application ( ret_val ) ;
2012-01-04 22:13:01 +00:00
}