aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--capture_loop.c8
-rw-r--r--capture_opts.c5
-rw-r--r--capture_opts.h77
-rw-r--r--gtk/main.c6
-rw-r--r--tshark.c13
5 files changed, 47 insertions, 62 deletions
diff --git a/capture_loop.c b/capture_loop.c
index 5957ec2f51..0d62461e67 100644
--- a/capture_loop.c
+++ b/capture_loop.c
@@ -1112,14 +1112,6 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
ld.packet_cb = capture_loop_packet_cb;
- /*
- * Some older Linux versions of libpcap don't work right without
- * a capture filter; if none was specified, use an empty string.
- * (Yes, that's a libpcap bug, and has been fixed for a while.)
- */
- if (capture_opts->cfilter == NULL)
- capture_opts->cfilter = g_strdup("");
-
/* We haven't yet gotten the capture statistics. */
*stats_known = FALSE;
diff --git a/capture_opts.c b/capture_opts.c
index 28d9488f99..70bccc2d6f 100644
--- a/capture_opts.c
+++ b/capture_opts.c
@@ -52,7 +52,7 @@ void
capture_opts_init(capture_options *capture_opts, void *cfile)
{
capture_opts->cf = cfile;
- capture_opts->cfilter = NULL; /* No capture filter string specified */
+ capture_opts->cfilter = g_strdup(""); /* No capture filter string specified */
capture_opts->iface = NULL; /* Default is "pick the first interface" */
#ifdef _WIN32
capture_opts->buffer_size = 1; /* 1 MB */
@@ -325,10 +325,11 @@ capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg,
capture_opts->autostop_packets = get_positive_int(optarg, "packet count");
break;
case 'f': /* capture filter */
- if (capture_opts->cfilter) {
+ if (capture_opts->has_cfilter) {
cmdarg_err("More than one -f argument specified");
return 1;
}
+ capture_opts->has_cfilter = TRUE;
capture_opts->cfilter = g_strdup(optarg);
break;
case 'H': /* Hide capture info dialog box */
diff --git a/capture_opts.h b/capture_opts.h
index 3f88ebe791..ed797e6ea7 100644
--- a/capture_opts.h
+++ b/capture_opts.h
@@ -44,58 +44,59 @@ typedef enum {
/** Capture options coming from user interface */
typedef struct capture_options_tag {
/* general */
- void *cf; /**< handle to cfile (note: untyped handle) */
- gchar *cfilter; /**< Capture filter string */
- gchar *iface; /**< the network interface to capture from */
+ void *cf; /**< handle to cfile (note: untyped handle) */
+ gboolean has_cfilter; /**< TRUE if capture filter specified on command line */
+ gchar *cfilter; /**< Capture filter string */
+ gchar *iface; /**< the network interface to capture from */
#ifdef _WIN32
- int buffer_size; /**< the capture buffer size (MB) */
+ int buffer_size; /**< the capture buffer size (MB) */
#endif
- gboolean has_snaplen; /**< TRUE if maximum capture packet length
- is specified */
- int snaplen; /**< Maximum captured packet length */
- gboolean promisc_mode; /**< Capture in promiscuous mode */
- int linktype; /**< Data link type to use, or -1 for
- "use default" */
- gboolean saving_to_file; /**< TRUE if capture is writing to a file */
- gchar *save_file; /**< the capture file name */
+ gboolean has_snaplen; /**< TRUE if maximum capture packet length
+ is specified */
+ int snaplen; /**< Maximum captured packet length */
+ gboolean promisc_mode; /**< Capture in promiscuous mode */
+ int linktype; /**< Data link type to use, or -1 for
+ "use default" */
+ gboolean saving_to_file; /**< TRUE if capture is writing to a file */
+ gchar *save_file; /**< the capture file name */
/* GUI related */
- gboolean real_time_mode; /**< Update list of packets in real time */
- gboolean show_info; /**< show the info dialog */
- gboolean quit_after_cap; /** Makes a "capture only mode". Implies -k */
- gboolean restart; /**< restart after closing is done */
+ gboolean real_time_mode; /**< Update list of packets in real time */
+ gboolean show_info; /**< show the info dialog */
+ gboolean quit_after_cap; /**< Makes a "capture only mode". Implies -k */
+ gboolean restart; /**< restart after closing is done */
/* multiple files (and ringbuffer) */
- gboolean multi_files_on; /**< TRUE if ring buffer in use */
+ gboolean multi_files_on; /**< TRUE if ring buffer in use */
- gboolean has_file_duration; /**< TRUE if ring duration specified */
- gint32 file_duration; /* Switch file after n seconds */
- gboolean has_ring_num_files;/**< TRUE if ring num_files specified */
- guint32 ring_num_files; /**< Number of multiple buffer files */
+ gboolean has_file_duration; /**< TRUE if ring duration specified */
+ gint32 file_duration; /**< Switch file after n seconds */
+ gboolean has_ring_num_files; /**< TRUE if ring num_files specified */
+ guint32 ring_num_files; /**< Number of multiple buffer files */
/* autostop conditions */
- gboolean has_autostop_files;/**< TRUE if maximum number of capture files
- are specified */
- gint32 autostop_files; /**< Maximum number of capture files */
-
- gboolean has_autostop_packets; /**< TRUE if maximum packet count is
- specified */
- int autostop_packets; /**< Maximum packet count */
- gboolean has_autostop_filesize; /**< TRUE if maximum capture file size
- is specified */
- gint32 autostop_filesize; /**< Maximum capture file size */
- gboolean has_autostop_duration; /**< TRUE if maximum capture duration
- is specified */
- gint32 autostop_duration; /**< Maximum capture duration */
+ gboolean has_autostop_files; /**< TRUE if maximum number of capture files
+ are specified */
+ gint32 autostop_files; /**< Maximum number of capture files */
+
+ gboolean has_autostop_packets; /**< TRUE if maximum packet count is
+ specified */
+ int autostop_packets; /**< Maximum packet count */
+ gboolean has_autostop_filesize; /**< TRUE if maximum capture file size
+ is specified */
+ gint32 autostop_filesize; /**< Maximum capture file size */
+ gboolean has_autostop_duration; /**< TRUE if maximum capture duration
+ is specified */
+ 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; /**< If not -1, in parent, process ID of child */
#ifdef _WIN32
- int signal_pipe_write_fd; /**< the pipe to signal the child */
+ 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) */
+ capture_state state; /**< current state of the capture engine */
+ gboolean output_to_pipe; /**< save_file is a pipe (named or stdout) */
} capture_options;
diff --git a/gtk/main.c b/gtk/main.c
index 5849411eb8..81de778d00 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -2880,10 +2880,8 @@ main(int argc, char *argv[])
}
/* if the user didn't supplied a capture filter, use the one to filter out remote connections like SSH */
- if (!start_capture && (capture_opts->cfilter == NULL || strlen(capture_opts->cfilter) == 0)) {
- if (capture_opts->cfilter) {
- g_free(capture_opts->cfilter);
- }
+ if (!start_capture && strlen(capture_opts->cfilter) == 0) {
+ g_free(capture_opts->cfilter);
capture_opts->cfilter = g_strdup(get_conn_cfilter());
}
#else /* HAVE_LIBPCAP */
diff --git a/tshark.c b/tshark.c
index ddb5bce457..cb86cd11ac 100644
--- a/tshark.c
+++ b/tshark.c
@@ -1103,11 +1103,12 @@ main(int argc, char *argv[])
rfilter = get_args_as_string(argc, argv, optind);
} else {
#ifdef HAVE_LIBPCAP
- if (capture_opts.cfilter != NULL) {
+ if (capture_opts.has_cfilter) {
cmdarg_err("Capture filters were specified both with \"-f\""
" and with additional command-line arguments");
exit(1);
}
+ capture_opts.has_cfilter = TRUE;
capture_opts.cfilter = get_args_as_string(argc, argv, optind);
#else
capture_option_specified = TRUE;
@@ -1147,7 +1148,7 @@ main(int argc, char *argv[])
support in capture files we read). */
#ifdef HAVE_LIBPCAP
if (cf_name != NULL) {
- if (capture_opts.cfilter != NULL) {
+ if (capture_opts.has_cfilter) {
cmdarg_err("Only read filters, not capture filters, "
"can be specified when reading a capture file.");
exit(1);
@@ -1561,14 +1562,6 @@ capture(void)
*/
relinquish_special_privs_perm();
- /*
- * Some older Linux versions of libpcap don't work right without
- * a capture filter; if none was specified, use an empty string.
- * (Yes, that's a libpcap bug, and has been fixed for a while.)
- */
- if (capture_opts.cfilter == NULL)
- capture_opts.cfilter = g_strdup("");
-
/* init the input filter from the network interface (capture pipe will do nothing) */
switch (capture_loop_init_filter(ld.pcap_h, ld.from_cap_pipe, capture_opts.iface, capture_opts.cfilter)) {