Improved message for known proto on non std port

This commit is contained in:
Luca Deri
2022-05-30 23:23:18 +02:00
parent b3bf695723
commit b306a4b8ed
+21 -2
View File
@@ -6161,8 +6161,27 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct
sport, dport); sport, dport);
if((r == NULL) if((r == NULL)
|| ((r->proto->protoId != ret.app_protocol) && (r->proto->protoId != ret.master_protocol))) || ((r->proto->protoId != ret.app_protocol) && (r->proto->protoId != ret.master_protocol))) {
ndpi_set_risk(ndpi_str, flow, NDPI_KNOWN_PROTOCOL_ON_NON_STANDARD_PORT, NULL); if(default_ports[0] != 0) {
char str[64];
u_int8_t i, offset;
offset = snprintf(str, sizeof(str), "Expected on port ");
for(i=0; (i<MAX_DEFAULT_PORTS) && (default_ports[i] != 0); i++) {
int rc = snprintf(&str[offset], sizeof(str)-offset, "%s%u",
(i > 0) ? "," : "", default_ports[i]);
if(rc > 0)
offset += rc;
else
break;
}
str[offset] = '\0';
ndpi_set_risk(ndpi_str, flow, NDPI_KNOWN_PROTOCOL_ON_NON_STANDARD_PORT, str);
}
}
} }
} }
} else if((!ndpi_is_ntop_protocol(&ret)) && default_ports && (default_ports[0] != 0)) { } else if((!ndpi_is_ntop_protocol(&ret)) && default_ports && (default_ports[0] != 0)) {