device list: clean and display stat at exit

This patch adds a cleaning function to device list. This also
permits to display per-interface statistics during the exit.
pull/757/head
Eric Leblond 12 years ago committed by Victor Julien
parent aa6b5b406d
commit a8c787a265

@ -2295,6 +2295,7 @@ int main(int argc, char **argv)
TagDestroyCtx();
LiveDeviceListClean();
RunModeShutDown();
OutputDeregisterAll();
TimeDeinit();

@ -159,6 +159,29 @@ int LiveBuildDeviceList(char * runmode)
return i;
}
int LiveDeviceListClean()
{
SCEnter();
LiveDevice *pd;
TAILQ_FOREACH(pd, &live_devices, next) {
SCLogNotice("Stats for '%s': pkts: %u, drop: %u (%.2f%%), invalid chksum: %u",
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);
SC_ATOMIC_DESTROY(pd->drop);
SC_ATOMIC_DESTROY(pd->invalid_checksums);
SCFree(pd);
}
SCReturnInt(TM_ECODE_OK);
}
#ifdef BUILD_UNIX_SOCKET
TmEcode LiveDeviceIfaceStat(json_t *cmd, json_t *answer, void *data)
{

@ -37,6 +37,7 @@ int LiveGetDeviceCount(void);
char *LiveGetDeviceName(int number);
LiveDevice *LiveGetDevice(char *dev);
int LiveBuildDeviceList(char * base);
int LiveDeviceListClean(void);
#ifdef BUILD_UNIX_SOCKET
TmEcode LiveDeviceIfaceStat(json_t *cmd, json_t *server_msg, void *data);

Loading…
Cancel
Save