diff options
author | Luca Deri <deri@ntop.org> | 2020-04-07 19:17:37 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2020-04-07 19:17:37 +0200 |
commit | db8497778ddc578a58caf5447f0b5de3972f64c6 (patch) | |
tree | ddd498ece57a403f7ff133e6135309e0182762b6 | |
parent | dea883a25d97a9b5564cfb6b9d1b0d61a8a818f3 (diff) |
Fixes #853 and adds a self check for duplicates
-rw-r--r-- | example/ndpiReader.c | 4 | ||||
-rw-r--r-- | src/lib/ndpi_content_match.c.inc | 3 | ||||
-rw-r--r-- | src/lib/ndpi_main.c | 18 |
3 files changed, 21 insertions, 4 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c index 1f09e610e..bc9df4294 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -95,7 +95,8 @@ static struct ndpi_detection_module_struct *ndpi_info_mod = NULL; extern u_int32_t max_num_packets_per_flow, max_packet_payload_dissection, max_num_reported_top_payloads; extern u_int16_t min_pattern_len, max_pattern_len; - +extern void ndpi_self_check_host_match(); /* Self check function */ + struct flow_info { struct ndpi_flow_info *flow; u_int16_t thread_id; @@ -3242,6 +3243,7 @@ int orginal_main(int argc, char **argv) { automataUnitTest(); serializerUnitTest(); analyzeUnitTest(); + ndpi_self_check_host_match(); gettimeofday(&startup_time, NULL); ndpi_info_mod = ndpi_init_detection_module(ndpi_no_prefs); diff --git a/src/lib/ndpi_content_match.c.inc b/src/lib/ndpi_content_match.c.inc index 8c8daa665..e7a745a13 100644 --- a/src/lib/ndpi_content_match.c.inc +++ b/src/lib/ndpi_content_match.c.inc @@ -8676,7 +8676,6 @@ static ndpi_protocol_match host_match[] = { { ".aiv-delivery.net", NULL, "\\.aiv-delivery\\.net", "AmazonVideo", NDPI_PROTOCOL_AMAZON_VIDEO, NDPI_PROTOCOL_CATEGORY_VIDEO, NDPI_PROTOCOL_FUN }, { ".aiv-cdn.net", NULL, "\\.aiv-cdn\\.net", "AmazonVideo", NDPI_PROTOCOL_AMAZON_VIDEO, NDPI_PROTOCOL_CATEGORY_VIDEO, NDPI_PROTOCOL_FUN }, { "1s3.lvlt.dash.us.aiv-cdn.net.c.footprint.net", NULL, "1s3\\.lvlt\\.dash\\.us\\.aiv-cdn\\.net\\.c\\.footprint\\.net", "AmazonVideo", NDPI_PROTOCOL_AMAZON_VIDEO, NDPI_PROTOCOL_CATEGORY_STREAMING, NDPI_PROTOCOL_FUN }, - { ".cloudfront.net", NULL, "\\.cloudfront\\.net", "AmazonVideo", NDPI_PROTOCOL_AMAZON_VIDEO, NDPI_PROTOCOL_CATEGORY_VIDEO, NDPI_PROTOCOL_FUN }, { ".s.loris.llnwd.net", NULL, "\\.s\\.loris\\.llnwd\\.net", "AmazonVideo", NDPI_PROTOCOL_AMAZON_VIDEO, NDPI_PROTOCOL_CATEGORY_VIDEO, NDPI_PROTOCOL_FUN }, { "atv-ext.amazon.com", NULL, NULL, "AmazonVideo", NDPI_PROTOCOL_AMAZON_VIDEO, NDPI_PROTOCOL_CATEGORY_VIDEO, NDPI_PROTOCOL_FUN }, { "c.media-amazon.com", NULL, NULL, "AmazonVideo", NDPI_PROTOCOL_AMAZON_VIDEO, NDPI_PROTOCOL_CATEGORY_VIDEO, NDPI_PROTOCOL_FUN }, @@ -8991,7 +8990,6 @@ static ndpi_protocol_match host_match[] = { { ".deezer.com", NULL, "\\.deezer" TLD, "Deezer", NDPI_PROTOCOL_DEEZER, NDPI_PROTOCOL_CATEGORY_MUSIC, NDPI_PROTOCOL_FUN }, - { ".microsoft.com", NULL, "\\.microsoft" TLD, "Microsoft", NDPI_PROTOCOL_MICROSOFT, NDPI_PROTOCOL_CATEGORY_WEB, NDPI_PROTOCOL_SAFE }, { "i-msdn.sec.s-msft.com", NULL, "i-msdn.sec\\.s-msft" TLD, "Microsoft", NDPI_PROTOCOL_MICROSOFT, NDPI_PROTOCOL_CATEGORY_SYSTEM_OS, NDPI_PROTOCOL_ACCEPTABLE }, { "i2-msdn.sec.s-msft.com", NULL, "i2-msdn\\.sec\\.s-msft" TLD, "Microsoft", NDPI_PROTOCOL_MICROSOFT, NDPI_PROTOCOL_CATEGORY_SYSTEM_OS, NDPI_PROTOCOL_ACCEPTABLE }, { ".webtrends.com", NULL, "\\.webtrends" TLD, "Microsoft", NDPI_PROTOCOL_MICROSOFT, NDPI_PROTOCOL_CATEGORY_WEB, NDPI_PROTOCOL_ACCEPTABLE }, @@ -9016,7 +9014,6 @@ static ndpi_protocol_match host_match[] = { { ".webex.com", NULL, "\\.webex" TLD, "Webex", NDPI_PROTOCOL_WEBEX, NDPI_PROTOCOL_CATEGORY_VOIP, NDPI_PROTOCOL_ACCEPTABLE }, { ".zoom.us", NULL, "\\.zoom" TLD, "Zoom", NDPI_PROTOCOL_ZOOM, NDPI_PROTOCOL_CATEGORY_VIDEO, NDPI_PROTOCOL_ACCEPTABLE }, - { ".cloudfront.net", NULL, "\\.cloudfront" TLD, "Zoom", NDPI_PROTOCOL_ZOOM, NDPI_PROTOCOL_CATEGORY_VIDEO, NDPI_PROTOCOL_ACCEPTABLE }, { ".ocsdomain.com", NULL, "\\.ocsdomain" TLD, "OCS", NDPI_PROTOCOL_OCS, NDPI_PROTOCOL_CATEGORY_MEDIA, NDPI_PROTOCOL_FUN }, { "ocs.fr", NULL, "ocs" TLD, "OCS", NDPI_PROTOCOL_OCS, NDPI_PROTOCOL_CATEGORY_MEDIA, NDPI_PROTOCOL_FUN }, diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index 4a187c9a9..5c016174b 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -691,6 +691,24 @@ static void destroy_hyperscan(struct ndpi_detection_module_struct *ndpi_str) { /* ******************************************************************** */ +/* Self check function to be called onli for testing purposes */ +void ndpi_self_check_host_match() { + u_int32_t i, j; + + for(i=0; host_match[i].string_to_match != NULL; i++) { + for(j=0; host_match[j].string_to_match != NULL; j++) { + if((i != j) && (strcmp(host_match[i].string_to_match, host_match[j].string_to_match) == 0)) { + printf("[INTERNAL ERROR]: Duplicate string detected '%s' [id: %u, id %u]\n", + host_match[i].string_to_match, i, j); + printf("\nPlease fix host_match[] in ndpi_content_match.c.inc\n"); + exit(0); + } + } + } +} + +/* ******************************************************************** */ + static void init_string_based_protocols(struct ndpi_detection_module_struct *ndpi_str) { int i; |