aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-10-11 06:01:16 +0000
committerGuy Harris <guy@alum.mit.edu>2000-10-11 06:01:16 +0000
commit54ecbe2d4e4d1eaf2d1e8ae0789d4378f3b9c874 (patch)
treecdb2790de7fc524542dbc3de9c99430d6296ce46
parent788a6283ffcabd89391817ff3d436a1965203d6b (diff)
downloadwireshark-54ecbe2d4e4d1eaf2d1e8ae0789d4378f3b9c874.tar.gz
wireshark-54ecbe2d4e4d1eaf2d1e8ae0789d4378f3b9c874.tar.bz2
wireshark-54ecbe2d4e4d1eaf2d1e8ae0789d4378f3b9c874.zip
Santeri Paavolainen's patch to add a "Capture->Stop" menu item to let
you stop an "Update list of packets in real time" capture from the main window as well as from the capture statistics dialog. svn path=/trunk/; revision=2487
-rw-r--r--AUTHORS4
-rw-r--r--capture.c36
-rw-r--r--capture.h5
-rw-r--r--doc/ethereal.pod.template7
-rw-r--r--gtk/capture_dlg.c8
-rw-r--r--gtk/capture_dlg.h3
-rw-r--r--gtk/menu.c16
7 files changed, 72 insertions, 7 deletions
diff --git a/AUTHORS b/AUTHORS
index 3b82fd9351..7708b30129 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -401,6 +401,10 @@ Brian Wellington <bwelling@xbill.org> {
Partial support for DNS-over-TCP
}
+Santeri Paavolainen <santtu@ssh.com> {
+ "Capture->Stop" menu bar item
+}
+
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to
give his permission to use his version of snprintf.c.
diff --git a/capture.c b/capture.c
index cd225918d5..fa158cc57e 100644
--- a/capture.c
+++ b/capture.c
@@ -1,7 +1,7 @@
/* capture.c
* Routines for packet capture windows
*
- * $Id: capture.c,v 1.128 2000/10/08 17:16:29 gerald Exp $
+ * $Id: capture.c,v 1.129 2000/10/11 06:01:14 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -126,6 +126,7 @@ static void capture_pcap_cb(u_char *, const struct pcap_pkthdr *,
const u_char *);
static void send_errmsg_to_parent(const char *);
static float pct(gint, gint);
+static void stop_capture(int signo);
typedef struct _loop_data {
gint go;
@@ -1012,6 +1013,12 @@ pipe_dispatch(int fd, loop_data *ld, struct pcap_hdr *hdr)
}
#endif
+/*
+ * This needs to be static, so that the SIGUSR1 handler can clear the "go"
+ * flag.
+ */
+static loop_data ld;
+
/* Do the low-level work of a capture.
Returns TRUE if it succeeds, FALSE otherwise. */
int
@@ -1023,7 +1030,6 @@ capture(void)
int pcap_encap;
int snaplen;
gchar err_str[PCAP_ERRBUF_SIZE], label_str[64];
- loop_data ld;
bpf_u_int32 netnum, netmask;
time_t upd_time, cur_time;
int err, inpkts;
@@ -1316,6 +1322,14 @@ capture(void)
#ifdef linux
if (!ld.from_pipe) pcap_fd = pcap_fileno(pch);
#endif
+
+#ifndef _WIN32
+ /*
+ * Catch SIGUSR1, so that we exit cleanly if the parent process
+ * kills us with it due to the user selecting "Capture->Stop".
+ */
+ signal(SIGUSR1, stop_capture);
+#endif
while (ld.go) {
while (gtk_events_pending()) gtk_main_iteration();
@@ -1527,6 +1541,12 @@ pct(gint num, gint denom) {
}
static void
+stop_capture(int signo)
+{
+ ld.go = FALSE;
+}
+
+static void
capture_delete_cb(GtkWidget *w, GdkEvent *event, gpointer data) {
capture_stop_cb(NULL, data);
}
@@ -1538,6 +1558,18 @@ capture_stop_cb(GtkWidget *w, gpointer data) {
ld->go = FALSE;
}
+void
+capture_stop(void)
+{
+ /*
+ * XXX - find some way of signaling the child in Win32.
+ */
+#ifndef _WIN32
+ if (fork_child != -1)
+ kill(fork_child, SIGUSR1);
+#endif
+}
+
static void
capture_pcap_cb(u_char *user, const struct pcap_pkthdr *phdr,
const u_char *pd) {
diff --git a/capture.h b/capture.h
index 0cecab4c23..bc65142e32 100644
--- a/capture.h
+++ b/capture.h
@@ -1,7 +1,7 @@
/* capture.h
* Definitions for packet capture windows
*
- * $Id: capture.h,v 1.23 2000/09/15 05:32:19 guy Exp $
+ * $Id: capture.h,v 1.24 2000/10/11 06:01:14 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -44,6 +44,9 @@ void do_capture(char *capfile_name);
/* Do the low-level work of a capture. */
int capture(void);
+/* Stop a capture from a menu item. */
+void capture_stop(void);
+
#endif /* HAVE_LIBPCAP */
#define EMPTY_FILTER ""
diff --git a/doc/ethereal.pod.template b/doc/ethereal.pod.template
index 2286f8f598..76f94e1064 100644
--- a/doc/ethereal.pod.template
+++ b/doc/ethereal.pod.template
@@ -281,6 +281,12 @@ file can be chosen by setting your TMPDIR environment variable before
starting B<Ethereal>. Otherwise, the default TMPDIR location is
system-dependent, but is likely either F</var/tmp> or F</tmp>.
+=item Capture:Stop
+
+In a capture that updates the packet display as packets arrive (so that
+Ethereal responds to user input other than pressing the "Stop" button in
+the capture packet statistics dialog box), stops the capture.
+
=item Display:Options
Allows you to sets the format of the packet timestamp displayed in the
@@ -988,6 +994,7 @@ B<http://www.ethereal.com>.
Per Flock <per.flock@axis.com>
Jack Keane <jkeane@OpenReach.com>
Brian Wellington <bwelling@xbill.org>
+ Santeri Paavolainen <santtu@ssh.com>
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to give his
permission to use his version of snprintf.c.
diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c
index f7f25cc9c1..5afdf6b275 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.33 2000/09/15 05:32:48 guy Exp $
+ * $Id: capture_dlg.c,v 1.34 2000/10/11 06:01:16 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -90,6 +90,12 @@ capture_prep_close_cb(GtkWidget *close_bt, gpointer parent_w);
static void
capture_prep_destroy_cb(GtkWidget *win, gpointer user_data);
+void
+capture_stop_cb(GtkWidget *w, gpointer d)
+{
+ capture_stop();
+}
+
/*
* Keep a static pointer to the current "Capture Preferences" window, if
* any, so that if somebody tries to do "Capture:Start" while there's
diff --git a/gtk/capture_dlg.h b/gtk/capture_dlg.h
index 10fddcaffd..6e35eb0e12 100644
--- a/gtk/capture_dlg.h
+++ b/gtk/capture_dlg.h
@@ -1,7 +1,7 @@
/* capture_dlg.h
* Definitions for packet capture windows
*
- * $Id: capture_dlg.h,v 1.1 1999/09/09 03:32:01 gram Exp $
+ * $Id: capture_dlg.h,v 1.2 2000/10/11 06:01:16 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -27,5 +27,6 @@
#define __CAPTURE_DLG_H__
void capture_prep_cb(GtkWidget *, gpointer);
+void capture_stop_cb(GtkWidget *, gpointer);
#endif /* capture.h */
diff --git a/gtk/menu.c b/gtk/menu.c
index 7d266335d6..ed990c83fa 100644
--- a/gtk/menu.c
+++ b/gtk/menu.c
@@ -1,7 +1,7 @@
/* menu.c
* Menu routines
*
- * $Id: menu.c,v 1.44 2000/09/09 08:17:51 guy Exp $
+ * $Id: menu.c,v 1.45 2000/10/11 06:01:16 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -124,7 +124,13 @@ static GtkItemFactoryEntry menu_items[] =
#ifdef HAVE_LIBPCAP
{"/_Capture", NULL, NULL, 0, "<Branch>" },
{"/Capture/_Start...", "<control>K", GTK_MENU_FUNC(capture_prep_cb), 0, NULL},
-#endif
+ /*
+ * XXX - this doesn't yet work in Win32.
+ */
+#ifndef _WIN32
+ {"/Capture/S_top", "<control>E", GTK_MENU_FUNC(capture_stop_cb), 0, NULL},
+#endif /* _WIN32 */
+#endif /* HAVE_LIBPCAP */
{"/_Display", NULL, NULL, 0, "<Branch>" },
{"/Display/_Options...", NULL, GTK_MENU_FUNC(display_opt_cb), 0, NULL},
{"/Display/_Match Selected", NULL, GTK_MENU_FUNC(match_selected_cb), 0, NULL},
@@ -346,6 +352,12 @@ set_menus_for_capture_in_progress(gboolean capture_in_progress)
{
set_menu_sensitivity("/File/Open...", !capture_in_progress);
set_menu_sensitivity("/Capture/Start...", !capture_in_progress);
+ /*
+ * XXX - this doesn't yet work in Win32.
+ */
+#ifndef _WIN32
+ set_menu_sensitivity("/Capture/Stop", capture_in_progress);
+#endif
}
/* Enable or disable menu items based on whether you have some captured