aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--capchild/capture_sync.c27
-rw-r--r--capchild/capture_sync.h2
-rw-r--r--dumpcap.c7
-rw-r--r--tshark.c8
-rw-r--r--ui/capture.c8
5 files changed, 34 insertions, 18 deletions
diff --git a/capchild/capture_sync.c b/capchild/capture_sync.c
index 6da5f63f4b..c3bd19cc5e 100644
--- a/capchild/capture_sync.c
+++ b/capchild/capture_sync.c
@@ -1703,21 +1703,30 @@ sync_pipe_input_cb(gint source, gpointer user_data)
/* (an error message doesn't mean we have to stop capturing) */
break;
case SP_BAD_FILTER: {
- char *ch=NULL;
- int indx=0;
+ const char *message=NULL;
+ guint32 indx = 0;
+ const gchar* end;
- ch = strtok(buffer, ":");
- if (ch) {
- indx = (int)strtol(ch, NULL, 10);
- ch = strtok(NULL, ":");
+ if (ws_strtou32(buffer, &end, &indx) && end[0] == ':') {
+ message = end + 1;
}
- capture_input_cfilter_error_message(cap_session, indx, ch);
+
+ capture_input_cfilter_error_message(cap_session, indx, (char*)message);
/* the capture child will close the sync_pipe, nothing to do for now */
break;
}
- case SP_DROPS:
- capture_input_drops(cap_session, (guint32)strtoul(buffer, NULL, 10));
+ case SP_DROPS: {
+ const char *name = NULL;
+ const gchar* end;
+ guint32 num = 0;
+
+ if (ws_strtou32(buffer, &end, &num) && end[0] == ':') {
+ name = end + 1;
+ }
+
+ capture_input_drops(cap_session, num, (char*)name);
break;
+ }
default:
g_assert_not_reached();
}
diff --git a/capchild/capture_sync.h b/capchild/capture_sync.h
index 2da20e4864..c0fdc1d72f 100644
--- a/capchild/capture_sync.h
+++ b/capchild/capture_sync.h
@@ -121,7 +121,7 @@ capture_input_new_packets(capture_session *cap_session, int to_read);
* Capture child told us how many dropped packets it counted.
*/
extern void
-capture_input_drops(capture_session *cap_session, guint32 dropped);
+capture_input_drops(capture_session *cap_session, guint32 dropped, char* interface_name);
/**
* Capture child told us that an error has occurred while starting the capture.
diff --git a/dumpcap.c b/dumpcap.c
index c053a15d73..b42e96863b 100644
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -5550,17 +5550,16 @@ report_capture_error(const char *error_msg, const char *secondary_error_msg)
static void
report_packet_drops(guint32 received, guint32 pcap_drops, guint32 drops, guint32 flushed, guint32 ps_ifdrop, gchar *name)
{
- char tmp[SP_DECISIZE+1+1];
guint32 total_drops = pcap_drops + drops + flushed;
- g_snprintf(tmp, sizeof(tmp), "%u", total_drops);
-
if (capture_child) {
+ char* tmp = g_strdup_printf("%u:%s", total_drops, name);
+
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
"Packets received/dropped on interface '%s': %u/%u (pcap:%u/dumpcap:%u/flushed:%u/ps_ifdrop:%u)",
name, received, total_drops, pcap_drops, drops, flushed, ps_ifdrop);
- /* XXX: Need to provide interface id, changes to consumers required. */
pipe_write_block(2, SP_DROPS, tmp);
+ g_free(tmp);
} else {
fprintf(stderr,
"Packets received/dropped on interface '%s': %u/%u (pcap:%u/dumpcap:%u/flushed:%u/ps_ifdrop:%u) (%.1f%%)\n",
diff --git a/tshark.c b/tshark.c
index 51bf2e649a..cbd9768a0a 100644
--- a/tshark.c
+++ b/tshark.c
@@ -2777,7 +2777,7 @@ report_counts_siginfo(int signum _U_)
/* capture child detected any packet drops? */
void
-capture_input_drops(capture_session *cap_session _U_, guint32 dropped)
+capture_input_drops(capture_session *cap_session _U_, guint32 dropped, char* interface_name)
{
if (print_packet_counts) {
/* We're printing packet counts to stderr.
@@ -2788,7 +2788,11 @@ capture_input_drops(capture_session *cap_session _U_, guint32 dropped)
if (dropped != 0) {
/* We're printing packet counts to stderr.
Send a newline so that we move to the line after the packet count. */
- fprintf(stderr, "%u packet%s dropped\n", dropped, plurality(dropped, "", "s"));
+ if (interface_name != NULL) {
+ fprintf(stderr, "%u packet%s dropped from %s\n", dropped, plurality(dropped, "", "s"), interface_name);
+ } else {
+ fprintf(stderr, "%u packet%s dropped\n", dropped, plurality(dropped, "", "s"));
+ }
}
}
diff --git a/ui/capture.c b/ui/capture.c
index 2478733b0f..5ad5c42afc 100644
--- a/ui/capture.c
+++ b/ui/capture.c
@@ -527,9 +527,13 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
/* Capture child told us how many dropped packets it counted.
*/
void
-capture_input_drops(capture_session *cap_session, guint32 dropped)
+capture_input_drops(capture_session *cap_session, guint32 dropped, char* interface_name)
{
- g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "%u packet%s dropped", dropped, plurality(dropped, "", "s"));
+ if (interface_name != NULL) {
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "%u packet%s dropped from %s", dropped, plurality(dropped, "", "s"), interface_name);
+ } else {
+ g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_INFO, "%u packet%s dropped", dropped, plurality(dropped, "", "s"));
+ }
g_assert(cap_session->state == CAPTURE_RUNNING);