2015-02-12 20:33:24 +00:00
/* wireshark-qt.cpp
2012-01-04 22:13:01 +00:00
*
* Wireshark - Network traffic analyzer
* By Gerald Combs < gerald @ wireshark . org >
* Copyright 1998 Gerald Combs
*
* This program is free software ; you can redistribute it and / or
* 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 .
*
* 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 .
*
* 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 .
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>
2014-12-31 10:23:14 +00:00
# ifdef Q_OS_UNIX
2014-05-12 16:57:44 +00:00
# include <signal.h>
2014-12-31 10:23:14 +00:00
# endif
2014-05-12 16:57:44 +00:00
2016-06-24 23:01:51 +00:00
# include <locale.h>
2014-12-25 01:10:40 +00:00
# ifdef HAVE_GETOPT_H
# include <getopt.h>
# endif
# ifndef HAVE_GETOPT_LONG
# include "wsutil/wsgetopt.h"
2012-01-04 22:13:01 +00:00
# endif
2017-05-03 21:56:55 +00:00
# ifndef _WIN32
# include <wsutil/glib-compat.h>
# endif
2014-06-29 21:37:21 +00:00
# include <wsutil/clopts_common.h>
# include <wsutil/cmdarg_err.h>
2013-01-16 00:13:33 +00:00
# include <wsutil/crash_info.h>
2013-11-19 19:45:38 +00:00
# include <wsutil/filesystem.h>
# include <wsutil/privileges.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>
2015-06-16 18:55:09 +00:00
# include <wsutil/unicode-utils.h>
2016-04-19 07:03:08 +00:00
# include <ws_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
2013-12-02 08:30:29 +00:00
# include <codecs/codecs.h>
2015-12-29 06:57:36 +00:00
# ifdef HAVE_EXTCAP
# include <extcap.h>
# endif
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
# include "log.h"
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"
2012-01-16 01:18:56 +00:00
2015-07-07 19:04:48 +00:00
# include "ui/qt/conversation_dialog.h"
2015-12-22 20:07:00 +00:00
# include "ui/qt/color_utils.h"
# 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"
2015-02-11 23:00:27 +00:00
# include "ui/qt/splash_overlay.h"
2015-01-01 09:19:57 +00:00
# include "ui/qt/wireshark_application.h"
2014-07-04 08:01:03 +00:00
# include "caputils/capture-pcap-util.h"
2014-07-03 09:16:12 +00:00
2012-01-04 22:13:01 +00:00
# ifdef _WIN32
2014-07-04 07:24:02 +00:00
# include "caputils / capture-wpcap.h"
# include "caputils / capture_wpcap_packet.h"
2012-03-30 14:55:00 +00:00
# include <tchar.h> /* Needed for Unicode */
2015-01-01 00:10:02 +00:00
# include <wsutil / file_util.h>
2014-09-29 23:27:11 +00:00
# include <wsutil / os_version_info.h>
2012-01-04 22:13:01 +00:00
# endif /* _WIN32 */
# ifdef HAVE_AIRPCAP
2014-08-01 00:29:36 +00:00
# include <caputils / airpcap.h>
# include <caputils / 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
2014-09-29 23:27:11 +00:00
# include "epan/crypt/airpdcap_ws.h"
2012-01-04 22:13:01 +00:00
In Qt 4, C strings are, by default, treated as 7-bit ASCII when
converted to QStrings, and, to get them to be treated as UTF-8, you need
to call the setCodecForCStrings method of the QTextCodec class to set
the codec to a UTF-8 codec.
In Qt 5, C strings are treated always as UTF-8 when converted to
QStrings, and there's no setCodecForCStrings method for the QTextCodec
class.
In addition, there's also no setCodecForTr method for the QTextCodec
class - and QObject isn't documented as even *having* a tr method, so I
don't know what to do there.
svn path=/trunk/; revision=47436
2013-02-02 03:59:57 +00:00
# if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
2012-01-04 22:13:01 +00:00
# include <QTextCodec>
In Qt 4, C strings are, by default, treated as 7-bit ASCII when
converted to QStrings, and, to get them to be treated as UTF-8, you need
to call the setCodecForCStrings method of the QTextCodec class to set
the codec to a UTF-8 codec.
In Qt 5, C strings are treated always as UTF-8 when converted to
QStrings, and there's no setCodecForCStrings method for the QTextCodec
class.
In addition, there's also no setCodecForTr method for the QTextCodec
class - and QObject isn't documented as even *having* a tr method, so I
don't know what to do there.
svn path=/trunk/; revision=47436
2013-02-02 03:59:57 +00:00
# endif
2014-09-29 23:27:11 +00:00
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
2017-01-04 16:20:19 +00:00
//#define DEBUG_STARTUP_TIME 1
/*
# Log level
# Console log level (for debugging)
# A bitmask of log levels:
# ERROR = 4
# CRITICAL = 8
# WARNING = 16
# MESSAGE = 32
# INFO = 64
# DEBUG = 128
*/
# define DEBUG_STARTUP_TIME_LOGLEVEL 252
2012-01-04 22:13:01 +00:00
/* update the main window */
void main_window_update ( void )
{
WiresharkApplication : : processEvents ( ) ;
}
# ifdef HAVE_LIBPCAP
/* quit a nested main window */
void main_window_nested_quit ( void )
{
// if (gtk_main_level() > 0)
2013-10-30 22:39:52 +00:00
wsApp - > quit ( ) ;
2012-01-04 22:13:01 +00:00
}
/* 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
}
# endif /* HAVE_LIBPCAP */
/*
* Report 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 ( 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 - pop this up in a window of some sort on UNIX + X11 if the controlling
* terminal isn ' t the standard error ?
*/
// 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
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
2016-11-28 23:58:40 +00:00
codec_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
}
// 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
{
2014-06-23 22:49:11 +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 22:49:11 +00:00
# endif
2014-06-23 21:55:56 +00:00
/* stuff used by libwireshark */
2014-01-05 18:40:07 +00:00
epan_get_runtime_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
# ifdef HAVE_AIRPCAP
2014-01-05 18:40:07 +00:00
g_string_append ( str , " , " ) ;
get_runtime_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
# endif
}
2012-01-04 22:13:01 +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
check_and_warn_user_startup ( const QString & cf_name )
{
# ifndef _WIN32
Q_UNUSED ( cf_name )
# endif
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 ,
" 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 ) ;
2014-09-29 23:27:11 +00:00
g_free ( cur_user ) ;
g_free ( cur_group ) ;
}
# ifdef _WIN32
/* Warn the user if npf.sys isn't loaded. */
if ( ! get_stdin_capture ( ) & & cf_name . isEmpty ( ) & & ! npf_sys_is_running ( ) & & recent . privs_warn_if_no_npf & & get_windows_major_version ( ) > = 6 ) {
simple_message_box ( ESD_TYPE_WARN , & recent . privs_warn_if_no_npf , " %s " ,
" The NPF driver isn't running. You may have trouble \n "
" capturing or listing interfaces. " ) ;
}
# endif
}
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
reset_library_path ( void )
{
QString app_path = QDir ( get_progfile_dir ( ) ) . path ( ) ;
foreach ( QString path , QCoreApplication : : libraryPaths ( ) ) {
QCoreApplication : : removeLibraryPath ( path ) ;
}
QCoreApplication : : addLibraryPath ( app_path ) ;
}
# 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
int opt ;
# 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
# ifdef _WIN32
2017-03-26 22:46:13 +00:00
int result ;
2015-06-11 22:05:44 +00:00
WSADATA wsaData ;
2012-01-04 22:13:01 +00:00
# endif /* _WIN32 */
char * rf_path ;
int rf_open_errno ;
# ifdef HAVE_LIBPCAP
gchar * err_str ;
# else
# ifdef _WIN32
# ifdef HAVE_AIRPCAP
gchar * err_str ;
# endif
# endif
# endif
2017-01-25 09:16:35 +00:00
gchar * err_msg = NULL ;
2016-06-19 21:12:30 +00:00
GString * comp_info_str = NULL ;
GString * runtime_info_str = NULL ;
2012-01-04 22:13:01 +00:00
2014-11-22 11:58:43 +00:00
QString dfilter , read_filter ;
2017-01-04 16:20:19 +00:00
/* Start time in microseconds*/
guint64 start_time = g_get_monotonic_time ( ) ;
# ifdef DEBUG_STARTUP_TIME
/* At least on Windows there is a problem with the loging as the preferences is taken
* into account and the preferences are loaded pretty late in the startup process .
*/
prefs . console_log_level = DEBUG_STARTUP_TIME_LOGLEVEL ;
prefs . gui_console_open = console_open_always ;
# endif /* DEBUG_STARTUP_TIME */
2014-06-29 21:37:21 +00:00
cmdarg_err_init ( wireshark_cmdarg_err , wireshark_cmdarg_err_cont ) ;
2015-06-16 18:55:09 +00:00
// In Qt 5, C strings are treated always as UTF-8 when converted to
// QStrings; in Qt 4, the codec must be set to make that happen
# if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
// Hopefully we won't have to use QString::fromUtf8() in as many places.
QTextCodec * utf8codec = QTextCodec : : codecForName ( " UTF-8 " ) ;
QTextCodec : : setCodecForCStrings ( utf8codec ) ;
// XXX - QObject doesn't *have* a tr method in 5.0, as far as I can see...
QTextCodec : : setCodecForTr ( utf8codec ) ;
# endif
/* Set the C-language locale to the native environment. */
2016-06-24 23:01:51 +00:00
setlocale ( LC_ALL , " " ) ;
2013-02-20 05:04:57 +00:00
# ifdef _WIN32
2015-06-17 17:55:19 +00:00
// QCoreApplication clobbers argv. Let's have a local copy.
2016-09-16 01:20:05 +00:00
argv = ( char * * ) g_malloc ( sizeof ( char * ) * argc ) ;
2015-06-17 17:55:19 +00:00
for ( opt = 0 ; opt < argc ; opt + + ) {
2016-09-16 01:20:05 +00:00
argv [ opt ] = qt_argv [ opt ] ;
2015-06-17 17:55:19 +00:00
}
2016-09-16 01:20:05 +00:00
arg_list_utf_16to8 ( argc , argv ) ;
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
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
*/
2016-09-16 01:20:05 +00:00
/* init_progfile_dir_error = */ init_progfile_dir ( argv [ 0 ] ,
2015-12-12 02:34:47 +00:00
( int ( * ) ( int , char * * ) ) get_gui_compiled_info ) ;
2015-01-31 04:06:49 +00:00
g_log ( NULL , G_LOG_LEVEL_DEBUG , " progfile_dir: %s " , get_progfile_dir ( ) ) ;
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 ( ) ;
/* ... and also load the packet.dll from wpcap */
wpcap_packet_load ( ) ;
# 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 ) ;
if ( g_airpcap_if_list = = NULL | | g_list_length ( g_airpcap_if_list ) = = 0 ) {
if ( err = = CANT_GET_AIRPCAP_INTERFACE_LIST & & err_str ! = NULL ) {
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " %s " , " Failed to open Airpcap Adapters. " ) ;
g_free ( err_str ) ;
}
airpcap_if_active = NULL ;
} else {
/* select the first ad default (THIS SHOULD BE CHANGED) */
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 */
2016-06-19 21:12:30 +00:00
comp_info_str = get_compiled_version_info ( get_wireshark_qt_compiled_info ,
2015-01-29 12:24:54 +00:00
get_gui_compiled_info ) ;
/* Assemble 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 ) ;
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 ,
" Could not create profiles directory \n \" %s \" " ,
rf_path ) ;
g_free ( rf_path ) ;
}
2016-05-11 12:31:59 +00:00
profile_store_persconffiles ( TRUE ) ;
/* 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. " ,
rf_path , strerror ( rf_open_errno ) ) ;
g_free ( rf_path ) ;
}
2016-09-16 01:20:05 +00:00
commandline_early_options ( argc , argv , comp_info_str , runtime_info_str ) ;
2015-01-29 12:24:54 +00:00
2015-01-30 23:34:18 +00:00
# ifdef _WIN32
reset_library_path ( ) ;
# endif
/* Create The Wireshark app */
2016-09-16 01:20:05 +00:00
WiresharkApplication ws_app ( 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();
AirPDcapInitContext ( & airpdcap_ctx ) ;
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 ;
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 "
2014-06-30 22:51:20 +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 ) ;
2016-09-11 14:10:46 +00:00
g_string_free ( comp_info_str , TRUE ) ;
g_string_free ( runtime_info_str , TRUE ) ;
2014-06-30 22:51:20 +00:00
# ifdef _WIN32
2012-01-04 22:13:01 +00:00
/* Start windows sockets */
2017-03-26 22:46:13 +00:00
result = WSAStartup ( MAKEWORD ( 1 , 1 ) , & wsaData ) ;
if ( result ! = 0 )
{
ret_val = INIT_FAILED ;
goto clean_exit ;
}
2012-01-04 22:13:01 +00:00
# endif /* _WIN32 */
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
2016-06-24 23:01:51 +00:00
g_log ( LOG_DOMAIN_MAIN , G_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.
2015-09-11 18:13:23 +00:00
main_w - > connect ( & ws_app , SIGNAL ( openCaptureFile ( QString , QString , unsigned int ) ) ,
main_w , SLOT ( openCaptureFile ( QString , QString , unsigned int ) ) ) ;
2016-10-19 08:19:28 +00:00
main_w - > connect ( & ws_app , SIGNAL ( openCaptureOptions ( ) ) ,
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 ( ) ) ;
}
2014-05-12 16:57:44 +00:00
# ifdef Q_OS_UNIX
// Replicates behavior in gtk_init();
signal ( SIGPIPE , SIG_IGN ) ;
# endif
2014-09-25 23:21:02 +00:00
set_console_log_handler ( ) ;
2017-01-04 16:20:19 +00:00
# ifdef DEBUG_STARTUP_TIME
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_INFO , " set_console_log_handler, elapsed time % " G_GUINT64_FORMAT " us \n " , g_get_monotonic_time ( ) - start_time ) ;
# endif
2012-01-04 22:13:01 +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 . */
2013-05-22 07:44:28 +00:00
capture_opts_init ( & global_capture_opts ) ;
2012-01-04 22:13:01 +00:00
# endif
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
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
/* Register all the plugin types we have. */
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
/* 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 ) ;
2013-12-02 08:30:29 +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
/* Register all audio codec plugins. */
register_all_codecs ( ) ;
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
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_INFO , " Calling epan init, elapsed time % " G_GUINT64_FORMAT " us \n " , g_get_monotonic_time ( ) - start_time ) ;
# 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 . */
if ( ! epan_init ( register_all_protocols , register_all_protocol_handoffs ,
splash_update , NULL ) ) {
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 . console_log_level = DEBUG_STARTUP_TIME_LOGLEVEL ;
prefs . gui_console_open = console_open_always ;
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_INFO , " epan done, elapsed time % " G_GUINT64_FORMAT " us \n " , g_get_monotonic_time ( ) - start_time ) ;
# endif
2016-06-19 09:01:56 +00:00
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 ) ;
}
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
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_INFO , " Register all tap listeners, elapsed time % " G_GUINT64_FORMAT " us \n " , g_get_monotonic_time ( ) - start_time ) ;
# 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 . */
/* 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 */
2014-01-05 18:40:07 +00:00
# ifdef HAVE_PLUGINS
2013-11-21 20:24:01 +00:00
register_all_plugin_tap_listeners ( ) ;
2014-01-05 18:40:07 +00:00
# endif
2013-11-21 20:24:01 +00:00
register_all_tap_listeners ( ) ;
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 ) ;
2015-07-07 23:18:00 +00:00
new_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 09:53:29 +00:00
# ifdef HAVE_EXTCAP
2017-01-04 16:20:19 +00:00
# ifdef DEBUG_STARTUP_TIME
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_INFO , " Calling extcap_register_preferences, elapsed time % " G_GUINT64_FORMAT " us \n " , g_get_monotonic_time ( ) - start_time ) ;
# endif
2017-01-04 09:53:29 +00:00
splash_update ( RA_EXTCAP , NULL , NULL ) ;
extcap_register_preferences ( ) ;
# endif
2013-09-02 16:03:13 +00:00
splash_update ( RA_PREFERENCES , NULL , NULL ) ;
2017-01-04 16:20:19 +00:00
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_INFO , " Calling module preferences, elapsed time % " G_GUINT64_FORMAT " us \n " , g_get_monotonic_time ( ) - start_time ) ;
2013-09-02 16:03:13 +00:00
2017-04-08 19:45:19 +00:00
global_commandline_info . prefs_p = ws_app . 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
2012-01-04 22:13:01 +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
2012-01-04 22:13:01 +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
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_INFO , " Calling fill_in_local_interfaces, elapsed time % " G_GUINT64_FORMAT " us \n " , g_get_monotonic_time ( ) - start_time ) ;
# endif
2016-06-24 23:48:23 +00:00
splash_update ( RA_INTERFACES , NULL , NULL ) ;
2013-06-27 19:24:39 +00:00
fill_in_local_interfaces ( main_window_update ) ;
2012-08-03 23:30:47 +00:00
2016-06-28 01:40:09 +00:00
if ( global_commandline_info . start_capture | | global_commandline_info . list_link_layer_types ) {
2014-09-29 23:27:11 +00:00
/* We're supposed to do a live capture or get a list of link-layer
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
}
}
2016-06-28 01:40:09 +00:00
if ( global_commandline_info . list_link_layer_types ) {
2014-09-29 23:27: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 + + ) {
device = g_array_index ( global_capture_opts . all_ifaces , interface_t , i ) ;
if ( device . selected ) {
# if defined(HAVE_PCAP_CREATE)
2015-07-17 15:01:27 +00:00
caps = capture_get_if_capabilities ( device . name , device . monitor_mode_supported , NULL , & err_str , main_window_update ) ;
2014-09-29 23:27:11 +00:00
# else
2015-07-17 15:01:27 +00:00
caps = capture_get_if_capabilities ( device . name , FALSE , NULL , & err_str , main_window_update ) ;
2014-09-29 23:27:11 +00:00
# endif
if ( caps = = NULL ) {
cmdarg_err ( " %s " , err_str ) ;
g_free ( err_str ) ;
2017-01-25 09:16:35 +00:00
ret_val = INVALID_CAPABILITY ;
goto clean_exit ;
2014-09-29 23:27:11 +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_val = INVALID_LINK_TYPE ;
goto clean_exit ;
2014-09-29 23:27:11 +00:00
}
# ifdef _WIN32
create_console ( ) ;
# endif /* _WIN32 */
# if defined(HAVE_PCAP_CREATE)
capture_opts_print_if_capabilities ( caps , device . name , device . monitor_mode_supported ) ;
# else
capture_opts_print_if_capabilities ( caps , device . name , FALSE ) ;
# endif
# ifdef _WIN32
destroy_console ( ) ;
# endif /* _WIN32 */
free_if_capabilities ( caps ) ;
}
}
2017-01-25 09:16:35 +00:00
ret_val = EXIT_SUCCESS ;
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 */
2017-01-04 16:20:19 +00:00
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
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_INFO , " Calling prefs_apply_all, elapsed time % " G_GUINT64_FORMAT " us \n " , g_get_monotonic_time ( ) - start_time ) ;
# endif
2013-01-18 00:50:14 +00:00
prefs_apply_all ( ) ;
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 ;
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 & & strcmp ( device . display_name , prefs . capture_device ) = = 0 ) {
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 ;
}
}
}
# 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
////////
2015-12-22 20:07:00 +00:00
packet_list_enable_color ( recent . packet_list_colorize ) ;
2012-01-04 22:13:01 +00:00
g_log ( NULL , G_LOG_LEVEL_DEBUG , " FIX: fetch recent color settings " ) ;
2015-12-22 20:07:00 +00:00
packet_list_enable_color ( TRUE ) ;
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
2013-08-31 16:53:24 +00:00
# ifdef HAVE_LIBPCAP
/* 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-01-05 18:40:07 +00:00
global_capture_opts . default_options . cfilter = g_strdup ( get_conn_cfilter ( ) ) ;
2013-08-31 16:53:24 +00:00
}
# else /* HAVE_LIBPCAP */
////////
# endif /* HAVE_LIBPCAP */
2012-11-03 22:48:29 +00:00
wsApp - > allSystemsGo ( ) ;
2017-01-04 16:20:19 +00:00
g_log ( LOG_DOMAIN_MAIN , G_LOG_LEVEL_INFO , " Wireshark is up and ready to go, elapsed time % " G_GUINT64_FORMAT " us \n " , g_get_monotonic_time ( ) - start_time ) ;
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 ( ) ;
2016-06-28 01:40:09 +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. */
// show_main_window(FALSE);
check_and_warn_user_startup ( cf_name ) ;
/* 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 ;
2015-12-17 04:15:03 +00:00
if ( capture_start ( & global_capture_opts , 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 ( ) ;
}
}
/* 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 ( ) ;
epan_cleanup ( ) ;
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
2016-05-11 13:16:44 +00:00
AirPDcapDestroyContext ( & airpdcap_ctx ) ;
# ifdef _WIN32
/* Shutdown windows sockets */
WSACleanup ( ) ;
/* 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-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
2016-05-11 13:16:44 +00:00
return ret_val ;
2012-01-04 22:13:01 +00:00
}
2012-09-04 08:18:31 +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 :
*/