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
This commit is contained in:
Guy Harris 2000-10-11 06:01:16 +00:00
parent 788a6283ff
commit 54ecbe2d4e
7 changed files with 72 additions and 7 deletions

View File

@ -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.

View File

@ -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();
@ -1526,6 +1540,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) {

View File

@ -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 ""

View File

@ -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.

View File

@ -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

View File

@ -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 */

View File

@ -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