diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2022-11-06 13:18:44 +0100 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2022-11-06 13:19:29 +0100 |
commit | e629dd59cdb0c5114b77b5ee5047c664af2cb373 (patch) | |
tree | 32954eab8c329565e9304a55534fed462e3db785 | |
parent | 7515c8aeec3f6e60aa7e97e6903f6306ca7af34e (diff) |
nDPIsrvd.h: Provide two additional convenient API functions.
* nDPIsrvd_json_buffer_string
* nDPIsrvd_json_buffer_length
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r-- | dependencies/nDPIsrvd.h | 10 | ||||
-rw-r--r-- | examples/c-analysed/c-analysed.c | 2 | ||||
-rw-r--r-- | examples/c-captured/c-captured.c | 3 |
3 files changed, 13 insertions, 2 deletions
diff --git a/dependencies/nDPIsrvd.h b/dependencies/nDPIsrvd.h index 60d7f4032..1c0b4c23e 100644 --- a/dependencies/nDPIsrvd.h +++ b/dependencies/nDPIsrvd.h @@ -1645,4 +1645,14 @@ static inline void nDPIsrvd_flow_info(struct nDPIsrvd_socket const * const sock, } } +static inline int nDPIsrvd_json_buffer_length(struct nDPIsrvd_socket const * const sock) +{ + return (int)sock->buffer.json_string_length; +} + +static inline char const *nDPIsrvd_json_buffer_string(struct nDPIsrvd_socket const * const sock) +{ + return sock->buffer.json_string; +} + #endif diff --git a/examples/c-analysed/c-analysed.c b/examples/c-analysed/c-analysed.c index 5e6e14fa8..5d86acfb6 100644 --- a/examples/c-analysed/c-analysed.c +++ b/examples/c-analysed/c-analysed.c @@ -150,7 +150,7 @@ static void csv_buf_add(csv_buf_t buf, size_t * const csv_buf_used, char const * if (siz_len > 0 && str != NULL) { - len = MIN(BUFFER_REMAINING(*csv_buf_used), siz_len); + len = MIN(BUFFER_REMAINING(*csv_buf_used), siz_len - 1); if (len == 0) { return; diff --git a/examples/c-captured/c-captured.c b/examples/c-captured/c-captured.c index 5168c8191..e9fccba76 100644 --- a/examples/c-captured/c-captured.c +++ b/examples/c-captured/c-captured.c @@ -372,7 +372,8 @@ static enum nDPIsrvd_callback_return captured_json_callback(struct nDPIsrvd_sock if (pkt == NULL) { syslog(LOG_DAEMON | LOG_ERR, "%s", "No packet data available."); - return CALLBACK_ERROR; + syslog(LOG_DAEMON | LOG_ERR, "JSON String: \"%.*s\"", nDPIsrvd_json_buffer_length(sock), nDPIsrvd_json_buffer_string(sock)); + return CALLBACK_OK; } if (flow_user->packets == NULL) { |