diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2021-04-08 20:33:25 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2021-04-09 00:18:35 +0200 |
commit | 0a7ad7a76ac34d7a0c7635591203de08979b60da (patch) | |
tree | 28b1afb918be5733b85501df4affbded3c4fe100 /examples/c-collectd | |
parent | e576162a43c78290961b0b6c8cd3e5cc2965316f (diff) |
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>
Diffstat (limited to 'examples/c-collectd')
-rw-r--r-- | examples/c-collectd/c-collectd.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/examples/c-collectd/c-collectd.c b/examples/c-collectd/c-collectd.c index 291676817..42e8b6020 100644 --- a/examples/c-collectd/c-collectd.c +++ b/examples/c-collectd/c-collectd.c @@ -89,6 +89,7 @@ static struct uint64_t flow_l3_other_count; uint64_t flow_l4_tcp_count; uint64_t flow_l4_udp_count; + uint64_t flow_l4_icmp_count; uint64_t flow_l4_other_count; } collectd_statistics = {}; @@ -313,13 +314,15 @@ static void print_collectd_exec_output(void) printf(COLLECTD_PUTVAL_N_FORMAT(flow_l3_ip4_count) COLLECTD_PUTVAL_N_FORMAT(flow_l3_ip6_count) COLLECTD_PUTVAL_N_FORMAT(flow_l3_other_count) COLLECTD_PUTVAL_N_FORMAT(flow_l4_tcp_count) - COLLECTD_PUTVAL_N_FORMAT(flow_l4_udp_count) COLLECTD_PUTVAL_N_FORMAT(flow_l4_other_count), + COLLECTD_PUTVAL_N_FORMAT(flow_l4_udp_count) COLLECTD_PUTVAL_N_FORMAT(flow_l4_icmp_count) + COLLECTD_PUTVAL_N_FORMAT(flow_l4_other_count), COLLECTD_PUTVAL_N(flow_l3_ip4_count), COLLECTD_PUTVAL_N(flow_l3_ip6_count), COLLECTD_PUTVAL_N(flow_l3_other_count), COLLECTD_PUTVAL_N(flow_l4_tcp_count), COLLECTD_PUTVAL_N(flow_l4_udp_count), + COLLECTD_PUTVAL_N(flow_l4_icmp_count), COLLECTD_PUTVAL_N(flow_l4_other_count)); memset(&collectd_statistics, 0, sizeof(collectd_statistics)); @@ -370,8 +373,8 @@ static int mainloop(int epollfd) return 1; } - enum nDPIsrvd_parse_return parse_ret = nDPIsrvd_parse(sock); - if (parse_ret != PARSE_OK) + enum nDPIsrvd_parse_return parse_ret = nDPIsrvd_parse_all(sock); + if (parse_ret != PARSE_NEED_MORE_DATA) { LOG(LOG_DAEMON | LOG_ERR, "nDPIsrvd parse failed with: %s", nDPIsrvd_enum_to_string(parse_ret)); return 1; @@ -424,14 +427,18 @@ static enum nDPIsrvd_callback_return captured_json_callback(struct nDPIsrvd_sock } struct nDPIsrvd_json_token const * const l4_proto = TOKEN_GET_SZ(sock, "l4_proto"); - if (TOKEN_VALUE_EQUALS_SZ(l3_proto, "tcp") != 0) + if (TOKEN_VALUE_EQUALS_SZ(l4_proto, "tcp") != 0) { collectd_statistics.flow_l4_tcp_count++; } - else if (TOKEN_VALUE_EQUALS_SZ(l3_proto, "tcp") != 0) + else if (TOKEN_VALUE_EQUALS_SZ(l4_proto, "udp") != 0) { collectd_statistics.flow_l4_udp_count++; } + else if (TOKEN_VALUE_EQUALS_SZ(l4_proto, "icmp") != 0) + { + collectd_statistics.flow_l4_icmp_count++; + } else if (l4_proto != NULL) { collectd_statistics.flow_l4_other_count++; |