From 2103ee0811e3f606b8129d044e22cd33804e2117 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Sat, 24 Sep 2022 23:25:33 +0200 Subject: Refactored client distributor C API. * Still not perfect, but the code before was not even able to deal with JSON arrays. Use common "speaking" function names for all functions in nDPIsrvd.h * Provide a more or less generic and easy extendable JSON walk function. * Modified C examples to align with the changed C API. * c-collectd: Reduced lot's of code duplication by providing mapping tables. * nDPId: IAT array requires one slot less (first packet has always an IAT of 0). Signed-off-by: Toni Uhlig --- examples/c-simple/c-simple.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'examples/c-simple') diff --git a/examples/c-simple/c-simple.c b/examples/c-simple/c-simple.c index abf2e3feb..a923d1424 100644 --- a/examples/c-simple/c-simple.c +++ b/examples/c-simple/c-simple.c @@ -150,13 +150,13 @@ static enum nDPIsrvd_callback_return simple_json_callback(struct nDPIsrvd_socket } struct nDPIsrvd_json_token const * const flow_event_name = TOKEN_GET_SZ(sock, "flow_event_name"); - if (TOKEN_VALUE_EQUALS_SZ(flow_event_name, "new") != 0) + if (TOKEN_VALUE_EQUALS_SZ(sock, flow_event_name, "new") != 0) { printf("Instance %.*s/%.*s (HT-Key: 0x%x), Thread %d, Flow %llu new\n", - alias->value_length, - alias->value, - source->value_length, - source->value, + nDPIsrvd_get_token_size(sock, alias), + nDPIsrvd_get_token_value(sock, alias), + nDPIsrvd_get_token_size(sock, source), + nDPIsrvd_get_token_value(sock, source), instance->alias_source_key, flow->thread_id, flow->id_as_ull); @@ -185,10 +185,10 @@ static void simple_flow_cleanup_callback(struct nDPIsrvd_socket * const sock, char const * const reason_str = nDPIsrvd_enum_to_string(reason); printf("Instance %.*s/%.*s (HT-Key: 0x%x), Thread %d, Flow %llu cleanup, reason: %s\n", - alias->value_length, - alias->value, - source->value_length, - source->value, + nDPIsrvd_get_token_size(sock, alias), + nDPIsrvd_get_token_value(sock, alias), + nDPIsrvd_get_token_size(sock, source), + nDPIsrvd_get_token_value(sock, source), instance->alias_source_key, flow->thread_id, flow->id_as_ull, -- cgit v1.2.3