aboutsummaryrefslogtreecommitdiffstats
path: root/dumpcap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2011-11-22 10:08:26 +0000
committerGuy Harris <guy@alum.mit.edu>2011-11-22 10:08:26 +0000
commit939feef06f2b2abeb4059389dff8469d22a2cb06 (patch)
treee711f8a925664daa57dad11e215e2aa3513ac67c /dumpcap.c
parentaad9adc89da3dc763101fab856187dcd35512172 (diff)
If we're not running as a child process, report the interfaces on which
we're capturing. (We do not require a -i flag; the message could be useful if you don't specify the interface, as it lets you know which interface was chosen, which might not be the interface you'd think it would be. Yes, that's arguably a libpcap bug, which I plan to look at; it should probably try to figure out which interfaces are "active" if possible, and prefer those.) Use cmdarg_err() for invalid capture filters and other capture errors. svn path=/trunk/; revision=39983
Diffstat (limited to 'dumpcap.c')
-rw-r--r--dumpcap.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/dumpcap.c b/dumpcap.c
index bf0def1217..96eb7d49af 100644
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -3708,6 +3708,7 @@ main(int argc, char *argv[])
#if defined(__APPLE__) && defined(__LP64__)
struct utsname osinfo;
#endif
+ char *sep;
#ifdef _WIN32
arg_list_utf_16to8(argc, argv);
@@ -4232,12 +4233,23 @@ main(int argc, char *argv[])
/* Let the user know what interfaces were chosen. */
/* get_interface_descriptive_name() is not available! */
+ sep = "";
+ if (!capture_child)
+ fprintf(stderr, "Interfaces: ");
for (j = 0; j < global_capture_opts.ifaces->len; j++) {
interface_options interface_opts;
interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, j);
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Interface: %s", interface_opts.name);
+ if (capture_child) {
+ g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Interface: %s\n",
+ interface_opts.name);
+ } else {
+ fprintf(stderr, "%s%s", sep, interface_opts.name);
+ }
+ sep = ", ";
}
+ if (!capture_child)
+ fprintf(stderr, "\n");
if (list_link_layer_types) {
/* Get the list of link-layer types for the capture device. */
@@ -4459,11 +4471,11 @@ report_cfilter_error(capture_options *capture_opts, guint i, const char *errmsg)
* the error message below.
*/
interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
- fprintf(stderr,
- "Invalid capture filter \"%s\" for interface %s!\n"
+ cmdarg_err(
+ "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.\n",
+ "See the User's Guide for a description of the capture filter syntax.",
interface_opts.cfilter, interface_opts.name, errmsg);
}
}
@@ -4479,9 +4491,9 @@ report_capture_error(const char *error_msg, const char *secondary_error_msg)
"Secondary Error: %s", secondary_error_msg);
sync_pipe_errmsg_to_parent(2, error_msg, secondary_error_msg);
} else {
- fprintf(stderr, "%s\n", error_msg);
+ cmdarg_err("%s", error_msg);
if (secondary_error_msg[0] != '\0')
- fprintf(stderr, "%s\n", secondary_error_msg);
+ cmdarg_err_cont("%s", secondary_error_msg);
}
}