nDPId-test: added JSON distribution + JSON parsing (Multithreaded design re-using most of nDPId/nDPIsrvd core)

* improved Makefile.old install targets
 * splitted nDPIsrvd_parse into nDPIsrvd_parse_line and nDPIsrvd_parse_all for the sake of readability
 * minor Python script improvments (check for nDPIsrvd.py on multiple locations, may be superseeded by setuptools in the future)
 * some paths needs to be absolute (chdir() during daemonize) and therefor additional checks introduced
 * test run script checks and fails if certain files are are missing (PCAP file <=> result output file)
 * removed not very useful "internal format error" JSON serialization if a BUG for same exists
 * fixed invalid l4 type statistics counters for nDPIsrvd-collectd

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
Toni Uhlig
2021-04-08 20:33:25 +02:00
parent e576162a43
commit 0a7ad7a76a
15 changed files with 533 additions and 270 deletions

19
utils.c
View File

@@ -55,6 +55,11 @@ static int create_pidfile(char const * const pidfile)
{
int pfd;
if (is_path_absolute("Pidfile", pidfile) != 0)
{
return 1;
}
pfd = open(pidfile, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (pfd < 0)
@@ -74,6 +79,20 @@ static int create_pidfile(char const * const pidfile)
return 0;
}
int is_path_absolute(char const * const prefix,
char const * const path)
{
if (path[0] != '/')
{
syslog(LOG_DAEMON | LOG_ERR,
"%s path must be absolut i.e. starting with a `/', path given: `%s'",
prefix, path);
return 1;
}
return 0;
}
int daemonize_with_pidfile(char const * const pidfile)
{
pid_str ps = {};