aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/ndpi_api.h33
-rw-r--r--src/lib/ndpi_main.c56
2 files changed, 22 insertions, 67 deletions
diff --git a/src/include/ndpi_api.h b/src/include/ndpi_api.h
index 48c87676d..9a0620f23 100644
--- a/src/include/ndpi_api.h
+++ b/src/include/ndpi_api.h
@@ -63,24 +63,6 @@ extern "C" {
*/
u_int32_t ndpi_detection_get_sizeof_ndpi_flow_struct(void);
-
- /**
- * Get the size of the flow tcp struct
- *
- * @return the size of the flow tcp struct
- *
- */
- u_int32_t ndpi_detection_get_sizeof_ndpi_flow_tcp_struct(void);
-
-
- /**
- * Get the size of the flow udp struct
- *
- * @return the size of the flow udp struct
- *
- */
- u_int32_t ndpi_detection_get_sizeof_ndpi_flow_udp_struct(void);
-
/*
Same as the API call above but used for matching raw id's added
via ndpi_add_string_value_to_automa()
@@ -884,20 +866,6 @@ extern "C" {
void ndpi_set_automa(struct ndpi_detection_module_struct *ndpi_struct,
void* automa);
- /* NDPI_PROTOCOL_TOR */
- /**
- * Check if the flow could be detected as TOR protocol
- *
- * @par ndpi_struct = the detection module
- * @par flow = the detected flow
- * @par certificate = the SSL/TLS certificate
- * @return 1 if the flow is TOR;
- * 0 else
- *
- */
- int ndpi_is_tls_tor(struct ndpi_detection_module_struct *ndpi_struct,
- struct ndpi_flow_struct *flow, char *certificate);
-
/* Wrappers functions */
/**
* Init Aho-Corasick automata
@@ -1012,7 +980,6 @@ extern "C" {
u_int16_t user_proto_id);
u_int16_t ndpi_map_ndpi_id_to_user_proto_id(struct ndpi_detection_module_struct *ndpi_str,
u_int16_t ndpi_proto_id);
- void ndpi_self_check_host_match(FILE *error_out);
/* Tells to called on what l4 protocol given application protocol can be found */
ndpi_l4_proto_info ndpi_get_l4_proto_info(struct ndpi_detection_module_struct *ndpi_struct, u_int16_t ndpi_proto_id);
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index 3ecff0fb0..8b0c6f612 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -282,18 +282,6 @@ u_int32_t ndpi_detection_get_sizeof_ndpi_flow_struct(void) {
/* *********************************************************************************** */
-u_int32_t ndpi_detection_get_sizeof_ndpi_flow_tcp_struct(void) {
- return(sizeof(struct ndpi_flow_tcp_struct));
-}
-
-/* *********************************************************************************** */
-
-u_int32_t ndpi_detection_get_sizeof_ndpi_flow_udp_struct(void) {
- return(sizeof(struct ndpi_flow_udp_struct));
-}
-
-/* *********************************************************************************** */
-
char *ndpi_get_proto_by_id(struct ndpi_detection_module_struct *ndpi_str, u_int id) {
return(!ndpi_is_valid_protoId(ndpi_str, id) ? NULL : ndpi_str->proto_defaults[id].protoName);
}
@@ -1021,28 +1009,21 @@ void ndpi_init_protocol_match(struct ndpi_detection_module_struct *ndpi_str,
/* ******************************************************************** */
/* Self check function to be called only for testing purposes */
-void ndpi_self_check_host_match(FILE *error_out) {
+static void self_check_host_match(struct ndpi_detection_module_struct *ndpi_str,
+ ndpi_protocol_match *hosts) {
u_int32_t i, j;
- for(i = 0; host_match[i].string_to_match != NULL; i++) {
- if(host_match[i].string_to_match[0] == '.') {
- if (error_out != NULL) {
- fprintf(error_out,
- "[NDPI] INTERNAL ERROR Invalid string detected '%s'. It can not start with '.'\n",
- host_match[i].string_to_match);
- fprintf(error_out, "\nPlease fix host_match[] in ndpi_content_match.c.inc\n");
- }
- abort();
+ for(i = 0; hosts[i].string_to_match != NULL; i++) {
+ if(hosts[i].string_to_match[0] == '.') {
+ NDPI_LOG_ERR(ndpi_str,
+ "[NDPI] INTERNAL ERROR Invalid string detected '%s'. It can not start with '.'\n",
+ hosts[i].string_to_match);
}
- 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)) {
- if (error_out != NULL) {
- fprintf(error_out,
- "[NDPI] INTERNAL ERROR duplicate string detected '%s' [id: %u, id %u]\n",
- host_match[i].string_to_match, i, j);
- fprintf(error_out, "\nPlease fix host_match[] in ndpi_content_match.c.inc\n");
- }
- abort();
+ for(j = 0; hosts[j].string_to_match != NULL; j++) {
+ if((i != j) && (strcmp(hosts[i].string_to_match, hosts[j].string_to_match) == 0)) {
+ NDPI_LOG_ERR(ndpi_str,
+ "[NDPI] INTERNAL ERROR duplicate string detected '%s' [id: %u, id %u]\n",
+ hosts[i].string_to_match, i, j);
}
}
}
@@ -1091,9 +1072,16 @@ static void ndpi_xgrams_init(struct ndpi_detection_module_struct *ndpi_str,
static void init_string_based_protocols(struct ndpi_detection_module_struct *ndpi_str) {
int i;
+ /* Sanity checks */
+ self_check_host_match(ndpi_str, host_match);
+ self_check_host_match(ndpi_str, teams_host_match);
+ self_check_host_match(ndpi_str, outlook_host_match);
+ self_check_host_match(ndpi_str, ms_onedrive_host_match);
+ self_check_host_match(ndpi_str, microsoft365_host_match);
+ self_check_host_match(ndpi_str, azure_host_match);
+
for(i = 0; host_match[i].string_to_match != NULL; i++)
ndpi_init_protocol_match(ndpi_str, &host_match[i]);
-
for(i = 0; teams_host_match[i].string_to_match != NULL; i++)
ndpi_init_protocol_match(ndpi_str, &teams_host_match[i]);
for(i = 0; outlook_host_match[i].string_to_match != NULL; i++)
@@ -1138,7 +1126,7 @@ static void init_string_based_protocols(struct ndpi_detection_module_struct *ndp
/* ******************************************************************** */
-static void ndpi_validate_protocol_initialization(struct ndpi_detection_module_struct *ndpi_str) {
+static void validate_protocol_initialization(struct ndpi_detection_module_struct *ndpi_str) {
u_int i;
for(i = 0; i < ndpi_str->num_supported_protocols; i++) {
@@ -4196,7 +4184,7 @@ int ndpi_finalize_initialization(struct ndpi_detection_module_struct *ndpi_str)
if(!ndpi_str->custom_categories.categories_loaded)
ndpi_enable_loaded_categories(ndpi_str);
- ndpi_validate_protocol_initialization(ndpi_str);
+ validate_protocol_initialization(ndpi_str);
if(ndpi_str->cfg.libgcrypt_init) {
if(!gcry_control(GCRYCTL_INITIALIZATION_FINISHED_P)) {