Added the ethereal capture preferences to the preference file.

svn path=/trunk/; revision=3298
This commit is contained in:
Jeff Foster 2001-04-13 14:59:30 +00:00
parent b6bd7af57a
commit 78ce39994c
8 changed files with 87 additions and 34 deletions

View File

@ -1,7 +1,7 @@
/* capture.c
* Routines for packet capture windows
*
* $Id: capture.c,v 1.147 2001/04/11 05:24:08 guy Exp $
* $Id: capture.c,v 1.148 2001/04/13 14:59:28 jfoster Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -160,8 +160,6 @@
#include "packet-ieee80211.h"
#include "packet-chdlc.h"
int promisc_mode = TRUE; /* capture in promiscuous mode */
int sync_mode; /* fork a child to do the capture, and sync between them */
static int sync_pipe[2]; /* used to sync father */
enum PIPES { READ, WRITE }; /* Constants 0 and 1 for READ and WRITE */
int quit_after_cap; /* Makes a "capture only mode". Implies -k */
@ -305,7 +303,7 @@ do_capture(char *capfile_name)
g_assert(cfile.save_file == NULL);
cfile.save_file = capfile_name;
if (sync_mode) { /* do the capture in a child process */
if (prefs.capture_auto_scroll) { /* do the capture in a child process */
char ssnap[24];
char scount[24]; /* need a constant for len of numbers */
char save_file_fd[24];
@ -346,7 +344,7 @@ do_capture(char *capfile_name)
sprintf(ssnap,"%d",cfile.snap);
argv = add_arg(argv, &argc, ssnap);
if (!promisc_mode)
if (!prefs.capture_prom_mode)
argv = add_arg(argv, &argc, "-p");
#ifdef _WIN32
@ -1283,7 +1281,7 @@ capture(gboolean *stats_known, struct pcap_stat *stats)
*stats_known = FALSE;
/* Open the network interface to capture from it. */
pch = pcap_open_live(cfile.iface, cfile.snap, promisc_mode,
pch = pcap_open_live(cfile.iface, cfile.snap, prefs.capture_prom_mode,
CAP_READ_TIMEOUT, err_str);
if (pch == NULL) {

View File

@ -1,7 +1,7 @@
/* capture.h
* Definitions for packet capture windows
*
* $Id: capture.h,v 1.25 2001/02/11 09:28:15 guy Exp $
* $Id: capture.h,v 1.26 2001/04/13 14:59:28 jfoster Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -31,8 +31,6 @@
/* Name we give to the child process when doing a "-S" capture. */
#define CHILD_NAME "ethereal-capture"
extern int promisc_mode; /* capture in promiscuous mode */
extern int sync_mode; /* fork a child to do the capture, and sync between them */
extern int sync_pipe[2]; /* used to sync father */
extern int quit_after_cap; /* Makes a "capture only mode". Implies -k */
extern gboolean capture_child; /* if this is the child for "-S" */

View File

@ -1,7 +1,7 @@
/* capture_dlg.c
* Routines for packet capture windows
*
* $Id: capture_dlg.c,v 1.39 2001/04/05 05:58:05 gram Exp $
* $Id: capture_dlg.c,v 1.40 2001/04/13 14:59:30 jfoster Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -57,6 +57,7 @@
#include "simple_dialog.h"
#include "dlg_utils.h"
#include "util.h"
#include "prefs.h"
#ifdef _WIN32
#include "capture-wpcap.h"
@ -259,25 +260,25 @@ capture_prep_cb(GtkWidget *w, gpointer d)
promisc_cb = dlg_check_button_new_with_label_with_mnemonic(
"Capture packets in _promiscuous mode", accel_group);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(promisc_cb), promisc_mode);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(promisc_cb), prefs.capture_prom_mode);
gtk_container_add(GTK_CONTAINER(main_vb), promisc_cb);
gtk_widget_show(promisc_cb);
sync_cb = dlg_check_button_new_with_label_with_mnemonic(
"_Update list of packets in real time", accel_group);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(sync_cb), sync_mode);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(sync_cb), prefs.capture_real_time);
gtk_container_add(GTK_CONTAINER(main_vb), sync_cb);
gtk_widget_show(sync_cb);
auto_scroll_cb = dlg_check_button_new_with_label_with_mnemonic(
"_Automatic scrolling in live capture", accel_group);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(auto_scroll_cb), auto_scroll_live);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(auto_scroll_cb), prefs.capture_auto_scroll);
gtk_container_add(GTK_CONTAINER(main_vb), auto_scroll_cb);
gtk_widget_show(auto_scroll_cb);
resolv_cb = dlg_check_button_new_with_label_with_mnemonic(
"Enable _name resolution", accel_group);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(resolv_cb), g_resolving_actif);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(resolv_cb), prefs.capture_name_resolve);
gtk_container_add(GTK_CONTAINER(main_vb), resolv_cb);
gtk_widget_show(resolv_cb);
@ -495,13 +496,13 @@ capture_prep_ok_cb(GtkWidget *ok_bt, gpointer parent_w) {
else if (cfile.snap < MIN_PACKET_SIZE)
cfile.snap = MIN_PACKET_SIZE;
promisc_mode = GTK_TOGGLE_BUTTON (promisc_cb)->active;
prefs.capture_prom_mode = GTK_TOGGLE_BUTTON (promisc_cb)->active;
sync_mode = GTK_TOGGLE_BUTTON (sync_cb)->active;
prefs.capture_real_time = GTK_TOGGLE_BUTTON (sync_cb)->active;
auto_scroll_live = GTK_TOGGLE_BUTTON (auto_scroll_cb)->active;
prefs.capture_auto_scroll = GTK_TOGGLE_BUTTON (auto_scroll_cb)->active;
g_resolving_actif = GTK_TOGGLE_BUTTON (resolv_cb)->active;
prefs.capture_name_resolve = GTK_TOGGLE_BUTTON (resolv_cb)->active;
gtk_widget_destroy(GTK_WIDGET(parent_w));

View File

@ -1,7 +1,7 @@
/* display_opts.c
* Routines for packet display windows
*
* $Id: display_opts.c,v 1.18 2000/11/01 08:31:35 guy Exp $
* $Id: display_opts.c,v 1.19 2001/04/13 14:59:30 jfoster Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -60,6 +60,7 @@
#include "display_opts.h"
#include "ui_util.h"
#include "dlg_utils.h"
#include "prefs.h"
extern capture_file cfile;
extern GtkWidget *packet_list;
@ -170,7 +171,7 @@ display_opt_cb(GtkWidget *w, gpointer d) {
button = dlg_check_button_new_with_label_with_mnemonic(
"_Automatic scrolling in live capture", accel_group);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), auto_scroll_live);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), prefs.capture_auto_scroll);
gtk_object_set_data(GTK_OBJECT(display_opt_w), E_DISPLAY_AUTO_SCROLL_KEY,
button);
gtk_box_pack_start(GTK_BOX(main_vb), button, TRUE, TRUE, 0);
@ -178,7 +179,7 @@ display_opt_cb(GtkWidget *w, gpointer d) {
button = dlg_check_button_new_with_label_with_mnemonic(
"Enable _name resolution", accel_group);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), g_resolving_actif);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), prefs.capture_name_resolve);
gtk_object_set_data(GTK_OBJECT(display_opt_w), E_DISPLAY_NAME_RESOLUTION_KEY,
button);
gtk_box_pack_start(GTK_BOX(main_vb), button, TRUE, TRUE, 0);
@ -264,11 +265,11 @@ get_display_options(GtkWidget *parent_w)
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
E_DISPLAY_AUTO_SCROLL_KEY);
auto_scroll_live = (GTK_TOGGLE_BUTTON (button)->active);
prefs.capture_auto_scroll = (GTK_TOGGLE_BUTTON (button)->active);
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
E_DISPLAY_NAME_RESOLUTION_KEY);
g_resolving_actif = (GTK_TOGGLE_BUTTON (button)->active);
prefs.capture_name_resolve = (GTK_TOGGLE_BUTTON (button)->active);
}

View File

@ -1,6 +1,6 @@
/* main.c
*
* $Id: main.c,v 1.191 2001/04/10 12:07:39 gram Exp $
* $Id: main.c,v 1.192 2001/04/13 14:59:30 jfoster Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -136,6 +136,7 @@
#include "colors.h"
#include "strutil.h"
#include "register.h"
#include "prefs.h"
#ifdef WIN32
#include "capture-wpcap.h"
@ -519,11 +520,11 @@ void expand_all_cb(GtkWidget *widget, gpointer data) {
void resolve_name_cb(GtkWidget *widget, gpointer data) {
if (cfile.protocol_tree) {
int tmp = g_resolving_actif;
g_resolving_actif = 1;
int tmp = prefs.capture_name_resolve;
prefs.capture_name_resolve = 1;
gtk_clist_clear ( GTK_CLIST(tree_view) );
proto_tree_draw(cfile.protocol_tree, tree_view);
g_resolving_actif = tmp;
prefs.capture_name_resolve = tmp;
}
}
@ -987,7 +988,7 @@ main(int argc, char *argv[])
prefs->gui_font_name = g_strdup(optarg);
break;
case 'n': /* No name resolution */
g_resolving_actif = 0;
prefs->capture_name_resolve = 0;
break;
case 'o': /* Override preference from command line */
switch (prefs_set_pref(optarg)) {
@ -1006,7 +1007,7 @@ main(int argc, char *argv[])
break;
case 'p': /* Don't capture in promiscuous mode */
#ifdef HAVE_LIBPCAP
promisc_mode = 0;
prefs->capture_prom_mode = 0;
#else
capture_option_specified = TRUE;
arg_error = TRUE;
@ -1043,7 +1044,7 @@ main(int argc, char *argv[])
break;
case 'S': /* "Sync" mode: used for following file ala tail -f */
#ifdef HAVE_LIBPCAP
sync_mode = TRUE;
prefs->capture_auto_scroll = TRUE;
#else
capture_option_specified = TRUE;
arg_error = TRUE;

View File

@ -1,7 +1,7 @@
/* menu.c
* Menu routines
*
* $Id: menu.c,v 1.50 2001/03/22 23:54:47 gram Exp $
* $Id: menu.c,v 1.51 2001/04/13 14:59:30 jfoster Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -400,7 +400,7 @@ set_menus_for_selected_packet(gboolean have_selected_packet)
set_menu_sensitivity("/Tools/Decode As...",
have_selected_packet && decode_as_ok());
set_menu_sensitivity("/Resolve Name",
have_selected_packet && !g_resolving_actif);
have_selected_packet && !prefs.capture_name_resolve);
}
/* Enable or disable menu items based on whether a tree row is selected. */

51
prefs.c
View File

@ -1,7 +1,7 @@
/* prefs.c
* Routines for handling preferences
*
* $Id: prefs.c,v 1.48 2001/04/02 09:53:42 guy Exp $
* $Id: prefs.c,v 1.49 2001/04/13 14:59:28 jfoster Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -611,6 +611,12 @@ read_prefs(int *gpf_errno_return, char **gpf_path_return,
prefs.gui_marked_bg.green = 0;
prefs.gui_marked_bg.blue = 0;
/* set the default values for the capture dialog box */
prefs.capture_prom_mode = 0;
prefs.capture_real_time = 0;
prefs.capture_auto_scroll = 0;
prefs.capture_name_resolve= 1;
}
/* Read the global preferences file, if it exists. */
@ -845,6 +851,12 @@ prefs_set_pref(char *prefarg)
#define PRS_GUI_MARKED_FG "gui.marked_frame.fg"
#define PRS_GUI_MARKED_BG "gui.marked_frame.bg"
/* 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_AUTO_SCROLL "capture.auto_scroll"
#define PRS_CAP_NAME_RESOLVE "capture.name_resolve"
#define RED_COMPONENT(x) ((((x) >> 16) & 0xff) * 65535 / 255)
#define GREEN_COMPONENT(x) ((((x) >> 8) & 0xff) * 65535 / 255)
#define BLUE_COMPONENT(x) (((x) & 0xff) * 65535 / 255)
@ -977,6 +989,20 @@ set_pref(gchar *pref_name, gchar *value)
prefs.gui_marked_bg.red = RED_COMPONENT(cval);
prefs.gui_marked_bg.green = GREEN_COMPONENT(cval);
prefs.gui_marked_bg.blue = BLUE_COMPONENT(cval);
/* handle the capture options */
} else if (strcmp(pref_name, PRS_CAP_PROM_MODE) == 0) {
prefs.capture_prom_mode = ((strcmp(value, "TRUE") == 0)?TRUE:FALSE);
} else if (strcmp(pref_name, PRS_CAP_REAL_TIME) == 0) {
prefs.capture_real_time = ((strcmp(value, "TRUE") == 0)?TRUE:FALSE);
} else if (strcmp(pref_name, PRS_CAP_AUTO_SCROLL) == 0) {
prefs.capture_auto_scroll = ((strcmp(value, "TRUE") == 0)?TRUE:FALSE);
} else if (strcmp(pref_name, PRS_CAP_NAME_RESOLVE) == 0) {
prefs.capture_name_resolve = ((strcmp(value, "TRUE") == 0)?TRUE:FALSE);
} else {
/* To which module does this preference belong? */
dotp = strchr(pref_name, '.');
@ -1301,6 +1327,23 @@ write_prefs(char **pf_path_return)
(prefs.gui_marked_bg.green * 255 / 65535),
(prefs.gui_marked_bg.blue * 255 / 65535));
/* write the capture options */
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");
fprintf(pf, "\n# Update packet list in real time during capture? TRUE/FALSE\n");
fprintf(pf, PRS_CAP_REAL_TIME ": %s\n",
prefs.capture_real_time == TRUE ? "TRUE" : "FALSE");
fprintf(pf, "\n# scroll packet list during capture? TRUE/FALSE\n");
fprintf(pf, PRS_CAP_AUTO_SCROLL ": %s\n",
prefs.capture_auto_scroll == TRUE ? "TRUE" : "FALSE");
fprintf(pf, "\n# resolve names during capture? TRUE/FALSE\n");
fprintf(pf, PRS_CAP_NAME_RESOLVE ": %s\n",
prefs.capture_name_resolve == TRUE ? "TRUE" : "FALSE");
g_list_foreach(modules, write_module_prefs, pf);
fclose(pf);
@ -1345,6 +1388,12 @@ copy_prefs(e_prefs *dest, e_prefs *src)
dest->gui_font_name = g_strdup(src->gui_font_name);
dest->gui_marked_fg = src->gui_marked_fg;
dest->gui_marked_bg = src->gui_marked_bg;
/* values for the capture dialog box */
dest->capture_prom_mode = src->capture_prom_mode;
dest->capture_real_time = src->capture_real_time;
dest->capture_auto_scroll = src->capture_auto_scroll;
dest->capture_name_resolve = src->capture_name_resolve;
}
/* Free a set of preferences. */

View File

@ -1,7 +1,7 @@
/* prefs.h
* Definitions for preference handling routines
*
* $Id: prefs.h,v 1.27 2001/01/03 07:53:44 guy Exp $
* $Id: prefs.h,v 1.28 2001/04/13 14:59:28 jfoster Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -50,6 +50,11 @@ typedef struct _e_prefs {
gchar *gui_font_name;
color_t gui_marked_fg;
color_t gui_marked_bg;
gboolean capture_prom_mode;
gboolean capture_real_time;
gboolean capture_auto_scroll;
gboolean capture_name_resolve;
} e_prefs;
extern e_prefs prefs;