nDPIsrvd.h: Provide two additional convenient API functions.

* nDPIsrvd_json_buffer_string
 * nDPIsrvd_json_buffer_length

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
Toni Uhlig
2022-11-06 13:18:44 +01:00
parent 7515c8aeec
commit e629dd59cd
3 changed files with 13 additions and 2 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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)
{