aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--capture.c10
-rw-r--r--capture.h4
-rw-r--r--file.c10
-rw-r--r--globals.h5
-rw-r--r--gtk/capture_dlg.c18
-rw-r--r--gtk/display_opts.c22
-rw-r--r--gtk/main.c34
7 files changed, 68 insertions, 35 deletions
diff --git a/capture.c b/capture.c
index 46c626b924..c90f451bff 100644
--- a/capture.c
+++ b/capture.c
@@ -1,7 +1,7 @@
/* capture.c
* Routines for packet capture windows
*
- * $Id: capture.c,v 1.166 2002/01/08 09:32:14 guy Exp $
+ * $Id: capture.c,v 1.167 2002/01/10 11:05:48 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -169,6 +169,8 @@
#include "capture-wpcap.h"
#endif
+int promisc_mode; /* 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 */
@@ -321,7 +323,7 @@ do_capture(char *capfile_name)
g_assert(cfile.save_file == NULL);
cfile.save_file = capfile_name;
- if (prefs.capture_real_time) { /* do the capture in a child process */
+ if (sync_mode) { /* do the capture in a child process */
char ssnap[24];
char scount[24]; /* need a constant for len of numbers */
char sautostop_filesize[24]; /* need a constant for len of numbers */
@@ -372,7 +374,7 @@ do_capture(char *capfile_name)
sprintf(sautostop_duration,"duration:%d",cfile.autostop_duration);
argv = add_arg(argv, &argc, sautostop_duration);
- if (!prefs.capture_prom_mode)
+ if (!promisc_mode)
argv = add_arg(argv, &argc, "-p");
#ifdef _WIN32
@@ -1343,7 +1345,7 @@ capture(gboolean *stats_known, struct pcap_stat *stats)
if they succeed; to tell if that's happened, we have to clear
the error buffer, and check if it's still a null string. */
open_err_str[0] = '\0';
- pch = pcap_open_live(cfile.iface, cfile.snap, prefs.capture_prom_mode,
+ pch = pcap_open_live(cfile.iface, cfile.snap, promisc_mode,
CAP_READ_TIMEOUT, open_err_str);
if (pch == NULL) {
diff --git a/capture.h b/capture.h
index b160ff7d10..9b001ae0e1 100644
--- a/capture.h
+++ b/capture.h
@@ -1,7 +1,7 @@
/* capture.h
* Definitions for packet capture windows
*
- * $Id: capture.h,v 1.27 2002/01/08 09:32:14 guy Exp $
+ * $Id: capture.h,v 1.28 2002/01/10 11:05:48 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -31,6 +31,8 @@
/* 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" */
diff --git a/file.c b/file.c
index 284ba530db..e7b858815a 100644
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.257 2002/01/05 04:12:14 gram Exp $
+ * $Id: file.c,v 1.258 2002/01/10 11:05:48 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -96,6 +96,10 @@
extern GtkWidget *packet_list, *byte_nb_ptr, *tree_view;
+#ifdef HAVE_LIBPCAP
+gboolean auto_scroll_live;
+#endif
+
static guint32 firstsec, firstusec;
static guint32 prevsec, prevusec;
@@ -502,7 +506,7 @@ continue_tail_cap_file(capture_file *cf, int to_read, int *err)
/* XXX - this cheats and looks inside the packet list to find the final
row number. */
- if (prefs.capture_auto_scroll && cf->plist_end != NULL)
+ if (auto_scroll_live && cf->plist_end != NULL)
gtk_clist_moveto(GTK_CLIST(packet_list),
GTK_CLIST(packet_list)->rows - 1, -1, 1.0, 1.0);
@@ -549,7 +553,7 @@ finish_tail_cap_file(capture_file *cf, int *err)
}
thaw_clist(cf);
- if (prefs.capture_auto_scroll && cf->plist_end != NULL)
+ if (auto_scroll_live && cf->plist_end != NULL)
/* XXX - this cheats and looks inside the packet list to find the final
row number. */
gtk_clist_moveto(GTK_CLIST(packet_list),
diff --git a/globals.h b/globals.h
index 5bb3dd4ba9..94b37fd91f 100644
--- a/globals.h
+++ b/globals.h
@@ -1,7 +1,7 @@
/* globals.h
* Global defines, etc.
*
- * $Id: globals.h,v 1.26 2001/06/05 07:38:33 guy Exp $
+ * $Id: globals.h,v 1.27 2002/01/10 11:05:48 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -34,6 +34,9 @@
extern capture_file cfile;
extern gchar *ethereal_path;
extern gchar *last_open_dir;
+#ifdef HAVE_LIBPCAP
+extern gboolean auto_scroll_live;
+#endif
extern field_info *finfo_selected;
extern ts_type timestamp_type;
diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c
index c96ccb1f75..bad40af210 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.53 2002/01/10 07:43:39 guy Exp $
+ * $Id: capture_dlg.c,v 1.54 2002/01/10 11:05:50 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -333,7 +333,7 @@ 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), prefs.capture_prom_mode);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(promisc_cb), promisc_mode);
gtk_container_add(GTK_CONTAINER(main_vb), promisc_cb);
gtk_widget_show(promisc_cb);
@@ -347,7 +347,7 @@ capture_prep_cb(GtkWidget *w, gpointer d)
/* Ring buffer mode is allowed only if we're not doing an "Update list of
packets in real time" capture, so force it off if we're doing such
a capture. */
- if (prefs.capture_real_time)
+ if (sync_mode)
cfile.ringbuffer_on = FALSE;
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(ringbuffer_on_tb),cfile.ringbuffer_on);
gtk_signal_connect(GTK_OBJECT(ringbuffer_on_tb), "toggled",
@@ -371,7 +371,7 @@ capture_prep_cb(GtkWidget *w, gpointer d)
/* Misc row: Capture file checkboxes */
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), prefs.capture_real_time);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(sync_cb), sync_mode);
gtk_signal_connect(GTK_OBJECT(sync_cb), "toggled",
GTK_SIGNAL_FUNC(capture_prep_adjust_sensitivity), GTK_OBJECT(cap_open_w));
gtk_container_add(GTK_CONTAINER(main_vb), sync_cb);
@@ -379,7 +379,7 @@ capture_prep_cb(GtkWidget *w, gpointer d)
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), prefs.capture_auto_scroll);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(auto_scroll_cb), auto_scroll_live);
gtk_container_add(GTK_CONTAINER(main_vb), auto_scroll_cb);
gtk_widget_show(auto_scroll_cb);
@@ -682,18 +682,18 @@ capture_prep_ok_cb(GtkWidget *ok_bt, gpointer parent_w) {
else if (cfile.snap < MIN_PACKET_SIZE)
cfile.snap = MIN_PACKET_SIZE;
- prefs.capture_prom_mode = GTK_TOGGLE_BUTTON (promisc_cb)->active;
+ promisc_mode = GTK_TOGGLE_BUTTON (promisc_cb)->active;
- prefs.capture_real_time = GTK_TOGGLE_BUTTON (sync_cb)->active;
+ sync_mode = GTK_TOGGLE_BUTTON (sync_cb)->active;
- prefs.capture_auto_scroll = GTK_TOGGLE_BUTTON (auto_scroll_cb)->active;
+ auto_scroll_live = GTK_TOGGLE_BUTTON (auto_scroll_cb)->active;
prefs.name_resolve = PREFS_RESOLV_NONE;
prefs.name_resolve |= (GTK_TOGGLE_BUTTON (m_resolv_cb)->active ? PREFS_RESOLV_MAC : PREFS_RESOLV_NONE);
prefs.name_resolve |= (GTK_TOGGLE_BUTTON (n_resolv_cb)->active ? PREFS_RESOLV_NETWORK : PREFS_RESOLV_NONE);
prefs.name_resolve |= (GTK_TOGGLE_BUTTON (t_resolv_cb)->active ? PREFS_RESOLV_TRANSPORT : PREFS_RESOLV_NONE);
- cfile.ringbuffer_on = GTK_TOGGLE_BUTTON (ringbuffer_on_tb)->active && !(prefs.capture_real_time);
+ cfile.ringbuffer_on = GTK_TOGGLE_BUTTON (ringbuffer_on_tb)->active && !(sync_mode);
if (cfile.ringbuffer_on == TRUE) {
if (save_file == NULL) {
simple_dialog(ESD_TYPE_CRIT, NULL,
diff --git a/gtk/display_opts.c b/gtk/display_opts.c
index 0903691f35..126c11109a 100644
--- a/gtk/display_opts.c
+++ b/gtk/display_opts.c
@@ -1,7 +1,7 @@
/* display_opts.c
* Routines for packet display windows
*
- * $Id: display_opts.c,v 1.22 2001/06/18 06:18:03 guy Exp $
+ * $Id: display_opts.c,v 1.23 2002/01/10 11:05:50 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -64,11 +64,13 @@
extern capture_file cfile;
/* Display callback data keys */
-#define E_DISPLAY_TIME_ABS_KEY "display_time_abs"
-#define E_DISPLAY_DATE_TIME_ABS_KEY "display_date_time_abs"
-#define E_DISPLAY_TIME_REL_KEY "display_time_rel"
-#define E_DISPLAY_TIME_DELTA_KEY "display_time_delta"
-#define E_DISPLAY_AUTO_SCROLL_KEY "display_auto_scroll"
+#define E_DISPLAY_TIME_ABS_KEY "display_time_abs"
+#define E_DISPLAY_DATE_TIME_ABS_KEY "display_date_time_abs"
+#define E_DISPLAY_TIME_REL_KEY "display_time_rel"
+#define E_DISPLAY_TIME_DELTA_KEY "display_time_delta"
+#ifdef HAVE_LIBPCAP
+#define E_DISPLAY_AUTO_SCROLL_KEY "display_auto_scroll"
+#endif
#define E_DISPLAY_M_NAME_RESOLUTION_KEY "display_mac_name_resolution"
#define E_DISPLAY_N_NAME_RESOLUTION_KEY "display_network_name_resolution"
#define E_DISPLAY_T_NAME_RESOLUTION_KEY "display_transport_name_resolution"
@@ -169,13 +171,15 @@ display_opt_cb(GtkWidget *w, gpointer d) {
gtk_box_pack_start(GTK_BOX(main_vb), button, TRUE, TRUE, 0);
gtk_widget_show(button);
+#ifdef HAVE_LIBPCAP
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), prefs.capture_auto_scroll);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), auto_scroll_live);
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);
gtk_widget_show(button);
+#endif
button = dlg_check_button_new_with_label_with_mnemonic(
"Enable _MAC name resolution", accel_group);
@@ -282,9 +286,11 @@ get_display_options(GtkWidget *parent_w)
if (GTK_TOGGLE_BUTTON (button)->active)
timestamp_type = DELTA;
+#ifdef HAVE_LIBPCAP
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
E_DISPLAY_AUTO_SCROLL_KEY);
- prefs.capture_auto_scroll = (GTK_TOGGLE_BUTTON (button)->active);
+ auto_scroll_live = (GTK_TOGGLE_BUTTON (button)->active);
+#endif
prefs.name_resolve = PREFS_RESOLV_NONE;
button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w),
diff --git a/gtk/main.c b/gtk/main.c
index ca945e0ec9..ab84ed7485 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1,6 +1,6 @@
/* main.c
*
- * $Id: main.c,v 1.224 2002/01/10 09:51:23 guy Exp $
+ * $Id: main.c,v 1.225 2002/01/10 11:05:50 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1062,9 +1062,20 @@ main(int argc, char *argv[])
to the "prefs.capture_prom_mode" setting in the preferences file;
it should do what the parent process tells it to do, and if
the parent process wants it not to run in promiscuous mode, it'll
- tell it so with a "-p" flag. */
+ tell it so with a "-p" flag.
+
+ Otherwise, set promiscuous mode from the preferences setting. */
if (capture_child)
- prefs->capture_prom_mode = TRUE;
+ promisc_mode = TRUE;
+ else
+ promisc_mode = prefs->capture_prom_mode;
+
+ /* Set "Update list of packets in real time" mode from the preferences
+ setting. */
+ sync_mode = prefs->capture_real_time;
+
+ /* And do the same for "Automatic scrolling in live capture" mode. */
+ auto_scroll_live = prefs->capture_auto_scroll;
#endif
/* Read the capture filter file. */
@@ -1226,7 +1237,12 @@ main(int argc, char *argv[])
#endif
break;
case 'l': /* Automatic scrolling in live capture mode */
- prefs->capture_auto_scroll = TRUE;
+#ifdef HAVE_LIBPCAP
+ auto_scroll_live = TRUE;
+#else
+ capture_option_specified = TRUE;
+ arg_error = TRUE;
+#endif
break;
case 'm': /* Fixed-width font for the display */
if (prefs->gui_font_name != NULL)
@@ -1264,7 +1280,7 @@ main(int argc, char *argv[])
break;
case 'p': /* Don't capture in promiscuous mode */
#ifdef HAVE_LIBPCAP
- prefs->capture_prom_mode = FALSE;
+ promisc_mode = FALSE;
#else
capture_option_specified = TRUE;
arg_error = TRUE;
@@ -1301,7 +1317,7 @@ main(int argc, char *argv[])
break;
case 'S': /* "Sync" mode: used for following file ala tail -f */
#ifdef HAVE_LIBPCAP
- prefs->capture_real_time = TRUE;
+ sync_mode = TRUE;
#else
capture_option_specified = TRUE;
arg_error = TRUE;
@@ -1411,15 +1427,15 @@ main(int argc, char *argv[])
if (cfile.ringbuffer_on) {
/* Ring buffer works only under certain conditions:
a) ring buffer does not work with temporary files;
- b) prefs->capture_real_time and cfile.ringbuffer_on are mutually
- exclusive - prefs->capture_real_time takes precedence;
+ b) sync_mode and cfile.ringbuffer_on are mutually exclusive -
+ sync_mode takes precedence;
c) it makes no sense to enable the ring buffer if the maximum
file size is set to "infinite". */
if (cfile.save_file == NULL) {
fprintf(stderr, "ethereal: Ring buffer requested, but capture isn't being saved to a permanent file.\n");
cfile.ringbuffer_on = FALSE;
}
- if (prefs->capture_real_time == TRUE) {
+ if (sync_mode) {
fprintf(stderr, "ethereal: Ring buffer requested, but an \"Update list of packets in real time\" capture is being done.\n");
cfile.ringbuffer_on = FALSE;
}