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.
This commit is contained in:
@@ -581,6 +581,15 @@ extern "C" {
|
||||
const char* ndpi_category_get_name(struct ndpi_detection_module_struct *ndpi_mod,
|
||||
ndpi_protocol_category_t category);
|
||||
|
||||
/**
|
||||
* Get classification confidence as string
|
||||
*
|
||||
* @par confidence = the confidence value
|
||||
* @return the string name of the confidence result
|
||||
*
|
||||
*/
|
||||
const char* ndpi_confidence_get_name(ndpi_confidence_t confidence);
|
||||
|
||||
/**
|
||||
* Set protocol category string
|
||||
*
|
||||
|
||||
@@ -77,7 +77,8 @@ extern "C" {
|
||||
void ndpi_set_detected_protocol(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow,
|
||||
u_int16_t upper_detected_protocol,
|
||||
u_int16_t lower_detected_protocol);
|
||||
u_int16_t lower_detected_protocol,
|
||||
ndpi_confidence_t confidence);
|
||||
|
||||
extern void ndpi_parse_packet_line_info(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow);
|
||||
|
||||
@@ -846,6 +846,28 @@ typedef struct {
|
||||
u_int16_t port_low, port_high;
|
||||
} ndpi_port_range;
|
||||
|
||||
typedef enum {
|
||||
NDPI_CONFIDENCE_UNKNOWN = 0, /* Unknown classification */
|
||||
NDPI_CONFIDENCE_MATCH_BY_PORT, /* Classification obtained looking only at the L4 ports */
|
||||
NDPI_CONFIDENCE_MATCH_BY_IP, /* Classification obtained looking only at the L3 addresses */
|
||||
NDPI_CONFIDENCE_DPI_SRC_DST_ID, /* Classification results based on ndpi_id_struct structures */
|
||||
NDPI_CONFIDENCE_DPI_CACHE, /* Classification results based on same LRU cache (i.e. correlation among sessions) */
|
||||
NDPI_CONFIDENCE_DPI, /* Deep packet inspection */
|
||||
|
||||
/*
|
||||
IMPORTANT
|
||||
|
||||
Please keep in sync with
|
||||
|
||||
ndpi_confidence_get_name()
|
||||
|
||||
in ndpi_main.c
|
||||
*/
|
||||
|
||||
/* Last one */
|
||||
NDPI_CONFIDENCE_MAX,
|
||||
} ndpi_confidence_t;
|
||||
|
||||
typedef enum {
|
||||
NDPI_PROTOCOL_SAFE = 0, /* Surely doesn't provide risks for the network. (e.g., a news site) */
|
||||
NDPI_PROTOCOL_ACCEPTABLE, /* Probably doesn't provide risks, but could be malicious (e.g., Dropbox) */
|
||||
@@ -1144,6 +1166,7 @@ struct ndpi_flow_struct {
|
||||
u_int16_t guessed_protocol_id, guessed_host_protocol_id, guessed_category, guessed_header_category;
|
||||
u_int8_t l4_proto, protocol_id_already_guessed:1, host_already_guessed:1, fail_with_unknown:1,
|
||||
init_finished:1, setup_packet_direction:1, packet_direction:1, check_extra_packets:1, is_ipv6:1;
|
||||
u_int8_t confidence; /* ndpi_confidence_t */
|
||||
|
||||
/*
|
||||
if ndpi_struct->direction_detect_disable == 1
|
||||
|
||||
Reference in New Issue
Block a user