*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#ifdef _WIN32 /* Needed for console I/O */
#if _MSC_VER < 1500
/* AttachConsole() needs this #define! */
+/* But we're not calling it from here any more; do we need this? */
#define _WIN32_WINNT 0x0501
#endif
+
#include <fcntl.h>
#include <conio.h>
+#include <ui/win32/console_win32.h>
#endif
#ifdef HAVE_LIBPORTAUDIO
#include <portaudio.h>
#endif /* HAVE_LIBPORTAUDIO */
+#include <wsutil/crash_info.h>
+
#include <epan/epan.h>
#include <epan/filesystem.h>
#include <wsutil/privileges.h>
#include <epan/epan_dissect.h>
#include <epan/timestamp.h>
-#include <epan/packet.h>
#include <epan/plugins.h>
#include <epan/dfilter/dfilter.h>
#include <epan/strutil.h>
#include <epan/stat_cmd_args.h>
#include <epan/uat.h>
#include <epan/column.h>
+#include <epan/disabled_protos.h>
/* general (not GTK specific) */
#include "../file.h"
+#include "../frame_tvbuff.h"
#include "../summary.h"
#include "../filters.h"
-#include "../disabled_protos.h"
#include "../color.h"
#include "../color_filters.h"
#include "../print.h"
#include "../ringbuffer.h"
#include "ui/util.h"
#include "../clopts_common.h"
-#include "../console_io.h"
#include "../cmdarg_err.h"
#include "../version_info.h"
#include "../merge.h"
#include "../log.h"
#include "../u3.h"
+#include "gtk_iface_monitor.h"
+
#include "ui/alert_box.h"
#include "ui/main_statusbar.h"
+#include "ui/preference_utils.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"
+#ifdef HAVE_LIBPCAP
+#include "ui/capture_globals.h"
+#include "ui/iface_lists.h"
+#endif
+
#include <wsutil/file_util.h>
#ifdef HAVE_LIBPCAP
-#include "../capture_ui_utils.h"
-#include "../capture-pcap-util.h"
-#include "../capture_ifinfo.h"
-#include "../capture.h"
-#include "../capture_sync.h"
-extern gint if_list_comparator_alph (const void *first_arg, const void *second_arg);
+#include "capture_ui_utils.h"
+#include "capture-pcap-util.h"
+#include "capture_ifinfo.h"
+#include "capture.h"
+#include "capture_sync.h"
#endif
#ifdef _WIN32
-#include "../capture-wpcap.h"
-#include "../capture_wpcap_packet.h"
+#include "capture-wpcap.h"
+#include "capture_wpcap_packet.h"
#include <tchar.h> /* Needed for Unicode */
#include <wsutil/unicode-utils.h>
#include <commctrl.h>
#include "ui/gtk/gui_utils.h"
#include "ui/gtk/color_dlg.h"
#include "ui/gtk/filter_dlg.h"
+#include "ui/gtk/fileset_dlg.h"
#include "ui/gtk/uat_gui.h"
#include "ui/gtk/main.h"
+#include "ui/gtk/main_80211_toolbar.h"
#include "ui/gtk/main_airpcap_toolbar.h"
#include "ui/gtk/main_filter_toolbar.h"
#include "ui/gtk/main_titlebar.h"
#include "ui/gtk/prefs_column.h"
#include "ui/gtk/prefs_dlg.h"
#include "ui/gtk/proto_help.h"
-#include "ui/gtk/new_packet_list.h"
+#include "ui/gtk/packet_list.h"
#include "ui/gtk/filter_expression_save_dlg.h"
#include "ui/gtk/old-gtk-compat.h"
#ifdef HAVE_LIBPCAP
-#include "../../image/wsicon16.xpm"
-#include "../../image/wsicon32.xpm"
-#include "../../image/wsicon48.xpm"
-#include "../../image/wsicon64.xpm"
-#include "../../image/wsiconcap16.xpm"
-#include "../../image/wsiconcap32.xpm"
-#include "../../image/wsiconcap48.xpm"
+#include "wsicon.h"
+#include "wsiconcap.h"
#endif
#ifdef HAVE_AIRPCAP
#ifdef HAVE_GTKOSXAPPLICATION
-#include <igemacintegration/gtkosxapplication.h>
+#include <gtkmacintegration/gtkosxapplication.h>
#endif
/*
*/
#define RC_FILE "gtkrc"
+#ifdef HAVE_LIBPCAP
+capture_options global_capture_opts;
+capture_session global_capture_session;
+#endif
+
capture_file cfile;
static gboolean capture_stopping;
/* internally used widgets */
static GtkWidget *menubar, *main_tb, *filter_tb, *tv_scrollw, *statusbar, *welcome_pane;
-#ifdef HAVE_AIRPCAP
GtkWidget *wireless_tb;
+#ifdef HAVE_AIRPCAP
int airpcap_dll_ret_val = -1;
#endif
static guint tap_update_timer_id;
-#ifdef _WIN32
-static gboolean has_console; /* TRUE if app has console */
-static gboolean console_wait; /* "Press any key..." */
-static void destroy_console(void);
-static gboolean stdin_capture = FALSE; /* Don't grab stdin & stdout if TRUE */
-#endif
static void console_log_handler(const char *log_domain,
GLogLevelFlags log_level, const char *message, gpointer user_data);
-#ifdef HAVE_LIBPCAP
-capture_options global_capture_opts;
-#endif
-
-
static void create_main_window(gint, gint, gint, e_prefs*);
static void show_main_window(gboolean);
static void main_save_window_geometry(GtkWidget *widget);
/* Match selected byte pattern */
static void
-match_selected_cb_do(gpointer data, int action, gchar *text)
+match_selected_cb_do(GtkWidget *filter_te, int action, gchar *text)
{
- GtkWidget *filter_te;
char *cur_filter, *new_filter;
if ((!text) || (0 == strlen(text))) {
return;
}
- g_assert(data);
- filter_te = g_object_get_data(G_OBJECT(data), E_DFILTER_TE_KEY);
g_assert(filter_te);
cur_filter = gtk_editable_get_chars(GTK_EDITABLE(filter_te), 0, -1);
}
void
-match_selected_ptree_cb(GtkWidget *w, gpointer data, MATCH_SELECTED_E action)
+match_selected_ptree_cb(gpointer data, MATCH_SELECTED_E action)
{
char *filter = NULL;
if (cfile.finfo_selected) {
filter = proto_construct_match_selected_string(cfile.finfo_selected,
cfile.edt);
- match_selected_cb_do((data ? data : w), action, filter);
+ match_selected_cb_do((GtkWidget *)g_object_get_data(G_OBJECT(data), E_DFILTER_TE_KEY), action, filter);
}
}
} else {
color_filters_set_tmp(filt_nr,filter, FALSE);
}
- new_packet_list_colorize_packets();
+ packet_list_colorize_packets();
}
}
}
static void selected_ptree_info_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
{
gchar *selected_proto_url;
- gchar *proto_abbrev = data;
+ gchar *proto_abbrev = (gchar *)data;
switch(btn) {
/* convert selected field to protocol abbreviation */
/* XXX - could this conversion be simplified? */
field_id = cfile.finfo_selected->hfinfo->id;
- /* if the selected field isn't a protocol, get it's parent */
+ /* if the selected field isn't a protocol, get its parent */
if(!proto_registrar_is_protocol(field_id)) {
field_id = proto_registrar_get_parent(cfile.finfo_selected->hfinfo->id);
}
static void selected_ptree_ref_answered_cb(gpointer dialog _U_, gint btn, gpointer data)
{
gchar *selected_proto_url;
- gchar *proto_abbrev = data;
+ gchar *proto_abbrev = (gchar *)data;
switch(btn) {
case(ESD_BTN_OK):
/* convert selected field to protocol abbreviation */
/* XXX - could this conversion be simplified? */
field_id = cfile.finfo_selected->hfinfo->id;
- /* if the selected field isn't a protocol, get it's parent */
+ /* if the selected field isn't a protocol, get its parent */
if(!proto_registrar_is_protocol(field_id)) {
field_id = proto_registrar_get_parent(cfile.finfo_selected->hfinfo->id);
}
get_ip_address_list_from_packet_list_row(gpointer data)
{
gint row = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_ROW_KEY));
- gint column = new_packet_list_get_column_id (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_COL_KEY)));
+ gint column = packet_list_get_column_id (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_COL_KEY)));
gint col;
frame_data *fdata;
GList *addr_list = NULL;
- fdata = (frame_data *) new_packet_list_get_row_data(row);
+ fdata = (frame_data *) packet_list_get_row_data(row);
if (fdata != NULL) {
epan_dissect_t edt;
epan_dissect_init(&edt, FALSE, FALSE);
col_custom_prime_edt(&edt, &cfile.cinfo);
- epan_dissect_run(&edt, &cfile.pseudo_header, cfile.pd, fdata, &cfile.cinfo);
+ epan_dissect_run(&edt, &cfile.phdr, frame_tvbuff_new_buffer(fdata, &cfile.buf),
+ fdata, &cfile.cinfo);
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
/* First check selected column */
get_filter_from_packet_list_row_and_column(gpointer data)
{
gint row = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_ROW_KEY));
- gint column = new_packet_list_get_column_id (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_COL_KEY)));
+ gint column = packet_list_get_column_id (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(data), E_MPACKET_LIST_COL_KEY)));
frame_data *fdata;
gchar *buf=NULL;
- fdata = (frame_data *) new_packet_list_get_row_data(row);
+ fdata = (frame_data *) packet_list_get_row_data(row);
if (fdata != NULL) {
epan_dissect_t edt;
epan_dissect_init(&edt, have_custom_cols(&cfile.cinfo), FALSE);
col_custom_prime_edt(&edt, &cfile.cinfo);
- epan_dissect_run(&edt, &cfile.pseudo_header, cfile.pd, fdata,
- &cfile.cinfo);
+ epan_dissect_run(&edt, &cfile.phdr, frame_tvbuff_new_buffer(fdata, &cfile.buf),
+ fdata, &cfile.cinfo);
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
if ((cfile.cinfo.col_custom_occurrence[column]) ||
/* 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]);
- if (hfi->parent == -1) {
+ if (hfi && hfi->parent == -1) {
/* Protocol only */
buf = se_strdup(cfile.cinfo.col_expr.col_expr[column]);
- } else if (hfi->type == FT_STRING) {
+ } else if (hfi && hfi->type == FT_STRING) {
/* Custom string, add quotes */
buf = se_strdup_printf("%s == \"%s\"", cfile.cinfo.col_expr.col_expr[column],
cfile.cinfo.col_expr.col_expr_val[column]);
}
void
-match_selected_plist_cb(GtkWidget *w _U_, gpointer data, MATCH_SELECTED_E action)
+match_selected_plist_cb(gpointer data, MATCH_SELECTED_E action)
{
- match_selected_cb_do(data,
+ match_selected_cb_do((GtkWidget *)g_object_get_data(G_OBJECT(data), E_DFILTER_TE_KEY),
action,
- get_filter_from_packet_list_row_and_column(data));
+ get_filter_from_packet_list_row_and_column((GtkWidget *)data));
}
/* This function allows users to right click in the details window and copy the text
copy_selected_plist_cb(GtkWidget *w _U_, gpointer data _U_, COPY_SELECTED_E action)
{
GString *gtk_text_str = g_string_new("");
- char labelstring[256];
+ char labelstring[ITEM_LABEL_LENGTH];
char *stringpointer = labelstring;
switch(action)
}
cf_reftime_packets(&cfile);
if (!frame->flags.ref_time && !frame->flags.passed_dfilter) {
- new_packet_list_freeze();
+ packet_list_freeze();
cfile.displayed_count--;
- new_packet_list_recreate_visible_rows();
- new_packet_list_thaw();
+ packet_list_recreate_visible_rows();
+ packet_list_thaw();
}
- new_packet_list_queue_draw();
+ packet_list_queue_draw();
}
timestamp_set_type(TS_RELATIVE);
recent.gui_time_format = TS_RELATIVE;
cf_timestamp_auto_precision(&cfile);
- new_packet_list_queue_draw();
+ packet_list_queue_draw();
break;
case(ESD_BTN_NO):
break;
case REFTIME_TOGGLE:
if (cfile.current_frame) {
if(recent.gui_time_format != TS_RELATIVE && cfile.current_frame->flags.ref_time==0) {
- reftime_dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_YES_NO,
+ reftime_dialog = (GtkWidget *)simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_YES_NO,
"%sSwitch to the appropriate Time Display Format?%s\n\n"
"Time References don't work well with the currently selected Time Display Format.\n\n"
"Do you want to switch to \"Seconds Since Beginning of Capture\" now?",
column_prefs_add_custom(COL_CUSTOM, cfile.finfo_selected->hfinfo->name,
cfile.finfo_selected->hfinfo->abbrev,0);
/* Recreate the packet list according to new preferences */
- new_packet_list_recreate ();
+ packet_list_recreate ();
if (!prefs.gui_use_pref_save) {
prefs_main_write();
}
- cfile.cinfo.columns_changed = FALSE; /* Reset value */
+ cfile.columns_changed = FALSE; /* Reset value */
}
}
}
void resolve_name_cb(GtkWidget *widget _U_, gpointer data _U_) {
+ static const e_addr_resolve resolv_flags = {TRUE, TRUE, TRUE, TRUE, TRUE, FALSE};
+
if (cfile.edt->tree) {
- guint32 tmp = gbl_resolv_flags;
- gbl_resolv_flags = RESOLV_ALL;
- proto_tree_draw(cfile.edt->tree, tree_view_gbl);
- gbl_resolv_flags = tmp;
+ proto_tree_draw_resolve(cfile.edt->tree, tree_view_gbl, &resolv_flags);
}
}
#ifdef HAVE_LIBPCAP
/* Nuke any child capture in progress. */
- capture_kill_child(&global_capture_opts);
+ capture_kill_child(&global_capture_session);
#endif
/* Are we in the middle of reading a capture? */
fprintf(output, " -I capture in monitor mode, if available\n");
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
- fprintf(output, " -B <buffer size> size of kernel buffer (def: 1MB)\n");
+ 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, " -D print list of interfaces and exit\n");
fprintf(output, " filesize:NUM - switch to next file after NUM KB\n");
fprintf(output, " files:NUM - ringbuffer: replace after NUM files\n");
#endif /* HAVE_LIBPCAP */
-
+#ifdef HAVE_PCAP_REMOTE
+ fprintf(output, "RPCAP options:\n");
+ fprintf(output, " -A <user>:<password> use RPCAP password authentication\n");
+#endif
/*fprintf(output, "\n");*/
fprintf(output, "Input file:\n");
fprintf(output, " -r <infile> set the filename to read from (no pipes or stdin!)\n");
fprintf(output, "\n");
fprintf(output, "User interface:\n");
fprintf(output, " -C <config profile> start with specified configuration profile\n");
- fprintf(output, " -d <display filter> start with the given display filter\n");
+ fprintf(output, " -Y <display filter> start with the given display filter\n");
fprintf(output, " -g <packet number> go to specified packet number after \"-r\"\n");
fprintf(output, " -J <jump filter> jump to the first packet matching the (display)\n");
fprintf(output, " filter\n");
fprintf(output, " -j search backwards for a matching packet after \"-J\"\n");
fprintf(output, " -m <font> set the font name used for most text\n");
- fprintf(output, " -t ad|a|r|d|dd|e output format of time stamps (def: r: rel. to first)\n");
+ fprintf(output, " -t a|ad|d|dd|e|r|u|ud output format of time stamps (def: r: rel. to first)\n");
fprintf(output, " -u s|hms output format of seconds (def: s: seconds)\n");
fprintf(output, " -X <key>:<value> eXtension options, see man page for details\n");
fprintf(output, " -z <statistics> show various statistics, see man page for details\n");
static void
show_version(void)
{
-#ifdef _WIN32
- create_console();
-#endif
-
printf(PACKAGE " " VERSION "%s\n"
"\n"
"%s"
"%s",
wireshark_svnversion, get_copyright_info(), comp_info_str->str,
runtime_info_str->str);
-
-#ifdef _WIN32
- destroy_console();
-#endif
-}
-
-/*
- * Print to the standard error. On Windows, create a console for the
- * standard error to show up on, if necessary.
- * XXX - pop this up in a window of some sort on UNIX+X11 if the controlling
- * terminal isn't the standard error?
- */
-void
-vfprintf_stderr(const char *fmt, va_list ap)
-{
-#ifdef _WIN32
- create_console();
-#endif
- vfprintf(stderr, fmt, ap);
-}
-
-void
-fprintf_stderr(const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- vfprintf_stderr(fmt, ap);
- va_end(ap);
}
/*
{
va_list ap;
- fprintf_stderr("wireshark: ");
+#ifdef _WIN32
+ create_console();
+#endif
+ fprintf(stderr, "wireshark: ");
va_start(ap, fmt);
- vfprintf_stderr(fmt, ap);
+ vfprintf(stderr, fmt, ap);
va_end(ap);
- fprintf_stderr("\n");
+ fprintf(stderr, "\n");
}
/*
{
va_list ap;
+#ifdef _WIN32
+ create_console();
+#endif
va_start(ap, fmt);
- vfprintf_stderr(fmt, ap);
- fprintf_stderr("\n");
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
va_end(ap);
}
return TRUE;
}
-/* Restart the tap update display timer with new configured interval */
-void reset_tap_update_timer(void)
-{
- g_source_remove(tap_update_timer_id);
- tap_update_timer_id = g_timeout_add(prefs.tap_update_interval, tap_update_cb, NULL);
-}
-
-void
-protect_thread_critical_region(void)
-{
- /* Threading support for TAP:s removed
- * http://www.wireshark.org/lists/wireshark-dev/200611/msg00199.html
- * See the commit for removed code:
- * http://anonsvn.wireshark.org/viewvc/viewvc.cgi?view=rev&revision=35027
- */
-}
-void
-unprotect_thread_critical_region(void)
-{
- /* Threading support for TAP:s removed
- * http://www.wireshark.org/lists/wireshark-dev/200611/msg00199.html
- */
-
-}
-
/*
* Periodically process outstanding hostname lookups. If we have new items,
* redraw the packet list and tree view.
resolv_update_cb(gpointer data _U_)
{
/* Anything new show up? */
- if (host_name_lookup_process(NULL)) {
+ if (host_name_lookup_process()) {
if (gtk_widget_get_window(pkt_scrollw))
gdk_window_invalidate_rect(gtk_widget_get_window(pkt_scrollw), NULL, TRUE);
if (gtk_widget_get_window(tv_scrollw))
}
-/* Set main_window_name and it's icon title to the capture filename */
-static void
-set_display_filename(capture_file *cf)
-{
- gchar *display_name;
- gchar *window_name;
-
- if (cf->filename) {
- display_name = cf_get_display_name(cf);
- window_name = g_strdup_printf("%s%s", cf->unsaved_changes ? "*" : "",
- display_name);
- g_free(display_name);
- main_set_window_name(window_name);
- g_free(window_name);
- } else {
- main_set_window_name("The Wireshark Network Analyzer");
- }
-}
-
/* Update various parts of the main window for a capture file "unsaved
changes" change - update the title to reflect whether there are
unsaved changes or not, and update the menus and toolbar to
void
main_update_for_unsaved_changes(capture_file *cf)
{
- set_display_filename(cf);
+ set_titlebar_for_capture_file(cf);
set_menus_for_capture_file(cf);
set_toolbar_for_capture_file(cf);
}
if(packet_list_colorize != recent.packet_list_colorize) {
recent.packet_list_colorize = packet_list_colorize;
color_filters_enable(packet_list_colorize);
- new_packet_list_colorize_packets();
+ packet_list_colorize_packets();
}
}
* data structures, so it wouldn't be easy to use a progress bar,
* rather than, say, a progress spinner, here! */
if(cf->count > 10000) {
- close_dlg = simple_dialog(ESD_TYPE_STOP, ESD_BTN_NONE,
+ close_dlg = (GtkWidget *)simple_dialog(ESD_TYPE_STOP, ESD_BTN_NONE,
"%sClosing file!%s\n\nPlease wait ...",
simple_dialog_primary_start(),
simple_dialog_primary_end());
capture file we're closing. */
destroy_packet_wins();
- /* Restore the standard title bar message. */
- main_set_window_name("The Wireshark Network Analyzer");
+ /* Update the titlebar to reflect the lack of a capture file. */
+ set_titlebar_for_capture_file(NULL);
- /* Disable all menu items that make sense only if you have a capture. */
+ /* Disable all menu and toolbar items that make sense only if
+ you have a capture. */
set_menus_for_capture_file(NULL);
set_toolbar_for_capture_file(NULL);
main_set_for_captured_packets(FALSE);
#ifdef HAVE_LIBPCAP
static GList *icon_list_create(
- const char **icon16_xpm,
- const char **icon32_xpm,
- const char **icon48_xpm,
- const char **icon64_xpm)
+ const guint8 *icon16_pb,
+ const guint8 *icon32_pb,
+ const guint8 *icon48_pb,
+ const guint8 *icon64_pb)
{
GList *icon_list = NULL;
GdkPixbuf * pixbuf16;
GdkPixbuf * pixbuf64;
- if(icon16_xpm != NULL) {
- pixbuf16 = gdk_pixbuf_new_from_xpm_data(icon16_xpm);
+ 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_xpm != NULL) {
- pixbuf32 = gdk_pixbuf_new_from_xpm_data(icon32_xpm);
+ 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_xpm != NULL) {
- pixbuf48 = gdk_pixbuf_new_from_xpm_data(icon48_xpm);
+ 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_xpm != NULL) {
- pixbuf64 = gdk_pixbuf_new_from_xpm_data(icon64_xpm);
+ if(icon64_pb != NULL) {
+ pixbuf64 = gdk_pixbuf_new_from_inline(-1, icon64_pb, FALSE, NULL);
g_assert(pixbuf64);
icon_list = g_list_append(icon_list, pixbuf64);
}
}
static void
-main_capture_set_main_window_title(capture_options *capture_opts)
-{
- GString *title = g_string_new("");
-
- g_string_append(title, "Capturing ");
- g_string_append_printf(title, "from %s ", cf_get_tempfile_source(capture_opts->cf));
- main_set_window_name(title->str);
- g_string_free(title, TRUE);
-}
-
-static void
-main_capture_cb_capture_prepared(capture_options *capture_opts)
+main_capture_cb_capture_prepared(capture_session *cap_session)
{
static GList *icon_list = NULL;
- main_capture_set_main_window_title(capture_opts);
+ set_titlebar_for_capture_in_progress((capture_file *)cap_session->cf);
if(icon_list == NULL) {
- icon_list = icon_list_create(wsiconcap16_xpm, wsiconcap32_xpm, wsiconcap48_xpm, NULL);
+ icon_list = icon_list_create(wsiconcap_16_pb_data, wsiconcap_32_pb_data, wsiconcap_48_pb_data, wsiconcap_64_pb_data);
}
gtk_window_set_icon_list(GTK_WINDOW(top_level), icon_list);
}
static void
-main_capture_cb_capture_update_started(capture_options *capture_opts)
+main_capture_cb_capture_update_started(capture_session *cap_session)
{
/* We've done this in "prepared" above, but it will be cleared while
switching to the next multiple file. */
- main_capture_set_main_window_title(capture_opts);
+ set_titlebar_for_capture_in_progress((capture_file *)cap_session->cf);
main_set_for_capture_in_progress(TRUE);
set_capture_if_dialog_for_capture_in_progress(TRUE);
}
static void
-main_capture_cb_capture_update_finished(capture_options *capture_opts)
+main_capture_cb_capture_update_finished(capture_session *cap_session)
{
- capture_file *cf = capture_opts->cf;
+ capture_file *cf = (capture_file *)cap_session->cf;
static GList *icon_list = NULL;
/* The capture isn't stopping any more - it's stopped. */
add_menu_recent_capture_file(cf->filename);
}
- /* Update the main window as appropriate */
- main_update_for_unsaved_changes(cf);
-
/* Enable menu items that make sense if you're not currently running
a capture. */
main_set_for_capture_in_progress(FALSE);
set_capture_if_dialog_for_capture_in_progress(FALSE);
+ /* Update the main window as appropriate. This has to occur AFTER
+ * main_set_for_capture_in_progress() or else some of the menus are
+ * incorrectly disabled (see bug
+ * https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8108) */
+ main_update_for_unsaved_changes(cf);
+
/* Set up main window for a capture file. */
main_set_for_capture_file(TRUE);
if(icon_list == NULL) {
- icon_list = icon_list_create(wsicon16_xpm, wsicon32_xpm, wsicon48_xpm, wsicon64_xpm);
+ icon_list = icon_list_create(wsicon_16_pb_data, wsicon_32_pb_data, wsicon_48_pb_data, wsicon_64_pb_data);
}
gtk_window_set_icon_list(GTK_WINDOW(top_level), icon_list);
}
static void
-main_capture_cb_capture_fixed_started(capture_options *capture_opts _U_)
+main_capture_cb_capture_fixed_started(capture_session *cap_session _U_)
{
/* Don't set up main window for a capture file. */
main_set_for_capture_file(FALSE);
}
static void
-main_capture_cb_capture_fixed_finished(capture_options *capture_opts _U_)
+main_capture_cb_capture_fixed_finished(capture_session *cap_session _U_)
{
#if 0
- capture_file *cf = capture_opts->cf;
+ capture_file *cf = (capture_file *)cap_session->cf;
#endif
static GList *icon_list = NULL;
/* The capture isn't stopping any more - it's stopped. */
capture_stopping = FALSE;
- /*set_display_filename(cf);*/
+ /*set_titlebar_for_capture_file(cf);*/
/* Enable menu items that make sense if you're not currently running
a capture. */
/* Restore the standard title bar message */
/* (just in case we have trouble opening the capture file). */
- main_set_window_name("The Wireshark Network Analyzer");
+ set_titlebar_for_capture_file(NULL);
if(icon_list == NULL) {
- icon_list = icon_list_create(wsicon16_xpm, wsicon32_xpm, wsicon48_xpm, wsicon64_xpm);
+ icon_list = icon_list_create(wsicon_16_pb_data, wsicon_32_pb_data, wsicon_48_pb_data, wsicon_64_pb_data);
}
gtk_window_set_icon_list(GTK_WINDOW(top_level), icon_list);
}
static void
-main_capture_cb_capture_stopping(capture_options *capture_opts _U_)
+main_capture_cb_capture_stopping(capture_session *cap_session _U_)
{
capture_stopping = TRUE;
set_menus_for_capture_stopping();
}
static void
-main_capture_cb_capture_failed(capture_options *capture_opts _U_)
+main_capture_cb_capture_failed(capture_session *cap_session _U_)
{
static GList *icon_list = NULL;
/* the capture failed before the first packet was captured
reset title, menus and icon */
-
- main_set_window_name("The Wireshark Network Analyzer");
+ set_titlebar_for_capture_file(NULL);
main_set_for_capture_in_progress(FALSE);
set_capture_if_dialog_for_capture_in_progress(FALSE);
main_set_for_capture_file(FALSE);
if(icon_list == NULL) {
- icon_list = icon_list_create(wsicon16_xpm, wsicon32_xpm, wsicon48_xpm, wsicon64_xpm);
+ icon_list = icon_list_create(wsicon_16_pb_data, wsicon_32_pb_data, wsicon_48_pb_data, wsicon_64_pb_data);
}
gtk_window_set_icon_list(GTK_WINDOW(top_level), icon_list);
static void
main_cf_cb_packet_selected(gpointer data)
{
- capture_file *cf = data;
+ capture_file *cf = (capture_file *)data;
/* Display the GUI protocol tree and packet bytes.
XXX - why do we dump core if we call "proto_tree_draw()"
static void
main_cf_callback(gint event, gpointer data, gpointer user_data _U_)
{
+ capture_file *cf = (capture_file *)data;
switch(event) {
+ case(cf_cb_file_opened):
+ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Opened");
+ fileset_file_opened(cf);
+ break;
case(cf_cb_file_closing):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Closing");
- main_cf_cb_file_closing(data);
+ main_cf_cb_file_closing(cf);
break;
case(cf_cb_file_closed):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Closed");
- main_cf_cb_file_closed(data);
+ main_cf_cb_file_closed(cf);
+ fileset_file_closed();
break;
case(cf_cb_file_read_started):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Read started");
- main_cf_cb_file_read_started(data);
+ main_cf_cb_file_read_started(cf);
break;
case(cf_cb_file_read_finished):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Read finished");
- main_cf_cb_file_read_finished(data);
+ main_cf_cb_file_read_finished(cf);
break;
case(cf_cb_file_reload_started):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Reload started");
- main_cf_cb_file_read_started(data);
+ main_cf_cb_file_read_started(cf);
break;
case(cf_cb_file_reload_finished):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Reload finished");
- main_cf_cb_file_read_finished(data);
+ main_cf_cb_file_read_finished(cf);
break;
case(cf_cb_file_rescan_started):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Rescan started");
break;
case(cf_cb_file_rescan_finished):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Rescan finished");
- main_cf_cb_file_rescan_finished(data);
+ main_cf_cb_file_rescan_finished(cf);
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(data);
+ main_cf_cb_file_rescan_finished(cf);
break;
case(cf_cb_packet_selected):
- main_cf_cb_packet_selected(data);
+ main_cf_cb_packet_selected(cf);
break;
case(cf_cb_packet_unselected):
- main_cf_cb_packet_unselected(data);
+ main_cf_cb_packet_unselected(cf);
break;
case(cf_cb_field_unselected):
- main_cf_cb_field_unselected(data);
+ main_cf_cb_field_unselected(cf);
break;
case(cf_cb_file_save_started):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Save started");
#ifdef HAVE_LIBPCAP
static void
-main_capture_callback(gint event, capture_options *capture_opts, gpointer user_data _U_)
+main_capture_callback(gint event, capture_session *cap_session, gpointer user_data _U_)
{
#ifdef HAVE_GTKOSXAPPLICATION
- GtkOSXApplication *theApp;
+ GtkosxApplication *theApp;
#endif
switch(event) {
case(capture_cb_capture_prepared):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture prepared");
- main_capture_cb_capture_prepared(capture_opts);
+ main_capture_cb_capture_prepared(cap_session);
break;
case(capture_cb_capture_update_started):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update started");
- main_capture_cb_capture_update_started(capture_opts);
+ main_capture_cb_capture_update_started(cap_session);
#ifdef HAVE_GTKOSXAPPLICATION
- theApp = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL);
- gtk_osxapplication_set_dock_icon_pixbuf(theApp,gdk_pixbuf_new_from_xpm_data(wsiconcap48_xpm));
+ 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));
#endif
break;
case(capture_cb_capture_update_continue):
break;
case(capture_cb_capture_update_finished):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update finished");
- main_capture_cb_capture_update_finished(capture_opts);
+ main_capture_cb_capture_update_finished(cap_session);
break;
case(capture_cb_capture_fixed_started):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed started");
- main_capture_cb_capture_fixed_started(capture_opts);
+ main_capture_cb_capture_fixed_started(cap_session);
break;
case(capture_cb_capture_fixed_continue):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed continue");
break;
case(capture_cb_capture_fixed_finished):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed finished");
- main_capture_cb_capture_fixed_finished(capture_opts);
+ main_capture_cb_capture_fixed_finished(cap_session);
break;
case(capture_cb_capture_stopping):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture stopping");
/* Beware: this state won't be called, if the capture child
- * closes the capturing on it's own! */
+ * closes the capturing on its own! */
#ifdef HAVE_GTKOSXAPPLICATION
- theApp = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL);
- gtk_osxapplication_set_dock_icon_pixbuf(theApp,gdk_pixbuf_new_from_xpm_data(wsicon64_xpm));
+ theApp = (GtkosxApplication *)g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
+ gtkosx_application_set_dock_icon_pixbuf(theApp, gdk_pixbuf_new_from_inline(-1, wsicon_64_pb_data, FALSE, NULL));
#endif
- main_capture_cb_capture_stopping(capture_opts);
+ main_capture_cb_capture_stopping(cap_session);
break;
case(capture_cb_capture_failed):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture failed");
- main_capture_cb_capture_failed(capture_opts);
+ main_capture_cb_capture_failed(cap_session);
break;
default:
g_warning("main_capture_callback: event %u unknown", event);
#ifdef _WIN32
/* Warn the user if npf.sys isn't loaded. */
- if (!stdin_capture && !cf_name && !npf_sys_is_running() && recent.privs_warn_if_no_npf && get_os_major_version() >= 6) {
+ if (!get_stdin_capture() && !cf_name && !npf_sys_is_running() && recent.privs_warn_if_no_npf && get_os_major_version() >= 6) {
priv_warning_dialog = simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
"The NPF driver isn't running. You may have trouble\n"
"capturing or listing interfaces.");
GtkWidget *splash_win = NULL;
GLogLevelFlags log_flags;
guint go_to_packet = 0;
- gboolean jump_backwards = FALSE;
+ search_direction jump_backwards = SD_FORWARD;
dfilter_t *jump_to_filter = NULL;
int optind_initial;
int status;
#ifdef HAVE_GTKOSXAPPLICATION
- GtkOSXApplication *theApp;
+ GtkosxApplication *theApp;
#endif
#ifdef HAVE_LIBPCAP
#else /* HAVE_LIBPCAP */
#define OPTSTRING_B ""
#endif /* HAVE_LIBPCAP */
-
+#ifdef HAVE_PCAP_REMOTE
+#define OPTSTRING_A "A:"
+#else
+#define OPTSTRING_A ""
+#endif
#ifdef HAVE_PCAP_CREATE
#define OPTSTRING_I "I"
#else
#define OPTSTRING_I ""
#endif
-#define OPTSTRING "a:b:" OPTSTRING_B "c:C:d:Df:g:Hhi:" OPTSTRING_I "jJ:kK:lLm:nN:o:P:pr:R:Ss:t:u:vw:X:y:z:"
+#define OPTSTRING "a:" OPTSTRING_A "b:" OPTSTRING_B "c:C:Df:g:Hhi:" OPTSTRING_I "jJ:kK:lLm:nN:o:P:pr:R:Ss:t:u:vw:X:y:Y:z:"
static const char optstring[] = OPTSTRING;
+
/* Set the C-language locale to the native environment. */
setlocale(LC_ALL, "");
#ifdef _WIN32
arg_list_utf_16to8(argc, argv);
+ create_app_running_mutex();
#endif /* _WIN32 */
/*
if (airpcap_if_list == NULL || g_list_length(airpcap_if_list) == 0){
if (err == CANT_GET_AIRPCAP_INTERFACE_LIST && err_str != NULL) {
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", "Failed to open Airpcap Adapters!");
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", "Failed to open Airpcap Adapters.");
g_free(err_str);
}
airpcap_if_active = NULL;
/* select the first ad default (THIS SHOULD BE CHANGED) */
airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
- }
+ }
break;
#if 0
/*
#endif
}
#endif /* HAVE_AIRPCAP */
-
- /* Start windows sockets */
- WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
#endif /* _WIN32 */
- profile_store_persconffiles (TRUE);
-
/* Assemble the compile-time version information string */
comp_info_str = g_string_new("Compiled ");
runtime_info_str = g_string_new("Running ");
get_runtime_version_info(runtime_info_str, get_gui_runtime_info);
+#ifdef _WIN32
+ ws_add_crash_info(PACKAGE " " VERSION "%s\n"
+ "\n"
+ "%s"
+ "\n"
+ "%s",
+ wireshark_svnversion, comp_info_str->str, runtime_info_str->str);
+
+ /* Start windows sockets */
+ WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
+#endif /* _WIN32 */
+
+ 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 parameterts */
recent_read_static(&rf_path, &rf_open_errno);
break;
case 'D': /* Print a list of capture devices and exit */
#ifdef HAVE_LIBPCAP
- if_list = capture_interface_list(&err, &err_str);
+ if_list = capture_interface_list(&err, &err_str,main_window_update);
if (if_list == NULL) {
switch (err) {
case CANT_GET_INTERFACE_LIST:
}
exit(2);
}
+#ifdef _WIN32
+ create_console();
+#endif /* _WIN32 */
capture_opts_print_interfaces(if_list);
free_interface_list(if_list);
+#ifdef _WIN32
+ destroy_console();
+#endif /* _WIN32 */
exit(0);
-#else
+#else /* HAVE_LIBPCAP */
capture_option_specified = TRUE;
arg_error = TRUE;
-#endif
+#endif /* HAVE_LIBPCAP */
break;
case 'h': /* Print help and exit */
print_usage(TRUE);
#ifdef _WIN32
case 'i':
if (strcmp(optarg, "-") == 0)
- stdin_capture = TRUE;
+ set_stdin_capture(TRUE);
break;
#endif
case 'P': /* Path settings - change these before the Preferences and alike are processed */
}
break;
case 'v': /* Show version and exit */
+#ifdef _WIN32
+ create_console();
+#endif
show_version();
+#ifdef _WIN32
+ destroy_console();
+#endif
exit(0);
break;
case 'X':
/* We might want to have component specific log levels later ... */
- log_flags =
- G_LOG_LEVEL_ERROR|
+ 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;
+ G_LOG_FLAG_FATAL|G_LOG_FLAG_RECURSION);
g_log_set_handler(NULL,
log_flags,
/* 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, &cfile);
+ capture_opts_init(&global_capture_opts);
+
+ capture_session_init(&global_capture_session, (void *)&cfile);
#endif
/* Initialize whatever we need to allocate colors for GTK+ */
splash_update(RA_PREFERENCES, NULL, (gpointer)splash_win);
- /* Now register the preferences for any non-dissector modules.
- We must do that before we read the preferences as well. */
- prefs_register_modules();
-
prefs_p = read_configuration_files (&gdp_path, &dp_path);
/* Removed thread code:
* http://anonsvn.wireshark.org/viewvc/viewvc.cgi?view=rev&revision=35027
prefs_to_capture_opts();
/*#ifdef HAVE_LIBPCAP
- if (global_capture_opts.all_ifaces->len == 0) {
- scan_local_interfaces(&global_capture_opts);
- }
+ fill_in_local_interfaces();
#endif*/
/* Now get our args */
while ((opt = getopt(argc, argv, optstring)) != -1) {
case 'i': /* Use interface x */
#ifdef HAVE_PCAP_CREATE
case 'I': /* Capture in monitor mode, if available */
+#endif
+#ifdef HAVE_PCAP_REMOTE
+ case 'A': /* Authentication */
#endif
case 's': /* Set the snapshot (capture) length */
case 'S': /* "Sync" mode: used for following file ala tail -f */
case 'C':
/* Configuration profile settings were already processed just ignore them this time*/
break;
- case 'd':
- dfilter = optarg;
- break;
case 'j': /* Search backwards for a matching packet from filter in option J */
- jump_backwards = TRUE;
+ jump_backwards = SD_BACKWARD;
break;
case 'g': /* Go to packet with the given packet number */
go_to_packet = get_positive_int(optarg, "go to packet");
#endif
break;
case 'm': /* Fixed-width font for the display */
- g_free(prefs_p->gui_font_name);
- prefs_p->gui_font_name = g_strdup(optarg);
+ g_free(prefs_p->gui_gtk2_font_name);
+ prefs_p->gui_gtk2_font_name = g_strdup(optarg);
break;
case 'n': /* No name resolution */
- gbl_resolv_flags = RESOLV_NONE;
+ gbl_resolv_flags.mac_name = FALSE;
+ gbl_resolv_flags.network_name = FALSE;
+ gbl_resolv_flags.transport_name = FALSE;
+ gbl_resolv_flags.concurrent_dns = FALSE;
break;
case 'N': /* Select what types of addresses/port #s to resolve */
- if (gbl_resolv_flags == RESOLV_ALL)
- gbl_resolv_flags = RESOLV_NONE;
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'",
timestamp_set_type(TS_UTC_WITH_DATE);
else {
cmdarg_err("Invalid time stamp type \"%s\"", optarg);
- cmdarg_err_cont("It must be \"r\" for relative, \"a\" for absolute,");
- cmdarg_err_cont("\"ad\" for absolute with date, or \"d\" for delta.");
+ cmdarg_err_cont("It must be \"a\" for absolute, \"ad\" for absolute with date, \"d\" for delta,");
+ cmdarg_err_cont("\"dd\" for delta displayed, \"e\" for epoch, \"r\" for relative, \"u\" for UTC, ");
+ cmdarg_err_cont("or \"ud\" for UTC with date.");
exit(1);
}
break;
case 'X':
/* ext ops were already processed just ignore them this time*/
break;
+ case 'Y':
+ dfilter = optarg;
+ break;
case 'z':
/* We won't call the init function for the stat this soon
as it would disallow MATE's fields (which are registered
* file - yes, you could have "-r" as the last part of the command,
* but that's a bit ugly.
*/
+#ifndef HAVE_GTKOSXAPPLICATION
+ /*
+ * For GTK+ Mac Integration, file name passed as free argument passed
+ * through grag-and-drop and opened twice sometimes causing crashes.
+ * Subject to report to GTK+ MAC.
+ */
cf_name = g_strdup(argv[0]);
+#endif
}
argc--;
argv++;
print_usage(FALSE);
exit(1);
}
-
-#ifdef HAVE_LIBPCAP
- if (global_capture_opts.all_ifaces->len == 0) {
- scan_local_interfaces(&global_capture_opts);
- }
-#endif
+
#ifdef HAVE_LIBPCAP
+ fill_in_local_interfaces(main_window_update);
if (start_capture && list_link_layer_types) {
/* Specifying *both* is bogus. */
cmdarg_err("You can't specify both -L and a live capture.");
}
if (start_capture || list_link_layer_types) {
- /* Did the user specify an interface to use? */
- if (!capture_opts_trim_iface(&global_capture_opts,
- (prefs_p->capture_device) ? get_if_name(prefs_p->capture_device) : NULL)) {
- exit(2);
+ /* 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. */
+ status = capture_opts_default_iface_if_necessary(&global_capture_opts,
+ ((prefs_p->capture_device) && (*prefs_p->capture_device != '\0')) ? get_if_name(prefs_p->capture_device) : NULL);
+ if (status != 0) {
+ exit(status);
}
}
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
if (device.selected) {
#if defined(HAVE_PCAP_CREATE)
- caps = capture_get_if_capabilities(device.name, device.monitor_mode_supported, &err_str);
+ caps = capture_get_if_capabilities(device.name, device.monitor_mode_supported, &err_str, main_window_update);
#else
- caps = capture_get_if_capabilities(device.name, FALSE, &err_str);
+ caps = capture_get_if_capabilities(device.name, FALSE, &err_str,main_window_update);
#endif
if (caps == NULL) {
cmdarg_err("%s", err_str);
cmdarg_err("The capture device \"%s\" has no data link types.", device.name);
exit(2);
}
+#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);
}
}
#ifdef HAVE_LIBPCAP
if ((global_capture_opts.num_selected == 0) &&
- (prefs.capture_device != NULL)) {
+ ((prefs.capture_device != NULL) && (*prefs_p->capture_device != '\0'))) {
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) {
+ if (!device.hidden && strstr(prefs.capture_device, device.name) != NULL) {
device.selected = TRUE;
global_capture_opts.num_selected++;
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
}
}
}
+ if (global_capture_opts.num_selected == 0 && global_capture_opts.all_ifaces->len == 1) {
+ interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, 0);
+ device.selected = TRUE;
+ global_capture_opts.num_selected++;
+ global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, 0);
+ g_array_insert_val(global_capture_opts.all_ifaces, 0, device);
+ }
#endif
/* disabled protocols as per configuration file */
#else
gtk_rc_parse(rc_file);
g_free(rc_file);
- rc_file = get_persconffile_path(RC_FILE, FALSE, FALSE);
+ rc_file = get_persconffile_path(RC_FILE, FALSE);
gtk_rc_parse(rc_file);
#endif
g_free(rc_file);
g_timeout_add(info_update_freq, resolv_update_cb, NULL);
- if (dfilter) {
- GtkWidget *filter_te;
- filter_te = gtk_bin_get_child(GTK_BIN(g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY)));
- gtk_entry_set_text(GTK_ENTRY(filter_te), dfilter);
-
- /* Run the display filter so it goes in effect. */
- main_filter_packets(&cfile, dfilter, FALSE);
- }
-
/* If we were given the name of a capture file, read it in now;
we defer it until now, so that, if we can't open it, and pop
up an alert box, the alert box is more likely to come up on
to use for this capture. */
if (global_capture_opts.ifaces->len == 0)
collect_ifaces(&global_capture_opts);
- if (capture_start(&global_capture_opts)) {
+ if (capture_start(&global_capture_opts, &global_capture_session,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
#endif /* HAVE_LIBPCAP */
}
+ if (dfilter) {
+ GtkWidget *filter_te;
+ filter_te = gtk_bin_get_child(GTK_BIN(g_object_get_data(G_OBJECT(top_level), E_DFILTER_CM_KEY)));
+ gtk_entry_set_text(GTK_ENTRY(filter_te), dfilter);
+
+ /* Run the display filter so it goes in effect. */
+ main_filter_packets(&cfile, dfilter, FALSE);
+ }
+
+
/* register our pid if we are being run from a U3 device */
u3_register_pid();
profile_store_persconffiles (FALSE);
#ifdef HAVE_GTKOSXAPPLICATION
- theApp = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL);
- gtk_osxapplication_set_dock_icon_pixbuf(theApp,gdk_pixbuf_new_from_xpm_data(wsicon64_xpm));
- gtk_osxapplication_ready(theApp);
+ theApp = (GtkosxApplication *)g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
+ gtkosx_application_set_dock_icon_pixbuf(theApp, gdk_pixbuf_new_from_inline(-1, wsicon_64_pb_data, FALSE, NULL));
+ gtkosx_application_ready(theApp);
#endif
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "Wireshark is up and ready to go");
+#ifdef HAVE_LIBPCAP
+ gtk_iface_mon_start();
+#endif
+
+ software_update_init();
+
/* we'll enter the GTK loop now and hand the control over to GTK ... */
gtk_main();
/* ... back from GTK, we're going down now! */
+#ifdef HAVE_LIBPCAP
+ gtk_iface_mon_stop();
+#endif
+
/* deregister our pid */
u3_deregister_pid();
g_object_unref(theApp);
#endif
+ software_update_cleanup();
+
/* Shutdown windows sockets */
WSACleanup();
/* RichEd20.DLL is needed for filter entries. */
ws_load_library("riched20.dll");
- has_console = FALSE;
- console_wait = FALSE;
+ set_has_console(FALSE);
+ set_console_wait(FALSE);
return main (__argc, __argv);
}
-/* The code to create and desstroy console windows should not be necessary,
- at least as I read the GLib source code, as it looks as if GLib is, on
- Win32, *supposed* to create a console window into which to display its
- output.
-
- That doesn't happen, however. I suspect there's something completely
- broken about that code in GLib-for-Win32, and that it may be related
- to the breakage that forces us to just call "printf()" on the message
- rather than passing the message on to "g_log_default_handler()"
- (which is the routine that does the aforementioned non-functional
- console window creation). */
-
-/*
- * If this application has no console window to which its standard output
- * would go, create one.
- */
-void
-create_console(void)
-{
- if (stdin_capture) {
- /* We've been handed "-i -". Don't mess with stdio. */
- return;
- }
-
- if (!has_console) {
- /* We have no console to which to print the version string, so
- create one and make it the standard input, output, and error. */
-
- /*
- * See if we have an existing console (i.e. we were run from a
- * command prompt)
- */
- if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
- if (AllocConsole()) {
- console_wait = TRUE;
- SetConsoleTitle(_T("Wireshark Debug Console"));
- } else {
- return; /* couldn't create console */
- }
- }
-
- ws_freopen("CONIN$", "r", stdin);
- ws_freopen("CONOUT$", "w", stdout);
- ws_freopen("CONOUT$", "w", stderr);
- fprintf(stdout, "\n");
- fprintf(stderr, "\n");
-
- /* Now register "destroy_console()" as a routine to be called just
- before the application exits, so that we can destroy the console
- after the user has typed a key (so that the console doesn't just
- disappear out from under them, giving the user no chance to see
- the message(s) we put in there). */
- atexit(destroy_console);
-
- /* Well, we have a console now. */
- has_console = TRUE;
- }
-}
-
-static void
-destroy_console(void)
-{
- if (console_wait) {
- printf("\n\nPress any key to exit\n");
- _getch();
- }
- FreeConsole();
-}
#endif /* _WIN32 */
/* the user wants a console or the application will terminate immediately */
create_console();
}
- if (has_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. */
g_object_ref(G_OBJECT(menubar));
g_object_ref(G_OBJECT(main_tb));
g_object_ref(G_OBJECT(filter_tb));
-#ifdef HAVE_AIRPCAP
g_object_ref(G_OBJECT(wireless_tb));
-#endif
g_object_ref(G_OBJECT(pkt_scrollw));
g_object_ref(G_OBJECT(tv_scrollw));
g_object_ref(G_OBJECT(byte_nb_ptr_gbl));
gtk_box_pack_start(GTK_BOX(main_vbox), filter_tb, FALSE, TRUE, 1);
}
-#ifdef HAVE_AIRPCAP
/* airpcap toolbar */
gtk_box_pack_start(GTK_BOX(main_vbox), wireless_tb, FALSE, TRUE, 1);
-#endif
/* fill the main layout panes */
switch(prefs.gui_layout_type) {
if (second_pane_widget2 != NULL)
gtk_paned_pack2(GTK_PANED(main_second_pane), second_pane_widget2, FALSE, FALSE);
- gtk_container_add(GTK_CONTAINER(main_vbox), main_first_pane);
+ gtk_box_pack_start(GTK_BOX(main_vbox), main_first_pane, TRUE, TRUE, 0);
/* welcome pane */
gtk_box_pack_start(GTK_BOX(main_vbox), welcome_pane, TRUE, TRUE, 0);
static void
is_widget_visible(GtkWidget *widget, gpointer data)
{
- gboolean *is_visible = data;
+ gboolean *is_visible = ( gboolean *)data;
if (!*is_visible) {
if (gtk_widget_get_visible(widget))
top_level_key_pressed_cb(GtkWidget *w _U_, GdkEventKey *event, gpointer user_data _U_)
{
if (event->keyval == GDK_F8) {
- new_packet_list_next();
+ packet_list_next();
return TRUE;
} else if (event->keyval == GDK_F7) {
- new_packet_list_prev();
+ packet_list_prev();
return TRUE;
} else if (event->state & NO_SHIFT_MOD_MASK) {
return FALSE; /* Skip control, alt, and other modifiers */
}
static void
-create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs_p)
+create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs_p
+#if !defined(HAVE_IGE_MAC_INTEGRATION) && !defined (HAVE_GTKOSXAPPLICATION)
+ _U_
+#endif
+ )
{
GtkAccelGroup *accel;
/* Main window */
top_level = window_new(GTK_WINDOW_TOPLEVEL, "");
- main_set_window_name("The Wireshark Network Analyzer");
+ set_titlebar_for_capture_file(NULL);
gtk_widget_set_name(top_level, "main window");
g_signal_connect(top_level, "delete_event", G_CALLBACK(main_window_delete_event_cb),
/* Vertical container for menu bar, toolbar(s), paned windows and progress/info box */
main_vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 1, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 0);
+
+ gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 0);
gtk_container_add(GTK_CONTAINER(top_level), main_vbox);
gtk_widget_show(main_vbox);
gtk_window_add_accel_group(GTK_WINDOW(top_level), accel);
gtk_widget_show(menubar);
#if defined(HAVE_IGE_MAC_INTEGRATION) || defined(HAVE_GTKOSXAPPLICATION)
+ } else {
+ gtk_widget_hide(menubar);
}
#endif
filter_tb = filter_toolbar_new();
/* Packet list */
- pkt_scrollw = new_packet_list_create();
+ pkt_scrollw = packet_list_create();
gtk_widget_set_size_request(pkt_scrollw, -1, pl_size);
gtk_widget_show_all(pkt_scrollw);
/* Tree view */
- tv_scrollw = proto_tree_view_new(prefs_p, &tree_view_gbl);
+ tv_scrollw = proto_tree_view_new(&tree_view_gbl);
gtk_widget_set_size_request(tv_scrollw, -1, tv_size);
gtk_widget_show(tv_scrollw);
gtk_widget_show(main_pane_h2);
#ifdef HAVE_AIRPCAP
wireless_tb = airpcap_toolbar_new();
- gtk_widget_show(wireless_tb);
+#else
+ wireless_tb = ws80211_toolbar_new();
#endif
+ gtk_widget_show(wireless_tb);
+
/* status bar */
statusbar = statusbar_new();
gtk_widget_show(statusbar);
#endif /* HAVE_AIRPCAP */
}
-/* Fill in capture options with values from the preferences */
-void
-prefs_to_capture_opts(void)
-{
-#ifdef HAVE_LIBPCAP
- /* Set promiscuous mode from the preferences setting. */
- /* the same applies to other preferences settings as well. */
- global_capture_opts.default_options.promisc_mode = prefs.capture_prom_mode;
- global_capture_opts.use_pcapng = prefs.capture_pcap_ng;
- global_capture_opts.show_info = prefs.capture_show_info;
- global_capture_opts.real_time_mode = prefs.capture_real_time;
- auto_scroll_live = prefs.capture_auto_scroll;
-#endif /* HAVE_LIBPCAP */
-
- /* Set the name resolution code's flags from the preferences. */
- gbl_resolv_flags = prefs.name_resolve;
-}
-
static void copy_global_profile (const gchar *profile_name)
{
char *pf_dir_path, *pf_dir_path2, *pf_filename;
welcome_if_panel_reload();
/* Recreate the packet list according to new preferences */
- new_packet_list_recreate ();
- cfile.cinfo.columns_changed = FALSE; /* Reset value */
+ packet_list_recreate ();
+ cfile.columns_changed = FALSE; /* Reset value */
user_font_apply();
/* Update menus with new recent values */
cf_redissect_packets(&cfile);
status_expert_update();
}
-
-#ifdef HAVE_LIBPCAP
-guint get_interface_type(gchar *name, gchar *description)
-{
-#if defined(__linux__)
- ws_statb64 statb;
- char *wireless_path;
-#endif
-#if defined(_WIN32)
- /*
- * Much digging failed to reveal any obvious way to get something such
- * as the SNMP MIB-II ifType value for an interface:
- *
- * http://www.iana.org/assignments/ianaiftype-mib
- *
- * by making some NDIS request.
- */
- if (description && (strstr(description,"generic dialup") != NULL ||
- strstr(description,"PPP/SLIP") != NULL )) {
- return IF_DIALUP;
- } else if (description && (strstr(description,"Wireless") != NULL ||
- strstr(description,"802.11") != NULL)) {
- return IF_WIRELESS;
- } else if (description && strstr(description,"AirPcap") != NULL ||
- strstr(name,"airpcap")) {
- return IF_AIRPCAP;
- } else if (description && strstr(description, "Bluetooth") != NULL ) {
- return IF_BLUETOOTH;
- }
-#elif defined(__APPLE__)
- /*
- * XXX - yes, fetching all the network addresses for an interface
- * gets you an AF_LINK address, of type "struct sockaddr_dl", and,
- * yes, that includes an SNMP MIB-II ifType value.
- *
- * However, it's IFT_ETHER, i.e. Ethernet, for AirPort interfaces,
- * not IFT_IEEE80211 (which isn't defined in OS X in any case).
- *
- * Perhaps some other BSD-flavored OSes won't make this mistake;
- * however, FreeBSD 7.0 and OpenBSD 4.2, at least, appear to have
- * made the same mistake, at least for my Belkin ZyDAS stick.
- *
- * XXX - this is wrong on a MacBook Air, as en0 is the AirPort
- * interface, and it's also wrong on a Mac that has no AirPort
- * interfaces and has multiple Ethernet interfaces.
- *
- * The SystemConfiguration framework is your friend here.
- * SCNetworkInterfaceGetInterfaceType() will get the interface
- * type. SCNetworkInterfaceCopyAll() gets all network-capable
- * interfaces on the system; SCNetworkInterfaceGetBSDName()
- * gets the "BSD name" of the interface, so we look for
- * an interface with the specified "BSD name" and get its
- * interface type. The interface type is a CFString, and:
- *
- * kSCNetworkInterfaceTypeIEEE80211 means IF_WIRELESS;
- * kSCNetworkInterfaceTypeBluetooth means IF_BLUETOOTH;
- * kSCNetworkInterfaceTypeModem or
- * kSCNetworkInterfaceTypePPP or
- * maybe kSCNetworkInterfaceTypeWWAN means IF_DIALUP
- */
- if (strcmp(name, "en1") == 0) {
- return IF_WIRELESS;
- }
- /*
- * XXX - PPP devices have names beginning with "ppp" and an IFT_ of
- * IFT_PPP, but they could be dial-up, or PPPoE, or mobile phone modem,
- * or VPN, or... devices. One might have to dive into the bowels of
- * IOKit to find out.
- */
-
- /*
- * XXX - there's currently no support for raw Bluetooth capture,
- * and IP-over-Bluetooth devices just look like fake Ethernet
- * devices. There's also Bluetooth modem support, but that'll
- * probably just give you a device that looks like a PPP device.
- */
-#elif defined(__linux__)
- /*
- * Look for /sys/class/net/{device}/wireless.
- */
- wireless_path = g_strdup_printf("/sys/class/net/%s/wireless", name);
- if (wireless_path != NULL) {
- if (ws_stat64(wireless_path, &statb) == 0) {
- g_free(wireless_path);
- return IF_WIRELESS;
- }
- }
- /*
- * Bluetooth devices.
- *
- * XXX - this is for raw Bluetooth capture; what about IP-over-Bluetooth
- * devices?
- */
- if ( strstr(name,"bluetooth") != NULL) {
- return IF_BLUETOOTH;
- }
-
- /*
- * USB devices.
- */
- if ( strstr(name,"usbmon") != NULL ) {
- return IF_USB;
- }
-#endif
- /*
- * Bridge, NAT, or host-only interfaces on VMWare hosts have the name
- * vmnet[0-9]+ or VMnet[0-9+ on Windows. Guests might use a native
- * (LANCE or E1000) driver or the vmxnet driver. These devices have an
- * IFT_ of IFT_ETHER, so we have to check the name.
- */
- if ( g_ascii_strncasecmp(name, "vmnet", 5) == 0) {
- return IF_VIRTUAL;
- }
-
- if ( g_ascii_strncasecmp(name, "vmxnet", 6) == 0) {
- return IF_VIRTUAL;
- }
-
- if (description && strstr(description, "VMware") != NULL ) {
- return IF_VIRTUAL;
- }
-
- return IF_WIRED;
-}
-
-/*
- * Fetch the list of local interfaces with capture_interface_list()
- * and set the list of "all interfaces" in *capture_opts to include
- * those interfaces.
- */
-void
-scan_local_interfaces(capture_options* capture_opts)
-{
- GList *if_entry, *lt_entry, *if_list;
- if_info_t *if_info, *temp;
- char *if_string;
- gchar *descr;
- if_capabilities_t *caps=NULL;
- gint linktype_count;
- cap_settings_t cap_settings;
- GSList *curr_addr;
- int ips = 0, i, err;
- guint count = 0, j;
- if_addr_t *addr, *temp_addr;
- link_row *link = NULL;
- data_link_info_t *data_link_info;
- interface_t device;
- GString *ip_str;
- interface_options interface_opts;
- gboolean found = FALSE;
-
-
- if (capture_opts->all_ifaces->len > 0) {
- for (i = (int)capture_opts->all_ifaces->len-1; i >= 0; i--) {
- device = g_array_index(capture_opts->all_ifaces, interface_t, i);
- if (device.local) {
- capture_opts->all_ifaces = g_array_remove_index(capture_opts->all_ifaces, i);
- }
- }
- }
- /* Scan through the list and build a list of strings to display. */
- if_list = capture_interface_list(&err, NULL);
- count = 0;
- for (if_entry = if_list; if_entry != NULL; if_entry = g_list_next(if_entry)) {
- if_info = if_entry->data;
- ip_str = g_string_new("");
- ips = 0;
- if (strstr(if_info->name, "rpcap:")) {
- continue;
- }
- device.name = g_strdup(if_info->name);
- device.hidden = FALSE;
- device.locked = FALSE;
- temp = g_malloc0(sizeof(if_info_t));
- temp->name = g_strdup(if_info->name);
- temp->description = g_strdup(if_info->description);
- temp->loopback = if_info->loopback;
- /* Is this interface hidden and, if so, should we include it anyway? */
-
- /* Do we have a user-supplied description? */
- descr = capture_dev_user_descr_find(if_info->name);
- if (descr != NULL) {
- /* Yes, we have a user-supplied description; use it. */
- if_string = g_strdup_printf("%s: %s", descr, if_info->name);
- g_free(descr);
- } else {
- /* No, we don't have a user-supplied description; did we get
- one from the OS or libpcap? */
- if (if_info->description != NULL) {
- /* Yes - use it. */
- if_string = g_strdup_printf("%s: %s", if_info->description, if_info->name);
- } else {
- /* No. */
- if_string = g_strdup(if_info->name);
- }
- }
- if (if_info->loopback) {
- device.display_name = g_strdup_printf("%s (loopback)", if_string);
- } else {
- device.display_name = g_strdup(if_string);
- }
- g_free(if_string);
- device.selected = FALSE;
- if (prefs_is_capture_device_hidden(if_info->name)) {
- device.hidden = TRUE;
- }
- device.type = get_interface_type(if_info->name, if_info->description);
- cap_settings = capture_get_cap_settings(if_info->name);
- caps = capture_get_if_capabilities(if_info->name, cap_settings.monitor_mode, NULL);
- for (; (curr_addr = g_slist_nth(if_info->addrs, ips)) != NULL; ips++) {
- temp_addr = g_malloc0(sizeof(if_addr_t));
- if (ips != 0) {
- g_string_append(ip_str, "\n");
- }
- addr = (if_addr_t *)curr_addr->data;
- if (addr) {
- temp_addr->ifat_type = addr->ifat_type;
- switch (addr->ifat_type) {
- case IF_AT_IPv4:
- temp_addr->addr.ip4_addr = addr->addr.ip4_addr;
- g_string_append(ip_str, ip_to_str((guint8 *)&addr->addr.ip4_addr));
- break;
- case IF_AT_IPv6:
- memcpy(temp_addr->addr.ip6_addr, addr->addr.ip6_addr, sizeof(addr->addr));
- g_string_append(ip_str, ip6_to_str((struct e_in6_addr *)&addr->addr.ip6_addr));
- break;
- default:
- /* In case we add non-IP addresses */
- break;
- }
- } else {
- g_free(temp_addr);
- temp_addr = NULL;
- }
- if (temp_addr) {
- temp->addrs = g_slist_append(temp->addrs, temp_addr);
- }
- }
-#ifdef HAVE_PCAP_REMOTE
- device.local = TRUE;
- device.remote_opts.src_type = CAPTURE_IFLOCAL;
- device.remote_opts.remote_host_opts.remote_host = g_strdup(capture_opts->default_options.remote_host);
- device.remote_opts.remote_host_opts.remote_port = g_strdup(capture_opts->default_options.remote_port);
- device.remote_opts.remote_host_opts.auth_type = capture_opts->default_options.auth_type;
- device.remote_opts.remote_host_opts.auth_username = g_strdup(capture_opts->default_options.auth_username);
- device.remote_opts.remote_host_opts.auth_password = g_strdup(capture_opts->default_options.auth_password);
- device.remote_opts.remote_host_opts.datatx_udp = capture_opts->default_options.datatx_udp;
- device.remote_opts.remote_host_opts.nocap_rpcap = capture_opts->default_options.nocap_rpcap;
- device.remote_opts.remote_host_opts.nocap_local = capture_opts->default_options.nocap_local;
-#endif
-#ifdef HAVE_PCAP_SETSAMPLING
- device.remote_opts.sampling_method = capture_opts->default_options.sampling_method;
- device.remote_opts.sampling_param = capture_opts->default_options.sampling_param;
-#endif
- linktype_count = 0;
- device.links = NULL;
- if (caps != NULL) {
-#if defined(HAVE_PCAP_CREATE)
- device.monitor_mode_enabled = cap_settings.monitor_mode;
- device.monitor_mode_supported = caps->can_set_rfmon;
-#endif
- for (lt_entry = caps->data_link_types; lt_entry != NULL; lt_entry = g_list_next(lt_entry)) {
- data_link_info = lt_entry->data;
- if (linktype_count == 0) {
- device.active_dlt = data_link_info->dlt;
- }
- link = (link_row *)g_malloc(sizeof(link_row));
- if (data_link_info->description != NULL) {
- link->dlt = data_link_info->dlt;
- link->name = g_strdup_printf("%s", data_link_info->description);
- } else {
- link->dlt = -1;
- link->name = g_strdup_printf("%s (not supported)", data_link_info->name);
- }
- device.links = g_list_append(device.links, link);
- linktype_count++;
- }
- } else {
- cap_settings.monitor_mode = FALSE;
-#if defined(HAVE_PCAP_CREATE)
- device.monitor_mode_enabled = FALSE;
- device.monitor_mode_supported = FALSE;
-#endif
- device.active_dlt = -1;
- }
- device.addresses = g_strdup(ip_str->str);
- device.no_addresses = ips;
- device.local = TRUE;
- device.if_info = *temp;
- device.last_packets = 0;
- device.pmode = capture_opts->default_options.promisc_mode;
- device.has_snaplen = capture_opts->default_options.has_snaplen;
- device.snaplen = capture_opts->default_options.snaplen;
- device.cfilter = g_strdup(capture_opts->default_options.cfilter);
-#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
- device.buffer = 1;
-#endif
-
- if (capture_opts->ifaces->len > 0) {
- for (j = 0; j < capture_opts->ifaces->len; j++) {
- interface_opts = g_array_index(capture_opts->ifaces, interface_options, j);
- if (strcmp(interface_opts.name, device.name) == 0) {
-#if defined(HAVE_PCAP_CREATE)
- device.buffer = interface_opts.buffer_size;
- device.monitor_mode_enabled = interface_opts.monitor_mode;
-#endif
- device.pmode = interface_opts.promisc_mode;
- device.has_snaplen = interface_opts.has_snaplen;
- device.snaplen = interface_opts.snaplen;
- device.cfilter = g_strdup(interface_opts.cfilter);
- device.active_dlt = interface_opts.linktype;
- device.selected = TRUE;
- capture_opts->num_selected++;
- break;
- }
- }
- }
- if (capture_opts->all_ifaces->len <= count) {
- g_array_append_val(capture_opts->all_ifaces, device);
- count = capture_opts->all_ifaces->len;
- } else {
- g_array_insert_val(capture_opts->all_ifaces, count, device);
- }
- if (caps != NULL) {
- free_if_capabilities(caps);
- }
-
- g_string_free(ip_str, TRUE);
- count++;
- }
- free_interface_list(if_list);
- /* see whether there are additional interfaces in ifaces */
- for (j = 0; j < capture_opts->ifaces->len; j++) {
- interface_opts = g_array_index(capture_opts->ifaces, interface_options, j);
- found = FALSE;
- for (i = 0; i < (int)capture_opts->all_ifaces->len; i++) {
- device = g_array_index(capture_opts->all_ifaces, interface_t, i);
- if (strcmp(device.name, interface_opts.name) == 0) {
- found = TRUE;
- break;
- }
- }
- if (!found) { /* new interface, maybe a pipe */
- device.name = g_strdup(interface_opts.name);
- device.display_name = g_strdup_printf("%s", device.name);
- device.hidden = FALSE;
- device.selected = TRUE;
- device.type = IF_PIPE;
-#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
- device.buffer = interface_opts.buffer_size;
-#endif
-#if defined(HAVE_PCAP_CREATE)
- device.monitor_mode_enabled = interface_opts.monitor_mode;
- device.monitor_mode_supported = FALSE;
-#endif
- device.pmode = interface_opts.promisc_mode;
- device.has_snaplen = interface_opts.has_snaplen;
- device.snaplen = interface_opts.snaplen;
- device.cfilter = g_strdup(interface_opts.cfilter);
- device.active_dlt = interface_opts.linktype;
- device.addresses = NULL;
- device.no_addresses = 0;
- device.last_packets = 0;
- device.links = NULL;
- device.local = TRUE;
- device.locked = FALSE;
-
- g_array_append_val(capture_opts->all_ifaces, device);
- capture_opts->num_selected++;
- }
- }
-}
-
-void hide_interface(gchar* new_hide)
-{
- gchar *tok;
- guint i;
- interface_t device;
- gboolean found = FALSE;
- GList *hidden_devices = NULL, *entry;
- if (new_hide != NULL) {
- for (tok = strtok (new_hide, ","); tok; tok = strtok(NULL, ",")) {
- hidden_devices = g_list_append(hidden_devices, tok);
- }
- }
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- found = FALSE;
- for (entry = hidden_devices; entry != NULL; entry = g_list_next(entry)) {
- if (strcmp(entry->data, device.name)==0) {
- device.hidden = TRUE;
- if (device.selected) {
- device.selected = FALSE;
- global_capture_opts.num_selected--;
- }
- found = TRUE;
- break;
- }
- }
- if (!found) {
- device.hidden = FALSE;
- }
- 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);
- }
-}
-#endif