diff options
author | Luca Deri <deri@ntop.org> | 2021-08-07 17:10:18 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2021-08-07 17:10:18 +0200 |
commit | 46ebd7128fd38f3eac5289ba281f3f25bad1d899 (patch) | |
tree | 6bfeb6009d2e9bd8f72c7db18b950a1e1945dfe0 /src/lib/ndpi_utils.c | |
parent | dc841574af54d59ca8cfd0aa30fcc471c598dbbb (diff) |
Added ability to report whether a protocol is encrypted
Added new API calls
- u_int8_t ndpi_is_valid_protoId(u_int16_t protoId);
Cleaned up code and organized in a function.
- u_int8_t ndpi_is_encrypted_proto(struct ndpi_detection_module_struct *ndpi_str, ndpi_protocol proto);
Check whether a protocol is encrypted or not based on master and app protocols
Diffstat (limited to 'src/lib/ndpi_utils.c')
-rw-r--r-- | src/lib/ndpi_utils.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c index 48788c15d..0008835f4 100644 --- a/src/lib/ndpi_utils.c +++ b/src/lib/ndpi_utils.c @@ -2226,3 +2226,21 @@ u_int8_t is_a_common_alpn(struct ndpi_detection_module_struct *ndpi_str, return(0); } + +/* ******************************************* */ + +u_int8_t ndpi_is_valid_protoId(u_int16_t protoId) { + return((protoId >= NDPI_MAX_SUPPORTED_PROTOCOLS + NDPI_MAX_NUM_CUSTOM_PROTOCOLS) ? 0 : 1); +} + +/* ******************************************* */ + +u_int8_t ndpi_is_encrypted_proto(struct ndpi_detection_module_struct *ndpi_str, + ndpi_protocol proto) { + + if(ndpi_is_valid_protoId(proto.master_protocol) && ndpi_is_valid_protoId(proto.app_protocol)) { + return((ndpi_str->proto_defaults[proto.master_protocol].isClearTextProto + && ndpi_str->proto_defaults[proto.app_protocol].isClearTextProto) ? 0 : 1); + } else + return(0); +} |