aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2001-02-11 22:46:27 +0000
committerGuy Harris <guy@alum.mit.edu>2001-02-11 22:46:27 +0000
commitcb1f3a809306278708b21551aff3131e3d7709ba (patch)
tree8f4e9fc0c799a7dafea62591a6630c8f4cda789c
parent56875e0937ff8cc24e644d6772795ab04aafd498 (diff)
In an "Update list of packets in real time" capture, pass the number of
dropped packets from the child to the parent. svn path=/trunk/; revision=3019
-rw-r--r--capture.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/capture.c b/capture.c
index d9410a825b..a10de50891 100644
--- a/capture.c
+++ b/capture.c
@@ -1,7 +1,7 @@
/* capture.c
* Routines for packet capture windows
*
- * $Id: capture.c,v 1.141 2001/02/11 22:36:57 guy Exp $
+ * $Id: capture.c,v 1.142 2001/02/11 22:46:27 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -174,6 +174,7 @@ static guint cap_input_id;
#define SP_CAPSTART ';' /* capture start message */
#define SP_PACKET_COUNT '*' /* count of packets captured since last message */
#define SP_ERROR '!' /* length of error message that follows */
+#define SP_DROPS '#' /* count of packets dropped in capture */
#ifdef _WIN32
static guint cap_timer_id;
@@ -737,6 +738,13 @@ cap_file_input_cb(gpointer data, gint source, GdkInputCondition condition)
q++;
nread--;
break;
+ case SP_DROPS :
+ cf->drops_known = TRUE;
+ cf->drops = atoi(p);
+ p = q + 1;
+ q++;
+ nread--;
+ break;
case SP_ERROR :
msglen = atoi(p);
p = q + 1;
@@ -1650,12 +1658,27 @@ capture(gboolean *stats_known, struct pcap_stat *stats)
{
/* Get the capture statistics, so we know how many packets were
dropped. */
- if (pcap_stats(pch, stats) >= 0)
+ if (pcap_stats(pch, stats) >= 0) {
*stats_known = TRUE;
- else {
- simple_dialog(ESD_TYPE_WARN, NULL,
+ if (capture_child) {
+ /* Let the parent process know. */
+ char tmp[20];
+ sprintf(tmp, "%d%c", stats->ps_drop, SP_DROPS);
+ write(1, tmp, strlen(tmp));
+ }
+ } else {
+ snprintf(errmsg, sizeof(errmsg),
"Can't get packet-drop statistics: %s",
pcap_geterr(pch));
+ if (capture_child) {
+ /* Tell the parent, so that they can pop up the message;
+ we're going to exit, so if we try to pop it up, either
+ it won't pop up or it'll disappear as soon as we exit. */
+ send_errmsg_to_parent(errmsg);
+ } else {
+ /* Just pop up the message ourselves. */
+ simple_dialog(ESD_TYPE_WARN, NULL, "%s", errmsg);
+ }
}
pcap_close(pch);
}