aboutsummaryrefslogtreecommitdiffstats
path: root/dumpcap.c
diff options
context:
space:
mode:
authortuexen <tuexen@f5534014-38df-0310-8fa8-9805f1628bb7>2011-06-27 11:30:39 +0000
committertuexen <tuexen@f5534014-38df-0310-8fa8-9805f1628bb7>2011-06-27 11:30:39 +0000
commit965f3e3dc5c8c7c71878d9c807683f756beed9df (patch)
tree452bd362859778292e8ded8da51ad4df9810d023 /dumpcap.c
parent9dc2190af3b8594003ad722c417680e97629117f (diff)
Improve the report of illegal capture filters. Also show the interface description.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@37802 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'dumpcap.c')
-rw-r--r--dumpcap.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/dumpcap.c b/dumpcap.c
index 1b46f50415..ae54145f26 100644
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -354,7 +354,7 @@ static void report_new_capture_file(const char *filename);
static void report_packet_count(int packet_count);
static void report_packet_drops(guint32 received, guint32 drops, gchar *name);
static void report_capture_error(const char *error_msg, const char *secondary_error_msg);
-static void report_cfilter_error(const char *cfilter, const char *errmsg);
+static void report_cfilter_error(capture_options *capture_opts, guint i, const char *errmsg);
#define MSG_MAX_LENGTH 4096
@@ -786,7 +786,7 @@ show_filter_code(capture_options *capture_opts)
if (!compile_capture_filter(interface_opts.name, pcap_h, &fcode,
interface_opts.cfilter)) {
pcap_close(pcap_h);
- report_cfilter_error(interface_opts.cfilter, errmsg);
+ report_cfilter_error(capture_opts, j, errmsg);
return FALSE;
}
pcap_close(pcap_h);
@@ -3029,7 +3029,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
char secondary_errmsg[MSG_MAX_LENGTH+1];
pcap_options *pcap_opts;
interface_options interface_opts;
- guint i;
+ guint i, error_index = 0;
interface_opts = capture_opts->default_options;
*errmsg = '\0';
@@ -3080,6 +3080,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
case INITFILTER_BAD_FILTER:
cfilter_error = TRUE;
+ error_index = i;
g_snprintf(errmsg, sizeof(errmsg), "%s", pcap_geterr(pcap_opts->pcap_h));
goto error;
@@ -3465,7 +3466,7 @@ error:
}
capture_opts->save_file = NULL;
if (cfilter_error)
- report_cfilter_error(interface_opts.cfilter, errmsg);
+ report_cfilter_error(capture_opts, error_index, errmsg);
else
report_capture_error(errmsg, secondary_errmsg);
@@ -4404,18 +4405,23 @@ report_new_capture_file(const char *filename)
}
static void
-report_cfilter_error(const char *cfilter, const char *errmsg)
+report_cfilter_error(capture_options *capture_opts, guint i, const char *errmsg)
{
- if (capture_child) {
- g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Capture filter error: %s", errmsg);
- pipe_write_block(2, SP_BAD_FILTER, errmsg);
- } else {
- fprintf(stderr,
- "Invalid capture filter: \"%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",
- cfilter, errmsg);
+ interface_options interface_opts;
+
+ if (i < capture_opts->ifaces->len) {
+ if (capture_child) {
+ g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Capture filter error: %s", errmsg);
+ pipe_write_block(2, SP_BAD_FILTER, errmsg);
+ } else {
+ interface_opts = g_array_index(capture_opts->ifaces, interface_options, i);
+ fprintf(stderr,
+ "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",
+ interface_opts.cfilter, interface_opts.name, errmsg);
+ }
}
}