aboutsummaryrefslogtreecommitdiffstats
path: root/capture_opts.c
diff options
context:
space:
mode:
authorMichael Tüxen <tuexen@fh-muenster.de>2011-10-20 19:44:40 +0000
committerMichael Tüxen <tuexen@fh-muenster.de>2011-10-20 19:44:40 +0000
commitc219f2eea54ef19c811bc1294416fb6b30a046f8 (patch)
treecced8090a0b70bd451688295b593f651386440d4 /capture_opts.c
parent3c1f16f904b786a6e98325362ae95b80ac41819f (diff)
Back out infrastructure change. We missed supporting
stdin and pipes. svn path=/trunk/; revision=39498
Diffstat (limited to 'capture_opts.c')
-rw-r--r--capture_opts.c128
1 files changed, 1 insertions, 127 deletions
diff --git a/capture_opts.c b/capture_opts.c
index cbfe1b9aa5..8f7325e1ea 100644
--- a/capture_opts.c
+++ b/capture_opts.c
@@ -38,9 +38,6 @@
#include <glib.h>
#include <epan/packet.h>
-#include <epan/prefs.h>
-#include "simple_dialog.h"
-#include "capture_ui_utils.h"
#include "capture_opts.h"
#include "ringbuffer.h"
@@ -60,8 +57,6 @@ 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;
@@ -527,83 +522,7 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg_str
#endif
g_array_append_val(capture_opts->ifaces, interface_opts);
- return 0;
-}
-
-int
-capture_opts_select_iface(capture_options *capture_opts, const char *optarg_str_p)
-{
- long adapter_index;
- char *p;
- GList *if_list;
- if_info_t *if_info;
- int err;
- guint i;
- gchar *err_str, *name = NULL;
- interface_t device;
-
- /*
- * If the argument is a number, treat it as an index into the list
- * of adapters, as printed by "tshark -D".
- *
- * This should be OK on UNIX systems, as interfaces shouldn't have
- * names that begin with digits. It can be useful on Windows, where
- * more than one interface can have the same name.
- */
- adapter_index = strtol(optarg_str_p, &p, 10);
- if (p != NULL && *p == '\0') {
- if (adapter_index < 0) {
- cmdarg_err("The specified adapter index is a negative number");
- return 1;
- }
- if (adapter_index > INT_MAX) {
- cmdarg_err("The specified adapter index is too large (greater than %d)",
- INT_MAX);
- return 1;
- }
- if (adapter_index == 0) {
- cmdarg_err("There is no interface with that adapter index");
- return 1;
- }
- if_list = capture_interface_list(&err, &err_str);
- if (if_list == NULL) {
- switch (err) {
- case CANT_GET_INTERFACE_LIST:
- cmdarg_err("%s", err_str);
- g_free(err_str);
- break;
-
- case NO_INTERFACES_FOUND:
- cmdarg_err("There are no interfaces on which a capture can be done");
- break;
- }
- return 2;
- }
- if_info = (if_info_t *)g_list_nth_data(if_list, adapter_index - 1);
- if (if_info == NULL) {
- cmdarg_err("There is no interface with that adapter index");
- return 1;
- }
- name = g_strdup(if_info->name);
- /* We don't set iface_descr here because doing so requires
- * capture_ui_utils.c which requires epan/prefs.c which is
- * probably a bit too much dependency for here...
- */
- free_interface_list(if_list);
- } else {
- name = g_strdup(optarg_str_p);
- }
- for(i = 0; i < capture_opts->all_ifaces->len; i++) {
- device = g_array_index(capture_opts->all_ifaces, interface_t, i);
- if (strcmp(device.name, name) == 0) {
- device.selected = TRUE;
- capture_opts->num_selected++;
- capture_opts->all_ifaces = g_array_remove_index(capture_opts->all_ifaces, i);
- g_array_insert_val(capture_opts->all_ifaces, i, device);
- break;
- }
- }
return 0;
}
@@ -907,7 +826,7 @@ gboolean capture_opts_trim_iface(capture_options *capture_opts, const char *capt
/* Did the user specify an interface to use? */
- if (capture_opts->num_selected == 0 && capture_opts->ifaces->len == 0) {
+ if (capture_opts->ifaces->len == 0) {
/* No - is a default specified in the preferences file? */
if (capture_device != NULL) {
/* Yes - use it. */
@@ -1038,49 +957,4 @@ 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.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.type == IF_REMOTE) {
-#ifdef HAVE_PCAP_REMOTE
- interface_opts.src_type = device.type;
- 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 */