Get rid of has_cfilter to simplify the handling of multiple interfaces.

svn path=/trunk/; revision=37478
This commit is contained in:
Michael Tüxen 2011-05-31 14:49:21 +00:00
parent 6516aa9864
commit 8f8f0e9ad6
5 changed files with 7 additions and 11 deletions

View File

@ -56,13 +56,13 @@ void
capture_opts_init(capture_options *capture_opts, void *cf)
{
capture_opts->cf = cf;
capture_opts->cfilter = g_strdup(""); /* No capture filter string specified */
capture_opts->cfilter = NULL; /* No capture filter string specified */
capture_opts->iface = NULL; /* Default is "pick the first interface" */
capture_opts->iface_descr = NULL;
capture_opts->ifaces = g_array_new(FALSE, FALSE, sizeof(interface_options));
capture_opts->default_options.name = NULL;
capture_opts->default_options.descr = NULL;
capture_opts->default_options.cfilter = g_strdup("");
capture_opts->default_options.cfilter = NULL;
capture_opts->default_options.snaplen = WTAP_MAX_PACKET_SIZE;
capture_opts->default_options.linktype = -1;
capture_opts->default_options.promisc_mode = TRUE;
@ -658,7 +658,6 @@ capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg_
capture_opts->autostop_packets = get_positive_int(optarg_str_p, "packet count");
break;
case 'f': /* capture filter */
capture_opts->has_cfilter = TRUE;
g_free(capture_opts->cfilter);
capture_opts->cfilter = g_strdup(optarg_str_p);
if (capture_opts->ifaces->len > 0) {

View File

@ -105,7 +105,6 @@ typedef struct interface_options_tag {
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
*< XXX: Can finally be be removed.
*< Replaced by interface_options.cfilter */

View File

@ -2518,7 +2518,7 @@ capture_loop_init_output(capture_options *capture_opts, loop_data *ld, char *err
}
successful = libpcap_write_interface_description_block(ld->pdh,
interface_opts.name,
interface_opts.cfilter,
interface_opts.cfilter?interface_opts.cfilter:"",
pcap_opts->linktype,
pcap_opts->snaplen,
&ld->bytes_written,
@ -2947,7 +2947,7 @@ do_file_switch_or_stop(capture_options *capture_opts,
pcap_opts = g_array_index(global_ld.pcaps, pcap_options *, i);
successful = libpcap_write_interface_description_block(global_ld.pdh,
interface_opts.name,
interface_opts.cfilter,
interface_opts.cfilter?interface_opts.cfilter:"",
pcap_opts->linktype,
pcap_opts->snaplen,
&(global_ld.bytes_written),

View File

@ -2956,8 +2956,7 @@ 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 && strlen(global_capture_opts.cfilter) == 0) {
g_free(global_capture_opts.cfilter);
if (!start_capture && !global_capture_opts.cfilter) {
global_capture_opts.cfilter = g_strdup(get_conn_cfilter());
}
#else /* HAVE_LIBPCAP */

View File

@ -1386,12 +1386,11 @@ main(int argc, char *argv[])
rfilter = get_args_as_string(argc, argv, optind);
} else {
#ifdef HAVE_LIBPCAP
if (global_capture_opts.has_cfilter) {
if (global_capture_opts.cfilter) {
cmdarg_err("Capture filters were specified both with \"-f\""
" and with additional command-line arguments");
return 1;
}
global_capture_opts.has_cfilter = TRUE;
global_capture_opts.cfilter = get_args_as_string(argc, argv, optind);
#else
capture_option_specified = TRUE;
@ -1438,7 +1437,7 @@ main(int argc, char *argv[])
support in capture files we read). */
#ifdef HAVE_LIBPCAP
if (cf_name != NULL) {
if (global_capture_opts.has_cfilter) {
if (global_capture_opts.cfilter) {
cmdarg_err("Only read filters, not capture filters, "
"can be specified when reading a capture file.");
return 1;