]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util-device: add function to avoid stat display
authorEric Leblond <eric@regit.org>
Thu, 27 Feb 2014 17:03:13 +0000 (18:03 +0100)
committerVictor Julien <victor@inliniac.net>
Mon, 3 Mar 2014 09:14:34 +0000 (10:14 +0100)
In the case of running mode like NFQ there is no need possibility
to compute the statistics as it is done in LiveDevice (drop and
checksum count are meaningless).

This patch adds a function that allow running mode to disable the
display of the counters at exit.

src/util-device.c
src/util-device.h

index 27d34ba8f24677d59a89a2c0bdf5c7ffcac5b5db..6359973bfa55d341ad6183acb39b03dbe68a1cff 100644 (file)
@@ -31,6 +31,8 @@
 static TAILQ_HEAD(, LiveDevice_) live_devices =
     TAILQ_HEAD_INITIALIZER(live_devices);
 
+/** if set to 0 when we don't have real devices */
+static int live_devices_stats = 1;
 
 /**
  *  \brief Add a pcap device for monitoring
@@ -159,18 +161,29 @@ int LiveBuildDeviceList(char * runmode)
     return i;
 }
 
+/** Call this function to disable stat on live devices
+ *
+ * This can be useful in the case, this is not a real interface.
+ */
+void LiveDeviceHasNoStats()
+{
+    live_devices_stats = 0;
+}
+
 int LiveDeviceListClean()
 {
     SCEnter();
     LiveDevice *pd, *tpd;
 
     TAILQ_FOREACH_SAFE(pd, &live_devices, next, tpd) {
-        SCLogNotice("Stats for '%s':  pkts: %" PRIu64", drop: %" PRIu64 " (%.2f%%), invalid chksum: %" PRIu64,
+        if (live_devices_stats) {
+            SCLogNotice("Stats for '%s':  pkts: %" PRIu64", drop: %" PRIu64 " (%.2f%%), invalid chksum: %" PRIu64,
                     pd->dev,
                     SC_ATOMIC_GET(pd->pkts),
                     SC_ATOMIC_GET(pd->drop),
                     100 * (SC_ATOMIC_GET(pd->drop) * 1.0) / SC_ATOMIC_GET(pd->pkts),
                     SC_ATOMIC_GET(pd->invalid_checksums));
+        }
         if (pd->dev)
             SCFree(pd->dev);
         SC_ATOMIC_DESTROY(pd->pkts);
index 455c2d2e26743c85e19f90747f44da5c0bb0f1c8..6744d923e4b3ae7846cccd822dc0489e046d5649 100644 (file)
@@ -37,6 +37,7 @@ int LiveGetDeviceCount(void);
 char *LiveGetDeviceName(int number);
 LiveDevice *LiveGetDevice(char *dev);
 int LiveBuildDeviceList(char * base);
+void LiveDeviceHasNoStats(void);
 int LiveDeviceListClean(void);
 
 #ifdef BUILD_UNIX_SOCKET