diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2022-07-05 17:01:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-05 17:01:00 +0200 |
commit | 76459094605efd46bd71ce28ce9616280f4a440d (patch) | |
tree | 9bbbc1bf8a9eae5111a2121e835f482fc7a05246 /src/lib/ndpi_utils.c | |
parent | 52d987b603f49d996b4060f43265d1cf43c3c482 (diff) |
Fix handling of NDPI_UNIDIRECTIONAL_TRAFFIC risk (#1636)
Diffstat (limited to 'src/lib/ndpi_utils.c')
-rw-r--r-- | src/lib/ndpi_utils.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c index e1a088ee5..15b71caf1 100644 --- a/src/lib/ndpi_utils.c +++ b/src/lib/ndpi_utils.c @@ -2303,6 +2303,33 @@ void ndpi_set_risk(struct ndpi_detection_module_struct *ndpi_str, /* ******************************************************************** */ +void ndpi_unset_risk(struct ndpi_detection_module_struct *ndpi_str, + struct ndpi_flow_struct *flow, ndpi_risk_enum r) { + if(ndpi_isset_risk(ndpi_str, flow, r)) { + u_int8_t i, j; + ndpi_risk v = 1ull << r; + + flow->risk &= ~v; + + for(i = 0; i < flow->num_risk_infos; i++) { + if(flow->risk_infos[i].id == r) { + flow->risk_infos[i].id = 0; + if(flow->risk_infos[i].info) { + ndpi_free(flow->risk_infos[i].info); + flow->risk_infos[i].info = NULL; + } + for(j = i + 1; j < flow->num_risk_infos; j++) { + flow->risk_infos[j - 1].id = flow->risk_infos[j].id; + flow->risk_infos[j - 1].info = flow->risk_infos[j].info; + } + flow->num_risk_infos--; + } + } + } +} + +/* ******************************************************************** */ + int ndpi_isset_risk(struct ndpi_detection_module_struct *ndpi_str, struct ndpi_flow_struct *flow, ndpi_risk_enum r) { ndpi_risk v = 1ull << r; |