util-device: add function to avoid stat display

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.
pull/852/merge
Eric Leblond 12 years ago committed by Victor Julien
parent a12c46c700
commit 6b2ca63d9d

@ -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);

@ -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

Loading…
Cancel
Save