From 3a087e951d96f509c75344ad6791591e10e4f1cd Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Tue, 11 Jan 2022 15:23:39 +0100 Subject: Add a "confidence" field about the reliability of the classification. (#1395) As a general rule, the higher the confidence value, the higher the "reliability/precision" of the classification. In other words, this new field provides an hint about "how" the flow classification has been obtained. For example, the application may want to ignore classification "by-port" (they are not real DPI classifications, after all) or give a second glance at flows classified via LRU caches (because of false positives). Setting only one value for the confidence field is a bit tricky: more work is probably needed in the next future to tweak/fix/improve the logic. --- src/lib/protocols/stun.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/lib/protocols/stun.c') diff --git a/src/lib/protocols/stun.c b/src/lib/protocols/stun.c index 722db1695..38df16146 100644 --- a/src/lib/protocols/stun.c +++ b/src/lib/protocols/stun.c @@ -53,6 +53,7 @@ void ndpi_int_stun_add_connection(struct ndpi_detection_module_struct *ndpi_stru struct ndpi_flow_struct *flow, u_int proto, u_int app_proto) { struct ndpi_packet_struct *packet = &ndpi_struct->packet; + ndpi_confidence_t confidence = NDPI_CONFIDENCE_DPI; if(ndpi_struct->stun_cache == NULL) ndpi_struct->stun_cache = ndpi_lru_cache_init(1024); @@ -71,6 +72,7 @@ void ndpi_int_stun_add_connection(struct ndpi_detection_module_struct *ndpi_stru printf("[LRU] FOUND %u / %u: no need to cache %u.%u\n", key, cached_proto, proto, app_proto); #endif app_proto = cached_proto, proto = NDPI_PROTOCOL_STUN; + confidence = NDPI_CONFIDENCE_DPI_CACHE; } else { u_int32_t key_rev = get_stun_lru_key(packet, 1); @@ -80,6 +82,7 @@ void ndpi_int_stun_add_connection(struct ndpi_detection_module_struct *ndpi_stru printf("[LRU] FOUND %u / %u: no need to cache %u.%u\n", key_rev, cached_proto, proto, app_proto); #endif app_proto = cached_proto, proto = NDPI_PROTOCOL_STUN; + confidence = NDPI_CONFIDENCE_DPI_CACHE; } else { if(app_proto != NDPI_PROTOCOL_STUN) { /* No sense to add STUN, but only subprotocols */ @@ -101,7 +104,7 @@ void ndpi_int_stun_add_connection(struct ndpi_detection_module_struct *ndpi_stru } } - ndpi_set_detected_protocol(ndpi_struct, flow, app_proto, proto); + ndpi_set_detected_protocol(ndpi_struct, flow, app_proto, proto, confidence); } typedef enum { -- cgit v1.2.3