aboutsummaryrefslogtreecommitdiff
path: root/src/lib/ndpi_main.c
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2024-08-24 17:43:04 +0200
committerLuca Deri <deri@ntop.org>2024-08-24 17:43:19 +0200
commitf7ee92c690ebce8841f1ab973b3d63146952f912 (patch)
treefb3ea3ce40b4e12ad25ee580583c2ab1a6aabc11 /src/lib/ndpi_main.c
parent0a4198b35a2c8085942ba1055b1766000f2825c4 (diff)
Added ndpi_get_protocol_by_name*( API call
Diffstat (limited to 'src/lib/ndpi_main.c')
-rw-r--r--src/lib/ndpi_main.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index ae1d546e4..8973e5536 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -298,6 +298,32 @@ u_int16_t ndpi_get_proto_by_name(struct ndpi_detection_module_struct *ndpi_str,
return(NDPI_PROTOCOL_UNKNOWN);
}
+/* *********************************************************************************** */
+
+/* NOTE: supported both HTTP and TLS.YouTube */
+ndpi_master_app_protocol ndpi_get_protocol_by_name(struct ndpi_detection_module_struct *ndpi_str, const char *name) {
+ char *dot, buf[256];
+ ndpi_master_app_protocol ret = { NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_UNKNOWN };
+
+ if(!ndpi_str || !name)
+ return(ret);
+
+ snprintf(buf, sizeof(buf), "%s", name);
+ dot = strchr(buf, '.');
+
+ if(dot) {
+ /* TLS.YouTube */
+ dot[0] = '\0';
+ ret.app_protocol = ndpi_get_proto_by_name(ndpi_str, &dot[1]);
+ } else {
+ /* TLS */
+ }
+
+ ret.master_protocol = ndpi_get_proto_by_name(ndpi_str, buf); /* both cases */
+
+ return(ret);
+}
+
/* ************************************************************************************* */
/* ************************************************************************************* */