Commit 421dafd2 authored by Michael Tüxen's avatar Michael Tüxen

Get rid of old non-interface specific settings which are now interface

specifc. This finalizes the change of the infrastructure.
This patch is based on work by Irene Ruengeler.

svn path=/trunk/; revision=37794
parent d374df09
......@@ -145,15 +145,10 @@ capture_start(capture_options *capture_opts)
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Start ...");
if (capture_opts->ifaces->len == 0) {
g_string_printf(source, "%s", get_iface_description(capture_opts));
if (capture_opts->cfilter && capture_opts->cfilter[0]) {
g_string_append_printf(source, " (%s)", capture_opts->cfilter);
}
#ifdef _WIN32
} else if (capture_opts->ifaces->len < 2) {
if (capture_opts->ifaces->len < 2) {
#else
} else if (capture_opts->ifaces->len < 4) {
if (capture_opts->ifaces->len < 4) {
#endif
for (i = 0; i < capture_opts->ifaces->len; i++) {
interface_options interface_opts;
......@@ -498,18 +493,23 @@ capture_input_error_message(capture_options *capture_opts, char *error_msg, char
capture filter when starting/running the capture.
*/
void
capture_input_cfilter_error_message(capture_options *capture_opts, char *error_message)
capture_input_cfilter_error_message(capture_options *capture_opts, guint i, char *error_message)
{
dfilter_t *rfcode = NULL;
gchar *safe_cfilter = simple_dialog_format_message(capture_opts->cfilter);
gchar *safe_cfilter_error_msg = simple_dialog_format_message(error_message);
dfilter_t *rfcode = NULL;
gchar *safe_cfilter;
gchar *safe_cfilter_error_msg;
interface_options interface_opts;
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture filter error message from child: \"%s\"", error_message);
g_assert(capture_opts->state == CAPTURE_PREPARING || capture_opts->state == CAPTURE_RUNNING);
g_assert(i < capture_opts->ifaces->len);
interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
safe_cfilter = simple_dialog_format_message(interface_opts.cfilter);
safe_cfilter_error_msg = simple_dialog_format_message(error_message);
/* Did the user try a display filter? */
if (dfilter_compile(capture_opts->cfilter, &rfcode) && rfcode != NULL) {
if (dfilter_compile(interface_opts.cfilter, &rfcode) && rfcode != NULL) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"%sInvalid capture filter: \"%s\"!%s\n"
"\n"
......
......@@ -94,7 +94,7 @@ extern void capture_input_error_message(capture_options *capture_opts, char *err
* Capture child told us that an error has occurred while parsing a
* capture filter when starting/running the capture.
*/
extern void capture_input_cfilter_error_message(capture_options *capture_opts, char *error_message);
extern void capture_input_cfilter_error_message(capture_options *capture_opts, guint i, char *error_message);
/**
* Capture child closed its side of the pipe, report any error and
......
This diff is collapsed.
......@@ -77,6 +77,7 @@ typedef struct interface_options_tag {
gchar *name;
gchar *descr;
gchar *cfilter;
gboolean has_snaplen;
int snaplen;
int linktype;
gboolean promisc_mode;
......@@ -105,68 +106,9 @@ typedef struct interface_options_tag {
typedef struct capture_options_tag {
/* general */
void *cf; /**< handle to cfile (note: untyped handle) */
gchar *cfilter; /**< Capture filter string
*< XXX: Can finally be be removed.
*< Replaced by interface_options.cfilter */
gchar *iface; /**< the network interface to capture from
*< XXX: Can finally be be removed.
*< Replaced by interface_options.name */
gchar *iface_descr; /**< A human readable description of iface.
*< NOTE: capture_opts.c is not able to
*< set this field because doing so
*< requires too many dependencies.
*< Readers of this field should use
*< get_iface_description() from
*< "capture_ui_utils.h" to access it.
*< XXX: Can finally be be removed.
*< Replaced by interface_options.descr */
GArray *ifaces; /**< array of interfaces.
Currently only used by dumpcap. */
interface_options default_options;
#ifdef HAVE_PCAP_REMOTE
/**< XXX: Should this whole block moved to
*< interface_options ? Yes!*/
capture_source src_type; /**< Capturing on remote interface */
gchar *remote_host; /**< Host name or network address
*< for remote capturing */
gchar *remote_port; /**< TCP port of remote RPCAP server */
capture_auth auth_type;
gchar *auth_username;
gchar *auth_password; /**< Remote authentication parameters */
gboolean datatx_udp; /**< Whether to use UDP for data transfer */
gboolean nocap_rpcap; /**< Whether to capture RPCAP own traffic */
gboolean nocap_local; /**< TODO: Whether to capture local traffic */
#endif
#ifdef HAVE_PCAP_SETSAMPLING
capture_sampling sampling_method; /**< PCAP packet sampling method
*< XXX: Can finally be be removed.
*< Replaced by interface_options.sampling_method */
int sampling_param; /**< PCAP packet sampling parameter
*< XXX: Can finally be be removed.
*< Replaced by interface_options.sampling_param */
#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
int buffer_size; /**< the capture buffer size (MB)
*< XXX: Can finally be be removed.
*< Replaced by interface_options.buffer_size */
#endif
gboolean has_snaplen; /**< TRUE if maximum capture packet length
is specified */
int snaplen; /**< Maximum captured packet length
*< XXX: Can finally be be removed.
*< Replaced by interface_options.snaplen */
gboolean promisc_mode; /**< Capture in promiscuous mode
*< XXX: Can finally be be removed.
*< Replaced by interface_options.promisc_mode */
int linktype; /**< Data link type to use, or -1 for
"use default"
*< XXX: Can finally be be removed.
*< Replaced by interface_options.linktype */
gboolean monitor_mode; /**< Capture in monitor mode, if available
*< XXX: Can finally be be removed.
*< Replaced by interface_options.monitor_mode */
gboolean saving_to_file; /**< TRUE if capture is writing to a file */
gchar *save_file; /**< the capture file name */
gboolean group_read_access; /**< TRUE is group read permission needs to be set */
......
......@@ -361,7 +361,6 @@ sync_pipe_start(capture_options *capture_opts) {
int i;
guint j;
interface_options interface_opts;
gboolean no_ifaces;
if (capture_opts->ifaces->len > 1)
capture_opts->use_pcapng = TRUE;
......@@ -428,57 +427,6 @@ sync_pipe_start(capture_options *capture_opts) {
g_snprintf(sautostop_duration, ARGV_NUMBER_LEN, "duration:%d",capture_opts->autostop_duration);
argv = sync_pipe_add_arg(argv, &argc, sautostop_duration);
}
if (capture_opts->ifaces->len == 0) {
no_ifaces = TRUE;
interface_opts.name = g_strdup(capture_opts->iface);
if (capture_opts->iface_descr) {
interface_opts.descr = g_strdup(capture_opts->iface_descr);
} else {
interface_opts.descr = NULL;
}
interface_opts.cfilter = g_strdup(capture_opts->cfilter);
interface_opts.snaplen = capture_opts->snaplen;
interface_opts.linktype = capture_opts->linktype;
interface_opts.promisc_mode = capture_opts->promisc_mode;
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
interface_opts.buffer_size = capture_opts->buffer_size;
#endif
interface_opts.monitor_mode = capture_opts->monitor_mode;
#ifdef HAVE_PCAP_REMOTE
interface_opts.src_type = capture_opts->src_type;
if (capture_opts->remote_host) {
interface_opts.remote_host = g_strdup(capture_opts->remote_host);
} else {
interface_opts.remote_host = NULL;
}
if (capture_opts->remote_port) {
interface_opts.remote_port = g_strdup(capture_opts->remote_port);
} else {
interface_opts.remote_port = NULL;
}
interface_opts.auth_type = capture_opts->auth_type;
if (capture_opts->auth_username) {
interface_opts.auth_username = g_strdup(capture_opts->auth_username);
} else {
interface_opts.auth_username = NULL;
}
if (capture_opts->auth_password) {
interface_opts.auth_password = g_strdup(capture_opts->auth_password);
} else {
interface_opts.auth_password = NULL;
}
interface_opts.datatx_udp = capture_opts->datatx_udp;
interface_opts.nocap_rpcap = capture_opts->nocap_rpcap;
interface_opts.nocap_local = capture_opts->nocap_local;
#endif
#ifdef HAVE_PCAP_SETSAMPLING
interface_opts.sampling_method = capture_opts->sampling_method;
interface_opts.sampling_param = capture_opts->sampling_param;
#endif
g_array_append_val(capture_opts->ifaces, interface_opts);
} else {
no_ifaces = FALSE;
}
for (j = 0; j < capture_opts->ifaces->len; j++) {
interface_opts = g_array_index(capture_opts->ifaces, interface_options, j);
......@@ -490,7 +438,12 @@ sync_pipe_start(capture_options *capture_opts) {
argv = sync_pipe_add_arg(argv, &argc, "-f");
argv = sync_pipe_add_arg(argv, &argc, interface_opts.cfilter);
}
if (interface_opts.cfilter == NULL &&
capture_opts->default_options.cfilter != NULL &&
strlen(capture_opts->default_options.cfilter) != 0) {
argv = sync_pipe_add_arg(argv, &argc, "-f");
argv = sync_pipe_add_arg(argv, &argc, capture_opts->default_options.cfilter);
}
if (interface_opts.snaplen != WTAP_MAX_PACKET_SIZE) {
argv = sync_pipe_add_arg(argv, &argc, "-s");
g_snprintf(ssnap, ARGV_NUMBER_LEN, "%d", interface_opts.snaplen);
......@@ -547,9 +500,6 @@ sync_pipe_start(capture_options *capture_opts) {
}
#endif
}
if (no_ifaces) {
capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, 0);
}
/* dumpcap should be running in capture child mode (hidden feature) */
#ifndef DEBUG_CHILD
......@@ -1674,7 +1624,8 @@ sync_pipe_input_cb(gint source, gpointer user_data)
/* (an error message doesn't mean we have to stop capturing) */
break;
case SP_BAD_FILTER:
capture_input_cfilter_error_message(capture_opts, buffer);
/* FIXME: Indicate the correct index */
capture_input_cfilter_error_message(capture_opts, 0, buffer);
/* the capture child will close the sync_pipe, nothing to do for now */
break;
case SP_DROPS:
......
......@@ -395,33 +395,26 @@ get_if_name(const char *if_text)
return if_name;
}
/* Return capture_opts->iface_descr (after setting it if it is not set)
* This is necessary because capture_opts.c can't set iface_descr (at least
/* Return interface_opts->descr (after setting it if it is not set)
* This is necessary because capture_opts.c can't set descr (at least
* not without adding significant dependencies there).
*/
const char *
get_iface_description(capture_options *capture_opts)
{
if (!capture_opts->iface_descr && capture_opts->iface)
capture_opts->iface_descr = get_interface_descriptive_name(capture_opts->iface);
return(capture_opts->iface_descr);
}
const char *
get_iface_description_for_interface(capture_options *capture_opts, guint i)
{
interface_options interface_opts;
interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
if (!interface_opts.descr && interface_opts.name) {
interface_opts.descr = get_interface_descriptive_name(interface_opts.name);
}
capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, i);
g_array_insert_val(capture_opts->ifaces, i, interface_opts);
return (interface_opts.descr);
interface_options interface_opts;
if (i < capture_opts->ifaces->len) {
interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
if (!interface_opts.descr && interface_opts.name) {
interface_opts.descr = get_interface_descriptive_name(interface_opts.name);
capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, i);
g_array_insert_val(capture_opts->ifaces, i, interface_opts);
}
return (interface_opts.descr);
} else {
return (NULL);
}
}
#endif /* HAVE_LIBPCAP */
......@@ -93,10 +93,10 @@ char *build_capture_combo_name(GList *if_list, gchar *if_name);
/** Return the interface description (after setting it if not already set)
*
* @param capture_opts The capture_options structure that contains the used interface
* @param i The index of the interface
*
* @return A pointer to capture_ops->iface_descr
* @return A pointer to interface_opts->descr
*/
const char *get_iface_description(capture_options *capture_opts);
const char *get_iface_description_for_interface(capture_options *capture_opts, guint i);
#endif
......@@ -3948,9 +3948,6 @@ main(int argc, char *argv[])
by the command line parameters. */
capture_opts_init(&global_capture_opts, NULL);
/* Default to capturing the entire packet. */
global_capture_opts.snaplen = WTAP_MAX_PACKET_SIZE;
/* We always save to a file - if no file was specified, we save to a
temporary file. */
global_capture_opts.saving_to_file = TRUE;
......
This diff is collapsed.
......@@ -139,6 +139,7 @@ static void
capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data)
{
interface_options interface_opts;
cap_settings_t cap_settings;
if_dlg_data_t *if_dlg_data = if_data;
#ifdef HAVE_AIRPCAP
......@@ -146,12 +147,6 @@ capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data)
airpcap_if_selected = airpcap_if_active;
#endif
g_free(global_capture_opts.iface);
g_free(global_capture_opts.iface_descr);
global_capture_opts.iface = g_strdup(if_dlg_data->device);
global_capture_opts.iface_descr = get_interface_descriptive_name(global_capture_opts.iface);
while (global_capture_opts.ifaces->len > 0) {
interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, 0);
global_capture_opts.ifaces = g_array_remove_index(global_capture_opts.ifaces, 0);
......@@ -165,6 +160,34 @@ capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data)
g_free(interface_opts.auth_password);
#endif
}
interface_opts.name = g_strdup(if_dlg_data->device);
interface_opts.descr = get_interface_descriptive_name(interface_opts.name);
cap_settings = capture_get_cap_settings (interface_opts.name);;
interface_opts.monitor_mode = cap_settings.monitor_mode;
interface_opts.linktype = capture_dev_user_linktype_find(interface_opts.name);
interface_opts.cfilter = global_capture_opts.default_options.cfilter;
interface_opts.snaplen = global_capture_opts.default_options.snaplen;
interface_opts.has_snaplen = global_capture_opts.default_options.has_snaplen;
interface_opts.promisc_mode = global_capture_opts.default_options.promisc_mode;
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
interface_opts.buffer_size = global_capture_opts.default_options.buffer_size;
#endif
#ifdef HAVE_PCAP_REMOTE
interface_opts.src_type = global_capture_opts.default_options.src_type;
interface_opts.remote_host = g_strdup(global_capture_opts.default_options.remote_host);
interface_opts.remote_port = g_strdup(global_capture_opts.default_options.remote_port);
interface_opts.auth_type = global_capture_opts.default_options.auth_type;
interface_opts.auth_username = g_strdup(global_capture_opts.default_options.auth_username);
interface_opts.auth_password = g_strdup(global_capture_opts.default_options.auth_password);
interface_opts.datatx_udp = global_capture_opts.default_options.datatx_udp;
interface_opts.nocap_rpcap = global_capture_opts.default_options.nocap_rpcap;
interface_opts.nocap_local = global_capture_opts.default_options.nocap_local;
#endif
#ifdef HAVE_PCAP_SETSAMPLING
interface_opts.sampling_method = global_capture_opts.default_options.sampling_method;
interface_opts.sampling_param = global_capture_opts.default_options.sampling_param;
#endif
g_array_insert_val(global_capture_opts.ifaces, 0, interface_opts);
/* XXX - remove this? */
if (global_capture_opts.save_file) {
......@@ -183,14 +206,51 @@ capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data)
static void
capture_prepare_cb(GtkWidget *prepare_bt _U_, gpointer if_data)
{
interface_options interface_opts;
cap_settings_t cap_settings;
if_dlg_data_t *if_dlg_data = if_data;
g_free(global_capture_opts.iface);
g_free(global_capture_opts.iface_descr);
global_capture_opts.iface = g_strdup(if_dlg_data->device);
global_capture_opts.iface_descr = get_interface_descriptive_name(global_capture_opts.iface);
while (global_capture_opts.ifaces->len > 0) {
interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, 0);
global_capture_opts.ifaces = g_array_remove_index(global_capture_opts.ifaces, 0);
g_free(interface_opts.name);
g_free(interface_opts.descr);
g_free(interface_opts.cfilter);
#ifdef HAVE_PCAP_REMOTE
g_free(interface_opts.remote_host);
g_free(interface_opts.remote_port);
g_free(interface_opts.auth_username);
g_free(interface_opts.auth_password);
#endif
}
interface_opts.name = g_strdup(if_dlg_data->device);
interface_opts.descr = get_interface_descriptive_name(interface_opts.name);
cap_settings = capture_get_cap_settings (interface_opts.name);;
interface_opts.monitor_mode = cap_settings.monitor_mode;
interface_opts.linktype = capture_dev_user_linktype_find(interface_opts.name);
interface_opts.cfilter = global_capture_opts.default_options.cfilter;
interface_opts.snaplen = global_capture_opts.default_options.snaplen;
interface_opts.has_snaplen = global_capture_opts.default_options.has_snaplen;
interface_opts.promisc_mode = global_capture_opts.default_options.promisc_mode;
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
interface_opts.buffer_size = global_capture_opts.default_options.buffer_size;
#endif
#ifdef HAVE_PCAP_REMOTE
interface_opts.src_type = global_capture_opts.default_options.src_type;
interface_opts.remote_host = g_strdup(global_capture_opts.default_options.remote_host);
interface_opts.remote_port = g_strdup(global_capture_opts.default_options.remote_port);
interface_opts.auth_type = global_capture_opts.default_options.auth_type;
interface_opts.auth_username = g_strdup(global_capture_opts.default_options.auth_username);
interface_opts.auth_password = g_strdup(global_capture_opts.default_options.auth_password);
interface_opts.datatx_udp = global_capture_opts.default_options.datatx_udp;
interface_opts.nocap_rpcap = global_capture_opts.default_options.nocap_rpcap;
interface_opts.nocap_local = global_capture_opts.default_options.nocap_local;
#endif
#ifdef HAVE_PCAP_SETSAMPLING
interface_opts.sampling_method = global_capture_opts.default_options.sampling_method;
interface_opts.sampling_param = global_capture_opts.default_options.sampling_param;
#endif
g_array_insert_val(global_capture_opts.ifaces, 0, interface_opts);
/* stop capturing from all interfaces, we are going to do real work now ... */
window_destroy(cap_if_w);
......
......@@ -2958,9 +2958,9 @@ main(int argc, char *argv[])
set_capture_if_dialog_for_capture_in_progress(FALSE);
}
/* if the user didn't supplied a capture filter, use the one to filter out remote connections like SSH */
if (!start_capture && !global_capture_opts.cfilter) {
global_capture_opts.cfilter = g_strdup(get_conn_cfilter());
/* if the user didn't supply a capture filter, use the one to filter out remote connections like SSH */
if (!start_capture && !global_capture_opts.default_options.cfilter) {
global_capture_opts.default_options.cfilter = g_strdup(get_conn_cfilter());
}
#else /* HAVE_LIBPCAP */
show_main_window(FALSE);
......@@ -3638,11 +3638,11 @@ prefs_to_capture_opts(void)
#ifdef HAVE_LIBPCAP
/* Set promiscuous mode from the preferences setting. */
/* the same applies to other preferences settings as well. */
global_capture_opts.promisc_mode = prefs.capture_prom_mode;
global_capture_opts.use_pcapng = prefs.capture_pcap_ng;
global_capture_opts.show_info = prefs.capture_show_info;
global_capture_opts.real_time_mode = prefs.capture_real_time;
auto_scroll_live = prefs.capture_auto_scroll;
global_capture_opts.default_options.promisc_mode = prefs.capture_prom_mode;
global_capture_opts.use_pcapng = prefs.capture_pcap_ng;
global_capture_opts.show_info = prefs.capture_show_info;
global_capture_opts.real_time_mode = prefs.capture_real_time;
auto_scroll_live = prefs.capture_auto_scroll;
#endif /* HAVE_LIBPCAP */
/* Set the name resolution code's flags from the preferences. */
......
......@@ -696,12 +696,10 @@ statusbar_get_interface_names(capture_options *capture_opts)
interface_names = g_string_new("");
if (capture_opts->ifaces->len == 0) {
g_string_append_printf(interface_names, "%s", get_iface_description(capture_opts));
#ifdef _WIN32
} else if (capture_opts->ifaces->len < 2) {
if (capture_opts->ifaces->len < 2) {
#else
} else if (capture_opts->ifaces->len < 4) {
if (capture_opts->ifaces->len < 4) {
#endif
for (i = 0; i < capture_opts->ifaces->len; i++) {
if (i > 0) {
......
......@@ -572,12 +572,6 @@ welcome_if_press_cb(GtkWidget *widget _U_, GdkEventButton *event _U_, gpointer d
cap_settings_t cap_settings;
interface_options interface_opts;
g_free(global_capture_opts.iface);
g_free(global_capture_opts.iface_descr);
global_capture_opts.iface = g_strdup(data);
global_capture_opts.iface_descr = NULL;
while (global_capture_opts.ifaces->len > 0) {
interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, 0);
global_capture_opts.ifaces = g_array_remove_index(global_capture_opts.ifaces, 0);
......@@ -594,22 +588,45 @@ welcome_if_press_cb(GtkWidget *widget _U_, GdkEventButton *event _U_, gpointer d
/* XXX - fix this */
/*global_capture_opts.iface_descr = get_interface_descriptive_name(global_capture_opts.iface);*/
cap_settings = capture_get_cap_settings (global_capture_opts.iface);;
global_capture_opts.monitor_mode = cap_settings.monitor_mode;
global_capture_opts.linktype = cap_settings.linktype;
interface_opts.name = g_strdup(data);
interface_opts.descr = NULL;
cap_settings = capture_get_cap_settings(interface_opts.name);
interface_opts.monitor_mode = cap_settings.monitor_mode;
interface_opts.linktype = cap_settings.linktype;
interface_opts.cfilter = g_strdup(global_capture_opts.default_options.cfilter);
interface_opts.snaplen = global_capture_opts.default_options.snaplen;
interface_opts.has_snaplen = global_capture_opts.default_options.has_snaplen;
interface_opts.promisc_mode = global_capture_opts.default_options.promisc_mode;
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
interface_opts.buffer_size = global_capture_opts.default_options.buffer_size;
#endif
#ifdef HAVE_PCAP_REMOTE
interface_opts.src_type = global_capture_opts.default_options.src_type;
interface_opts.remote_host = g_strdup(global_capture_opts.default_options.remote_host);
interface_opts.remote_port = g_strdup(global_capture_opts.default_options.remote_port);
interface_opts.auth_type = global_capture_opts.default_options.auth_type;
interface_opts.auth_username = g_strdup(global_capture_opts.default_options.auth_username);
interface_opts.auth_password = g_strdup(global_capture_opts.default_options.auth_password);
interface_opts.datatx_udp = global_capture_opts.default_options.datatx_udp;
interface_opts.nocap_rpcap = global_capture_opts.default_options.nocap_rpcap;
interface_opts.nocap_local = global_capture_opts.default_options.nocap_local;
#endif
#ifdef HAVE_PCAP_SETSAMPLING
interface_opts.sampling_method = global_capture_opts.default_options.sampling_method;
interface_opts.sampling_param = global_capture_opts.default_options.sampling_param;
#endif
/* XXX - remove this? */
if (global_capture_opts.save_file) {
g_free(global_capture_opts.save_file);
global_capture_opts.save_file = NULL;
}
#ifdef HAVE_AIRPCAP
airpcap_if_active = get_airpcap_if_from_name(airpcap_if_list, global_capture_opts.iface);
airpcap_if_active = get_airpcap_if_from_name(airpcap_if_list, interface_opts.name);
airpcap_if_selected = airpcap_if_active;
airpcap_set_toolbar_start_capture(airpcap_if_active);
#endif
g_array_append_val(global_capture_opts.ifaces, interface_opts);
capture_start_cb(NULL, NULL);
return FALSE;
......
......@@ -139,11 +139,14 @@ summary_fill_in(capture_file *cf, summary_tally *st)
#ifdef HAVE_LIBPCAP
/* FIXME: This needs additional functionality to support multiple interfaces */
void
summary_fill_in_capture(capture_options *capture_opts, summary_tally *st)
{
st->cfilter = capture_opts->cfilter;
st->iface = capture_opts->iface;
st->iface_descr = get_iface_description(capture_opts);
if (capture_opts->ifaces->len > 0) {
st->cfilter = g_array_index(capture_opts->ifaces, interface_options, 0).cfilter;
st->iface = g_array_index(capture_opts->ifaces, interface_options, 0).name;
st->iface_descr = get_iface_description_for_interface(capture_opts, 0);
}
}
#endif
......@@ -1392,12 +1392,12 @@ main(int argc, char *argv[])
rfilter = get_args_as_string(argc, argv, optind);
} else {
#ifdef HAVE_LIBPCAP
if (global_capture_opts.cfilter) {
cmdarg_err("Capture filters were specified both with \"-f\""
if (global_capture_opts.default_options.cfilter) {
cmdarg_err("A default capture filter was specified both with \"-f\""
" and with additional command-line arguments");
return 1;
}
global_capture_opts.cfilter = get_args_as_string(argc, argv, optind);
global_capture_opts.default_options.cfilter = get_args_as_string(argc, argv, optind);
#else
capture_option_specified = TRUE;
#endif
......@@ -1443,7 +1443,7 @@ main(int argc, char *argv[])
support in capture files we read). */
#ifdef HAVE_LIBPCAP
if (cf_name != NULL) {
if (global_capture_opts.cfilter) {
if (global_capture_opts.default_options.cfilter) {
cmdarg_err("Only read filters, not capture filters, "
"can be specified when reading a capture file.");
return 1;
......@@ -2149,14 +2149,17 @@ capture_input_error_message(capture_options *capture_opts _U_, char *error_msg,
/* capture child detected an capture filter related error */
void
capture_input_cfilter_error_message(capture_options *capture_opts, char *error_message)
capture_input_cfilter_error_message(capture_options *capture_opts, guint i, char *error_message)
{
dfilter_t *rfcode = NULL;
interface_options interface_opts;
g_assert(i < capture_opts->ifaces->len);
interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
if (dfilter_compile(capture_opts->cfilter, &rfcode) && rfcode != NULL) {
if (dfilter_compile(interface_opts.cfilter, &rfcode) && rfcode != NULL) {
cmdarg_err(
"Invalid capture filter: \"%s\"!\n"
"Invalid capture filter: \"%s\" for interface %s!\n"
"\n"
"That string looks like a valid display filter; however, it isn't a valid\n"
"capture filter (%s).\n"
......@@ -2165,15 +2168,15 @@ capture_input_cfilter_error_message(capture_options *capture_opts, char *error_m
"so you can't use most display filter expressions as capture filters.\n"
"\n"
"See the User's Guide for a description of the capture filter syntax.",
capture_opts->cfilter, error_message);
interface_opts.cfilter, interface_opts.name, error_message);
dfilter_free(rfcode);
} else {
cmdarg_err(
"Invalid capture filter: \"%s\"!\n"
"Invalid capture filter: \"%s\" for interface %s!\n"
"\n"
"That string isn't a valid capture filter (%s).\n"
"See the User's Guide for a description of the capture filter syntax.",
capture_opts->cfilter, error_message);
interface_opts.cfilter, interface_opts.name, error_message);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment