aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--capture.c35
-rw-r--r--capture.h4
-rw-r--r--gtk/main.c33
3 files changed, 42 insertions, 30 deletions
diff --git a/capture.c b/capture.c
index 49a0f547e8..229ddf84c0 100644
--- a/capture.c
+++ b/capture.c
@@ -79,6 +79,41 @@ static gboolean normal_do_capture(capture_options *capture_opts, gboolean is_tem
static void stop_capture_signal_handler(int signo);
+void
+capture_opts_init(capture_options *capture_opts, void *cfile)
+{
+ capture_opts->cf = cfile;
+#ifdef _WIN32
+ capture_opts->buffer_size = 1; /* 1 MB */
+#endif
+ capture_opts->has_snaplen = FALSE;
+ capture_opts->snaplen = MIN_PACKET_SIZE;
+ capture_opts->promisc_mode = TRUE;
+ capture_opts->linktype = -1; /* the default linktype */
+ capture_opts->capture_child = FALSE;
+ capture_opts->save_file = NULL;
+ capture_opts->save_file_fd = -1;
+ capture_opts->sync_mode = TRUE;
+ capture_opts->show_info = TRUE;
+ capture_opts->quit_after_cap = FALSE;
+
+ capture_opts->multi_files_on = FALSE;
+ capture_opts->has_file_duration = FALSE;
+ capture_opts->file_duration = 60; /* 1 min */
+ capture_opts->has_ring_num_files = TRUE;
+ capture_opts->ring_num_files = 2;
+
+ capture_opts->has_autostop_files = FALSE;
+ capture_opts->autostop_files = 1;
+ capture_opts->has_autostop_packets = FALSE;
+ capture_opts->autostop_packets = 1;
+ capture_opts->has_autostop_filesize = FALSE;
+ capture_opts->autostop_filesize = 1024 * 1024; /* 1 MB */
+ capture_opts->has_autostop_duration = FALSE;
+ capture_opts->autostop_duration = 60; /* 1 min */
+}
+
+
/* open the output file (temporary/specified name/ringbuffer) and close the old one */
/* Returns TRUE if the file opened successfully, FALSE otherwise. */
static gboolean
diff --git a/capture.h b/capture.h
index 6beeac44c3..fb847104e8 100644
--- a/capture.h
+++ b/capture.h
@@ -85,6 +85,10 @@ typedef struct capture_options_tag {
} capture_options;
+/* initialize the capture_options with some reasonable values */
+extern void
+capture_opts_init(capture_options *capture_opts, void *cfile);
+
/**
* Open a specified file, or create a temporary file, and start a capture
* to the file in question.
diff --git a/gtk/main.c b/gtk/main.c
index b273f3748d..08173592d2 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1570,31 +1570,8 @@ main(int argc, char *argv[])
}
#endif
- capture_opts->cf = &cfile;
#ifdef HAVE_LIBPCAP
- capture_opts->has_snaplen = FALSE;
- capture_opts->snaplen = MIN_PACKET_SIZE;
- capture_opts->linktype = -1;
-#ifdef _WIN32
- capture_opts->buffer_size = 1;
-#endif
- capture_opts->save_file_fd = -1;
- capture_opts->quit_after_cap = FALSE;
-
- capture_opts->has_autostop_packets = FALSE;
- capture_opts->autostop_packets = 1;
- capture_opts->has_autostop_duration = FALSE;
- capture_opts->autostop_duration = 60 /* 1 min */;
- capture_opts->has_autostop_filesize = FALSE;
- capture_opts->autostop_filesize = 1024 * 1024 /* 1 MB */;
- capture_opts->has_autostop_files = FALSE;
- capture_opts->autostop_files = 1;
-
- capture_opts->multi_files_on = FALSE;
- capture_opts->has_ring_num_files = TRUE;
- capture_opts->ring_num_files = 2;
- capture_opts->has_file_duration = FALSE;
- capture_opts->file_duration = 60 /* 1 min */;
+ capture_opts_init(capture_opts, &cfile);
/* If this is a capture child process, it should pay no attention
to the "prefs.capture_prom_mode" setting in the preferences file;
@@ -1604,12 +1581,8 @@ main(int argc, char *argv[])
Otherwise, set promiscuous mode from the preferences setting. */
/* the same applies to other preferences settings as well. */
- if (capture_opts->capture_child) {
- capture_opts->promisc_mode = TRUE; /* maybe changed by command line below */
- capture_opts->show_info = TRUE; /* maybe changed by command line below */
- capture_opts->sync_mode = TRUE; /* always true in child process */
- auto_scroll_live = FALSE; /* doesn't matter in child process */
-
+ if (!capture_opts->capture_child) {
+ auto_scroll_live = FALSE;
} else {
capture_opts->promisc_mode = prefs->capture_prom_mode;
capture_opts->show_info = prefs->capture_show_info;