aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-05-22 07:44:28 +0000
committerGuy Harris <guy@alum.mit.edu>2013-05-22 07:44:28 +0000
commit8596d17d7f424f6a68154a537d67f1150758e5f7 (patch)
treec001df238a88757313991c76047808fe4c451727
parent54ca6dae29aabe8ad5acb602f5727317dea50340 (diff)
Pull the capture-session state information out of capture_opts and put
it into a separate capture_session structure. capture_opts should contain only user-specified option information (and stuff directly derived from it, such as the "capturing from a pipe" flag). svn path=/trunk/; revision=49493
-rw-r--r--Makefile.common1
-rw-r--r--capture.c163
-rw-r--r--capture.h35
-rw-r--r--capture_ifinfo.c1
-rw-r--r--capture_info.c4
-rw-r--r--capture_info.h8
-rw-r--r--capture_opts.c20
-rw-r--r--capture_opts.h21
-rw-r--r--capture_sync.c79
-rw-r--r--capture_sync.h6
-rw-r--r--dumpcap.c3
-rw-r--r--tshark.c42
-rw-r--r--ui/capture_globals.h4
-rw-r--r--ui/gtk/capture_dlg.c24
-rw-r--r--ui/gtk/capture_if_dlg.c2
-rw-r--r--ui/gtk/capture_info_dlg.c18
-rw-r--r--ui/gtk/drag_and_drop.c2
-rw-r--r--ui/gtk/main.c49
-rw-r--r--ui/gtk/main_80211_toolbar.c1
-rw-r--r--ui/gtk/main_statusbar.c48
-rw-r--r--ui/gtk/main_statusbar_private.h2
-rw-r--r--ui/iface_lists.c2
-rw-r--r--ui/qt/main.cpp4
23 files changed, 278 insertions, 261 deletions
diff --git a/Makefile.common b/Makefile.common
index 411c8d9cda..a22b3c7c2e 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -97,6 +97,7 @@ SHARK_COMMON_CAPTURE_SRC = \
# corresponding headers
SHARK_COMMON_CAPTURE_INCLUDES = \
capture_ifinfo.h \
+ capture_session.h \
capture_sync.h \
capture_ui_utils.h
diff --git a/capture.c b/capture.c
index 2a12d6549b..ae940a2d69 100644
--- a/capture.c
+++ b/capture.c
@@ -77,7 +77,7 @@ typedef struct {
static GList *capture_callbacks = NULL;
static void
-capture_callback_invoke(int event, capture_options *capture_opts)
+capture_callback_invoke(int event, capture_session *cap_session)
{
capture_callback_data_t *cb;
GList *cb_item = capture_callbacks;
@@ -87,7 +87,7 @@ capture_callback_invoke(int event, capture_options *capture_opts)
while(cb_item != NULL) {
cb = (capture_callback_data_t *)cb_item->data;
- cb->cb_fct(event, capture_opts, cb->user_data);
+ cb->cb_fct(event, cap_session, cb->user_data);
cb_item = g_list_next(cb_item);
}
}
@@ -130,13 +130,13 @@ capture_callback_remove(capture_callback_t func)
* @return TRUE if the capture starts successfully, FALSE otherwise.
*/
gboolean
-capture_start(capture_options *capture_opts)
+capture_start(capture_options *capture_opts, capture_session *cap_session)
{
gboolean ret;
guint i;
GString *source = g_string_new("");
- capture_opts->state = CAPTURE_PREPARING;
+ cap_session->state = CAPTURE_PREPARING;
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Start ...");
#ifdef _WIN32
if (capture_opts->ifaces->len < 2) {
@@ -165,10 +165,10 @@ capture_start(capture_options *capture_opts)
} else {
g_string_append_printf(source, "%u interfaces", capture_opts->ifaces->len);
}
- cf_set_tempfile_source((capture_file *)capture_opts->cf, source->str);
+ cf_set_tempfile_source((capture_file *)cap_session->cf, source->str);
g_string_free(source, TRUE);
/* try to start the capture child process */
- ret = sync_pipe_start(capture_opts);
+ ret = sync_pipe_start(capture_opts, cap_session);
if(!ret) {
if(capture_opts->save_file != NULL) {
g_free(capture_opts->save_file);
@@ -176,17 +176,17 @@ capture_start(capture_options *capture_opts)
}
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Start failed!");
- capture_opts->state = CAPTURE_STOPPED;
+ cap_session->state = CAPTURE_STOPPED;
} else {
/* the capture child might not respond shortly after bringing it up */
/* (for example: it will block if no input arrives from an input capture pipe (e.g. mkfifo)) */
/* to prevent problems, bring the main GUI into "capture mode" right after a successful */
/* spawn/exec of the capture child, without waiting for any response from it */
- capture_callback_invoke(capture_cb_capture_prepared, capture_opts);
+ capture_callback_invoke(capture_cb_capture_prepared, cap_session);
if(capture_opts->show_info)
- capture_info_open(capture_opts);
+ capture_info_open(cap_session);
}
return ret;
@@ -194,54 +194,55 @@ capture_start(capture_options *capture_opts)
void
-capture_stop(capture_options *capture_opts)
+capture_stop(capture_session *cap_session)
{
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Stop ...");
- capture_callback_invoke(capture_cb_capture_stopping, capture_opts);
+ capture_callback_invoke(capture_cb_capture_stopping, cap_session);
/* stop the capture child gracefully */
- sync_pipe_stop(capture_opts);
+ sync_pipe_stop(cap_session);
}
void
-capture_restart(capture_options *capture_opts)
+capture_restart(capture_session *cap_session)
{
+ capture_options *capture_opts = cap_session->capture_opts;
+
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Restart");
capture_opts->restart = TRUE;
- capture_stop(capture_opts);
+ capture_stop(cap_session);
}
void
-capture_kill_child(capture_options *capture_opts)
+capture_kill_child(capture_session *cap_session)
{
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "Capture Kill");
/* kill the capture child */
- sync_pipe_kill(capture_opts->fork_child);
+ sync_pipe_kill(cap_session->fork_child);
}
-
-
/* We've succeeded in doing a (non real-time) capture; try to read it into a new capture file */
static gboolean
-capture_input_read_all(capture_options *capture_opts, gboolean is_tempfile, gboolean drops_known,
-guint32 drops)
+capture_input_read_all(capture_session *cap_session, gboolean is_tempfile,
+ gboolean drops_known, guint32 drops)
{
+ capture_options *capture_opts = cap_session->capture_opts;
int err;
/* Capture succeeded; attempt to open the capture file. */
- if (cf_open((capture_file *)capture_opts->cf, capture_opts->save_file, is_tempfile, &err) != CF_OK) {
+ if (cf_open((capture_file *)cap_session->cf, capture_opts->save_file, is_tempfile, &err) != CF_OK) {
/* We're not doing a capture any more, so we don't have a save file. */
return FALSE;
}
/* Set the read filter to NULL. */
/* XXX - this is odd here; try to put it somewhere where it fits better */
- cf_set_rfcode((capture_file *)capture_opts->cf, NULL);
+ cf_set_rfcode((capture_file *)cap_session->cf, NULL);
/* Get the packet-drop statistics.
@@ -262,7 +263,7 @@ guint32 drops)
thus not have to set them here - "cf_read()" will get them from
the file and use them. */
if (drops_known) {
- cf_set_drops_known((capture_file *)capture_opts->cf, TRUE);
+ cf_set_drops_known((capture_file *)cap_session->cf, TRUE);
/* XXX - on some systems, libpcap doesn't bother filling in
"ps_ifdrop" - it doesn't even set it to zero - so we don't
@@ -272,11 +273,11 @@ guint32 drops)
several statistics - perhaps including various interface
error statistics - and would tell us which of them it
supplies, allowing us to display only the ones it does. */
- cf_set_drops((capture_file *)capture_opts->cf, drops);
+ cf_set_drops((capture_file *)cap_session->cf, drops);
}
/* read in the packet data */
- switch (cf_read((capture_file *)capture_opts->cf, FALSE)) {
+ switch (cf_read((capture_file *)cap_session->cf, FALSE)) {
case CF_READ_OK:
case CF_READ_ERROR:
@@ -293,7 +294,7 @@ guint32 drops)
}
/* if we didn't capture even a single packet, close the file again */
- if(cf_get_packet_count((capture_file *)capture_opts->cf) == 0 && !capture_opts->restart) {
+ if(cf_get_packet_count((capture_file *)cap_session->cf) == 0 && !capture_opts->restart) {
simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
"%sNo packets captured!%s\n"
"\n"
@@ -310,8 +311,8 @@ guint32 drops)
#endif
"",
simple_dialog_primary_start(), simple_dialog_primary_end(),
- (cf_is_tempfile((capture_file *)capture_opts->cf)) ? "temporary " : "");
- cf_close((capture_file *)capture_opts->cf);
+ (cf_is_tempfile((capture_file *)cap_session->cf)) ? "temporary " : "");
+ cf_close((capture_file *)cap_session->cf);
}
return TRUE;
}
@@ -319,38 +320,39 @@ guint32 drops)
/* capture child tells us we have a new (or the first) capture file */
gboolean
-capture_input_new_file(capture_options *capture_opts, gchar *new_file)
+capture_input_new_file(capture_session *cap_session, gchar *new_file)
{
+ capture_options *capture_opts = cap_session->capture_opts;
gboolean is_tempfile;
int err;
- if(capture_opts->state == CAPTURE_PREPARING) {
+ if(cap_session->state == CAPTURE_PREPARING) {
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture started!");
}
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "File: \"%s\"", new_file);
- g_assert(capture_opts->state == CAPTURE_PREPARING || capture_opts->state == CAPTURE_RUNNING);
+ g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
/* free the old filename */
if(capture_opts->save_file != NULL) {
/* we start a new capture file, close the old one (if we had one before). */
/* (we can only have an open capture file in real_time_mode!) */
- if( ((capture_file *) capture_opts->cf)->state != FILE_CLOSED) {
+ if( ((capture_file *) cap_session->cf)->state != FILE_CLOSED) {
if(capture_opts->real_time_mode) {
- capture_callback_invoke(capture_cb_capture_update_finished, capture_opts);
- cf_finish_tail((capture_file *)capture_opts->cf, &err);
- cf_close((capture_file *)capture_opts->cf);
+ capture_callback_invoke(capture_cb_capture_update_finished, cap_session);
+ cf_finish_tail((capture_file *)cap_session->cf, &err);
+ cf_close((capture_file *)cap_session->cf);
} else {
- capture_callback_invoke(capture_cb_capture_fixed_finished, capture_opts);
+ capture_callback_invoke(capture_cb_capture_fixed_finished, cap_session);
}
}
g_free(capture_opts->save_file);
is_tempfile = FALSE;
- cf_set_tempfile((capture_file *)capture_opts->cf, FALSE);
+ cf_set_tempfile((capture_file *)cap_session->cf, FALSE);
} else {
/* we didn't have a save_file before; must be a tempfile */
is_tempfile = TRUE;
- cf_set_tempfile((capture_file *)capture_opts->cf, TRUE);
+ cf_set_tempfile((capture_file *)cap_session->cf, TRUE);
}
/* save the new filename */
@@ -359,7 +361,7 @@ capture_input_new_file(capture_options *capture_opts, gchar *new_file)
/* if we are in real-time mode, open the new file now */
if(capture_opts->real_time_mode) {
/* Attempt to open the capture file and set up to read from it. */
- switch(cf_start_tail((capture_file *)capture_opts->cf, capture_opts->save_file, is_tempfile, &err)) {
+ switch(cf_start_tail((capture_file *)cap_session->cf, capture_opts->save_file, is_tempfile, &err)) {
case CF_OK:
break;
case CF_ERROR:
@@ -370,7 +372,7 @@ capture_input_new_file(capture_options *capture_opts, gchar *new_file)
return FALSE;
}
} else {
- capture_callback_invoke(capture_cb_capture_prepared, capture_opts);
+ capture_callback_invoke(capture_cb_capture_prepared, cap_session);
}
if(capture_opts->show_info) {
@@ -379,11 +381,11 @@ capture_input_new_file(capture_options *capture_opts, gchar *new_file)
}
if(capture_opts->real_time_mode) {
- capture_callback_invoke(capture_cb_capture_update_started, capture_opts);
+ capture_callback_invoke(capture_cb_capture_update_started, cap_session);
} else {
- capture_callback_invoke(capture_cb_capture_fixed_started, capture_opts);
+ capture_callback_invoke(capture_cb_capture_fixed_started, cap_session);
}
- capture_opts->state = CAPTURE_RUNNING;
+ cap_session->state = CAPTURE_RUNNING;
return TRUE;
}
@@ -391,16 +393,16 @@ capture_input_new_file(capture_options *capture_opts, gchar *new_file)
/* capture child tells us we have new packets to read */
void
-capture_input_new_packets(capture_options *capture_opts, int to_read)
+capture_input_new_packets(capture_session *cap_session, int to_read)
{
+ capture_options *capture_opts = cap_session->capture_opts;
int err;
-
g_assert(capture_opts->save_file);
if(capture_opts->real_time_mode) {
/* Read from the capture file the number of records the child told us it added. */
- switch (cf_continue_tail((capture_file *)capture_opts->cf, to_read, &err)) {
+ switch (cf_continue_tail((capture_file *)cap_session->cf, to_read, &err)) {
case CF_READ_OK:
case CF_READ_ERROR:
@@ -409,22 +411,22 @@ capture_input_new_packets(capture_options *capture_opts, int to_read)
file.
XXX - abort on a read error? */
- capture_callback_invoke(capture_cb_capture_update_continue, capture_opts);
+ capture_callback_invoke(capture_cb_capture_update_continue, cap_session);
break;
case CF_READ_ABORTED:
/* Kill the child capture process; the user wants to exit, and we
shouldn't just leave it running. */
- capture_kill_child(capture_opts);
+ capture_kill_child(cap_session);
break;
}
} else {
/* increase the capture file packet counter by the number of incoming packets */
- cf_set_packet_count((capture_file *)capture_opts->cf,
- cf_get_packet_count((capture_file *)capture_opts->cf) + to_read);
- cf_fake_continue_tail((capture_file *)capture_opts->cf);
+ cf_set_packet_count((capture_file *)cap_session->cf,
+ cf_get_packet_count((capture_file *)cap_session->cf) + to_read);
+ cf_fake_continue_tail((capture_file *)cap_session->cf);
- capture_callback_invoke(capture_cb_capture_fixed_continue, capture_opts);
+ capture_callback_invoke(capture_cb_capture_fixed_continue, cap_session);
}
/* update the main window so we get events (e.g. from the stop toolbar button) */
@@ -441,14 +443,14 @@ capture_input_new_packets(capture_options *capture_opts, int to_read)
/* Capture child told us how many dropped packets it counted.
*/
void
-capture_input_drops(capture_options *capture_opts, guint32 dropped)
+capture_input_drops(capture_session *cap_session, guint32 dropped)
{
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "%u packet%s dropped", dropped, plurality(dropped, "", "s"));
- g_assert(capture_opts->state == CAPTURE_RUNNING);
+ g_assert(cap_session->state == CAPTURE_RUNNING);
- cf_set_drops_known((capture_file *)capture_opts->cf, TRUE);
- cf_set_drops((capture_file *)capture_opts->cf, dropped);
+ cf_set_drops_known((capture_file *)cap_session->cf, TRUE);
+ cf_set_drops((capture_file *)cap_session->cf, dropped);
}
@@ -459,7 +461,8 @@ capture_input_drops(capture_options *capture_opts, guint32 dropped)
The secondary message might be a null string.
*/
void
-capture_input_error_message(capture_options *capture_opts, char *error_msg, char *secondary_error_msg)
+capture_input_error_message(capture_session *cap_session, char *error_msg,
+ char *secondary_error_msg)
{
gchar *safe_error_msg;
gchar *safe_secondary_error_msg;
@@ -467,7 +470,7 @@ capture_input_error_message(capture_options *capture_opts, char *error_msg, char
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Error message from child: \"%s\", \"%s\"",
error_msg, secondary_error_msg);
- g_assert(capture_opts->state == CAPTURE_PREPARING || capture_opts->state == CAPTURE_RUNNING);
+ g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
safe_error_msg = simple_dialog_format_message(error_msg);
if (*secondary_error_msg != '\0') {
@@ -488,14 +491,14 @@ capture_input_error_message(capture_options *capture_opts, char *error_msg, char
/* the capture child will close the sync_pipe if required, nothing to do for now */
}
-
-
/* Capture child told us that an error has occurred while parsing a
capture filter when starting/running the capture.
*/
void
-capture_input_cfilter_error_message(capture_options *capture_opts, guint i, char *error_message)
+capture_input_cfilter_error_message(capture_session *cap_session, guint i,
+ char *error_message)
{
+ capture_options *capture_opts = cap_session->capture_opts;
dfilter_t *rfcode = NULL;
gchar *safe_cfilter;
gchar *safe_descr;
@@ -504,7 +507,7 @@ capture_input_cfilter_error_message(capture_options *capture_opts, guint i, char
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture filter error message from child: \"%s\"", error_message);
- g_assert(capture_opts->state == CAPTURE_PREPARING || capture_opts->state == CAPTURE_RUNNING);
+ g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
g_assert(i < capture_opts->ifaces->len);
interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
@@ -542,24 +545,24 @@ capture_input_cfilter_error_message(capture_options *capture_opts, guint i, char
/* the capture child will close the sync_pipe if required, nothing to do for now */
}
-
/* capture child closed its side of the pipe, do the required cleanup */
void
-capture_input_closed(capture_options *capture_opts, gchar *msg)
+capture_input_closed(capture_session *cap_session, gchar *msg)
{
+ capture_options *capture_opts = cap_session->capture_opts;
int err;
int packet_count_save;
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture stopped!");
- g_assert(capture_opts->state == CAPTURE_PREPARING || capture_opts->state == CAPTURE_RUNNING);
+ g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
if (msg != NULL)
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", msg);
- if(capture_opts->state == CAPTURE_PREPARING) {
+ if(cap_session->state == CAPTURE_PREPARING) {
/* We didn't start a capture; note that the attempt to start it
failed. */
- capture_callback_invoke(capture_cb_capture_failed, capture_opts);
+ capture_callback_invoke(capture_cb_capture_failed, cap_session);
} else {
/* We started a capture; process what's left of the capture file if
we were in "update list of packets in real time" mode, or process
@@ -568,14 +571,14 @@ capture_input_closed(capture_options *capture_opts, gchar *msg)
cf_read_status_t status;
/* Read what remains of the capture file. */
- status = cf_finish_tail((capture_file *)capture_opts->cf, &err);
+ status = cf_finish_tail((capture_file *)cap_session->cf, &err);
/* XXX: If -Q (quit-after-cap) then cf->count clr'd below so save it first */
- packet_count_save = cf_get_packet_count((capture_file *)capture_opts->cf);
+ packet_count_save = cf_get_packet_count((capture_file *)cap_session->cf);
/* Tell the GUI we are not doing a capture any more.
Must be done after the cf_finish_tail(), so file lengths are
correctly displayed */
- capture_callback_invoke(capture_cb_capture_update_finished, capture_opts);
+ capture_callback_invoke(capture_cb_capture_update_finished, cap_session);
/* Finish the capture. */
switch (status) {
@@ -598,8 +601,8 @@ capture_input_closed(capture_options *capture_opts, gchar *msg)
#endif
"",
simple_dialog_primary_start(), simple_dialog_primary_end(),
- cf_is_tempfile((capture_file *)capture_opts->cf) ? "temporary " : "");
- cf_close((capture_file *)capture_opts->cf);
+ cf_is_tempfile((capture_file *)cap_session->cf) ? "temporary " : "");
+ cf_close((capture_file *)cap_session->cf);
}
break;
case CF_READ_ERROR:
@@ -616,12 +619,12 @@ capture_input_closed(capture_options *capture_opts, gchar *msg)
}
} else {
/* first of all, we are not doing a capture any more */
- capture_callback_invoke(capture_cb_capture_fixed_finished, capture_opts);
+ capture_callback_invoke(capture_cb_capture_fixed_finished, cap_session);
/* this is a normal mode capture and if no error happened, read in the capture file data */
if(capture_opts->save_file != NULL) {
- capture_input_read_all(capture_opts, cf_is_tempfile((capture_file *)capture_opts->cf),
- cf_get_drops_known((capture_file *)capture_opts->cf), cf_get_drops((capture_file *)capture_opts->cf));
+ capture_input_read_all(cap_session, cf_is_tempfile((capture_file *)cap_session->cf),
+ cf_get_drops_known((capture_file *)cap_session->cf), cf_get_drops((capture_file *)cap_session->cf));
}
}
}
@@ -629,11 +632,11 @@ capture_input_closed(capture_options *capture_opts, gchar *msg)
if(capture_opts->show_info)
capture_info_close();
- capture_opts->state = CAPTURE_STOPPED;
+ cap_session->state = CAPTURE_STOPPED;
/* if we couldn't open a capture file, there's nothing more for us to do */
if(capture_opts->save_file == NULL) {
- cf_close((capture_file *)capture_opts->cf);
+ cf_close((capture_file *)cap_session->cf);
return;
}
@@ -644,7 +647,7 @@ capture_input_closed(capture_options *capture_opts, gchar *msg)
ws_unlink(capture_opts->save_file);
/* if it was a tempfile, throw away the old filename (so it will become a tempfile again) */
- if(cf_is_tempfile((capture_file *)capture_opts->cf)) {
+ if(cf_is_tempfile((capture_file *)cap_session->cf)) {
g_free(capture_opts->save_file);
capture_opts->save_file = NULL;
}
@@ -655,9 +658,9 @@ capture_input_closed(capture_options *capture_opts, gchar *msg)
}
/* close the currently loaded capture file */
- cf_close((capture_file *)capture_opts->cf);
+ cf_close((capture_file *)cap_session->cf);
- capture_start(capture_opts);
+ capture_start(capture_opts, cap_session);
} else {
/* We're not doing a capture any more, so we don't have a save file. */
g_free(capture_opts->save_file);
diff --git a/capture.h b/capture.h
index e73b2b4be4..7082b8be88 100644
--- a/capture.h
+++ b/capture.h
@@ -32,6 +32,7 @@
*/
#include "capture_opts.h"
+#include "capture_session.h"
#ifdef __cplusplus
extern "C" {
@@ -49,7 +50,7 @@ typedef enum {
capture_cb_capture_failed
} capture_cbs;
-typedef void (*capture_callback_t) (gint event, capture_options *capture_opts,
+typedef void (*capture_callback_t) (gint event, capture_session *cap_session,
gpointer user_data);
extern void
@@ -64,48 +65,60 @@ capture_callback_remove(capture_callback_t func);
* @param capture_opts the numerous capture options
* @return TRUE if the capture starts successfully, FALSE otherwise.
*/
-extern gboolean capture_start(capture_options *capture_opts);
+extern gboolean
+capture_start(capture_options *capture_opts, capture_session *cap_session);
/** Stop a capture session (usually from a menu item). */
-extern void capture_stop(capture_options *capture_opts);
+extern void
+capture_stop(capture_session *cap_session);
/** Restart the current captured packets and start again. */
-extern void capture_restart(capture_options *capture_opts);
+extern void
+capture_restart(capture_session *cap_session);
/** Terminate the capture child cleanly when exiting. */
-extern void capture_kill_child(capture_options *capture_opts);
+extern void
+capture_kill_child(capture_session *cap_session);
/**
* Capture child told us we have a new (or the first) capture file.
*/
-extern gboolean capture_input_new_file(capture_options *capture_opts, gchar *new_file);
+extern gboolean
+capture_input_new_file(capture_session *cap_session, gchar *new_file);
/**
* Capture child told us we have new packets to read.
*/
-extern void capture_input_new_packets(capture_options *capture_opts, int to_read);
+extern void
+capture_input_new_packets(capture_session *cap_session, int to_read);
/**
* Capture child told us how many dropped packets it counted.
*/
-extern void capture_input_drops(capture_options *capture_opts, guint32 dropped);
+extern void
+capture_input_drops(capture_session *cap_session, guint32 dropped);
/**
* Capture child told us that an error has occurred while starting the capture.
*/
-extern void capture_input_error_message(capture_options *capture_opts, char *error_message, char *secondary_error_msg);
+extern void
+capture_input_error_message(capture_session *cap_session, char *error_message,
+ char *secondary_error_msg);
/**
* Capture child told us that an error has occurred while parsing a
* capture filter when starting/running the capture.
*/
-extern void capture_input_cfilter_error_message(capture_options *capture_opts, guint i, char *error_message);
+extern void
+capture_input_cfilter_error_message(capture_session *cap_session, guint i,
+ char *error_message);
/**
* Capture child closed its side of the pipe, report any error and
* do the required cleanup.
*/
-extern void capture_input_closed(capture_options *capture_opts, gchar *msg);
+extern void
+capture_input_closed(capture_session *cap_session, gchar *msg);
struct if_stat_cache_s;
typedef struct if_stat_cache_s if_stat_cache_t;
diff --git a/capture_ifinfo.c b/capture_ifinfo.c
index af76eabbc8..40967a6117 100644
--- a/capture_ifinfo.c
+++ b/capture_ifinfo.c
@@ -49,6 +49,7 @@
#include <glib.h>
#include "capture_opts.h"
+#include "capture_session.h"
#include "capture_sync.h"
#include "log.h"
diff --git a/capture_info.c b/capture_info.c
index a4c5651fd3..fdb1ead30c 100644
--- a/capture_info.c
+++ b/capture_info.c
@@ -75,7 +75,7 @@ static info_data_t info_data;
/* open the info */
-void capture_info_open(capture_options *capture_opts)
+void capture_info_open(capture_session *cap_session)
{
info_data.counts.total = 0;
info_data.counts.sctp = 0;
@@ -95,7 +95,7 @@ void capture_info_open(capture_options *capture_opts)
info_data.wtap = NULL;
info_data.ui.counts = &info_data.counts;
- capture_info_ui_create(&info_data.ui, capture_opts);
+ capture_info_ui_create(&info_data.ui, cap_session);
}
diff --git a/capture_info.h b/capture_info.h
index 98c8242fb3..4b250efcd7 100644
--- a/capture_info.h
+++ b/capture_info.h
@@ -33,13 +33,14 @@
#define __CAPTURE_INFO_H__
#include "capture_opts.h"
+#include "capture_session.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* open the info - init values (wtap, counts), create dialog */
-extern void capture_info_open(capture_options *capture_opts);
+extern void capture_info_open(capture_session *cap_session);
/* new file arrived - (eventually close old wtap), open wtap */
extern gboolean capture_info_new_file(const char *new_filename);
@@ -65,9 +66,8 @@ typedef struct {
/** Create the capture info dialog */
-extern void capture_info_ui_create(
-capture_info *cinfo,
-capture_options *capture_opts);
+extern void
+capture_info_ui_create(capture_info *cinfo, capture_session *cap_session);
/** Update the capture info counters in the dialog */
extern void capture_info_ui_update(
diff --git a/capture_opts.c b/capture_opts.c
index 785a22a5c1..cc5bf10ef9 100644
--- a/capture_opts.c
+++ b/capture_opts.c
@@ -54,9 +54,8 @@ static gboolean capture_opts_output_to_pipe(const char *save_file, gboolean *is_
void
-capture_opts_init(capture_options *capture_opts, void *cf)
+capture_opts_init(capture_options *capture_opts)
{
- capture_opts->cf = cf;
capture_opts->ifaces = g_array_new(FALSE, FALSE, sizeof(interface_options));
capture_opts->all_ifaces = g_array_new(FALSE, FALSE, sizeof(interface_t));
capture_opts->num_selected = 0;
@@ -114,18 +113,7 @@ capture_opts_init(capture_options *capture_opts, void *cf)
capture_opts->has_autostop_duration = FALSE;
capture_opts->autostop_duration = 60; /* 1 min */
-
- capture_opts->fork_child = -1; /* invalid process handle */
-#ifdef _WIN32
- capture_opts->signal_pipe_write_fd = -1;
-#endif
- capture_opts->state = CAPTURE_STOPPED;
capture_opts->output_to_pipe = FALSE;
-#ifndef _WIN32
- capture_opts->owner = getuid();
- capture_opts->group = getgid();
-#endif
- capture_opts->session_started = FALSE;
}
@@ -135,7 +123,6 @@ capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_optio
guint i;
g_log(log_domain, log_level, "CAPTURE OPTIONS :");
- g_log(log_domain, log_level, "CFile : %p", capture_opts->cf);
for (i = 0; i < capture_opts->ifaces->len; i++) {
interface_options interface_opts;
@@ -229,11 +216,6 @@ capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_optio
g_log(log_domain, log_level, "AutostopPackets (%u) : %u", capture_opts->has_autostop_packets, capture_opts->autostop_packets);
g_log(log_domain, log_level, "AutostopFilesize(%u) : %u (KB)", capture_opts->has_autostop_filesize, capture_opts->autostop_filesize);
g_log(log_domain, log_level, "AutostopDuration(%u) : %u", capture_opts->has_autostop_duration, capture_opts->autostop_duration);
-
- g_log(log_domain, log_level, "ForkChild : %d", capture_opts->fork_child);
-#ifdef _WIN32
- g_log(log_domain, log_level, "SignalPipeWrite : %d", capture_opts->signal_pipe_write_fd);
-#endif
}
/*
diff --git a/capture_opts.h b/capture_opts.h
index c380b9d145..7d966bc559 100644
--- a/capture_opts.h
+++ b/capture_opts.h
@@ -42,13 +42,6 @@
extern "C" {
#endif /* __cplusplus */
-/* Current state of capture engine. XXX - differentiate states */
-typedef enum {
- CAPTURE_STOPPED, /**< stopped */
- CAPTURE_PREPARING, /**< preparing, but still no response from capture child */
- CAPTURE_RUNNING /**< capture child signalled ok, capture is running now */
-} capture_state;
-
#ifdef HAVE_PCAP_REMOTE
/* Type of capture source */
typedef enum {
@@ -168,7 +161,6 @@ typedef struct interface_options_tag {
/** Capture options coming from user interface */
typedef struct capture_options_tag {
/* general */
- void *cf; /**< handle to cfile (note: untyped handle) */
GArray *ifaces; /**< array of interfaces.
Currently only used by dumpcap. */
GArray *all_ifaces;
@@ -209,23 +201,12 @@ typedef struct capture_options_tag {
gint32 autostop_duration; /**< Maximum capture duration */
/* internally used (don't touch from outside) */
- int fork_child; /**< If not -1, in parent, process ID of child */
- int fork_child_status; /**< Child exit status */
-#ifdef _WIN32
- int signal_pipe_write_fd; /**< the pipe to signal the child */
-#endif
- capture_state state; /**< current state of the capture engine */
gboolean output_to_pipe; /**< save_file is a pipe (named or stdout) */
-#ifndef _WIN32
- uid_t owner; /**< owner of the cfile */
- gid_t group; /**< group of the cfile */
-#endif
- gboolean session_started;
} capture_options;
/* initialize the capture_options with some reasonable values */
extern void
-capture_opts_init(capture_options *capture_opts, void *cf);
+capture_opts_init(capture_options *capture_opts);
/* set a command line option value */
extern int
diff --git a/capture_sync.c b/capture_sync.c
index fded034adf..a6319c4be0 100644
--- a/capture_sync.c
+++ b/capture_sync.c
@@ -118,7 +118,21 @@ static void pipe_convert_header(const guchar *header, int header_len, char *indi
static ssize_t pipe_read_block(int pipe_fd, char *indicator, int len, char *msg,
char **err_msg);
-
+void
+capture_session_init(capture_session *cap_session, void *cf)
+{
+ cap_session->cf = cf;
+ cap_session->fork_child = -1; /* invalid process handle */
+#ifdef _WIN32
+ cap_session->signal_pipe_write_fd = -1;
+#endif
+ cap_session->state = CAPTURE_STOPPED;
+#ifndef _WIN32
+ cap_session->owner = getuid();
+ cap_session->group = getgid();
+#endif
+ cap_session->session_started = FALSE;
+}
/* Append an arg (realloc) to an argc/argv array */
/* (add a string pointer to a NULL-terminated array of string pointers) */
@@ -320,7 +334,8 @@ init_pipe_args(int *argc) {
#define ARGV_NUMBER_LEN 24
/* a new capture run: start a new dumpcap task and hand over parameters through command line */
gboolean
-sync_pipe_start(capture_options *capture_opts) {
+sync_pipe_start(capture_options *capture_opts, capture_session *cap_session)
+{
char ssnap[ARGV_NUMBER_LEN];
char scount[ARGV_NUMBER_LEN];
char sfilesize[ARGV_NUMBER_LEN];
@@ -368,7 +383,7 @@ sync_pipe_start(capture_options *capture_opts) {
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_start");
capture_opts_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, capture_opts);
- capture_opts->fork_child = -1;
+ cap_session->fork_child = -1;
argv = init_pipe_args(&argc);
if (!argv) {
@@ -594,7 +609,7 @@ sync_pipe_start(capture_options *capture_opts) {
g_free( (gpointer) argv);
return FALSE;
}
- capture_opts->fork_child = (int) pi.hProcess;
+ cap_session->fork_child = (int) pi.hProcess;
g_string_free(args, TRUE);
/* associate the operating system filehandle to a C run-time file handle */
@@ -615,7 +630,7 @@ sync_pipe_start(capture_options *capture_opts) {
return FALSE;
}
- if ((capture_opts->fork_child = fork()) == 0) {
+ if ((cap_session->fork_child = fork()) == 0) {
/*
* Child process - run dumpcap with the right arguments to make
* it just capture with the specified capture parameters
@@ -658,7 +673,7 @@ sync_pipe_start(capture_options *capture_opts) {
ws_close(sync_pipe[PIPE_WRITE]);
#endif
- if (capture_opts->fork_child == -1) {
+ if (cap_session->fork_child == -1) {
/* We couldn't even create the child process. */
report_failure("Couldn't create child process: %s", g_strerror(errno));
ws_close(sync_pipe_read_fd);
@@ -668,7 +683,8 @@ sync_pipe_start(capture_options *capture_opts) {
return FALSE;
}
- capture_opts->fork_child_status = 0;
+ cap_session->fork_child_status = 0;
+ cap_session->capture_opts = capture_opts;
/* we might wait for a moment till child is ready, so update screen now */
main_window_update();
@@ -679,8 +695,8 @@ sync_pipe_start(capture_options *capture_opts) {
the child process wants to tell us something. */
/* we have a running capture, now wait for the real capture filename */
- pipe_input_set_handler(sync_pipe_read_fd, (gpointer) capture_opts,
- &capture_opts->fork_child, sync_pipe_input_cb);
+ pipe_input_set_handler(sync_pipe_read_fd, (gpointer) cap_session,
+ &cap_session->fork_child, sync_pipe_input_cb);
return TRUE;
}
@@ -1612,7 +1628,7 @@ pipe_read_block(int pipe_fd, char *indicator, int len, char *msg,
static gboolean
sync_pipe_input_cb(gint source, gpointer user_data)
{
- capture_options *capture_opts = (capture_options *)user_data;
+ capture_session *cap_session = (capture_session *)user_data;
int ret;
char buffer[SP_MAX_MSG_LEN+1];
ssize_t nread;
@@ -1639,7 +1655,7 @@ sync_pipe_input_cb(gint source, gpointer user_data)
If we got an EOF, nread is 0 and primary_msg isn't set. This
is an indication that the capture is finished. */
- ret = sync_pipe_wait_for_child(capture_opts->fork_child, &wait_msg);
+ ret = sync_pipe_wait_for_child(cap_session->fork_child, &wait_msg);
if(nread == 0) {
/* We got an EOF from the sync pipe. That means that the capture
child exited, and not in the middle of a message; we treat
@@ -1660,13 +1676,13 @@ sync_pipe_input_cb(gint source, gpointer user_data)
}
/* No more child process. */
- capture_opts->fork_child = -1;
- capture_opts->fork_child_status = ret;
+ cap_session->fork_child = -1;
+ cap_session->fork_child_status = ret;
#ifdef _WIN32
ws_close(capture_opts->signal_pipe_write_fd);
#endif
- capture_input_closed(capture_opts, primary_msg);
+ capture_input_closed(cap_session, primary_msg);
g_free(primary_msg);
return FALSE;
}
@@ -1674,7 +1690,7 @@ sync_pipe_input_cb(gint source, gpointer user_data)
/* we got a valid message block from the child, process it */
switch(indicator) {
case SP_FILE:
- if(!capture_input_new_file(capture_opts, buffer)) {
+ if(!capture_input_new_file(cap_session, buffer)) {
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_input_cb: file failed, closing capture");
/* We weren't able to open the new capture file; user has been
@@ -1694,15 +1710,15 @@ sync_pipe_input_cb(gint source, gpointer user_data)
This can also happen if the user specified "-", meaning
"standard output", as the capture file. */
- sync_pipe_stop(capture_opts);
- capture_input_closed(capture_opts, NULL);
+ sync_pipe_stop(cap_session);
+ capture_input_closed(cap_session, NULL);
return FALSE;
}
break;
case SP_PACKET_COUNT:
npackets = atoi(buffer);
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_input_cb: new packets %u", npackets);
- capture_input_new_packets(capture_opts, npackets);
+ capture_input_new_packets(cap_session, npackets);
break;
case SP_ERROR_MSG:
/* convert primary message */
@@ -1712,7 +1728,7 @@ sync_pipe_input_cb(gint source, gpointer user_data)
pipe_convert_header((guchar*)primary_msg + primary_len, 4, &indicator, &secondary_len);
secondary_msg = primary_msg + primary_len + 4;
/* message output */
- capture_input_error_message(capture_opts, primary_msg, secondary_msg);
+ capture_input_error_message(cap_session, primary_msg, secondary_msg);
/* the capture child will close the sync_pipe, nothing to do for now */
/* (an error message doesn't mean we have to stop capturing) */
break;
@@ -1723,12 +1739,12 @@ sync_pipe_input_cb(gint source, gpointer user_data)
ch = strtok(buffer, ":");
indx = (int)strtol(ch, NULL, 10);
ch = strtok(NULL, ":");
- capture_input_cfilter_error_message(capture_opts, indx, ch);
+ capture_input_cfilter_error_message(cap_session, indx, ch);
/* the capture child will close the sync_pipe, nothing to do for now */
break;
}
case SP_DROPS:
- capture_input_drops(capture_opts, (guint32)strtoul(buffer, NULL, 10));
+ capture_input_drops(cap_session, (guint32)strtoul(buffer, NULL, 10));
break;
default:
g_assert_not_reached();
@@ -1923,21 +1939,20 @@ sync_pipe_signame(int sig)
#ifdef _WIN32
/* tell the child through the signal pipe that we want to quit the capture */
static void
-signal_pipe_capquit_to_child(capture_options *capture_opts)
+signal_pipe_capquit_to_child(capture_session *cap_session)
{
const char quit_msg[] = "QUIT";
int ret;
-
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "signal_pipe_capquit_to_child");
/* it doesn't matter *what* we send here, the first byte will stop the capture */
/* simply sending a "QUIT" string */
- /*pipe_write_block(capture_opts->signal_pipe_write_fd, SP_QUIT, quit_msg);*/
- ret = write(capture_opts->signal_pipe_write_fd, quit_msg, sizeof quit_msg);
+ /*pipe_write_block(cap_session->signal_pipe_write_fd, SP_QUIT, quit_msg);*/
+ ret = write(cap_session->signal_pipe_write_fd, quit_msg, sizeof quit_msg);
if(ret == -1) {
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_WARNING,
- "signal_pipe_capquit_to_child: %d header: error %s", capture_opts->signal_pipe_write_fd, g_strerror(errno));
+ "signal_pipe_capquit_to_child: %d header: error %s", cap_session->signal_pipe_write_fd, g_strerror(errno));
}
}
#endif
@@ -1945,7 +1960,7 @@ signal_pipe_capquit_to_child(capture_options *capture_opts)
/* user wants to stop the capture run */
void
-sync_pipe_stop(capture_options *capture_opts)
+sync_pipe_stop(capture_session *cap_session)
{
#ifdef _WIN32
int count;
@@ -1953,10 +1968,10 @@ sync_pipe_stop(capture_options *capture_opts)
gboolean terminate = TRUE;
#endif
- if (capture_opts->fork_child != -1) {
+ if (cap_session->fork_child != -1) {
#ifndef _WIN32
/* send the SIGINT signal to close the capture child gracefully. */
- int sts = kill(capture_opts->fork_child, SIGINT);
+ int sts = kill(cap_session->fork_child, SIGINT);
if (sts != 0) {
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_WARNING,
"Sending SIGINT to child failed: %s\n", g_strerror(errno));
@@ -1967,11 +1982,11 @@ sync_pipe_stop(capture_options *capture_opts)
/* First, use the special signal pipe to try to close the capture child
* gracefully.
*/
- signal_pipe_capquit_to_child(capture_opts);
+ signal_pipe_capquit_to_child(cap_session);
/* Next, wait for the process to exit on its own */
for (count = 0; count < STOP_SLEEP_TIME / STOP_CHECK_TIME; count++) {
- if (GetExitCodeProcess((HANDLE) capture_opts->fork_child, &childstatus) &&
+ if (GetExitCodeProcess((HANDLE) cap_session->fork_child, &childstatus) &&
childstatus != STILL_ACTIVE) {
terminate = FALSE;
break;
@@ -1983,7 +1998,7 @@ sync_pipe_stop(capture_options *capture_opts)
if (terminate) {
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_WARNING,
"sync_pipe_stop: forcing child to exit");
- sync_pipe_kill(capture_opts->fork_child);
+ sync_pipe_kill(cap_session->fork_child);
}
#endif
}
diff --git a/capture_sync.h b/capture_sync.h
index 92888c9449..f8e6f63e6d 100644
--- a/capture_sync.h
+++ b/capture_sync.h
@@ -34,7 +34,6 @@
#ifndef __CAPTURE_SYNC_H__
#define __CAPTURE_SYNC_H__
-
/**
* Start a new capture session.
* Create a capture child which is doing the real capture work.
@@ -44,14 +43,15 @@
* Most of the parameters are passed through the global capture_opts.
*
* @param capture_opts the options
+ * @param cap_session a handle for the capture session
* @return TRUE if a capture could be started, FALSE if not
*/
extern gboolean
-sync_pipe_start(capture_options *capture_opts);
+sync_pipe_start(capture_options *capture_opts, capture_session *cap_session);
/** User wants to stop capturing, gracefully close the capture child */
extern void
-sync_pipe_stop(capture_options *capture_opts);
+sync_pipe_stop(capture_session *cap_session);
/** User wants to stop the program, just kill the child as soon as possible */
extern void
diff --git a/dumpcap.c b/dumpcap.c
index 509398c843..56a01aa4bb 100644
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -110,6 +110,7 @@
#include "sync_pipe.h"
#include "capture_opts.h"
+#include "capture_session.h"
#include "capture_ifinfo.h"
#include "capture_sync.h"
@@ -4451,7 +4452,7 @@ main(int argc, char *argv[])
/* Set the initial values in the capture options. This might be overwritten
by the command line parameters. */
- capture_opts_init(&global_capture_opts, NULL);
+ capture_opts_init(&global_capture_opts);
/* We always save to a file - if no file was specified, we save to a
temporary file. */
diff --git a/tshark.c b/tshark.c
index a0c1991799..6c99cc0335 100644
--- a/tshark.c
+++ b/tshark.c
@@ -89,6 +89,7 @@
#include "capture-wpcap.h"
#include <wsutil/unicode-utils.h>
#endif /* _WIN32 */
+#include "capture_session.h"
#include "capture_sync.h"
#endif /* HAVE_LIBPCAP */
#include "log.h"
@@ -146,6 +147,7 @@ static const char *separator = "";
static gboolean print_packet_counts = TRUE;
static capture_options global_capture_opts;
+static capture_session global_capture_session;
#ifdef SIGINFO
static gboolean infodelay; /* if TRUE, don't print capture info in SIGINFO handler */
@@ -1056,7 +1058,8 @@ main(int argc, char *argv[])
initialize_funnel_ops();
#ifdef HAVE_LIBPCAP
- capture_opts_init(&global_capture_opts, &cfile);
+ capture_opts_init(&global_capture_opts);
+ capture_session_init(&global_capture_session, (void *)&cfile);
#endif
timestamp_set_type(TS_RELATIVE);
@@ -2005,7 +2008,7 @@ main(int argc, char *argv[])
* Instead, pass on the exit status from the capture child.
*/
capture();
- exit_status = global_capture_opts.fork_child_status;
+ exit_status = global_capture_session.fork_child_status;
if (print_packet_info) {
if (!write_finale()) {
@@ -2232,7 +2235,7 @@ capture(void)
#endif /* SIGINFO */
#endif /* _WIN32 */
- global_capture_opts.state = CAPTURE_PREPARING;
+ global_capture_session.state = CAPTURE_PREPARING;
/* Let the user know which interfaces were chosen. */
for (i = 0; i < global_capture_opts.ifaces->len; i++) {
@@ -2271,7 +2274,7 @@ capture(void)
fflush(stderr);
g_string_free(str, TRUE);
- ret = sync_pipe_start(&global_capture_opts);
+ ret = sync_pipe_start(&global_capture_opts, &global_capture_session);
if (!ret)
return FALSE;
@@ -2390,27 +2393,28 @@ capture_input_cfilter_error_message(capture_options *capture_opts, guint i, char
/* capture child tells us we have a new (or the first) capture file */
gboolean
-capture_input_new_file(capture_options *capture_opts, gchar *new_file)
+capture_input_new_file(capture_session *cap_session, gchar *new_file)
{
+ capture_options *capture_opts = cap_session->capture_opts;
gboolean is_tempfile;
int err;
- if (capture_opts->state == CAPTURE_PREPARING) {
+ if (cap_session->state == CAPTURE_PREPARING) {
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture started!");
}
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "File: \"%s\"", new_file);
- g_assert(capture_opts->state == CAPTURE_PREPARING || capture_opts->state == CAPTURE_RUNNING);
+ g_assert(cap_session->state == CAPTURE_PREPARING || cap_session->state == CAPTURE_RUNNING);
/* free the old filename */
if (capture_opts->save_file != NULL) {
/* we start a new capture file, close the old one (if we had one before) */
- if ( ((capture_file *) capture_opts->cf)->state != FILE_CLOSED) {
- if ( ((capture_file *) capture_opts->cf)->wth != NULL) {
- wtap_close(((capture_file *) capture_opts->cf)->wth);
+ if ( ((capture_file *) cap_session->cf)->state != FILE_CLOSED) {
+ if ( ((capture_file *) cap_session->cf)->wth != NULL) {
+ wtap_close(((capture_file *) cap_session->cf)->wth);
}
- ((capture_file *) capture_opts->cf)->state = FILE_CLOSED;
+ ((capture_file *) cap_session->cf)->state = FILE_CLOSED;
}
g_free(capture_opts->save_file);
@@ -2426,7 +2430,7 @@ capture_input_new_file(capture_options *capture_opts, gchar *new_file)
/* if we are in real-time mode, open the new file now */
if (do_dissection) {
/* Attempt to open the capture file and set up to read from it. */
- switch(cf_open((capture_file *)capture_opts->cf, capture_opts->save_file, is_tempfile, &err)) {
+ switch(cf_open((capture_file *)cap_session->cf, capture_opts->save_file, is_tempfile, &err)) {
case CF_OK:
break;
case CF_ERROR:
@@ -2438,7 +2442,7 @@ capture_input_new_file(capture_options *capture_opts, gchar *new_file)
}
}
- capture_opts->state = CAPTURE_RUNNING;
+ cap_session->state = CAPTURE_RUNNING;
return TRUE;
}
@@ -2446,13 +2450,13 @@ capture_input_new_file(capture_options *capture_opts, gchar *new_file)
/* capture child tells us we have new packets to read */
void
-capture_input_new_packets(capture_options *capture_opts, int to_read)
+capture_input_new_packets(capture_session *cap_session, int to_read)
{
gboolean ret;
int err;
gchar *err_info;
gint64 data_offset;
- capture_file *cf = (capture_file *)capture_opts->cf;
+ capture_file *cf = (capture_file *)cap_session->cf;
gboolean filtering_tap_listeners;
guint tap_flags;
@@ -2477,7 +2481,7 @@ capture_input_new_packets(capture_options *capture_opts, int to_read)
ret = wtap_read(cf->wth, &err, &err_info, &data_offset);
if (ret == FALSE) {
/* read from file failed, tell the capture child to stop */
- sync_pipe_stop(capture_opts);
+ sync_pipe_stop(cap_session);
wtap_close(cf->wth);
cf->wth = NULL;
} else {
@@ -2575,9 +2579,9 @@ capture_input_drops(capture_options *capture_opts _U_, guint32 dropped)
* do the required cleanup.
*/
void
-capture_input_closed(capture_options *capture_opts, gchar *msg)
+capture_input_closed(capture_session *cap_session, gchar *msg)
{
- capture_file *cf = (capture_file *) capture_opts->cf;
+ capture_file *cf = (capture_file *) cap_session->cf;
if (msg != NULL)
fprintf(stderr, "tshark: %s\n", msg);
@@ -2640,7 +2644,7 @@ static void
capture_cleanup(int signum _U_)
{
/* tell the capture child to stop */
- sync_pipe_stop(&global_capture_opts);
+ sync_pipe_stop(&global_capture_session);
/* don't stop our own loop already here, otherwise status messages and
* cleanup wouldn't be done properly. The child will indicate the stop of
diff --git a/ui/capture_globals.h b/ui/capture_globals.h
index 2bf0eeaa66..d388c6b48d 100644
--- a/ui/capture_globals.h
+++ b/ui/capture_globals.h
@@ -25,12 +25,16 @@
#ifndef __CAPTURE_GLOBALS_H__
#define __CAPTURE_GLOBALS_H__
+#include "../capture_session.h"
+
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
extern capture_options global_capture_opts;
+extern capture_session global_capture_session;
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/ui/gtk/capture_dlg.c b/ui/gtk/capture_dlg.c
index 547fea87e7..b79ded2717 100644
--- a/ui/gtk/capture_dlg.c
+++ b/ui/gtk/capture_dlg.c
@@ -555,7 +555,7 @@ capture_stop_cb(GtkWidget *w _U_, gpointer d _U_)
airpcap_set_toolbar_stop_capture(airpcap_if_active);
#endif
- capture_stop(&global_capture_opts);
+ capture_stop(&global_capture_session);
}
/* restart (stop - delete old file - start) running capture */
@@ -567,7 +567,7 @@ capture_restart_cb(GtkWidget *w _U_, gpointer d _U_)
airpcap_set_toolbar_start_capture(airpcap_if_active);
#endif
- capture_restart(&global_capture_opts);
+ capture_restart(&global_capture_session);
}
enum cfc_state_t {
@@ -4715,7 +4715,7 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
gtk_widget_set_sensitive(GTK_WIDGET(all_cb), if_present);
/* Promiscuous mode row */
promisc_cb = gtk_check_button_new_with_mnemonic("Use _promiscuous mode on all interfaces");
- if (!global_capture_opts.session_started) {
+ if (!global_capture_session.session_started) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(promisc_cb), prefs.capture_prom_mode);
} else {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(promisc_cb), get_all_prom_mode());
@@ -5233,7 +5233,7 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
window_present(cap_open_w);
cap_open_complete = TRUE; /* "Capture:Start" is now OK */
- global_capture_opts.session_started = TRUE;
+ global_capture_session.session_started = TRUE;
}
/* user pressed the "Start" button (in dialog or toolbar) */
@@ -5283,17 +5283,17 @@ capture_start_cb(GtkWidget *w _U_, gpointer d _U_)
main_auto_scroll_live_changed(auto_scroll_live);
/* XXX - can this ever happen? */
- if (global_capture_opts.state != CAPTURE_STOPPED)
+ if (global_capture_session.state != CAPTURE_STOPPED)
return;
/* close the currently loaded capture file */
- cf_close((capture_file *)global_capture_opts.cf);
+ cf_close((capture_file *)global_capture_session.cf);
/* Copy the selected interfaces to the set of interfaces to use for
this capture. */
collect_ifaces(&global_capture_opts);
- if (capture_start(&global_capture_opts)) {
+ if (capture_start(&global_capture_opts, &global_capture_session)) {
/* The capture succeeded, which means the capture filter syntax is
valid; add this capture filter to the recent capture filter list. */
for (i = 0; i < global_capture_opts.ifaces->len; i++) {
@@ -5570,7 +5570,7 @@ create_and_fill_model(GtkTreeView *view)
temp = g_strdup_printf("<b>%s</b>\n<span size='small'>%s</span>", device.display_name, device.addresses);
}
linkname = NULL;
- if(global_capture_opts.session_started == FALSE && capture_dev_user_linktype_find(device.name) != -1) {
+ if(global_capture_session.session_started == FALSE && capture_dev_user_linktype_find(device.name) != -1) {
device.active_dlt = capture_dev_user_linktype_find(device.name);
}
for (list = device.links; list != NULL; list = g_list_next(list)) {
@@ -5583,10 +5583,10 @@ create_and_fill_model(GtkTreeView *view)
if (!linkname)
linkname = g_strdup("unknown");
pmode = capture_dev_user_pmode_find(device.name);
- if (global_capture_opts.session_started == FALSE && pmode != -1) {
+ if (global_capture_session.session_started == FALSE && pmode != -1) {
device.pmode = pmode;
}
- if(global_capture_opts.session_started == FALSE) {
+ if(global_capture_session.session_started == FALSE) {
hassnap = capture_dev_user_hassnap_find(device.name);
snaplen = capture_dev_user_snaplen_find(device.name);
if(snaplen != -1 && hassnap != -1) {
@@ -5606,10 +5606,10 @@ create_and_fill_model(GtkTreeView *view)
}
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
- if (global_capture_opts.session_started == FALSE && capture_dev_user_buffersize_find(device.name) != -1) {
+ if (global_capture_session.session_started == FALSE && capture_dev_user_buffersize_find(device.name) != -1) {
buffer = capture_dev_user_buffersize_find(device.name);
device.buffer = buffer;
- } else if (global_capture_opts.session_started == FALSE) {
+ } else if (global_capture_session.session_started == FALSE) {
device.buffer = DEFAULT_CAPTURE_BUFFER_SIZE;
}
#endif
diff --git a/ui/gtk/capture_if_dlg.c b/ui/gtk/capture_if_dlg.c
index 07cec6e7aa..1faec060fa 100644
--- a/ui/gtk/capture_if_dlg.c
+++ b/ui/gtk/capture_if_dlg.c
@@ -32,6 +32,8 @@
#include <epan/prefs.h>
+#include "../capture_opts.h"
+#include "../capture_session.h"
#include "../capture_ifinfo.h"
#include "../capture.h"
#include "../capture-pcap-util.h"
diff --git a/ui/gtk/capture_info_dlg.c b/ui/gtk/capture_info_dlg.c
index 870f7a2045..2ec2118fbe 100644
--- a/ui/gtk/capture_info_dlg.c
+++ b/ui/gtk/capture_info_dlg.c
@@ -72,25 +72,25 @@ typedef struct {
/* Workhorse for stopping capture */
static void
-capture_info_stop(capture_options *capture_opts)
+capture_info_stop(capture_session *cap_session)
{
#ifdef HAVE_AIRPCAP
airpcap_set_toolbar_stop_capture(airpcap_if_active);
#endif
- capture_stop(capture_opts);
+ capture_stop(cap_session);
}
/* "delete-event" signal callback. Note different signature than "clicked" signal callback */
static gboolean
capture_info_delete_cb(GtkWidget *w _U_, GdkEvent *event _U_, gpointer data) {
- capture_info_stop((capture_options *)data);
+ capture_info_stop((capture_session *)data);
return TRUE;
}
/* "clicked" signal callback */
static void
capture_info_stop_clicked_cb(GtkButton *w _U_, gpointer data) {
- capture_info_stop((capture_options *)data);
+ capture_info_stop((capture_session *)data);
}
static gboolean
@@ -110,10 +110,10 @@ capture_info_ui_update_cb(gpointer data)
/* create the capture info dialog */
/* will keep pointers to the fields in the counts parameter */
-void capture_info_ui_create(
-capture_info *cinfo,
-capture_options *capture_opts)
+void
+capture_info_ui_create(capture_info *cinfo, capture_session *cap_session)
{
+ capture_options *capture_opts = cap_session->capture_opts;
unsigned int i;
GtkWidget *main_vb, *stop_bt, *counts_grid;
GtkWidget *counts_fr, *running_grid, *running_label, *lb, *bbox, *ci_help;
@@ -297,8 +297,8 @@ capture_options *capture_opts)
stop_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_STOP);
window_set_cancel_button(info->cap_w, stop_bt, NULL);
- g_signal_connect(stop_bt, "clicked", G_CALLBACK(capture_info_stop_clicked_cb), capture_opts);
- g_signal_connect(info->cap_w, "delete_event", G_CALLBACK(capture_info_delete_cb), capture_opts);
+ g_signal_connect(stop_bt, "clicked", G_CALLBACK(capture_info_stop_clicked_cb), cap_session);
+ g_signal_connect(info->cap_w, "delete_event", G_CALLBACK(capture_info_delete_cb), cap_session);
ci_help = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
gtk_widget_set_tooltip_text(ci_help, "Get help about this dialog");
diff --git a/ui/gtk/drag_and_drop.c b/ui/gtk/drag_and_drop.c
index a49ed17659..cb12955316 100644
--- a/ui/gtk/drag_and_drop.c
+++ b/ui/gtk/drag_and_drop.c
@@ -254,7 +254,7 @@ dnd_data_received(GtkWidget *widget _U_, GdkDragContext *dc _U_, gint x _U_, gin
#ifdef HAVE_LIBPCAP
/* if a capture is running, do nothing but warn the user */
- if((global_capture_opts.state != CAPTURE_STOPPED)) {
+ if((global_capture_session.state != CAPTURE_STOPPED)) {
simple_dialog(ESD_TYPE_CONFIRMATION,
ESD_BTN_OK,
"%sDrag and Drop currently not possible!%s\n\n"
diff --git a/ui/gtk/main.c b/ui/gtk/main.c
index 580642478d..197fcce996 100644
--- a/ui/gtk/main.c
+++ b/ui/gtk/main.c
@@ -209,6 +209,9 @@
*/
#define RC_FILE "gtkrc"
+capture_options global_capture_opts;
+capture_session global_capture_session;
+
capture_file cfile;
static gboolean capture_stopping;
@@ -980,7 +983,7 @@ main_do_quit(void)
#ifdef HAVE_LIBPCAP
/* Nuke any child capture in progress. */
- capture_kill_child(&global_capture_opts);
+ capture_kill_child(&global_capture_session);
#endif
/* Are we in the middle of reading a capture? */
@@ -1514,11 +1517,11 @@ static GList *icon_list_create(
}
static void
-main_capture_cb_capture_prepared(capture_options *capture_opts)
+main_capture_cb_capture_prepared(capture_session *cap_session)
{
static GList *icon_list = NULL;
- set_titlebar_for_capture_in_progress((capture_file *)capture_opts->cf);
+ set_titlebar_for_capture_in_progress((capture_file *)cap_session->cf);
if(icon_list == NULL) {
icon_list = icon_list_create(wsiconcap_16_pb_data, wsiconcap_32_pb_data, wsiconcap_48_pb_data, wsiconcap_64_pb_data);
@@ -1535,11 +1538,11 @@ main_capture_cb_capture_prepared(capture_options *capture_opts)
}
static void
-main_capture_cb_capture_update_started(capture_options *capture_opts)
+main_capture_cb_capture_update_started(capture_session *cap_session)
{
/* We've done this in "prepared" above, but it will be cleared while
switching to the next multiple file. */
- set_titlebar_for_capture_in_progress((capture_file *)capture_opts->cf);
+ set_titlebar_for_capture_in_progress((capture_file *)cap_session->cf);
main_set_for_capture_in_progress(TRUE);
set_capture_if_dialog_for_capture_in_progress(TRUE);
@@ -1553,9 +1556,9 @@ main_capture_cb_capture_update_started(capture_options *capture_opts)
}
static void
-main_capture_cb_capture_update_finished(capture_options *capture_opts)
+main_capture_cb_capture_update_finished(capture_session *cap_session)
{
- capture_file *cf = (capture_file *)capture_opts->cf;
+ capture_file *cf = (capture_file *)cap_session->cf;
static GList *icon_list = NULL;
/* The capture isn't stopping any more - it's stopped. */
@@ -1593,17 +1596,17 @@ main_capture_cb_capture_update_finished(capture_options *capture_opts)
}
static void
-main_capture_cb_capture_fixed_started(capture_options *capture_opts _U_)
+main_capture_cb_capture_fixed_started(capture_session *cap_session _U_)
{
/* Don't set up main window for a capture file. */
main_set_for_capture_file(FALSE);
}
static void
-main_capture_cb_capture_fixed_finished(capture_options *capture_opts _U_)
+main_capture_cb_capture_fixed_finished(capture_session *cap_session _U_)
{
#if 0
- capture_file *cf = capture_opts->cf;
+ capture_file *cf = (capture_file *)cap_session->cf;
#endif
static GList *icon_list = NULL;
@@ -1637,7 +1640,7 @@ main_capture_cb_capture_fixed_finished(capture_options *capture_opts _U_)
}
static void
-main_capture_cb_capture_stopping(capture_options *capture_opts _U_)
+main_capture_cb_capture_stopping(capture_session *cap_session _U_)
{
capture_stopping = TRUE;
set_menus_for_capture_stopping();
@@ -1649,7 +1652,7 @@ main_capture_cb_capture_stopping(capture_options *capture_opts _U_)
}
static void
-main_capture_cb_capture_failed(capture_options *capture_opts _U_)
+main_capture_cb_capture_failed(capture_session *cap_session _U_)
{
static GList *icon_list = NULL;
@@ -1813,7 +1816,7 @@ main_cf_callback(gint event, gpointer data, gpointer user_data _U_)
#ifdef HAVE_LIBPCAP
static void
-main_capture_callback(gint event, capture_options *capture_opts, gpointer user_data _U_)
+main_capture_callback(gint event, capture_session *cap_session, gpointer user_data _U_)
{
#ifdef HAVE_GTKOSXAPPLICATION
GtkosxApplication *theApp;
@@ -1821,11 +1824,11 @@ main_capture_callback(gint event, capture_options *capture_opts, gpointer user_d
switch(event) {
case(capture_cb_capture_prepared):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture prepared");
- main_capture_cb_capture_prepared(capture_opts);
+ main_capture_cb_capture_prepared(cap_session);
break;
case(capture_cb_capture_update_started):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update started");
- main_capture_cb_capture_update_started(capture_opts);
+ main_capture_cb_capture_update_started(cap_session);
#ifdef HAVE_GTKOSXAPPLICATION
theApp = (GtkosxApplication *)g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
gtkosx_application_set_dock_icon_pixbuf(theApp, gdk_pixbuf_new_from_inline(-1, wsiconcap_48_pb_data, FALSE, NULL));
@@ -1836,18 +1839,18 @@ main_capture_callback(gint event, capture_options *capture_opts, gpointer user_d
break;
case(capture_cb_capture_update_finished):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update finished");
- main_capture_cb_capture_update_finished(capture_opts);
+ main_capture_cb_capture_update_finished(cap_session);
break;
case(capture_cb_capture_fixed_started):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed started");
- main_capture_cb_capture_fixed_started(capture_opts);
+ main_capture_cb_capture_fixed_started(cap_session);
break;
case(capture_cb_capture_fixed_continue):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed continue");
break;
case(capture_cb_capture_fixed_finished):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture fixed finished");
- main_capture_cb_capture_fixed_finished(capture_opts);
+ main_capture_cb_capture_fixed_finished(cap_session);
break;
case(capture_cb_capture_stopping):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture stopping");
@@ -1857,11 +1860,11 @@ main_capture_callback(gint event, capture_options *capture_opts, gpointer user_d
theApp = (GtkosxApplication *)g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
gtkosx_application_set_dock_icon_pixbuf(theApp, gdk_pixbuf_new_from_inline(-1, wsicon_64_pb_data, FALSE, NULL));
#endif
- main_capture_cb_capture_stopping(capture_opts);
+ main_capture_cb_capture_stopping(cap_session);
break;
case(capture_cb_capture_failed):
g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture failed");
- main_capture_cb_capture_failed(capture_opts);
+ main_capture_cb_capture_failed(cap_session);
break;
default:
g_warning("main_capture_callback: event %u unknown", event);
@@ -2476,7 +2479,9 @@ main(int argc, char *argv[])
/* Set the initial values in the capture options. This might be overwritten
by preference settings and then again by the command line parameters. */
- capture_opts_init(&global_capture_opts, &cfile);
+ capture_opts_init(&global_capture_opts);
+
+ capture_session_init(&global_capture_session, (void *)&cfile);
#endif
/* Initialize whatever we need to allocate colors for GTK+ */
@@ -3131,7 +3136,7 @@ main(int argc, char *argv[])
to use for this capture. */
if (global_capture_opts.ifaces->len == 0)
collect_ifaces(&global_capture_opts);
- if (capture_start(&global_capture_opts)) {
+ if (capture_start(&global_capture_opts, &global_capture_session)) {
/* The capture started. Open stat windows; we do so after creating
the main window, to avoid GTK warnings, and after successfully
opening the capture file, so we know we have something to compute
diff --git a/ui/gtk/main_80211_toolbar.c b/ui/gtk/main_80211_toolbar.c
index 5cfcb3a599..6f26ee07ea 100644
--- a/ui/gtk/main_80211_toolbar.c
+++ b/ui/gtk/main_80211_toolbar.c
@@ -45,6 +45,7 @@
#include "ui/gtk/old-gtk-compat.h"
#include <ws80211_utils.h>
+#include "capture_session.h"
#include "capture_sync.h"
static GtkWidget *tb80211_tb, *tb80211_iface_list_box, *tb80211_freq_list_box, *tb80211_chan_type_box, *tb80211_info_label;
diff --git a/ui/gtk/main_statusbar.c b/ui/gtk/main_statusbar.c
index 8c8866c5df..c3bff4781f 100644
--- a/ui/gtk/main_statusbar.c
+++ b/ui/gtk/main_statusbar.c
@@ -40,6 +40,7 @@
#include "../file.h"
#ifdef HAVE_LIBPCAP
#include "../capture_opts.h"
+#include "../capture_session.h"
#include "../capture_ui_utils.h"
#include "../capture.h"
#endif
@@ -771,7 +772,7 @@ statusbar_cf_file_read_finished_cb(capture_file *cf)
#ifdef HAVE_LIBPCAP
static void
-statusbar_capture_prepared_cb(capture_options *capture_opts _U_)
+statusbar_capture_prepared_cb(capture_session *cap_session _U_)
{
static const gchar msg[] = " Waiting for capture input data ...";
statusbar_push_file_msg(msg);
@@ -808,8 +809,9 @@ statusbar_get_interface_names(capture_options *capture_opts)
}
static void
-statusbar_capture_update_started_cb(capture_options *capture_opts)
+statusbar_capture_update_started_cb(capture_session *cap_session)
{
+ capture_options *capture_opts = cap_session->capture_opts;
GString *interface_names;
statusbar_pop_file_msg();
@@ -825,10 +827,11 @@ statusbar_capture_update_started_cb(capture_options *capture_opts)
}
static void
-statusbar_capture_update_continue_cb(capture_options *capture_opts)
+statusbar_capture_update_continue_cb(capture_session *cap_session)
{
GString *interface_names;
- capture_file *cf = (capture_file *)capture_opts->cf;
+ capture_options *capture_opts = cap_session->capture_opts;
+ capture_file *cf = (capture_file *)cap_session->cf;
status_expert_update();
@@ -855,9 +858,9 @@ statusbar_capture_update_continue_cb(capture_options *capture_opts)
}
static void
-statusbar_capture_update_finished_cb(capture_options *capture_opts)
+statusbar_capture_update_finished_cb(capture_session *cap_session)
{
- capture_file *cf = (capture_file *)capture_opts->cf;
+ capture_file *cf = (capture_file *)cap_session->cf;
/* Pop the "<live capture in progress>" message off the status bar. */
statusbar_pop_file_msg();
@@ -866,8 +869,9 @@ statusbar_capture_update_finished_cb(capture_options *capture_opts)
}
static void
-statusbar_capture_fixed_started_cb(capture_options *capture_opts)
+statusbar_capture_fixed_started_cb(capture_session *cap_session)
{
+ capture_options *capture_opts = cap_session->capture_opts;
GString *interface_names;
statusbar_pop_file_msg();
@@ -882,9 +886,9 @@ statusbar_capture_fixed_started_cb(capture_options *capture_opts)
}
static void
-statusbar_capture_fixed_continue_cb(capture_options *capture_opts)
+statusbar_capture_fixed_continue_cb(capture_session *cap_session)
{
- capture_file *cf = (capture_file *)capture_opts->cf;
+ capture_file *cf = (capture_file *)cap_session->cf;
gchar *capture_msg;
@@ -896,10 +900,10 @@ statusbar_capture_fixed_continue_cb(capture_options *capture_opts)
static void
-statusbar_capture_fixed_finished_cb(capture_options *capture_opts _U_)
+statusbar_capture_fixed_finished_cb(capture_session *cap_session _U_)
{
#if 0
- capture_file *cf = capture_opts->cf;
+ capture_file *cf = (capture_file *)cap_session->cf;
#endif
/* Pop the "<live capture in progress>" message off the status bar. */
@@ -911,10 +915,10 @@ statusbar_capture_fixed_finished_cb(capture_options *capture_opts _U_)
}
static void
-statusbar_capture_failed_cb(capture_options *capture_opts _U_)
+statusbar_capture_failed_cb(capture_session *cap_session _U_)
{
#if 0
- capture_file *cf = capture_opts->cf;
+ capture_file *cf = (capture_file *)cap_session->cf;
#endif
/* Pop the "<live capture in progress>" message off the status bar. */
@@ -1062,37 +1066,37 @@ statusbar_cf_callback(gint event, gpointer data, gpointer user_data _U_)
#ifdef HAVE_LIBPCAP
void
-statusbar_capture_callback(gint event, capture_options *capture_opts,
+statusbar_capture_callback(gint event, capture_session *cap_session,
gpointer user_data _U_)
{
switch(event) {
case(capture_cb_capture_prepared):
- statusbar_capture_prepared_cb(capture_opts);
+ statusbar_capture_prepared_cb(cap_session);
break;
case(capture_cb_capture_update_started):
- statusbar_capture_update_started_cb(capture_opts);
+ statusbar_capture_update_started_cb(cap_session);
break;
case(capture_cb_capture_update_continue):
- statusbar_capture_update_continue_cb(capture_opts);
+ statusbar_capture_update_continue_cb(cap_session);
break;
case(capture_cb_capture_update_finished):
- statusbar_capture_update_finished_cb(capture_opts);
+ statusbar_capture_update_finished_cb(cap_session);
break;
case(capture_cb_capture_fixed_started):
- statusbar_capture_fixed_started_cb(capture_opts);
+ statusbar_capture_fixed_started_cb(cap_session);
break;
case(capture_cb_capture_fixed_continue):
- statusbar_capture_fixed_continue_cb(capture_opts);
+ statusbar_capture_fixed_continue_cb(cap_session);
break;
case(capture_cb_capture_fixed_finished):
- statusbar_capture_fixed_finished_cb(capture_opts);
+ statusbar_capture_fixed_finished_cb(cap_session);
break;
case(capture_cb_capture_stopping):
/* Beware: this state won't be called, if the capture child
* closes the capturing on its own! */
break;
case(capture_cb_capture_failed):
- statusbar_capture_failed_cb(capture_opts);
+ statusbar_capture_failed_cb(cap_session);
break;
default:
g_warning("statusbar_capture_callback: event %u unknown", event);
diff --git a/ui/gtk/main_statusbar_private.h b/ui/gtk/main_statusbar_private.h
index 5dc1d93ad0..e4fbe7b99f 100644
--- a/ui/gtk/main_statusbar_private.h
+++ b/ui/gtk/main_statusbar_private.h
@@ -34,7 +34,7 @@ void statusbar_widgets_pack(GtkWidget *statusbar);
void statusbar_widgets_show_or_hide(GtkWidget *statusbar);
void statusbar_cf_callback(gint event, gpointer data, gpointer user_data);
#ifdef HAVE_LIBPCAP
-void statusbar_capture_callback(gint event, capture_options *capture_opts,
+void statusbar_capture_callback(gint event, capture_session *cap_session,
gpointer user_data);
#endif
diff --git a/ui/iface_lists.c b/ui/iface_lists.c
index 4483033374..aec2e91ecf 100644
--- a/ui/iface_lists.c
+++ b/ui/iface_lists.c
@@ -39,8 +39,6 @@
#include "ui/capture_globals.h"
#include "ui/iface_lists.h"
-capture_options global_capture_opts;
-
/*
* Used when sorting an interface list into alphabetical order by
* their friendly names.
diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp
index 19679a9bb6..c7e356d21e 100644
--- a/ui/qt/main.cpp
+++ b/ui/qt/main.cpp
@@ -811,7 +811,9 @@ int main(int argc, char *argv[])
/* Set the initial values in the capture options. This might be overwritten
by preference settings and then again by the command line parameters. */
- capture_opts_init(&global_capture_opts, &cfile);
+ capture_opts_init(&global_capture_opts);
+
+ capture_session_init(&global_capture_session, (void *)&cfile);
#endif
/* Register all dissectors; we must do this before checking for the