From 14b1a44c0f8d4feb0a7dab687c36cb0d0c2a311a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20T=C3=BCxen?= Date: Wed, 25 Jan 2012 13:04:32 +0000 Subject: Third try. This time pipes and stdin are supported and the test scripts are passed. Use a global list containing all interfaces and only change properties of the entries when changes are made in the GUI. Do not misuse the list of interfaces specified on the command line anymore. This patch does not provide any new functionality, it just provides the base for future extensions like removing remote interface, mulitple airpcap devices and multiple pipes. This patch was provided by Irene Ruengeler. svn path=/trunk/; revision=40715 --- capture_opts.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) (limited to 'capture_opts.c') diff --git a/capture_opts.c b/capture_opts.c index f200be3735..e2074b5555 100644 --- a/capture_opts.c +++ b/capture_opts.c @@ -38,6 +38,9 @@ #include #include +#include +#include "ui/simple_dialog.h" +#include "capture_ui_utils.h" #include "capture_opts.h" #include "ringbuffer.h" @@ -57,6 +60,8 @@ capture_opts_init(capture_options *capture_opts, void *cf) { capture_opts->cf = cf; capture_opts->ifaces = g_array_new(FALSE, FALSE, sizeof(interface_options)); + capture_opts->all_ifaces = g_array_new(FALSE, FALSE, sizeof(interface_t)); + capture_opts->num_selected = 0; capture_opts->default_options.name = NULL; capture_opts->default_options.descr = NULL; capture_opts->default_options.cfilter = NULL; @@ -431,7 +436,7 @@ get_auth_arguments(capture_options *capture_opts, const char *arg) } #endif -static int +int capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg_str_p) { long adapter_index; @@ -527,6 +532,7 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg_str return 0; } + int capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg_str_p, gboolean *start_capture) { @@ -827,7 +833,7 @@ gboolean capture_opts_trim_iface(capture_options *capture_opts, const char *capt /* Did the user specify an interface to use? */ - if (capture_opts->ifaces->len == 0) { + if (capture_opts->num_selected == 0 && capture_opts->ifaces->len == 0) { /* No - is a default specified in the preferences file? */ if (capture_device != NULL) { /* Yes - use it. */ @@ -959,4 +965,49 @@ static gboolean capture_opts_output_to_pipe(const char *save_file, gboolean *is_ return 0; } +void +collect_ifaces(capture_options *capture_opts) +{ + guint i; + interface_t device; + interface_options interface_opts; + for (i = 0; i < capture_opts->all_ifaces->len; i++) { + device = g_array_index(capture_opts->all_ifaces, interface_t, i); + if (!device.hidden && device.selected) { + interface_opts.name = g_strdup(device.name); + interface_opts.descr = g_strdup(device.display_name); + interface_opts.monitor_mode = device.monitor_mode_enabled; + interface_opts.linktype = device.active_dlt; + interface_opts.cfilter = g_strdup(device.cfilter); + interface_opts.snaplen = device.snaplen; + interface_opts.has_snaplen = device.has_snaplen; + interface_opts.promisc_mode = device.pmode; +#if defined(_WIN32) || defined(HAVE_PCAP_CREATE) + interface_opts.buffer_size = device.buffer; +#endif + if (!device.local) { +#ifdef HAVE_PCAP_REMOTE + interface_opts.src_type = CAPTURE_IFREMOTE; + interface_opts.remote_host = g_strdup(device.remote_opts.remote_host_opts.remote_host); + interface_opts.remote_port = g_strdup(device.remote_opts.remote_host_opts.remote_port); + interface_opts.auth_type = device.remote_opts.remote_host_opts.auth_type; + interface_opts.auth_username = g_strdup(device.remote_opts.remote_host_opts.auth_username); + interface_opts.auth_password = g_strdup(device.remote_opts.remote_host_opts.auth_password); + interface_opts.datatx_udp = device.remote_opts.remote_host_opts.datatx_udp; + interface_opts.nocap_rpcap = device.remote_opts.remote_host_opts.nocap_rpcap; + interface_opts.nocap_local = device.remote_opts.remote_host_opts.nocap_local; +#endif +#ifdef HAVE_PCAP_SETSAMPLING + interface_opts.sampling_method = device.remote_opts.sampling_method; + interface_opts.sampling_param = device.remote_opts.sampling_param; +#endif + } + g_array_append_val(capture_opts->ifaces, interface_opts); + } else { + continue; + } + } +} + + #endif /* HAVE_LIBPCAP */ -- cgit v1.2.3