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;
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) {
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 */
}
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,
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),
}
/* 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 */
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;
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;