diff options
author | Luca Deri <deri@ntop.org> | 2020-05-24 08:46:10 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2020-05-24 08:46:10 +0200 |
commit | ee35834be6e40ac9de03b3685052ed701847ca53 (patch) | |
tree | 7b1985b8daf12dec40b2b370f942b6396c40326e /src/lib/ndpi_utils.c | |
parent | e5c2c400efa7a9b239be36ca95dd296a779ae363 (diff) |
Added flow risk serilization
Diffstat (limited to 'src/lib/ndpi_utils.c')
-rw-r--r-- | src/lib/ndpi_utils.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c index 4a30b1954..69ef5990c 100644 --- a/src/lib/ndpi_utils.c +++ b/src/lib/ndpi_utils.c @@ -902,6 +902,26 @@ char* ndpi_base64_encode(unsigned char const* bytes_to_encode, size_t in_len) { } /* ********************************** */ + +static void ndpi_serialize_risk(ndpi_serializer *serializer, + struct ndpi_flow_struct *flow) { + if(flow->risk != 0) { + u_int32_t i; + + ndpi_serialize_start_of_block(serializer, "flow_risk"); + + for(i = 0; i < NDPI_MAX_RISK; i++) { + ndpi_risk_enum r = (ndpi_risk_enum)i; + + if(NDPI_ISSET_BIT(flow->risk, r)) + ndpi_serialize_uint32_string(serializer, i, ndpi_risk2str(r)); + } + + ndpi_serialize_end_of_block(serializer); + } +} + +/* ********************************** */ /* ********************************** */ int ndpi_flow2json(struct ndpi_detection_module_struct *ndpi_struct, @@ -951,6 +971,8 @@ int ndpi_flow2json(struct ndpi_detection_module_struct *ndpi_struct, break; } + ndpi_serialize_risk(serializer, flow); + ndpi_serialize_start_of_block(serializer, "ndpi"); ndpi_serialize_string_string(serializer, "proto", ndpi_protocol2name(ndpi_struct, l7_protocol, buf, sizeof(buf))); if(l7_protocol.category != NDPI_PROTOCOL_CATEGORY_UNSPECIFIED) |