summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/Makefile.am4
-rw-r--r--gtk/Makefile.nmake1
-rw-r--r--gtk/capture_dlg.c12
-rw-r--r--gtk/capture_prefs.c182
-rw-r--r--gtk/capture_prefs.h33
-rw-r--r--gtk/gui_prefs.c7
-rw-r--r--gtk/prefs_dlg.c37
-rw-r--r--prefs.c24
-rw-r--r--prefs.h3
-rw-r--r--tethereal.c40
10 files changed, 305 insertions, 38 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 94ba7856b5..07c4e69731 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for the GTK interface routines for Ethereal
#
-# $Id: Makefile.am,v 1.36 2001/12/08 09:27:50 guy Exp $
+# $Id: Makefile.am,v 1.37 2002/01/10 07:43:39 guy Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@zing.org>
@@ -31,6 +31,8 @@ CLEANFILES = \
libui_a_SOURCES = \
capture_dlg.c \
capture_dlg.h \
+ capture_prefs.c \
+ capture_prefs.h \
color_dlg.c \
color_dlg.h \
colors.c \
diff --git a/gtk/Makefile.nmake b/gtk/Makefile.nmake
index 54d5f03480..666425a54d 100644
--- a/gtk/Makefile.nmake
+++ b/gtk/Makefile.nmake
@@ -19,6 +19,7 @@ CVARSDLL=-DWIN32 -DNULL=0 -D_MT -D_DLL
# some functions that have disappeared in gtk+-1.3. I might
# get around to #ifdef'ing them out in our gtkclist.c.
OBJECTS=capture_dlg.obj \
+ capture_prefs.obj \
color_dlg.obj \
colors.obj \
color_utils.obj \
diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c
index 5a6eb0429a..c96ccb1f75 100644
--- a/gtk/capture_dlg.c
+++ b/gtk/capture_dlg.c
@@ -1,7 +1,7 @@
/* capture_dlg.c
* Routines for packet capture windows
*
- * $Id: capture_dlg.c,v 1.52 2001/12/09 03:20:19 guy Exp $
+ * $Id: capture_dlg.c,v 1.53 2002/01/10 07:43:39 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -211,9 +211,15 @@ capture_prep_cb(GtkWidget *w, gpointer d)
if_cb = gtk_combo_new();
if (if_list != NULL)
gtk_combo_set_popdown_strings(GTK_COMBO(if_cb), if_list);
- if (cfile.iface)
+ if (cfile.iface == NULL && prefs.capture_device != NULL) {
+ /* No interface was specified on the command line or in a previous
+ capture, but there is one specified in the preferences file;
+ make the one from the preferences file the default */
+ cfile.iface = g_strdup(prefs.capture_device);
+ }
+ if (cfile.iface != NULL)
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), cfile.iface);
- else if (if_list)
+ else if (if_list != NULL)
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry), if_list->data);
gtk_table_attach_defaults(GTK_TABLE(table), if_cb, 1, 2, 0, 1);
gtk_widget_show(if_cb);
diff --git a/gtk/capture_prefs.c b/gtk/capture_prefs.c
new file mode 100644
index 0000000000..0039d2900e
--- /dev/null
+++ b/gtk/capture_prefs.c
@@ -0,0 +1,182 @@
+/* capture_prefs.c
+ * Dialog box for capture preferences
+ *
+ * $Id: capture_prefs.c,v 1.1 2002/01/10 07:43:39 guy Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_LIBPCAP
+
+#include <string.h>
+#include <errno.h>
+#include <gtk/gtk.h>
+
+#include <pcap.h>
+
+#include "globals.h"
+#include "capture_prefs.h"
+#include "gtkglobals.h"
+#include "prefs_dlg.h"
+#include "prefs.h"
+#include "prefs-int.h"
+#include "ui_util.h"
+#include "dlg_utils.h"
+#include "pcap-util.h"
+#if 0
+#include "proto_draw.h"
+#endif
+#include "main.h"
+
+static void create_option_check_button(GtkWidget *main_vb, const gchar *key,
+ GtkWidget *main_tb, int table_position, const gchar *label_text,
+ gboolean active);
+
+#define DEVICE_KEY "device"
+#define PROM_MODE_KEY "prom_mode"
+#define CAPTURE_REAL_TIME_KEY "capture_real_time"
+#define AUTO_SCROLL_KEY "capture_real_time"
+
+#define CAPTURE_TABLE_ROWS 4
+GtkWidget*
+capture_prefs_show(void)
+{
+ GtkWidget *main_tb, *main_vb;
+ GtkWidget *if_cb, *if_lb;
+ GtkWidget *promisc_cb, *sync_cb, *auto_scroll_cb;
+ GList *if_list;
+ int err;
+ char err_str[PCAP_ERRBUF_SIZE];
+
+ /* Main vertical box */
+ main_vb = gtk_vbox_new(FALSE, 7);
+ gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
+
+ /* Main table */
+ main_tb = gtk_table_new(CAPTURE_TABLE_ROWS, 3, FALSE);
+ gtk_box_pack_start(GTK_BOX(main_vb), main_tb, FALSE, FALSE, 0);
+ gtk_table_set_row_spacings(GTK_TABLE(main_tb), 10);
+ gtk_table_set_col_spacings(GTK_TABLE(main_tb), 15);
+ gtk_widget_show(main_tb);
+
+ /* Default device */
+ if_lb = gtk_label_new("Interface:");
+ gtk_table_attach_defaults(GTK_TABLE(main_tb), if_lb, 0, 1, 0, 1);
+ gtk_widget_show(if_lb);
+
+ if_cb = gtk_combo_new();
+ /*
+ * XXX - what if we can't get the list?
+ */
+ if_list = get_interface_list(&err, err_str);
+ if (if_list != NULL)
+ gtk_combo_set_popdown_strings(GTK_COMBO(if_cb), if_list);
+ if (prefs.capture_device)
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry),
+ prefs.capture_device);
+ gtk_table_attach_defaults(GTK_TABLE(main_tb), if_cb, 1, 2, 0, 1);
+ gtk_widget_show(if_cb);
+ gtk_object_set_data(GTK_OBJECT(main_vb), DEVICE_KEY, if_cb);
+
+ free_interface_list(if_list);
+
+ /* Promiscuous mode */
+ create_option_check_button(main_vb, PROM_MODE_KEY, main_tb, 1,
+ "Capture packets in promiscuous mode:", prefs.capture_prom_mode);
+
+ /* Real-time capture */
+ create_option_check_button(main_vb, CAPTURE_REAL_TIME_KEY, main_tb, 2,
+ "Update list of packets in real time", prefs.capture_real_time);
+
+ /* Auto-scroll real-time capture */
+ create_option_check_button(main_vb, CAPTURE_REAL_TIME_KEY, main_tb, 3,
+ "Automatic scrolling in live capture", prefs.capture_auto_scroll);
+
+ /* Show 'em what we got */
+ gtk_widget_show_all(main_vb);
+
+ return(main_vb);
+}
+
+static void
+create_option_check_button(GtkWidget *main_vb, const gchar *key,
+ GtkWidget *main_tb, int table_position, const gchar *label_text,
+ gboolean active)
+{
+ GtkWidget *hbox, *check_box;
+
+ hbox = gtk_hbox_new(FALSE, 0);
+ gtk_table_attach_defaults(GTK_TABLE(main_tb), hbox, 1, 3,
+ table_position, table_position + 1);
+
+ check_box = gtk_check_button_new_with_label(label_text);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_box), active);
+
+ gtk_box_pack_start( GTK_BOX(hbox), check_box, FALSE, FALSE, 0 );
+ gtk_object_set_data(GTK_OBJECT(main_vb), key, check_box);
+}
+
+void
+capture_prefs_fetch(GtkWidget *w)
+{
+ GtkWidget *if_cb, *promisc_cb, *sync_cb, *auto_scroll_cb;
+ gchar *if_text;
+ gchar *if_name;
+
+ if_cb = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(w), DEVICE_KEY);
+ promisc_cb = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(w),
+ PROM_MODE_KEY);
+ sync_cb = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(w),
+ CAPTURE_REAL_TIME_KEY);
+ auto_scroll_cb = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(w),
+ AUTO_SCROLL_KEY);
+
+ if (prefs.capture_device != NULL) {
+ g_free(prefs.capture_device);
+ prefs.capture_device = NULL;
+ }
+ if_text =
+ g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(if_cb)->entry)));
+ if_name = strtok(if_text, " \t");
+ if (if_name != NULL)
+ prefs.capture_device = g_strdup(if_name);
+ g_free(if_text);
+
+ prefs.capture_prom_mode = GTK_TOGGLE_BUTTON (promisc_cb)->active;
+
+ prefs.capture_real_time = GTK_TOGGLE_BUTTON (sync_cb)->active;
+
+ prefs.capture_auto_scroll = GTK_TOGGLE_BUTTON (auto_scroll_cb)->active;
+}
+
+void
+capture_prefs_apply(GtkWidget *w)
+{
+}
+
+void
+capture_prefs_destroy(GtkWidget *w)
+{
+}
+
+#endif /* HAVE_LIBPCAP */
diff --git a/gtk/capture_prefs.h b/gtk/capture_prefs.h
new file mode 100644
index 0000000000..ba52a851dc
--- /dev/null
+++ b/gtk/capture_prefs.h
@@ -0,0 +1,33 @@
+/* capture_prefs.h
+ * Definitions for capture preferences window
+ *
+ * $Id: capture_prefs.h,v 1.1 2002/01/10 07:43:39 guy Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __CAPTURE_PREFS_H__
+#define __CAPTURE_PREFS_H__
+
+GtkWidget *capture_prefs_show(void);
+void capture_prefs_fetch(GtkWidget *w);
+void capture_prefs_apply(GtkWidget *w);
+void capture_prefs_destroy(GtkWidget *w);
+
+#endif
diff --git a/gtk/gui_prefs.c b/gtk/gui_prefs.c
index 555acc8f15..ac34e11638 100644
--- a/gtk/gui_prefs.c
+++ b/gtk/gui_prefs.c
@@ -1,12 +1,11 @@
/* gui_prefs.c
* Dialog box for GUI preferences
*
- * $Id: gui_prefs.c,v 1.27 2001/12/31 04:41:50 gerald Exp $
+ * $Id: gui_prefs.c,v 1.28 2002/01/10 07:43:39 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
- *
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -261,8 +260,6 @@ create_option_check_button(GtkWidget *main_vb, const gchar *key,
gboolean active)
{
GtkWidget *hbox, *check_box;
- int menu_index, index;
- const enum_val_t *enum_valp;
hbox = gtk_hbox_new(FALSE, 0);
gtk_table_attach_defaults(GTK_TABLE(main_tb), hbox, 1, 3,
diff --git a/gtk/prefs_dlg.c b/gtk/prefs_dlg.c
index 093d7f7009..e6fefd3d98 100644
--- a/gtk/prefs_dlg.c
+++ b/gtk/prefs_dlg.c
@@ -1,7 +1,7 @@
/* prefs_dlg.c
* Routines for handling preferences
*
- * $Id: prefs_dlg.c,v 1.34 2001/12/04 07:23:47 guy Exp $
+ * $Id: prefs_dlg.c,v 1.35 2002/01/10 07:43:39 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -58,6 +58,7 @@
#include "print_prefs.h"
#include "stream_prefs.h"
#include "gui_prefs.h"
+#include "capture_prefs.h"
#include "ui_util.h"
#include "dlg_utils.h"
#include "simple_dialog.h"
@@ -72,10 +73,11 @@ static gboolean prefs_main_delete_cb(GtkWidget *, gpointer);
static void prefs_main_destroy_cb(GtkWidget *, gpointer);
static void prefs_tree_select_cb(GtkCTree *, GtkCTreeNode *, gint, gpointer);
-#define E_PRINT_PAGE_KEY "printer_options_page"
-#define E_COLUMN_PAGE_KEY "column_options_page"
-#define E_STREAM_PAGE_KEY "tcp_stream_options_page"
-#define E_GUI_PAGE_KEY "gui_options_page"
+#define E_PRINT_PAGE_KEY "printer_options_page"
+#define E_COLUMN_PAGE_KEY "column_options_page"
+#define E_STREAM_PAGE_KEY "tcp_stream_options_page"
+#define E_GUI_PAGE_KEY "gui_options_page"
+#define E_CAPTURE_PAGE_KEY "capture_options_page"
#define FIRST_PROTO_PREFS_PAGE 4
@@ -274,7 +276,7 @@ void
prefs_cb(GtkWidget *w, gpointer dummy) {
GtkWidget *main_vb, *top_hb, *bbox, *prefs_nb, *ct_sb, *frame,
*ok_bt, *apply_bt, *save_bt, *cancel_bt;
- GtkWidget *print_pg, *column_pg, *stream_pg, *gui_pg;
+ GtkWidget *print_pg, *column_pg, *stream_pg, *gui_pg, *capture_pg;
gchar label_str[MAX_TREE_NODE_NAME_LEN], *label_ptr = label_str;
GtkCTreeNode *ct_node;
struct ct_struct cts;
@@ -397,6 +399,21 @@ prefs_cb(GtkWidget *w, gpointer dummy) {
GINT_TO_POINTER(cts.page));
cts.page++;
+#ifdef HAVE_LIBPCAP
+ /* capture prefs */
+ frame = gtk_frame_new("Capture");
+ gtk_widget_show(GTK_WIDGET(frame));
+ capture_pg = capture_prefs_show();
+ gtk_container_add(GTK_CONTAINER(frame), capture_pg);
+ gtk_object_set_data(GTK_OBJECT(prefs_w), E_CAPTURE_PAGE_KEY, capture_pg);
+ gtk_notebook_append_page (GTK_NOTEBOOK(prefs_nb), frame, NULL);
+ strcpy(label_str, "Capture");
+ ct_node = gtk_ctree_insert_node(GTK_CTREE(cts.ctree), NULL, NULL,
+ &label_ptr, 5, NULL, NULL, NULL, NULL, TRUE, TRUE);
+ gtk_ctree_node_set_row_data(GTK_CTREE(cts.ctree), ct_node,
+ GINT_TO_POINTER(cts.page));
+ cts.page++;
+#endif
/* Registered prefs */
cts.notebook = prefs_nb;
@@ -603,6 +620,7 @@ prefs_main_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
column_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_COLUMN_PAGE_KEY));
stream_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_STREAM_PAGE_KEY));
gui_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
+ capture_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_CAPTURE_PAGE_KEY));
prefs_module_foreach(module_prefs_fetch, &must_redissect);
/* Now apply those preferences. */
@@ -610,6 +628,7 @@ prefs_main_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
column_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_COLUMN_PAGE_KEY));
stream_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_STREAM_PAGE_KEY));
gui_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
+ capture_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_CAPTURE_PAGE_KEY));
prefs_apply_all();
/* Now destroy the "Preferences" dialog. */
@@ -633,6 +652,7 @@ prefs_main_apply_cb(GtkWidget *apply_bt, gpointer parent_w)
column_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_COLUMN_PAGE_KEY));
stream_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_STREAM_PAGE_KEY));
gui_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
+ capture_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_CAPTURE_PAGE_KEY));
prefs_module_foreach(module_prefs_fetch, &must_redissect);
/* Now apply those preferences. */
@@ -640,6 +660,7 @@ prefs_main_apply_cb(GtkWidget *apply_bt, gpointer parent_w)
column_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_COLUMN_PAGE_KEY));
stream_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_STREAM_PAGE_KEY));
gui_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
+ capture_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_CAPTURE_PAGE_KEY));
prefs_apply_all();
if (must_redissect) {
@@ -663,6 +684,7 @@ prefs_main_save_cb(GtkWidget *save_bt, gpointer parent_w)
column_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_COLUMN_PAGE_KEY));
stream_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_STREAM_PAGE_KEY));
gui_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
+ capture_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_CAPTURE_PAGE_KEY));
prefs_module_foreach(module_prefs_fetch, &must_redissect);
/* Create the directory that holds personal configuration files, if
@@ -700,6 +722,7 @@ prefs_main_save_cb(GtkWidget *save_bt, gpointer parent_w)
column_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_COLUMN_PAGE_KEY));
stream_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_STREAM_PAGE_KEY));
gui_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
+ capture_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_CAPTURE_PAGE_KEY));
prefs_apply_all();
if (must_redissect) {
@@ -791,6 +814,7 @@ prefs_main_cancel_cb(GtkWidget *cancel_bt, gpointer parent_w)
column_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_COLUMN_PAGE_KEY));
stream_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_STREAM_PAGE_KEY));
gui_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
+ capture_prefs_apply(gtk_object_get_data(GTK_OBJECT(parent_w), E_CAPTURE_PAGE_KEY));
prefs_apply_all();
gtk_widget_destroy(GTK_WIDGET(parent_w));
@@ -820,6 +844,7 @@ prefs_main_destroy_cb(GtkWidget *win, gpointer user_data)
column_prefs_destroy(gtk_object_get_data(GTK_OBJECT(prefs_w), E_COLUMN_PAGE_KEY));
stream_prefs_destroy(gtk_object_get_data(GTK_OBJECT(prefs_w), E_STREAM_PAGE_KEY));
gui_prefs_destroy(gtk_object_get_data(GTK_OBJECT(prefs_w), E_GUI_PAGE_KEY));
+ capture_prefs_destroy(gtk_object_get_data(GTK_OBJECT(prefs_w), E_CAPTURE_PAGE_KEY));
/* Free up the saved preferences (both for "prefs" and for registered
preferences). */
diff --git a/prefs.c b/prefs.c
index d0cf745757..39fe66c2ae 100644
--- a/prefs.c
+++ b/prefs.c
@@ -1,7 +1,7 @@
/* prefs.c
* Routines for handling preferences
*
- * $Id: prefs.c,v 1.75 2001/12/31 04:41:48 gerald Exp $
+ * $Id: prefs.c,v 1.76 2002/01/10 07:43:37 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -801,6 +801,7 @@ read_prefs(int *gpf_errno_return, char **gpf_path_return,
prefs.gui_geometry_main_height = -1;
/* set the default values for the capture dialog box */
+ prefs.capture_device = NULL;
prefs.capture_prom_mode = TRUE;
prefs.capture_real_time = FALSE;
prefs.capture_auto_scroll = FALSE;
@@ -1073,8 +1074,9 @@ prefs_set_pref(char *prefarg)
#define PRS_CAP_NAME_RESOLVE "capture.name_resolve"
/* values for the capture dialog box */
-#define PRS_CAP_REAL_TIME "capture.real_time_update"
-#define PRS_CAP_PROM_MODE "capture.prom_mode"
+#define PRS_CAP_DEVICE "capture.device"
+#define PRS_CAP_PROM_MODE "capture.prom_mode"
+#define PRS_CAP_REAL_TIME "capture.real_time_update"
#define PRS_CAP_AUTO_SCROLL "capture.auto_scroll"
#define RED_COMPONENT(x) ((((x) >> 16) & 0xff) * 65535 / 255)
@@ -1322,12 +1324,14 @@ set_pref(gchar *pref_name, gchar *value)
prefs.gui_geometry_main_height = strtol(value, NULL, 10);
/* handle the capture options */
+ } else if (strcmp(pref_name, PRS_CAP_DEVICE) == 0) {
+ if (prefs.capture_device != NULL)
+ g_free(prefs.capture_device);
+ prefs.capture_device = g_strdup(value);
} else if (strcmp(pref_name, PRS_CAP_PROM_MODE) == 0) {
prefs.capture_prom_mode = ((strcasecmp(value, "true") == 0)?TRUE:FALSE);
-
} else if (strcmp(pref_name, PRS_CAP_REAL_TIME) == 0) {
prefs.capture_real_time = ((strcasecmp(value, "true") == 0)?TRUE:FALSE);
-
} else if (strcmp(pref_name, PRS_CAP_AUTO_SCROLL) == 0) {
prefs.capture_auto_scroll = ((strcasecmp(value, "true") == 0)?TRUE:FALSE);
@@ -1738,6 +1742,11 @@ write_prefs(const char **pf_path_return)
name_resolve_to_string(prefs.name_resolve));
/* write the capture options */
+ if (prefs.capture_device != NULL) {
+ fprintf(pf, "\n# Default capture device\n");
+ fprintf(pf, PRS_CAP_DEVICE ": %s\n", prefs.capture_device);
+ }
+
fprintf(pf, "\n# Capture in promiscuous mode? TRUE/FALSE\n");
fprintf(pf, PRS_CAP_PROM_MODE ": %s\n",
prefs.capture_prom_mode == TRUE ? "TRUE" : "FALSE");
@@ -1801,6 +1810,7 @@ copy_prefs(e_prefs *dest, e_prefs *src)
dest->gui_geometry_main_width = src->gui_geometry_main_width;
dest->gui_geometry_main_height = src->gui_geometry_main_height;
/* values for the capture dialog box */
+ dest->capture_device = g_strdup(src->capture_device);
dest->capture_prom_mode = src->capture_prom_mode;
dest->capture_real_time = src->capture_real_time;
dest->capture_auto_scroll = src->capture_auto_scroll;
@@ -1825,6 +1835,10 @@ free_prefs(e_prefs *pr)
g_free(pr->gui_font_name);
pr->gui_font_name = NULL;
}
+ if (pr->capture_device != NULL) {
+ g_free(pr->capture_device);
+ pr->capture_device = NULL;
+ }
}
static void
diff --git a/prefs.h b/prefs.h
index 3e283042e6..a6eccc3de6 100644
--- a/prefs.h
+++ b/prefs.h
@@ -1,7 +1,7 @@
/* prefs.h
* Definitions for preference handling routines
*
- * $Id: prefs.h,v 1.35 2001/12/31 04:41:48 gerald Exp $
+ * $Id: prefs.h,v 1.36 2002/01/10 07:43:37 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -77,6 +77,7 @@ typedef struct _e_prefs {
gint gui_geometry_main_width;
gint gui_geometry_main_height;
guint32 name_resolve;
+ gchar *capture_device;
gboolean capture_prom_mode;
gboolean capture_real_time;
gboolean capture_auto_scroll;
diff --git a/tethereal.c b/tethereal.c
index e17f5e0fa1..98f31bc5b1 100644
--- a/tethereal.c
+++ b/tethereal.c
@@ -1,6 +1,6 @@
/* tethereal.c
*
- * $Id: tethereal.c,v 1.113 2002/01/03 22:03:24 guy Exp $
+ * $Id: tethereal.c,v 1.114 2002/01/10 07:43:37 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -717,24 +717,30 @@ main(int argc, char *argv[])
/* Yes; did the user specify an interface to use? */
if (cfile.iface == NULL) {
- /* No - pick the first one from the list of interfaces. */
- if_list = get_interface_list(&err, err_str);
- if (if_list == NULL) {
- switch (err) {
-
- case CANT_GET_INTERFACE_LIST:
- fprintf(stderr, "tethereal: Can't get list of interfaces: %s\n",
- err_str);
- break;
-
- case NO_INTERFACES_FOUND:
- fprintf(stderr, "tethereal: There are no interfaces on which a capture can be done\n");
- break;
+ /* No - is a default specified in the preferences file? */
+ if (prefs->capture_device != NULL) {
+ /* Yes - use it. */
+ cfile.iface = g_strdup(prefs->capture_device);
+ } else {
+ /* No - pick the first one from the list of interfaces. */
+ if_list = get_interface_list(&err, err_str);
+ if (if_list == NULL) {
+ switch (err) {
+
+ case CANT_GET_INTERFACE_LIST:
+ fprintf(stderr, "tethereal: Can't get list of interfaces: %s\n",
+ err_str);
+ break;
+
+ case NO_INTERFACES_FOUND:
+ fprintf(stderr, "tethereal: There are no interfaces on which a capture can be done\n");
+ break;
+ }
+ exit(2);
}
- exit(2);
+ cfile.iface = g_strdup(if_list->data); /* first interface */
+ free_interface_list(if_list);
}
- cfile.iface = g_strdup(if_list->data); /* first interface */
- free_interface_list(if_list);
}
capture(packet_count, out_file_type);