]> The Tcpdump Group git mirrors - tcpdump/blobdiff - tcpdump.c
It is once per second, not every 10 seconds.
[tcpdump] / tcpdump.c
index 0d6ff7830d690a3c40dd2f29ae3d0abc997e2498..520d69f7d5f17c346787f030ce767a63519c1ba1 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -2082,7 +2082,7 @@ main(int argc, char **argv)
        if (ndo->ndo_vflag > 0 && WFileName && !print) {
                /*
                 * When capturing to a file, if "--print" wasn't specified,
-                *"-v" means tcpdump should, every 10 seconds,
+                *"-v" means tcpdump should, once per second,
                 * "v"erbosely report the number of packets captured.
                 */
 #ifdef USE_WIN32_MM_TIMER
@@ -2693,6 +2693,18 @@ RETSIGTYPE requestinfo(int signo _U_)
 }
 #endif
 
+static void
+print_packets_captured (void)
+{
+       static u_int prev_packets_captured, first = 1;
+
+       if (infodelay == 0 && (first || packets_captured != prev_packets_captured)) {
+               fprintf(stderr, "Got %u\r", packets_captured);
+               first = 0;
+               prev_packets_captured = packets_captured;
+       }
+}
+
 /*
  * Called once each second in verbose mode while dumping to file
  */
@@ -2700,14 +2712,12 @@ RETSIGTYPE requestinfo(int signo _U_)
 void CALLBACK verbose_stats_dump (UINT timer_id _U_, UINT msg _U_, DWORD_PTR arg _U_,
                                  DWORD_PTR dw1 _U_, DWORD_PTR dw2 _U_)
 {
-       if (infodelay == 0)
-               fprintf(stderr, "Got %u\r", packets_captured);
+       print_packets_captured();
 }
 #elif defined(HAVE_ALARM)
 static void verbose_stats_dump(int sig _U_)
 {
-       if (infodelay == 0)
-               fprintf(stderr, "Got %u\r", packets_captured);
+       print_packets_captured();
        alarm(1);
 }
 #endif