#include <stdio.h>
#include <string.h>
-#include <ctype.h>
#include <locale.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
#endif
-#ifndef HAVE_GETOPT
+#ifndef HAVE_GETOPT_LONG
#include "wsutil/wsgetopt.h"
#endif
#ifdef HAVE_LIBZ
-#include <zlib.h> /* to get the libz version number */
-#endif
-
-#ifdef HAVE_LIBCAP
-# include <sys/capability.h>
-#endif
-
-#ifdef _WIN32 /* Needed for console I/O */
-
-#include <fcntl.h>
-#include <conio.h>
-#include <ui/win32/console_win32.h>
+#include <zlib.h> /* to get the libz version number */
#endif
#ifdef HAVE_LIBPORTAUDIO
#endif /* HAVE_LIBPORTAUDIO */
#include <wsutil/clopts_common.h>
+#include <wsutil/copyright_info.h>
#include <wsutil/crash_info.h>
#include <wsutil/filesystem.h>
#include <wsutil/file_util.h>
#include <wsutil/privileges.h>
#include <wsutil/report_err.h>
#include <wsutil/u3.h>
-#include <wsutil/copyright_info.h>
-#include <wsutil/os_version_info.h>
+#include <wsutil/ws_diag_control.h>
#include <wsutil/ws_version_info.h>
#include <wiretap/merge.h>
#include <epan/column.h>
#include <epan/disabled_protos.h>
#include <epan/epan.h>
+#include <epan/proto.h>
#include <epan/epan_dissect.h>
#include <epan/dfilter/dfilter.h>
#include <epan/strutil.h>
-#include <epan/emem.h>
#include <epan/ex-opt.h>
#include <epan/funnel.h>
#include <epan/expert.h>
-#include <epan/frequency-utils.h>
#include <epan/prefs.h>
#include <epan/prefs-int.h>
#include <epan/tap.h>
-#include <epan/stat_cmd_args.h>
+#include <epan/stat_tap_ui.h>
#include <epan/uat.h>
#include <epan/print.h>
#include <epan/timestamp.h>
+#include <epan/conversation_table.h>
+
+#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
+#include <epan/asn1.h>
+#include <epan/dissectors/packet-kerberos.h>
+#endif
#include <wsutil/cmdarg_err.h>
#include <wsutil/plugins.h>
#include "../color_filters.h"
#include "../register.h"
#include "../ringbuffer.h"
-#include "../version_info.h"
#include "../log.h"
#include "gtk_iface_monitor.h"
#include "ui/alert_box.h"
+#include "ui/console.h"
#include "ui/decode_as_utils.h"
#include "ui/filters.h"
#include "ui/main_statusbar.h"
#include "ui/recent.h"
#include "ui/recent_utils.h"
#include "ui/software_update.h"
-#include "ui/simple_dialog.h"
#include "ui/ui_util.h"
#include "ui/util.h"
#include "codecs/codecs.h"
-#include "capture-pcap-util.h"
+#include "caputils/capture-pcap-util.h"
#ifdef HAVE_LIBPCAP
-#include <capchild/capture_ifinfo.h>
+#include "caputils/capture_ifinfo.h"
#include "ui/capture.h"
#include <capchild/capture_sync.h>
#endif
#ifdef _WIN32
-#include "capture-wpcap.h"
-#include "capture_wpcap_packet.h"
+#include "caputils/capture-wpcap.h"
+#include "caputils/capture_wpcap_packet.h"
#include <tchar.h> /* Needed for Unicode */
+#include <wsutil/os_version_info.h>
#include <wsutil/unicode-utils.h>
#include <commctrl.h>
#include <shellapi.h>
#include "ui/gtk/main_toolbar.h"
#include "ui/gtk/main_toolbar_private.h"
#include "ui/gtk/main_welcome.h"
+#include "ui/gtk/main_welcome_private.h"
#include "ui/gtk/drag_and_drop.h"
#include "ui/gtk/capture_file_dlg.h"
#include "ui/gtk/packet_panes.h"
#include "ui/gtk/proto_help.h"
#include "ui/gtk/packet_list.h"
#include "ui/gtk/filter_expression_save_dlg.h"
+#include "ui/gtk/conversations_table.h"
+#include "ui/gtk/hostlist_table.h"
+#include "ui/gtk/service_response_time_table.h"
+#include "ui/gtk/response_time_delay_table.h"
+#include "ui/gtk/simple_stattable.h"
+#include "simple_dialog.h"
+#ifdef HAVE_GRESOURCE
+#include "wireshark-gresources.h"
+#else
+#include "ui/gtk/pixbuf-csource.h"
+#endif
#include "ui/gtk/old-gtk-compat.h"
-#ifdef HAVE_LIBPCAP
-#include "wsicon.h"
-#include "wsiconcap.h"
-#endif
-
#ifdef HAVE_AIRPCAP
-#include <airpcap.h>
-#include "airpcap_loader.h"
+#include <caputils/airpcap.h>
+#include <caputils/airpcap_loader.h>
#include "airpcap_dlg.h"
#include "airpcap_gui_utils.h"
#endif
#ifdef HAVE_LIBPCAP
capture_options global_capture_opts;
capture_session global_capture_session;
+info_data_t global_info_data;
#endif
capture_file cfile;
static guint tap_update_timer_id;
-static void console_log_handler(const char *log_domain,
- GLogLevelFlags log_level, const char *message, gpointer user_data);
-
static void create_main_window(gint, gint, gint, e_prefs*);
static void show_main_window(gboolean);
static void main_save_window_geometry(GtkWidget *widget);
filter = proto_construct_match_selected_string(cfile.finfo_selected,
cfile.edt);
match_selected_cb_do((GtkWidget *)g_object_get_data(G_OBJECT(data), E_DFILTER_TE_KEY), action, filter);
+ wmem_free(NULL, filter);
}
}
}
packet_list_colorize_packets();
}
+ wmem_free(NULL, filter);
}
}
case(ESD_BTN_OK):
if (cfile.finfo_selected) {
/* open wiki page using the protocol abbreviation */
- selected_proto_url = g_strdup_printf("http://wiki.wireshark.org/Protocols/%s", proto_abbrev);
+ selected_proto_url = g_strdup_printf("https://wiki.wireshark.org/Protocols/%s", proto_abbrev);
browser_open_url(selected_proto_url);
g_free(selected_proto_url);
}
proto_abbrev = proto_registrar_get_abbrev(field_id);
- if (!proto_is_private(field_id)) {
- /* ask the user if the wiki page really should be opened */
- dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_OK_CANCEL,
- "%sOpen Wireshark Wiki page of protocol \"%s\"?%s\n"
- "\n"
- "This will open the \"%s\" related Wireshark Wiki page in your Web browser.\n"
- "\n"
- "The Wireshark Wiki is a collaborative approach to provide information "
- "about Wireshark in several ways (not limited to protocol specifics).\n"
- "\n"
- "This Wiki is new, so the page of the selected protocol "
- "may not exist and/or may not contain valuable information.\n"
- "\n"
- "As everyone can edit the Wiki and add new content (or extend existing), "
- "you are encouraged to add information if you can.\n"
- "\n"
- "Hint 1: If you are new to wiki editing, try out editing the Sandbox first!\n"
- "\n"
- "Hint 2: If you want to add a new protocol page, you should use the ProtocolTemplate, "
- "which will save you a lot of editing and will give a consistent look over the pages.",
- simple_dialog_primary_start(), proto_abbrev, simple_dialog_primary_end(), proto_abbrev);
- simple_dialog_set_cb(dialog, selected_ptree_info_answered_cb, (gpointer)proto_abbrev);
- } else {
- /* appologize to the user that the wiki page cannot be opened */
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "%sCan't open Wireshark Wiki page of protocol \"%s\"%s\n"
- "\n"
- "This would open the \"%s\" related Wireshark Wiki page in your Web browser.\n"
- "\n"
- "Since this is a private protocol, such information is not available in "
- "a public wiki. Therefore this wiki entry is blocked.\n"
- "\n"
- "Sorry for the inconvenience.\n",
- simple_dialog_primary_start(), proto_abbrev, simple_dialog_primary_end(), proto_abbrev);
- }
+ /* ask the user if the wiki page really should be opened */
+ dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_OK_CANCEL,
+ "%sOpen Wireshark Wiki page of protocol \"%s\"?%s\n"
+ "\n"
+ "This will open the \"%s\" related Wireshark Wiki page in your Web browser.\n"
+ "\n"
+ "The Wireshark Wiki is a collaborative approach to provide information "
+ "about Wireshark in several ways (not limited to protocol specifics).\n"
+ "\n"
+ "This Wiki is new, so the page of the selected protocol "
+ "may not exist and/or may not contain valuable information.\n"
+ "\n"
+ "As everyone can edit the Wiki and add new content (or extend existing), "
+ "you are encouraged to add information if you can.\n"
+ "\n"
+ "Hint 1: If you are new to wiki editing, try out editing the Sandbox first!\n"
+ "\n"
+ "Hint 2: If you want to add a new protocol page, you should use the ProtocolTemplate, "
+ "which will save you a lot of editing and will give a consistent look over the pages.",
+ simple_dialog_primary_start(), proto_abbrev, simple_dialog_primary_end(), proto_abbrev);
+ simple_dialog_set_cb(dialog, selected_ptree_info_answered_cb, (gpointer)proto_abbrev);
}
}
case(ESD_BTN_OK):
if (cfile.finfo_selected) {
/* open reference page using the protocol abbreviation */
- selected_proto_url = g_strdup_printf("http://www.wireshark.org/docs/dfref/%c/%s", proto_abbrev[0], proto_abbrev);
+ selected_proto_url = g_strdup_printf("https://www.wireshark.org/docs/dfref/%c/%s", proto_abbrev[0], proto_abbrev);
browser_open_url(selected_proto_url);
g_free(selected_proto_url);
}
proto_abbrev = proto_registrar_get_abbrev(field_id);
- if (!proto_is_private(field_id)) {
- /* ask the user if the wiki page really should be opened */
- dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_OK_CANCEL,
- "%sOpen Wireshark filter reference page of protocol \"%s\"?%s\n"
- "\n"
- "This will open the \"%s\" related Wireshark filter reference page in your Web browser.\n"
- "\n",
- simple_dialog_primary_start(), proto_abbrev, simple_dialog_primary_end(), proto_abbrev);
- simple_dialog_set_cb(dialog, selected_ptree_ref_answered_cb, (gpointer)proto_abbrev);
- } else {
- /* appologize to the user that the wiki page cannot be opened */
- simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
- "%sCan't open Wireshark filter reference page of protocol \"%s\"%s\n"
- "\n"
- "This would open the \"%s\" related Wireshark filter reference page in your Web browser.\n"
- "\n"
- "Since this is a private protocol, such information is not available on "
- "a public website. Therefore this filter entry is blocked.\n"
- "\n"
- "Sorry for the inconvenience.\n",
- simple_dialog_primary_start(), proto_abbrev, simple_dialog_primary_end(), proto_abbrev);
- }
+ /* ask the user if the wiki page really should be opened */
+ dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_OK_CANCEL,
+ "%sOpen Wireshark filter reference page of protocol \"%s\"?%s\n"
+ "\n"
+ "This will open the \"%s\" related Wireshark filter reference page in your Web browser.\n"
+ "\n",
+ simple_dialog_primary_start(), proto_abbrev, simple_dialog_primary_end(), proto_abbrev);
+ simple_dialog_set_cb(dialog, selected_ptree_ref_answered_cb, (gpointer)proto_abbrev);
}
}
static gboolean
is_address_column (gint column)
{
- if (((cfile.cinfo.col_fmt[column] == COL_DEF_SRC) ||
- (cfile.cinfo.col_fmt[column] == COL_RES_SRC) ||
- (cfile.cinfo.col_fmt[column] == COL_DEF_DST) ||
- (cfile.cinfo.col_fmt[column] == COL_RES_DST)) &&
+ if (((cfile.cinfo.columns[column].col_fmt == COL_DEF_SRC) ||
+ (cfile.cinfo.columns[column].col_fmt == COL_RES_SRC) ||
+ (cfile.cinfo.columns[column].col_fmt == COL_DEF_DST) ||
+ (cfile.cinfo.columns[column].col_fmt == COL_RES_DST)) &&
strlen(cfile.cinfo.col_expr.col_expr_val[column]))
{
return TRUE;
fdata, &cfile.cinfo);
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
- if ((cfile.cinfo.col_custom_occurrence[column]) ||
+ if ((cfile.cinfo.columns[column].col_custom_occurrence) ||
(strchr (cfile.cinfo.col_expr.col_expr_val[column], ',') == NULL))
{
/* Only construct the filter when a single occurrence is displayed
*/
if (strlen(cfile.cinfo.col_expr.col_expr[column]) != 0 &&
strlen(cfile.cinfo.col_expr.col_expr_val[column]) != 0) {
- /* leak a little but safer than ep_ here */
- if (cfile.cinfo.col_fmt[column] == COL_CUSTOM) {
- header_field_info *hfi = proto_registrar_get_byname(cfile.cinfo.col_custom_field[column]);
+ /* leak a little; is there a safe wmem_ scope here? */
+ if (cfile.cinfo.columns[column].col_fmt == COL_CUSTOM) {
+ header_field_info *hfi = proto_registrar_get_byname(cfile.cinfo.columns[column].col_custom_field);
if (hfi && hfi->parent == -1) {
/* Protocol only */
buf = g_strdup(cfile.cinfo.col_expr.col_expr[column]);
{
case COPY_SELECTED_DESCRIPTION:
if (cfile.finfo_selected->rep &&
- strlen (cfile.finfo_selected->rep->representation) > 0) {
+ strlen(cfile.finfo_selected->rep->representation) > 0) {
g_string_append(gtk_text_str, cfile.finfo_selected->rep->representation);
}
break;
} else {
/*
* Don't show anything if the field name is zero-length;
- * the pseudo-field for "proto_tree_add_text()" is such
+ * the pseudo-field for text-only items is such
* a field, and we don't want "Text (text)" showing up
* on the status line if you've selected such a field.
*
* but we'd have to add checks for null pointers in some
* places if we did that.
*
- * Or perhaps protocol tree items added with
- * "proto_tree_add_text()" should have -1 as the field index,
- * with no pseudo-field being used, but that might also
- * require special checks for -1 to be added.
+ * Or perhaps text-only items should have -1 as the field
+ * index, with no pseudo-field being used, but that might
+ * also require special checks for -1 to be added.
*/
statusbar_push_field_msg("%s", "");
}
void resolve_name_cb(GtkWidget *widget _U_, gpointer data _U_)
{
- static const e_addr_resolve resolv_flags = {TRUE, TRUE, TRUE, TRUE, TRUE, FALSE};
+ static const e_addr_resolve resolv_flags = {
+ TRUE, /* mac_name */
+ TRUE, /* network_name */
+ TRUE, /* transport_name */
+ TRUE, /* concurrent_dns */
+ TRUE, /* dns_pkt_addr_resolution */
+ TRUE, /* use_external_net_name_resolver */
+ FALSE /* load_hosts_file_from_profile_only */
+ };
if (cfile.edt->tree) {
proto_tree_draw_resolve(cfile.edt->tree, tree_view_gbl, &resolv_flags);
output = stdout;
fprintf(output, "Wireshark %s\n"
"Interactively dump and analyze network traffic.\n"
- "See http://www.wireshark.org for more information.\n",
+ "See https://www.wireshark.org for more information.\n",
get_ws_vcs_version_info());
} else {
output = stderr;
#ifdef HAVE_PCAP_CREATE
fprintf(output, " -I capture in monitor mode, if available\n");
#endif
-#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
fprintf(output, " -B <buffer size> size of kernel buffer (def: %dMB)\n", DEFAULT_CAPTURE_BUFFER_SIZE);
#endif
fprintf(output, " -y <link type> link layer type (def: first appropriate)\n");
fprintf(output, "Processing:\n");
fprintf(output, " -R <read filter> packet filter in Wireshark display filter syntax\n");
fprintf(output, " -n disable all name resolutions (def: all enabled)\n");
- fprintf(output, " -N <name resolve flags> enable specific name resolution(s): \"mntC\"\n");
+ fprintf(output, " -N <name resolve flags> enable specific name resolution(s): \"mnNtCd\"\n");
+ fprintf(output, " --disable-protocol <proto_name>\n");
+ fprintf(output, " disable dissection of proto_name\n");
+ fprintf(output, " --enable-heuristic <short_name>\n");
+ fprintf(output, " enable dissection of heuristic protocol\n");
+ fprintf(output, " --disable-heuristic <short_name>\n");
+ fprintf(output, " disable dissection of heuristic protocol\n");
fprintf(output, "\n");
fprintf(output, "User interface:\n");
#endif
}
-static void
-show_version(void)
-{
- printf("Wireshark %s\n"
- "\n"
- "%s"
- "\n"
- "%s"
- "\n"
- "%s",
- get_ws_vcs_version_info(), get_copyright_info(), comp_info_str->str,
- runtime_info_str->str);
-}
-
/*
* Report an error in command-line arguments.
* Creates a console on Windows.
void
main_auto_scroll_live_changed(gboolean auto_scroll_live_in)
{
- /* Update menubar and toolbar */
- menu_auto_scroll_live_changed(auto_scroll_live_in);
+ /* Update menubar and toolbar */
+ menu_auto_scroll_live_changed(auto_scroll_live_in);
toolbar_auto_scroll_live_changed(auto_scroll_live_in);
/* change auto scroll state */
#ifdef HAVE_LIBPCAP
static GList *icon_list_create(
+#ifdef HAVE_GRESOURCE
+ const gchar *icon16_path,
+ const gchar *icon32_path,
+ const gchar *icon48_path,
+ const gchar *icon64_path)
+#else
const guint8 *icon16_pb,
const guint8 *icon32_pb,
const guint8 *icon48_pb,
const guint8 *icon64_pb)
+#endif
{
GList *icon_list = NULL;
- GdkPixbuf * pixbuf16;
- GdkPixbuf * pixbuf32;
- GdkPixbuf * pixbuf48;
- GdkPixbuf * pixbuf64;
-
-
- if(icon16_pb != NULL) {
+ GdkPixbuf *pixbuf16 = NULL;
+ GdkPixbuf *pixbuf32 = NULL;
+ GdkPixbuf *pixbuf48 = NULL;
+ GdkPixbuf *pixbuf64 = NULL;
+
+#ifdef HAVE_GRESOURCE
+ if (icon16_path != NULL)
+ pixbuf16 = ws_gdk_pixbuf_new_from_resource(icon16_path);
+ if (icon32_path != NULL)
+ pixbuf32 = ws_gdk_pixbuf_new_from_resource(icon32_path);
+ if (icon48_path != NULL)
+ pixbuf48 = ws_gdk_pixbuf_new_from_resource(icon48_path);
+ if (icon64_path != NULL)
+ pixbuf64 = ws_gdk_pixbuf_new_from_resource(icon64_path);
+#else
+ if (icon16_pb != NULL)
pixbuf16 = gdk_pixbuf_new_from_inline(-1, icon16_pb, FALSE, NULL);
- g_assert(pixbuf16);
- icon_list = g_list_append(icon_list, pixbuf16);
- }
-
- if(icon32_pb != NULL) {
+ if (icon32_pb != NULL)
pixbuf32 = gdk_pixbuf_new_from_inline(-1, icon32_pb, FALSE, NULL);
- g_assert(pixbuf32);
- icon_list = g_list_append(icon_list, pixbuf32);
- }
-
- if(icon48_pb != NULL) {
+ if (icon48_pb != NULL)
pixbuf48 = gdk_pixbuf_new_from_inline(-1, icon48_pb, FALSE, NULL);
- g_assert(pixbuf48);
- icon_list = g_list_append(icon_list, pixbuf48);
- }
-
- if(icon64_pb != NULL) {
+ if (icon64_pb != NULL)
pixbuf64 = gdk_pixbuf_new_from_inline(-1, icon64_pb, FALSE, NULL);
- g_assert(pixbuf64);
+#endif
+
+ if (pixbuf16 != NULL)
+ icon_list = g_list_append(icon_list, pixbuf16);
+ if (pixbuf32 != NULL)
+ icon_list = g_list_append(icon_list, pixbuf32);
+ if (pixbuf48 != NULL)
+ icon_list = g_list_append(icon_list, pixbuf48);
+ if (pixbuf64 != NULL)
icon_list = g_list_append(icon_list, pixbuf64);
- }
return icon_list;
}
set_titlebar_for_capture_in_progress((capture_file *)cap_session->cf);
if(icon_list == NULL) {
- icon_list = icon_list_create(wsiconcap_16_pb_data, wsiconcap_32_pb_data, wsiconcap_48_pb_data, wsiconcap_64_pb_data);
+#ifdef HAVE_GRESOURCE
+ icon_list = icon_list_create("/org/wireshark/image/wsiconcap16.png",
+ "/org/wireshark/image/wsiconcap32.png",
+ "/org/wireshark/image/wsiconcap48.png",
+ "/org/wireshark/image/wsiconcap64.png");
+#else
+ icon_list = icon_list_create(wsiconcap_16_pb_data,
+ wsiconcap_32_pb_data,
+ wsiconcap_48_pb_data,
+ wsiconcap_64_pb_data);
+#endif
}
gtk_window_set_icon_list(GTK_WINDOW(top_level), icon_list);
main_set_for_capture_file(TRUE);
if(icon_list == NULL) {
- icon_list = icon_list_create(wsicon_16_pb_data, wsicon_32_pb_data, wsicon_48_pb_data, wsicon_64_pb_data);
+#ifdef HAVE_GRESOURCE
+ icon_list = icon_list_create("/org/wireshark/image/wsicon16.png",
+ "/org/wireshark/image/wsicon32.png",
+ "/org/wireshark/image/wsicon48.png",
+ "/org/wireshark/image/wsicon64.png");
+#else
+ icon_list = icon_list_create(wsicon_16_pb_data,
+ wsicon_32_pb_data,
+ wsicon_48_pb_data,
+ wsicon_64_pb_data);
+#endif
}
gtk_window_set_icon_list(GTK_WINDOW(top_level), icon_list);
set_titlebar_for_capture_file(NULL);
if(icon_list == NULL) {
- icon_list = icon_list_create(wsicon_16_pb_data, wsicon_32_pb_data, wsicon_48_pb_data, wsicon_64_pb_data);
+#ifdef HAVE_GRESOURCE
+ icon_list = icon_list_create("/org/wireshark/image/wsicon16.png",
+ "/org/wireshark/image/wsicon32.png",
+ "/org/wireshark/image/wsicon48.png",
+ "/org/wireshark/image/wsicon64.png");
+#else
+ icon_list = icon_list_create(wsicon_16_pb_data,
+ wsicon_32_pb_data,
+ wsicon_48_pb_data,
+ wsicon_64_pb_data);
+#endif
}
gtk_window_set_icon_list(GTK_WINDOW(top_level), icon_list);
main_set_for_capture_file(FALSE);
if(icon_list == NULL) {
- icon_list = icon_list_create(wsicon_16_pb_data, wsicon_32_pb_data, wsicon_48_pb_data, wsicon_64_pb_data);
+#ifdef HAVE_GRESOURCE
+ icon_list = icon_list_create("/org/wireshark/image/wsicon16.png",
+ "/org/wireshark/image/wsicon32.png",
+ "/org/wireshark/image/wsicon48.png",
+ "/org/wireshark/image/wsicon64.png");
+#else
+ icon_list = icon_list_create(wsicon_16_pb_data,
+ wsicon_32_pb_data,
+ wsicon_48_pb_data,
+ wsicon_64_pb_data);
+#endif
}
gtk_window_set_icon_list(GTK_WINDOW(top_level), icon_list);
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Rescan finished");
main_cf_cb_file_rescan_finished(cf);
break;
+ case(cf_cb_file_retap_started):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Retap started");
+ break;
+ case(cf_cb_file_retap_finished):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Retap finished");
+ break;
case(cf_cb_file_fast_save_finished):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Fast save finished");
main_cf_cb_file_rescan_finished(cf);
main_capture_cb_capture_update_started(cap_session);
#ifdef HAVE_GTKOSXAPPLICATION
theApp = (GtkosxApplication *)g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
- gtkosx_application_set_dock_icon_pixbuf(theApp, gdk_pixbuf_new_from_inline(-1, wsiconcap_48_pb_data, FALSE, NULL));
+#ifdef HAVE_GRESOURCE
+ gtkosx_application_set_dock_icon_pixbuf(theApp, ws_gdk_pixbuf_new_from_resource("/org/wireshark/image/wsicon48.png"));
+#else
+ gtkosx_application_set_dock_icon_pixbuf(theApp, gdk_pixbuf_new_from_inline(-1, wsicon_48_pb_data, FALSE, NULL));
+#endif
#endif
break;
case(capture_cb_capture_update_continue):
* closes the capturing on its own! */
#ifdef HAVE_GTKOSXAPPLICATION
theApp = (GtkosxApplication *)g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
+#ifdef HAVE_GRESOURCE
+ gtkosx_application_set_dock_icon_pixbuf(theApp, ws_gdk_pixbuf_new_from_resource("/org/wireshark/image/wsicon64.png"));
+#else
gtkosx_application_set_dock_icon_pixbuf(theApp, gdk_pixbuf_new_from_inline(-1, wsicon_64_pb_data, FALSE, NULL));
+#endif
#endif
main_capture_cb_capture_stopping(cap_session);
break;
g_string_append(str, ", with Pango ");
g_string_append(str, PANGO_VERSION_STRING);
- /* Libpcap */
+ /* Capture libraries */
g_string_append(str, ", ");
- get_compiled_pcap_version(str);
+ get_compiled_caplibs_version(str);
/* LIBZ */
g_string_append(str, ", ");
#else /* HAVE_LIBZ */
g_string_append(str, "without libz");
#endif /* HAVE_LIBZ */
-
- /*
- * XXX - these libraries are actually used only by dumpcap,
- * but we mention them here so that a user reporting a bug
- * can get information about dumpcap's libraries without
- * having to run dumpcap.
- */
-#ifndef _WIN32
- /* This is UN*X-only. */
- /* LIBCAP */
- g_string_append(str, ", ");
-#ifdef HAVE_LIBCAP
- g_string_append(str, "with POSIX capabilities");
-#ifdef _LINUX_CAPABILITY_VERSION
- g_string_append(str, " (Linux)");
-#endif /* _LINUX_CAPABILITY_VERSION */
-#else /* HAVE_LIBCAP */
- g_string_append(str, "without POSIX capabilities");
-#endif /* HAVE_LIBCAP */
-#endif /* _WIN32 */
-
-#ifdef __linux__
- /* This is a Linux-specific library. */
- /* LIBNL */
- g_string_append(str, ", ");
-#if defined(HAVE_LIBNL1)
- g_string_append(str, "with libnl 1");
-#elif defined(HAVE_LIBNL2)
- g_string_append(str, "with libnl 2");
-#elif defined(HAVE_LIBNL3)
- g_string_append(str, "with libnl 3");
-#else /* no libnl */
- g_string_append(str, "without libnl");
-#endif /* libnl version */
-#endif /* __linux__ */
}
static void
get_wireshark_runtime_info(GString *str)
{
#ifdef HAVE_LIBPCAP
- /* Libpcap */
+ /* Capture libraries */
g_string_append(str, ", ");
- get_runtime_pcap_version(str);
+ get_runtime_caplibs_version(str);
#endif
/* zlib */
/* Read the disabled protocols file. */
read_disabled_protos_list(gdp_path, &gdp_open_errno, &gdp_read_errno,
dp_path, &dp_open_errno, &dp_read_errno);
+ read_disabled_heur_dissector_list(gdp_path, &gdp_open_errno, &gdp_read_errno,
+ dp_path, &dp_open_errno, &dp_read_errno);
if (*gdp_path != NULL) {
if (gdp_open_errno != 0) {
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"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"
- "http://wiki.wireshark.org/CaptureSetup/CapturePrivileges", cur_user, cur_group);
+ "https://wiki.wireshark.org/CaptureSetup/CapturePrivileges", cur_user, cur_group);
g_free(cur_user);
g_free(cur_group);
simple_dialog_check_set(priv_warning_dialog, "Don't show this message again.");
gint pl_size = 280, tv_size = 95, bv_size = 75;
gchar *rc_file, *cf_name = NULL, *rfilter = NULL, *dfilter = NULL, *jfilter = NULL;
dfilter_t *rfcode = NULL;
+ gchar *err_msg;
gboolean rfilter_parse_failed = FALSE;
e_prefs *prefs_p;
char badopt;
GtkWidget *splash_win = NULL;
- GLogLevelFlags log_flags;
guint go_to_packet = 0;
search_direction jump_backwards = SD_FORWARD;
dfilter_t *jump_to_filter = NULL;
- int optind_initial;
unsigned int in_file_type = WTAP_TYPE_AUTO;
#ifdef HAVE_GTKOSXAPPLICATION
GtkosxApplication *theApp;
#endif
+ GSList *disable_protocol_slist = NULL;
+ GSList *enable_heur_slist = NULL;
+ GSList *disable_heur_slist = NULL;
#define OPTSTRING OPTSTRING_CAPTURE_COMMON "C:g:Hh" "jJ:kK:lm:nN:o:P:r:R:St:u:vw:X:Y:z:"
-
+ static const struct option long_options[] = {
+ {"help", no_argument, NULL, 'h'},
+ {"read-file", required_argument, NULL, 'r' },
+ {"read-filter", required_argument, NULL, 'R' },
+ {"display-filter", required_argument, NULL, 'Y' },
+ {"version", no_argument, NULL, 'v'},
+ LONGOPT_CAPTURE_COMMON
+ {0, 0, 0, 0 }
+ };
static const char optstring[] = OPTSTRING;
+#ifdef HAVE_GRESOURCE
+ main_register_resource();
+#endif
+
cmdarg_err_init(wireshark_cmdarg_err, wireshark_cmdarg_err_cont);
/* Set the C-language locale to the native environment. */
switch (airpcap_dll_ret_val) {
case AIRPCAP_DLL_OK:
/* load the airpcap interfaces */
- airpcap_if_list = get_airpcap_interface_list(&err, &err_str);
+ g_airpcap_if_list = get_airpcap_interface_list(&err, &err_str);
- if (airpcap_if_list == NULL || g_list_length(airpcap_if_list) == 0){
+ 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);
} else {
/* select the first ad default (THIS SHOULD BE CHANGED) */
- airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
+ airpcap_if_active = airpcap_get_default_if(g_airpcap_if_list);
}
break;
#if 0
#endif /* HAVE_AIRPCAP */
#endif /* _WIN32 */
- /* Assemble the compile-time version information string */
- comp_info_str = g_string_new("Compiled ");
+ /* Get the compile-time version information string */
+ comp_info_str = get_compiled_version_info(get_wireshark_gtk_compiled_info,
+ get_gui_compiled_info);
- get_compiled_version_info(comp_info_str, get_wireshark_gtk_compiled_info,
- get_gui_compiled_info);
-
- /* Assemble the run-time version information string */
- runtime_info_str = g_string_new("Running ");
- get_runtime_version_info(runtime_info_str, get_wireshark_runtime_info);
+ /* Get the run-time version information string */
+ runtime_info_str = get_runtime_version_info(get_wireshark_runtime_info);
/* Add it to the information to be reported on a crash. */
ws_add_crash_info("Wireshark %s\n"
rf_path, g_strerror(rf_open_errno));
}
- /* "pre-scan" the command line parameters, if we have "console only"
- parameters. We do this so we don't start GTK+ if we're only showing
- command-line help or version information.
-
- XXX - this pre-scan is done before we start GTK+, so we haven't
- run gtk_init() on the arguments. That means that GTK+ arguments
- have not been removed from the argument list; those arguments
- begin with "--", and will be treated as an error by getopt().
-
- We thus ignore errors - *and* set "opterr" to 0 to suppress the
- error messages. */
+ /*
+ * In order to have the -X opts assigned before the wslua machine starts
+ * we need to call getopt_long before epan_init() gets called.
+ *
+ * In addition, we process "console only" parameters (ones where we
+ * send output to the console and exit) here, so we don't start GTK+
+ * if we're only showing command-line help or version information.
+ *
+ * XXX - this pre-scan is done before we start GTK+, so we haven't
+ * run gtk_init() on the arguments. That means that GTK+ arguments
+ * have not been removed from the argument list; those arguments
+ * begin with "--", and will be treated as an error by getopt_long().
+ *
+ * We thus ignore errors - *and* set "opterr" to 0 to suppress the
+ * error messages.
+ *
+ * XXX - should we, instead, first call gtk_parse_args(), without
+ * calling gtk_init(), and then call this?
+ *
+ * In order to handle, for example, -o options, we also need to call it
+ * *after* epan_init() gets called, so that the dissectors have had a
+ * chance to register their preferences, so we have another getopt_long()
+ * call later.
+ *
+ * XXX - can we do this all with one getopt_long() call, saving the
+ * arguments we can't handle until after initializing libwireshark,
+ * and then process them after initializing libwireshark?
+ *
+ * Note that we don't want to initialize libwireshark until after the
+ * GUI is up, as that can take a while, and we want a window of some
+ * sort up to show progress while that's happening.
+ */
opterr = 0;
- optind_initial = optind;
- while ((opt = getopt(argc, argv, optstring)) != -1) {
+
+ while ((opt = getopt_long(argc, argv, optstring, long_options, NULL)) != -1) {
switch (opt) {
case 'C': /* Configuration Profile */
if (profile_exists (optarg, FALSE)) {
break;
case 'D': /* Print a list of capture devices and exit */
#ifdef HAVE_LIBPCAP
- if_list = capture_interface_list(&err, &err_str,main_window_update);
+ if_list = capture_interface_list(&err, &err_str, NULL);
if (if_list == NULL) {
- switch (err) {
- case CANT_GET_INTERFACE_LIST:
- case DONT_HAVE_PCAP:
- cmdarg_err("%s", err_str);
- g_free(err_str);
- break;
-
- case NO_INTERFACES_FOUND:
- cmdarg_err("There are no interfaces on which a capture can be done");
- break;
+ if (err == 0)
+ cmdarg_err("There are no interfaces on which a capture can be done");
+ else {
+ cmdarg_err("%s", err_str);
+ g_free(err_str);
}
exit(2);
}
#ifdef _WIN32
create_console();
#endif
- show_version();
+ show_version("Wireshark", comp_info_str, runtime_info_str);
#ifdef _WIN32
destroy_console();
#endif
/* Only the static part of it will be read, as we don't have the gui now to fill the */
/* recent lists which is done in the dynamic part. */
/* We have to do this already here, so command line parameters can overwrite these values. */
- recent_read_profile_static(&rf_path, &rf_open_errno);
- if (rf_path != NULL && rf_open_errno != 0) {
+ if (!recent_read_profile_static(&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);
}
if (recent.gui_fileopen_remembered_dir &&
set_last_open_dir(get_persdatafile_dir());
}
- /* Set getopt index back to initial value, so it will start with the
- first command line parameter again. Also reset opterr to 1, so that
- error messages are printed by getopt().
-
- XXX - this seems to work on most platforms, but time will tell.
- The Single UNIX Specification says "The getopt() function need
- not be reentrant", so this isn't guaranteed to work. The Mac
- OS X 10.4[.x] getopt() man page says
-
- In order to use getopt() to evaluate multiple sets of arguments, or to
- evaluate a single set of arguments multiple times, the variable optreset
- must be set to 1 before the second and each additional set of calls to
- getopt(), and the variable optind must be reinitialized.
-
- ...
-
- The optreset variable was added to make it possible to call the getopt()
- function multiple times. This is an extension to the IEEE Std 1003.2
- (``POSIX.2'') specification.
-
- which I think comes from one of the other BSDs.
-
- XXX - if we want to control all the command-line option errors, so
- that we can display them where we choose (e.g., in a window), we'd
- want to leave opterr as 0, and produce our own messages using optopt.
- We'd have to check the value of optopt to see if it's a valid option
- letter, in which case *presumably* the error is "this option requires
- an argument but none was specified", or not a valid option letter,
- in which case *presumably* the error is "this option isn't valid".
- Some versions of getopt() let you supply a option string beginning
- with ':', which means that getopt() will return ':' rather than '?'
- for "this option requires an argument but none was specified", but
- not all do. */
- optind = optind_initial;
- opterr = 1;
-
#if !GLIB_CHECK_VERSION(2,31,0)
g_thread_init(NULL);
#endif
#ifdef HAVE_LIBPCAP
capture_callback_add(main_capture_callback, NULL);
#endif
+
cf_callback_add(statusbar_cf_callback, NULL);
#ifdef HAVE_LIBPCAP
capture_callback_add(statusbar_capture_callback, NULL);
#endif
- /* Arrange that if we have no console window, and a GLib message logging
- routine is called to log a message, we pop up a console window.
-
- We do that by inserting our own handler for all messages logged
- to the default domain; that handler pops up a console if necessary,
- and then calls the default handler. */
-
- /* We might want to have component specific log levels later ... */
-
- log_flags = (GLogLevelFlags)
- (G_LOG_LEVEL_ERROR|
- G_LOG_LEVEL_CRITICAL|
- G_LOG_LEVEL_WARNING|
- G_LOG_LEVEL_MESSAGE|
- G_LOG_LEVEL_INFO|
- G_LOG_LEVEL_DEBUG|
- G_LOG_FLAG_FATAL|
- G_LOG_FLAG_RECURSION);
+ cf_callback_add(welcome_cf_callback, NULL);
+#ifdef HAVE_LIBPCAP
+ capture_callback_add(welcome_capture_callback, NULL);
+#endif
- g_log_set_handler(NULL,
- log_flags,
- console_log_handler, NULL /* user_data */);
- g_log_set_handler(LOG_DOMAIN_MAIN,
- log_flags,
- console_log_handler, NULL /* user_data */);
+ set_console_log_handler();
#ifdef HAVE_LIBPCAP
- g_log_set_handler(LOG_DOMAIN_CAPTURE,
- log_flags,
- console_log_handler, NULL /* user_data */);
- g_log_set_handler(LOG_DOMAIN_CAPTURE_CHILD,
- log_flags,
- console_log_handler, NULL /* user_data */);
-
/* 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);
- capture_session_init(&global_capture_session, (void *)&cfile);
+ capture_session_init(&global_capture_session, &cfile);
#endif
init_report_err(failure_alert_box, open_failure_alert_box,
/* Register all the plugin types we have. */
epan_register_plugin_types(); /* Types known to libwireshark */
wtap_register_plugin_types(); /* Types known to libwiretap */
- codec_register_plugin_types(); /* Types known to libcodec */
+ codec_register_plugin_types(); /* Types known to libwscodecs */
/* Scan for plugins. This does *not* call their registration routines;
that's done later. */
"-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. */
- epan_init(register_all_protocols,register_all_protocol_handoffs,
- splash_update, (gpointer) splash_win);
+ if (!epan_init(register_all_protocols,register_all_protocol_handoffs,
+ splash_update, (gpointer) splash_win))
+ return 2;
splash_update(RA_LISTENERS, NULL, (gpointer)splash_win);
#endif
register_all_tap_listeners();
+ conversation_table_set_gui_info(init_conversation_table);
+ hostlist_table_set_gui_info(init_hostlist_table);
+ srt_table_iterate_tables(register_service_response_tables, NULL);
+ rtd_table_iterate_tables(register_response_time_delay_tables, NULL);
+ new_stat_tap_iterate_tables(register_simple_stat_tables, NULL);
splash_update(RA_PREFERENCES, NULL, (gpointer)splash_win);
/*#ifdef HAVE_LIBPCAP
fill_in_local_interfaces();
#endif*/
+ /*
+ * To reset the options parser, set optreset to 1 on platforms that
+ * have optreset (documented in *BSD and OS X, apparently present but
+ * not documented in Solaris - the Illumos repository seems to
+ * suggest that the first Solaris getopt_long(), at least as of 2004,
+ * was based on the NetBSD one, it had optreset) and set optind to 1,
+ * and set optind to 0 otherwise (documented as working in the GNU
+ * getopt_long(). Setting optind to 0 didn't originally work in the
+ * NetBSD one, but that was added later - we don't want to depend on
+ * it if we have optreset).
+ *
+ * Also reset opterr to 1, so that error messages are printed by
+ * getopt_long().
+ *
+ * XXX - if we want to control all the command-line option errors, so
+ * that we can display them where we choose (e.g., in a window), we'd
+ * want to leave opterr as 0, and produce our own messages using optopt.
+ * We'd have to check the value of optopt to see if it's a valid option
+ * letter, in which case *presumably* the error is "this option requires
+ * an argument but none was specified", or not a valid option letter,
+ * in which case *presumably* the error is "this option isn't valid".
+ * Some versions of getopt() let you supply a option string beginning
+ * with ':', which means that getopt() will return ':' rather than '?'
+ * for "this option requires an argument but none was specified", but
+ * not all do. But we're now using getopt_long() - what does it do?
+ */
+#ifdef HAVE_OPTRESET
+ optreset = 1;
+ optind = 1;
+#else
+ optind = 0;
+#endif
+ opterr = 1;
+
/* Now get our args */
- while ((opt = getopt(argc, argv, optstring)) != -1) {
+ while ((opt = getopt_long(argc, argv, optstring, long_options, NULL)) != -1) {
switch (opt) {
/*** capture option specific ***/
case 'a': /* autostop criteria */
case 'S': /* "Sync" mode: used for following file ala tail -f */
case 'w': /* Write to capture file xxx */
case 'y': /* Set the pcap data link type */
-#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
case 'B': /* Buffer size */
-#endif /* _WIN32 or HAVE_PCAP_CREATE */
+#endif
#ifdef HAVE_LIBPCAP
status = capture_opts_add_opt(&global_capture_opts, opt, optarg,
&start_capture);
prefs_p->gui_gtk2_font_name = g_strdup(optarg);
break;
case 'n': /* No name resolution */
- gbl_resolv_flags.mac_name = FALSE;
- gbl_resolv_flags.network_name = FALSE;
- gbl_resolv_flags.transport_name = FALSE;
- gbl_resolv_flags.concurrent_dns = FALSE;
+ disable_name_resolution();
break;
case 'N': /* Select what types of addresses/port #s to resolve */
badopt = string_to_name_resolve(optarg, &gbl_resolv_flags);
if (badopt != '\0') {
- cmdarg_err("-N specifies unknown resolving option '%c'; valid options are 'm', 'n', and 't'",
+ cmdarg_err("-N specifies unknown resolving option '%c'; valid options are 'C', 'd', m', 'n', 'N', and 't'",
badopt);
exit(1);
}
by the preferences set callback) from being used as
part of a tap filter. Instead, we just add the argument
to a list of stat arguments. */
+ if (strcmp("help", optarg) == 0) {
+ fprintf(stderr, "wireshark: The available statistics for the \"-z\" option are:\n");
+ list_stat_cmd_args();
+ exit(0);
+ }
if (!process_stat_cmd_arg(optarg)) {
cmdarg_err("Invalid -z argument.");
cmdarg_err_cont(" -z argument must be one of :");
exit(1);
}
break;
+ case LONGOPT_DISABLE_PROTOCOL: /* disable dissection of protocol */
+ disable_protocol_slist = g_slist_append(disable_protocol_slist, optarg);
+ break;
+ case LONGOPT_ENABLE_HEURISTIC: /* enable heuristic dissection of protocol */
+ enable_heur_slist = g_slist_append(enable_heur_slist, optarg);
+ break;
+ case LONGOPT_DISABLE_HEURISTIC: /* disable heuristic dissection of protocol */
+ disable_heur_slist = g_slist_append(disable_heur_slist, optarg);
+ break;
default:
case '?': /* Bad flag - print usage message */
arg_error = TRUE;
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
if (device.selected) {
+ gchar* auth_str = NULL;
+#ifdef HAVE_PCAP_REMOTE
+ if (device.remote_opts.remote_host_opts.auth_type == CAPTURE_AUTH_PWD) {
+ auth_str = g_strdup_printf("%s:%s", device.remote_opts.remote_host_opts.auth_username,
+ device.remote_opts.remote_host_opts.auth_password);
+ }
+#endif
#if defined(HAVE_PCAP_CREATE)
- caps = capture_get_if_capabilities(device.name, device.monitor_mode_supported, &err_str, main_window_update);
+ caps = capture_get_if_capabilities(device.name, device.monitor_mode_supported, auth_str, &err_str, main_window_update);
#else
- caps = capture_get_if_capabilities(device.name, FALSE, &err_str,main_window_update);
+ caps = capture_get_if_capabilities(device.name, FALSE, auth_str, &err_str,main_window_update);
#endif
+ g_free(auth_str);
if (caps == NULL) {
cmdarg_err("%s", err_str);
g_free(err_str);
/* disabled protocols as per configuration file */
if (gdp_path == NULL && dp_path == NULL) {
set_disabled_protos_list();
+ set_disabled_heur_dissector_list();
+ }
+
+ if(disable_protocol_slist) {
+ GSList *proto_disable;
+ for (proto_disable = disable_protocol_slist; proto_disable != NULL; proto_disable = g_slist_next(proto_disable))
+ {
+ proto_disable_proto_by_name((char*)proto_disable->data);
+ }
+ }
+
+ if(enable_heur_slist) {
+ GSList *heur_enable;
+ for (heur_enable = enable_heur_slist; heur_enable != NULL; heur_enable = g_slist_next(heur_enable))
+ {
+ proto_enable_heuristic_by_name((char*)heur_enable->data, TRUE);
+ }
+ }
+
+ if(disable_heur_slist) {
+ GSList *heur_disable;
+ for (heur_disable = disable_heur_slist; heur_disable != NULL; heur_disable = g_slist_next(heur_disable))
+ {
+ proto_enable_heuristic_by_name((char*)heur_disable->data, FALSE);
+ }
}
build_column_format_array(&cfile.cinfo, prefs_p->num_cols, TRUE);
create_main_window(pl_size, tv_size, bv_size, prefs_p);
/* Read the dynamic part of the recent file, as we have the gui now ready for it. */
- recent_read_dynamic(&rf_path, &rf_open_errno);
- if (rf_path != NULL && rf_open_errno != 0) {
+ 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);
}
color_filters_enable(recent.packet_list_colorize);
switch (user_font_apply()) {
case FA_SUCCESS:
break;
- case FA_FONT_NOT_RESIZEABLE:
- /* "user_font_apply()" popped up an alert box. */
- /* turn off zooming - font can't be resized */
+ case FA_ZOOMED_TOO_FAR:
+ /* The zoom level is too big for this font; turn off zooming. */
+ recent.gui_zoom_level = 0;
+ break;
case FA_FONT_NOT_AVAILABLE:
/* XXX - did we successfully load the un-zoomed version earlier?
If so, this *probably* means the font is available, but not at
/* in any other case than FA_SUCCESS, turn off zooming */
recent.gui_zoom_level = 0;
/* XXX: would it be a good idea to disable zooming (insensitive GUI)? */
+ break;
}
dnd_init(top_level);
show_main_window(TRUE);
check_and_warn_user_startup(cf_name);
if (rfilter != NULL) {
- if (!dfilter_compile(rfilter, &rfcode)) {
- bad_dfilter_alert_box(top_level, rfilter);
+ if (!dfilter_compile(rfilter, &rfcode, &err_msg)) {
+ bad_dfilter_alert_box(top_level, rfilter, err_msg);
+ g_free(err_msg);
rfilter_parse_failed = TRUE;
}
}
cf_goto_frame(&cfile, go_to_packet);
} else if (jfilter != NULL) {
/* try to compile given filter */
- if (!dfilter_compile(jfilter, &jump_to_filter)) {
- bad_dfilter_alert_box(top_level, jfilter);
+ if (!dfilter_compile(jfilter, &jump_to_filter, &err_msg)) {
+ bad_dfilter_alert_box(top_level, jfilter, err_msg);
+ g_free(err_msg);
} else {
/* Filter ok, jump to the first packet matching the filter
conditions. Default search direction is forward, but if
to use for this capture. */
if (global_capture_opts.ifaces->len == 0)
collect_ifaces(&global_capture_opts);
- if (capture_start(&global_capture_opts, &global_capture_session,main_window_update)) {
+ if (capture_start(&global_capture_opts, &global_capture_session, &global_info_data,main_window_update)) {
/* 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
#ifdef HAVE_GTKOSXAPPLICATION
theApp = (GtkosxApplication *)g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
+#ifdef HAVE_GRESOURCE
+ gtkosx_application_set_dock_icon_pixbuf(theApp, ws_gdk_pixbuf_new_from_resource("/org/wireshark/image/wsicon64.png"));
+#else
gtkosx_application_set_dock_icon_pixbuf(theApp, gdk_pixbuf_new_from_inline(-1, wsicon_64_pb_data, FALSE, NULL));
+#endif
gtkosx_application_ready(theApp);
#endif
destroy_console();
#endif
+#ifdef HAVE_GRESOURCE
+ main_unregister_resource();
+#endif
+
exit(0);
}
#endif /* _WIN32 */
-static void
-console_log_handler(const char *log_domain, GLogLevelFlags log_level,
- const char *message, gpointer user_data _U_)
-{
- time_t curr;
- struct tm *today;
- const char *level;
-
-
- /* ignore log message, if log_level isn't interesting based
- upon the console log preferences.
- If the preferences haven't been loaded loaded yet, display the
- message anyway.
-
- The default console_log_level preference value is such that only
- ERROR, CRITICAL and WARNING level messages are processed;
- MESSAGE, INFO and DEBUG level messages are ignored. */
- if((log_level & G_LOG_LEVEL_MASK & prefs.console_log_level) == 0 &&
- prefs.console_log_level != 0) {
- return;
- }
-
-#ifdef _WIN32
- if (prefs.gui_console_open != console_open_never || log_level & G_LOG_LEVEL_ERROR) {
- /* the user wants a console or the application will terminate immediately */
- create_console();
- }
- if (get_has_console()) {
- /* For some unknown reason, the above doesn't appear to actually cause
- anything to be sent to the standard output, so we'll just splat the
- message out directly, just to make sure it gets out. */
-#endif
- switch(log_level & G_LOG_LEVEL_MASK) {
- case G_LOG_LEVEL_ERROR:
- level = "Err ";
- break;
- case G_LOG_LEVEL_CRITICAL:
- level = "Crit";
- break;
- case G_LOG_LEVEL_WARNING:
- level = "Warn";
- break;
- case G_LOG_LEVEL_MESSAGE:
- level = "Msg ";
- break;
- case G_LOG_LEVEL_INFO:
- level = "Info";
- break;
- case G_LOG_LEVEL_DEBUG:
- level = "Dbg ";
- break;
- default:
- fprintf(stderr, "unknown log_level %u\n", log_level);
- level = NULL;
- g_assert_not_reached();
- }
-
- /* create a "timestamp" */
- time(&curr);
- today = localtime(&curr);
-
- fprintf(stderr, "%02u:%02u:%02u %8s %s %s\n",
- today->tm_hour, today->tm_min, today->tm_sec,
- log_domain != NULL ? log_domain : "",
- level, message);
-#ifdef _WIN32
- if(log_level & G_LOG_LEVEL_ERROR) {
- /* wait for a key press before the following error handler will terminate the program
- this way the user at least can read the error message */
- printf("\n\nPress any key to exit\n");
- _getch();
- }
- } else {
- /* XXX - on UN*X, should we just use g_log_default_handler()?
- We want the error messages to go to the standard output;
- on Mac OS X, that will cause them to show up in various
- per-user logs accessible through Console (details depend
- on whether you're running 10.0 through 10.4 or running
- 10.5 and later), and, on other UN*X desktop environments,
- if they don't show up in some form of console log, that's
- a deficiency in that desktop environment. (Too bad
- Windows doesn't set the standard output and error for
- GUI apps to something that shows up in such a log.) */
- g_log_default_handler(log_domain, log_level, message, user_data);
- }
-#endif
-}
/*
}
}
-
/*
* Rearrange the main window widgets
*/
/* Set profile name and update the status bar */
set_profile_name (profile_name);
profile_bar_update ();
- filter_expression_reinit(FILTER_EXPRESSION_REINIT_DESTROY);
/* Reset current preferences and apply the new */
prefs_reset();
(void) read_configuration_files (&gdp_path, &dp_path);
- recent_read_profile_static(&rf_path, &rf_open_errno);
- if (rf_path != NULL && rf_open_errno != 0) {
+ if (!recent_read_profile_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, g_strerror(rf_open_errno));
+ g_free(rf_path);
}
if (recent.gui_fileopen_remembered_dir &&
test_for_directory(recent.gui_fileopen_remembered_dir) == EISDIR) {
prefs_to_capture_opts();
prefs_apply_all();
+#ifdef HAVE_LIBPCAP
+ update_local_interfaces();
+#endif
macros_post_update();
/* Update window view and redraw the toolbar */
proto_enable_all();
if (gdp_path == NULL && dp_path == NULL) {
set_disabled_protos_list();
+ set_disabled_heur_dissector_list();
}
/* Reload color filters */
main_pane_load_window_geometry();
}
+void
+main_fields_changed (void)
+{
+ /* Reload color filters */
+ color_filters_reload();
+
+ /* Syntax check filter */
+ filter_te_syntax_check_cb(main_display_filter_widget, NULL);
+ if (cfile.dfilter) {
+ /* Check if filter is still valid */
+ dfilter_t *dfp = NULL;
+ if (!dfilter_compile(cfile.dfilter, &dfp, NULL)) {
+ /* Not valid. Enable 'Apply' button and remove dfilter. */
+ g_signal_emit_by_name(G_OBJECT(main_display_filter_widget), "changed");
+ g_free(cfile.dfilter);
+ cfile.dfilter = NULL;
+ }
+ dfilter_free(dfp);
+ }
+
+ if (have_custom_cols(&cfile.cinfo)) {
+ /* Recreate packet list according to new/changed/deleted fields */
+ packet_list_recreate();
+ } else if (cfile.state != FILE_CLOSED) {
+ /* Redissect packets if we have any */
+ redissect_packets();
+ }
+ destroy_packet_wins(); /* TODO: close windows until we can recreate */
+
+ proto_free_deregistered_fields();
+}
+
/** redissect packets and update UI */
void redissect_packets(void)
{