Merge pull request #752 from marcopiangatello/dev
ndpi_has_human_readeable_string Test
This commit is contained in:
+20
-3
@@ -58,7 +58,9 @@
|
|||||||
|
|
||||||
#include "ndpi_util.h"
|
#include "ndpi_util.h"
|
||||||
|
|
||||||
|
|
||||||
/** Client parameters **/
|
/** Client parameters **/
|
||||||
|
|
||||||
static char *_pcap_file[MAX_NUM_READER_THREADS]; /**< Ingress pcap file/interfaces */
|
static char *_pcap_file[MAX_NUM_READER_THREADS]; /**< Ingress pcap file/interfaces */
|
||||||
static FILE *playlist_fp[MAX_NUM_READER_THREADS] = { NULL }; /**< Ingress playlist */
|
static FILE *playlist_fp[MAX_NUM_READER_THREADS] = { NULL }; /**< Ingress playlist */
|
||||||
static FILE *results_file = NULL;
|
static FILE *results_file = NULL;
|
||||||
@@ -831,6 +833,15 @@ static void printFlow(u_int16_t id, struct ndpi_flow_info *flow, u_int16_t threa
|
|||||||
if(flow->bittorent_hash[0] != '\0') fprintf(out, "[BT Hash: %s]", flow->bittorent_hash);
|
if(flow->bittorent_hash[0] != '\0') fprintf(out, "[BT Hash: %s]", flow->bittorent_hash);
|
||||||
if(flow->dhcp_fingerprint[0] != '\0') fprintf(out, "[DHCP Fingerprint: %s]", flow->dhcp_fingerprint);
|
if(flow->dhcp_fingerprint[0] != '\0') fprintf(out, "[DHCP Fingerprint: %s]", flow->dhcp_fingerprint);
|
||||||
|
|
||||||
|
//fprintf(out, "[Num_Packt_Human_Readable_String: %d]", flow->n_pckt_human_readable_string);
|
||||||
|
|
||||||
|
|
||||||
|
//if( (flow->detected_protocol.app_protocol == NDPI_PROTOCOL_HTTP ) && (flow->n_pckt_human_readable_string == 0) ) printf("!WARNING!");
|
||||||
|
//if( (flow->detected_protocol.app_protocol == NDPI_PROTOCOL_FTP_CONTROL) && (flow->n_pckt_human_readable_string == 0) ) printf("!WARNING!");
|
||||||
|
//if( (flow->detected_protocol.app_protocol == NDPI_PROTOCOL_NTP ) && (flow->n_pckt_human_readable_string != 0) ) printf("!WARNING!");
|
||||||
|
//if( (flow->detected_protocol.app_protocol == NDPI_PROTOCOL_IP_ICMP ) && (flow->n_pckt_human_readable_string != 0) ) printf("!WARNING!");
|
||||||
|
//if( (flow->detected_protocol.app_protocol == NDPI_PROTOCOL_VNC ) && (flow->n_pckt_human_readable_string != 0 ) ) printf("!WARNING!");
|
||||||
|
|
||||||
fprintf(out, "\n");
|
fprintf(out, "\n");
|
||||||
} else {
|
} else {
|
||||||
#ifdef HAVE_JSON_C
|
#ifdef HAVE_JSON_C
|
||||||
@@ -2286,8 +2297,8 @@ static void printFlowsStats() {
|
|||||||
qsort(all_flows, num_flows, sizeof(struct flow_info), cmpFlows);
|
qsort(all_flows, num_flows, sizeof(struct flow_info), cmpFlows);
|
||||||
|
|
||||||
if(verbose > 1) {
|
if(verbose > 1) {
|
||||||
for(i=0; i<num_flows; i++)
|
for(i=0; i<num_flows; i++)
|
||||||
printFlow(i+1, all_flows[i].flow, all_flows[i].thread_id);
|
printFlow(i+1, all_flows[i].flow, all_flows[i].thread_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(thread_id = 0; thread_id < num_threads; thread_id++) {
|
for(thread_id = 0; thread_id < num_threads; thread_id++) {
|
||||||
@@ -2793,7 +2804,10 @@ static void ndpi_process_packet(u_char *args,
|
|||||||
/* allocate an exact size buffer to check overflows */
|
/* allocate an exact size buffer to check overflows */
|
||||||
uint8_t *packet_checked = malloc(header->caplen);
|
uint8_t *packet_checked = malloc(header->caplen);
|
||||||
|
|
||||||
/* ndpi_has_human_readeable_string(ndpi_info_mod, (char*)packet, header->caplen, 3); */
|
ndpi_thread_info[thread_id].workflow->hrs = 0;
|
||||||
|
if (ndpi_has_human_readeable_string(ndpi_info_mod, (char*)packet, header->caplen) == 1) {
|
||||||
|
ndpi_thread_info[thread_id].workflow->hrs = 1;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(packet_checked, packet, header->caplen);
|
memcpy(packet_checked, packet, header->caplen);
|
||||||
p = ndpi_workflow_process_packet(ndpi_thread_info[thread_id].workflow, header, packet_checked);
|
p = ndpi_workflow_process_packet(ndpi_thread_info[thread_id].workflow, header, packet_checked);
|
||||||
@@ -3783,11 +3797,14 @@ int orginal_main(int argc, char **argv) {
|
|||||||
for(i=0; i<num_loops; i++)
|
for(i=0; i<num_loops; i++)
|
||||||
test_lib();
|
test_lib();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(results_path) free(results_path);
|
if(results_path) free(results_path);
|
||||||
if(results_file) fclose(results_file);
|
if(results_file) fclose(results_file);
|
||||||
if(extcap_dumper) pcap_dump_close(extcap_dumper);
|
if(extcap_dumper) pcap_dump_close(extcap_dumper);
|
||||||
if(ndpi_info_mod) ndpi_exit_detection_module(ndpi_info_mod);
|
if(ndpi_info_mod) ndpi_exit_detection_module(ndpi_info_mod);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -459,11 +459,32 @@ static struct ndpi_flow_info *get_ndpi_flow_info(struct ndpi_workflow * workflow
|
|||||||
|
|
||||||
*src = newflow->src_id, *dst = newflow->dst_id;
|
*src = newflow->src_id, *dst = newflow->dst_id;
|
||||||
|
|
||||||
|
if(workflow->hrs == 1){
|
||||||
|
/* count if no SSL protocol */
|
||||||
|
if((newflow->detected_protocol.app_protocol != NDPI_PROTOCOL_SSL)
|
||||||
|
&& (newflow->detected_protocol.master_protocol != NDPI_PROTOCOL_SSL)){
|
||||||
|
newflow->n_pckt_human_readable_string++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return newflow;
|
return newflow;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
struct ndpi_flow_info *flow = *(struct ndpi_flow_info**)ret;
|
struct ndpi_flow_info *flow = *(struct ndpi_flow_info**)ret;
|
||||||
|
|
||||||
|
if(workflow->hrs == 1){
|
||||||
|
/* count if no SSL protocol */
|
||||||
|
if((flow->detected_protocol.app_protocol != NDPI_PROTOCOL_SSL)
|
||||||
|
&& (flow->detected_protocol.master_protocol != NDPI_PROTOCOL_SSL)){
|
||||||
|
flow->n_pckt_human_readable_string++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if((flow->detected_protocol.app_protocol == NDPI_PROTOCOL_SSL)
|
||||||
|
|| (flow->detected_protocol.master_protocol == NDPI_PROTOCOL_SSL)){
|
||||||
|
flow->n_pckt_human_readable_string = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(is_changed) {
|
if(is_changed) {
|
||||||
if(flow->src_ip == iph->saddr
|
if(flow->src_ip == iph->saddr
|
||||||
&& flow->dst_ip == iph->daddr
|
&& flow->dst_ip == iph->daddr
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ typedef struct ndpi_flow_info {
|
|||||||
u_int64_t last_seen;
|
u_int64_t last_seen;
|
||||||
u_int64_t src2dst_bytes, dst2src_bytes;
|
u_int64_t src2dst_bytes, dst2src_bytes;
|
||||||
u_int32_t src2dst_packets, dst2src_packets;
|
u_int32_t src2dst_packets, dst2src_packets;
|
||||||
|
u_int32_t n_pckt_human_readable_string;
|
||||||
|
|
||||||
// result only, not used for flow identification
|
// result only, not used for flow identification
|
||||||
ndpi_protocol detected_protocol;
|
ndpi_protocol detected_protocol;
|
||||||
@@ -199,6 +200,9 @@ typedef struct ndpi_workflow {
|
|||||||
void **ndpi_flows_root;
|
void **ndpi_flows_root;
|
||||||
struct ndpi_detection_module_struct *ndpi_struct;
|
struct ndpi_detection_module_struct *ndpi_struct;
|
||||||
u_int32_t num_allocated_flows;
|
u_int32_t num_allocated_flows;
|
||||||
|
|
||||||
|
int hrs;
|
||||||
|
|
||||||
} ndpi_workflow_t;
|
} ndpi_workflow_t;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user