forked from osmocom/wireshark
Go back to setting the capture filter to an empty string when we start;
that obviates the need to check for a null capture filter string, and fixes bug 1055. Keep track of whether it was set from the command line, though, so we can catch attempts to set the filter more than once, and attempts to set it when we're not capturing. Clean up white space. svn path=/trunk/; revision=19047
This commit is contained in:
parent
14be5e2bcc
commit
a28b428aff
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -45,6 +45,7 @@ typedef enum {
|
|||
typedef struct capture_options_tag {
|
||||
/* general */
|
||||
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 */
|
||||
|
||||
|
@ -63,14 +64,14 @@ typedef struct capture_options_tag {
|
|||
/* 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 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 has_file_duration; /**< TRUE if ring duration specified */
|
||||
gint32 file_duration; /* Switch file after n seconds */
|
||||
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 */
|
||||
|
||||
|
|
|
@ -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) {
|
||||
if (!start_capture && strlen(capture_opts->cfilter) == 0) {
|
||||
g_free(capture_opts->cfilter);
|
||||
}
|
||||
capture_opts->cfilter = g_strdup(get_conn_cfilter());
|
||||
}
|
||||
#else /* HAVE_LIBPCAP */
|
||||
|
|
13
tshark.c
13
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)) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue