aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2010-05-17 23:13:24 +0000
committerGuy Harris <guy@alum.mit.edu>2010-05-17 23:13:24 +0000
commit859c6e4d3ee7d483f74f338c563f9ab9ee9a10e1 (patch)
treed604cce61b3885ad62220e64ef5925f000a8d117
parentd1573b53c076e933d8bd6bcdaf3ca6fb04ccad82 (diff)
If dumpcap is run with -D, don't select a default interface; it's not
necessary. If it's run with -D and -M, and we found no interfaces, don't treat that as an error; let the code that reads our output just indicate it as "no interfaces available", so *its* caller can decide whether to report an error or not (in some cases in Wireshark, it's obvious that there are no interfaces, e.g. there aren't any listed on the welcome screen, so popping up a dialog is pointless). svn path=/trunk/; revision=32849
-rw-r--r--dumpcap.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/dumpcap.c b/dumpcap.c
index 0a6f5fff10..c33b16921e 100644
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -3443,15 +3443,6 @@ main(int argc, char *argv[])
}
}
- if (capture_opts_trim_iface(&global_capture_opts, NULL) == FALSE) {
- /* cmdarg_err() already called .... */
- exit_main(1);
- }
-
- /* Let the user know what interface was chosen. */
- /* get_interface_descriptive_name() is not available! */
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Interface: %s\n", global_capture_opts.iface);
-
if (list_interfaces) {
/* Get the list of interfaces */
GList *if_list;
@@ -3464,13 +3455,22 @@ main(int argc, char *argv[])
case CANT_GET_INTERFACE_LIST:
cmdarg_err("%s", err_str);
g_free(err_str);
+ exit_main(2);
break;
case NO_INTERFACES_FOUND:
- cmdarg_err("There are no interfaces on which a capture can be done");
+ /*
+ * If we're being run by another program, just give them
+ * an empty list of interfaces, don't report this as
+ * an error; that lets them decide whether to report
+ * this as an error or not.
+ */
+ if (!machine_readable) {
+ cmdarg_err("There are no interfaces on which a capture can be done");
+ exit_main(2);
+ }
break;
}
- exit_main(2);
}
if (machine_readable) /* tab-separated values to stdout */
@@ -3479,7 +3479,25 @@ main(int argc, char *argv[])
capture_opts_print_interfaces(if_list);
free_interface_list(if_list);
exit_main(0);
- } else if (list_link_layer_types) {
+ }
+
+ /*
+ * "-D" requires no interface to be selected; it's supposed to list
+ * all interfaces.
+ *
+ * If -D wasn't specified, we have to have an interface; if none
+ * was specified, pick a default.
+ */
+ if (capture_opts_trim_iface(&global_capture_opts, NULL) == FALSE) {
+ /* cmdarg_err() already called .... */
+ exit_main(1);
+ }
+
+ /* Let the user know what interface was chosen. */
+ /* get_interface_descriptive_name() is not available! */
+ g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Interface: %s\n", global_capture_opts.iface);
+
+ if (list_link_layer_types) {
/* Get the list of link-layer types for the capture device. */
if_capabilities_t *caps;
gchar *err_str;