int
capture_child_start(capture_options *capture_opts, gboolean *stats_known, struct pcap_stat *stats)
{
- g_assert(capture_opts->capture_child);
-
#ifndef _WIN32
/*
* Catch SIGUSR1, so that we exit cleanly if the parent process
}
void
-capture_stop(capture_options *capture_opts)
+capture_child_stop(capture_options *capture_opts)
{
- /* stop the capture child, if we have one */
- if (!capture_opts->capture_child) {
- sync_pipe_stop(capture_opts);
- }
-
/* stop the capture loop */
capture_loop_stop();
}
+void
+capture_stop(capture_options *capture_opts)
+{
+ /* stop the capture child, if we have one */
+ sync_pipe_stop(capture_opts);
+}
+
void
capture_kill_child(capture_options *capture_opts)
{
gboolean promisc_mode; /**< Capture in promiscuous mode */
int linktype; /**< Data link type to use, or -1 for
"use default" */
- gboolean capture_child; /**< True if this is the child for "-S" */
gchar *save_file; /**< the capture file name */
/* GUI related */
*/
extern void capture_input_closed(capture_options *capture_opts);
-/** Do the low-level work of a capture (start the capture child).
- * Returns TRUE if it succeeds, FALSE otherwise. */
-extern int capture_child_start(capture_options *capture_opts, gboolean *stats_known, struct pcap_stat *stats);
-
/** Stop a capture (usually from a menu item). */
extern void capture_stop(capture_options *capture_opts);
/** Terminate the capture child cleanly when exiting. */
extern void capture_kill_child(capture_options *capture_opts);
+
+
+/** Do the low-level work of a capture (start the capture child).
+ * Returns TRUE if it succeeds, FALSE otherwise. */
+extern int capture_child_start(capture_options *capture_opts, gboolean *stats_known, struct pcap_stat *stats);
+
+/** Stop a capture child (usually from a menu item). */
+extern void capture_child_stop(capture_options *capture_opts);
+
/** Do the low-level work of a capture.
* Returns TRUE if it succeeds, FALSE otherwise. */
extern int capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct pcap_stat *stats);
mode or fork mode, it shouldn't do any UI stuff until we pop up the
capture-progress window, and, since we couldn't start the
capture, we haven't popped it up. */
- if (!capture_opts->capture_child) {
- main_window_update();
- }
+
/* On Win32 OSes, the capture devices are probably available to all
users; don't warn about permissions problems.
if (ld->cap_pipe_fd == -1) {
- /* If this is a child process that does the capturing in sync
- * mode or fork mode, it shouldn't do any UI stuff until we pop up the
- * capture-progress window, and, since we couldn't start the
- * capture, we haven't popped it up.
- */
- if (!capture_opts->capture_child) {
- main_window_update();
- }
-
if (ld->cap_pipe_err == PIPNEXIST) {
/* Pipe doesn't exist, so output message for interface */
in other places as well - and I don't think that works all the
time in any case, due to libpcap bugs. */
- if (capture_opts->capture_child) {
/* Well, we should be able to start capturing.
- This is the child process for a sync mode capture, so sync out
- the capture file, so the header makes it to the file system,
+ Sync out the capture file, so the header makes it to the file system,
and send a "capture started successfully and capture file created"
message to our parent so that they'll open the capture file and
update its windows to indicate that we have a live capture in
fflush(wtap_dump_file(ld.wtap_pdh));
sync_pipe_capstart_to_parent();
sync_pipe_filename_to_parent(capture_opts->save_file);
- }
/* initialize capture stop (and alike) conditions */
init_capture_stop_conditions();
if (cnd_file_duration) {
cnd_reset(cnd_file_duration);
}
- if (capture_opts->capture_child) {
- sync_pipe_filename_to_parent(capture_opts->save_file);
- }
+ sync_pipe_filename_to_parent(capture_opts->save_file);
} else {
/* File switch failed: stop here */
ld.go = FALSE;
/* do sync here */
fflush(wtap_dump_file(ld.wtap_pdh));
- if (capture_opts->capture_child) {
- /* This is the child process for a sync mode capture, so send
- our parent a message saying we've written out "ld.sync_packets"
+ /* Send our parent a message saying we've written out "ld.sync_packets"
packets to the capture file. */
sync_pipe_packet_count_to_parent(ld.packets_sync_pipe);
- }
ld.packets_sync_pipe = 0;
}
cnd_reset(cnd_file_duration);
if(cnd_autostop_size)
cnd_reset(cnd_autostop_size);
- if (capture_opts->capture_child) {
- sync_pipe_filename_to_parent(capture_opts->save_file);
- }
+ sync_pipe_filename_to_parent(capture_opts->save_file);
} else {
/* File switch failed: stop here */
ld.go = FALSE;
dropped. */
if (pcap_stats(ld.pcap_h, stats) >= 0) {
*stats_known = TRUE;
- if (capture_opts->capture_child) {
- /* Let the parent process know. */
- sync_pipe_drops_to_parent(stats->ps_drop);
- }
+ /* Let the parent process know. */
+ sync_pipe_drops_to_parent(stats->ps_drop);
} else {
g_snprintf(errmsg, sizeof(errmsg),
"Can't get packet-drop statistics: %s",
static void
capture_loop_popup_errmsg(capture_options *capture_opts, const char *errmsg)
{
- if (capture_opts->capture_child) {
- /* This is the child process for a sync mode capture.
- Send the error message to our parent, so they can display a
+ /* Send the error message to our parent, so they can display a
dialog box containing it. */
sync_pipe_errmsg_to_parent(errmsg);
- } else {
- /* Display the dialog box ourselves; there's no parent. */
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", errmsg);
- }
}
infinite, in effect */
capture_opts->promisc_mode = TRUE; /* promiscuous mode is the default */
capture_opts->linktype = -1; /* the default linktype */
- capture_opts->capture_child = FALSE;
capture_opts->save_file = NULL;
capture_opts->sync_mode = TRUE;
capture_opts->show_info = TRUE;
g_warning("SnapLen (%u): %u", capture_opts->has_snaplen, capture_opts->snaplen);
g_warning("Promisc : %u", capture_opts->promisc_mode);
g_warning("LinkType : %d", capture_opts->linktype);
- g_warning("Child : %u", capture_opts->capture_child);
g_warning("SaveFile : %s", capture_opts->save_file);
g_warning("SyncMode : %u", capture_opts->sync_mode);
g_warning("ShowInfo : %u", capture_opts->show_info);
int to_read = 0;
- /* we are a capture parent */
- g_assert(!capture_opts->capture_child);
-
if ((nread = read(source, buffer, BUFSIZE)) <= 0) {
/* The child has closed the sync pipe, meaning it's not going to be
capturing any more packets. Pick up its exit status, and
static void
capture_info_delete_cb(GtkWidget *w _U_, GdkEvent *event _U_, gpointer data _U_) {
- capture_stop(capture_opts);
+ capture_child_stop(capture_opts);
}
ethereal_tap_list *tli = NULL;
gchar *tap_opt = NULL;
GtkWidget *splash_win = NULL;
+ gboolean capture_child; /* True if this is the child for "-S" */
#define OPTSTRING_INIT "a:b:B:c:f:Hhi:klLm:nN:o:pP:Qr:R:Ss:t:T:w:vy:z:"
command_name = get_basename(ethereal_path);
/* Set "capture_child" to indicate whether this is going to be a child
process for a "-S" capture. */
- capture_opts->capture_child = (strcmp(command_name, CHILD_NAME) == 0);
- if (capture_opts->capture_child) {
+ capture_child = (strcmp(command_name, CHILD_NAME) == 0);
+ if (capture_child) {
strcat(optstring, OPTSTRING_CHILD);
}
#endif
they're supposed to override saved preferences. */
if ((argc < 2 || strcmp(argv[1], "-G") != 0)
#ifdef HAVE_LIBPCAP
- && !capture_opts->capture_child
+ && !capture_child
#endif
) {
splash_win = splash_new("Loading Ethereal ...");
Otherwise, set promiscuous mode from the preferences setting. */
/* the same applies to other preferences settings as well. */
- if (capture_opts->capture_child) {
+ if (capture_child) {
auto_scroll_live = FALSE;
} else {
capture_opts->promisc_mode = prefs->capture_prom_mode;
gtk_rc_parse(rc_file);
#ifdef HAVE_LIBPCAP
- font_init(capture_opts->capture_child);
+ font_init(capture_child);
#else
font_init(FALSE);
#endif
/* Is this a "child" ethereal, which is only supposed to pop up a
capture box to let us stop the capture, and run a capture
to a file that our parent will read? */
- if (capture_opts->capture_child) {
+ if (capture_child) {
/* This is the child process for a sync mode or fork mode capture,
so just do the low-level work of a capture - don't create
a temporary file and fork off *another* child process (so don't