diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2022-09-22 19:07:08 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2022-09-22 19:07:08 +0200 |
commit | 9a28475bba88b711b7075b58473b7e5b5df1f393 (patch) | |
tree | 73cdf56320f14b5fe0fbfb2e930cf7ea025f9117 /nDPId-test.c | |
parent | 28971cd7647a79253000fb33e52b5d2129e5ba62 (diff) |
Improved flown analyse event:
* store packet directions
* merged direction based IATs
* merged direction based PKTLENs
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'nDPId-test.c')
-rw-r--r-- | nDPId-test.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/nDPId-test.c b/nDPId-test.c index d2198cdf4..e77846c67 100644 --- a/nDPId-test.c +++ b/nDPId-test.c @@ -4,6 +4,8 @@ #include <unistd.h> static void nDPIsrvd_memprof_log(char const * const format, ...); +static void nDPIsrvd_memprof_log_alloc(size_t alloc_size); +static void nDPIsrvd_memprof_log_free(size_t free_size); #define NO_MAIN 1 #include "utils.c" @@ -128,6 +130,10 @@ static pthread_mutex_t nDPId_start_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t nDPIsrvd_start_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t distributor_start_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER; +static unsigned long long int nDPIsrvd_alloc_count = 0; +static unsigned long long int nDPIsrvd_alloc_bytes = 0; +static unsigned long long int nDPIsrvd_free_count = 0; +static unsigned long long int nDPIsrvd_free_bytes = 0; #define THREAD_ERROR(thread_arg) \ do \ @@ -154,6 +160,18 @@ static void nDPIsrvd_memprof_log(char const * const format, ...) va_end(ap); } +void nDPIsrvd_memprof_log_alloc(size_t alloc_size) +{ + nDPIsrvd_alloc_count++; + nDPIsrvd_alloc_bytes += alloc_size; +} + +void nDPIsrvd_memprof_log_free(size_t free_size) +{ + nDPIsrvd_free_count++; + nDPIsrvd_free_bytes += free_size; +} + static int setup_pipe(int pipefd[PIPE_FDS]) { if (pipe(pipefd) != 0) @@ -1103,6 +1121,13 @@ int main(int argc, char ** argv) return 1; } + if (nDPIsrvd_alloc_bytes != nDPIsrvd_free_bytes || nDPIsrvd_alloc_count != nDPIsrvd_free_count) + { + logger(1, "%s: %s", argv[0], "nDPIsrvd.h memory leak detected."); + logger(1, "%s: Allocated / Free'd bytes: %llu / %llu", argv[0], nDPIsrvd_alloc_bytes, nDPIsrvd_free_bytes); + logger(1, "%s: Allocated / Free'd count: %llu / %llu", argv[0], nDPIsrvd_alloc_count, nDPIsrvd_free_count); + } + if (nDPId_return.cur_active_flows != 0 || nDPId_return.cur_idle_flows != 0) { logger(1, |