Aligned DNS to HTTP dissection

This commit is contained in:
Luca Deri
2019-02-07 22:44:48 +01:00
parent 2ec41c1732
commit ddf0066c11
4 changed files with 26 additions and 25 deletions
+1 -1
View File
@@ -1459,7 +1459,7 @@ static void setupDetection(u_int16_t thread_id, pcap_t * pcap_handle) {
ndpi_set_detection_preferences(ndpi_thread_info[thread_id].workflow->ndpi_struct, ndpi_set_detection_preferences(ndpi_thread_info[thread_id].workflow->ndpi_struct,
ndpi_pref_http_dont_dissect_response, 0); ndpi_pref_http_dont_dissect_response, 0);
ndpi_set_detection_preferences(ndpi_thread_info[thread_id].workflow->ndpi_struct, ndpi_set_detection_preferences(ndpi_thread_info[thread_id].workflow->ndpi_struct,
ndpi_pref_dns_dissect_response, 0); ndpi_pref_dns_dont_dissect_response, 0);
ndpi_set_detection_preferences(ndpi_thread_info[thread_id].workflow->ndpi_struct, ndpi_set_detection_preferences(ndpi_thread_info[thread_id].workflow->ndpi_struct,
ndpi_pref_enable_category_substring_match, 1); ndpi_pref_enable_category_substring_match, 1);
+2 -2
View File
@@ -827,7 +827,7 @@ typedef enum {
typedef enum { typedef enum {
ndpi_pref_http_dont_dissect_response = 0, ndpi_pref_http_dont_dissect_response = 0,
ndpi_pref_dns_dissect_response, ndpi_pref_dns_dont_dissect_response,
ndpi_pref_direction_detect_disable, ndpi_pref_direction_detect_disable,
ndpi_pref_disable_metadata_export, ndpi_pref_disable_metadata_export,
ndpi_pref_enable_category_substring_match ndpi_pref_enable_category_substring_match
@@ -1008,7 +1008,7 @@ struct ndpi_detection_module_struct {
ndpi_proto_defaults_t proto_defaults[NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS]; ndpi_proto_defaults_t proto_defaults[NDPI_MAX_SUPPORTED_PROTOCOLS+NDPI_MAX_NUM_CUSTOM_PROTOCOLS];
u_int8_t http_dont_dissect_response:1, dns_dissect_response:1, u_int8_t http_dont_dissect_response:1, dns_dont_dissect_response:1,
direction_detect_disable:1, /* disable internal detection of packet direction */ direction_detect_disable:1, /* disable internal detection of packet direction */
disable_metadata_export:1, /* No metadata is exported */ disable_metadata_export:1, /* No metadata is exported */
enable_category_substring_match:1 /* Default is perfect match */ enable_category_substring_match:1 /* Default is perfect match */
+2 -2
View File
@@ -942,8 +942,8 @@ int ndpi_set_detection_preferences(struct ndpi_detection_module_struct *ndpi_mod
ndpi_mod->http_dont_dissect_response = (u_int8_t)value; ndpi_mod->http_dont_dissect_response = (u_int8_t)value;
break; break;
case ndpi_pref_dns_dissect_response: case ndpi_pref_dns_dont_dissect_response:
ndpi_mod->dns_dissect_response = (u_int8_t)value; ndpi_mod->dns_dont_dissect_response = (u_int8_t)value;
break; break;
case ndpi_pref_direction_detect_disable: case ndpi_pref_direction_detect_disable:
+5 -4
View File
@@ -128,7 +128,6 @@ void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct nd
} }
} else } else
invalid = 1; invalid = 1;
} else { } else {
/* DNS Reply */ /* DNS Reply */
@@ -140,7 +139,7 @@ void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct nd
|| ((dns_header.additional_rrs > 0) && (dns_header.additional_rrs <= NDPI_MAX_DNS_REQUESTS))) || ((dns_header.additional_rrs > 0) && (dns_header.additional_rrs <= NDPI_MAX_DNS_REQUESTS)))
) { ) {
/* This is a good reply */ /* This is a good reply */
if(ndpi_struct->dns_dissect_response) { if(ndpi_struct->dns_dont_dissect_response == 0) {
x++; x++;
if(flow->packet.payload[x] != '\0') { if(flow->packet.payload[x] != '\0') {
@@ -199,8 +198,10 @@ void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct nd
off++; off++;
} }
if(is_query && ndpi_struct->dns_dissect_response) if(is_query && (ndpi_struct->dns_dont_dissect_response == 0)) {
return; /* The response will set the verdict */ // dpi_set_detected_protocol(ndpi_struct, flow, (d_port == 5355) ? NDPI_PROTOCOL_LLMNR : NDPI_PROTOCOL_DNS, NDPI_PROTOCOL_UNKNOWN);
return; /* The response will set the verdict */
}
flow->host_server_name[j] = '\0'; flow->host_server_name[j] = '\0';