aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2018-01-26 23:40:23 +0100
committerLuca Deri <deri@ntop.org>2018-01-26 23:40:23 +0100
commitda588f6a30e4c4ce6497fca3939284123017780f (patch)
tree1483625b20ab7740554e72cf2c665f435e2ff128
parentee7a30385ba2ba030c1afb4d4f4cee7abef70329 (diff)
Improved hyperscan support
-rw-r--r--src/lib/ndpi_content_match.c.inc8
-rw-r--r--src/lib/ndpi_main.c17
2 files changed, 17 insertions, 8 deletions
diff --git a/src/lib/ndpi_content_match.c.inc b/src/lib/ndpi_content_match.c.inc
index 435a5dde4..aa5a990ea 100644
--- a/src/lib/ndpi_content_match.c.inc
+++ b/src/lib/ndpi_content_match.c.inc
@@ -8162,11 +8162,11 @@ ndpi_protocol_match host_match[] = {
{ ".sina.com.cn", NULL, NULL, "Sina", NDPI_PROTOCOL_SINA, NDPI_PROTOCOL_CATEGORY_SOCIAL_NETWORK, NDPI_PROTOCOL_FUN },
/* https://support.cipafilter.com/index.php?/Knowledgebase/Article/View/117/0/snapchat---how-to-block */
- { "feelinsonice.appspot.com", NULL, NULL, "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
+ { "feelinsonice.appspot.com", NULL, "\\.appspot\\.com$", "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
{ "feelinsonice-hrd.appspot.com", NULL, NULL, "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
- { "feelinsonice.com", NULL, NULL, "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
- { ".snapchat.", NULL, NULL, "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
- { ".snapads.", NULL, NULL, "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
+ { "feelinsonice.com", NULL, "\\.feelsonice\\.com$", "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
+ { ".snapchat.", NULL, "\\.snapchat\\.com$", "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
+ { ".snapads.", NULL, "\\.snapads\\.com$", "Snapchat", NDPI_PROTOCOL_SNAPCHAT, NDPI_PROTOCOL_CATEGORY_CHAT, NDPI_PROTOCOL_FUN },
/* Detected "instagram.c10r.facebook.com". Omitted "*amazonaws.com" and "*facebook.com" CDNs e.g. "ig-telegraph-shv-04-frc3.facebook.com" */
{ ".cdninstagram.com", NULL, NULL, "Instagram", NDPI_PROTOCOL_INSTAGRAM, NDPI_PROTOCOL_CATEGORY_SOCIAL_NETWORK, NDPI_PROTOCOL_FUN },
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index cfcef8c0b..8d65a50cf 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -750,20 +750,23 @@ static int init_hyperscan(struct ndpi_detection_module_struct *ndpi_mod) {
const char **expressions;
unsigned int *ids;
hs_compile_error_t *compile_err;
- struct hs *hs = (struct hs*)ndpi_mod->hyperscan;
+ struct hs *hs;
ndpi_mod->hyperscan = (void*)malloc(sizeof(struct hs));
if(!ndpi_mod->hyperscan) return(-1);
+ hs = (struct hs*)ndpi_mod->hyperscan;
for(i=0; host_match[i].string_to_match != NULL; i++) {
- if(host_match[i].pattern_to_match)
+ if(host_match[i].pattern_to_match) {
+ /* printf("[DEBUG] %s\n", host_match[i].pattern_to_match); */
num_patterns++;
+ }
}
- expressions = (const char**)malloc(sizeof(char*)*num_patterns);
+ expressions = (const char**)calloc(sizeof(char*), num_patterns+1);
if(!expressions) return(-1);
- ids = (unsigned int*)malloc(sizeof(unsigned int)*num_patterns);
+ ids = (unsigned int*)calloc(sizeof(unsigned int), num_patterns+1);
if(!ids) {
free(expressions);
return(-1);
@@ -794,6 +797,8 @@ static int init_hyperscan(struct ndpi_detection_module_struct *ndpi_mod) {
return 0;
}
+/* ******************************************************************** */
+
static void destroy_hyperscan(struct ndpi_detection_module_struct *ndpi_mod) {
if(ndpi_mod->hyperscan) {
struct hs *hs = (struct hs*)ndpi_mod->hyperscan;
@@ -805,6 +810,8 @@ static void destroy_hyperscan(struct ndpi_detection_module_struct *ndpi_mod) {
#endif
+/* ******************************************************************** */
+
static void init_string_based_protocols(struct ndpi_detection_module_struct *ndpi_mod)
{
int i;
@@ -5056,6 +5063,8 @@ static int ndpi_automa_match_string_subprotocol(struct ndpi_detection_module_str
#else
+/* ******************************************************************** */
+
static int hyperscanEventHandler(unsigned int id, unsigned long long from,
unsigned long long to, unsigned int flags, void *ctx) {
*((int *)ctx) = (int)id;