diff options
Diffstat (limited to 'example')
-rw-r--r-- | example/intrusion_detection.c | 4 | ||||
-rw-r--r-- | example/ndpiReader.c | 10 | ||||
-rw-r--r-- | example/reader_util.c | 22 | ||||
-rw-r--r-- | example/reader_util.h | 2 |
4 files changed, 19 insertions, 19 deletions
diff --git a/example/intrusion_detection.c b/example/intrusion_detection.c index cce25a8b8..7296c2d29 100644 --- a/example/intrusion_detection.c +++ b/example/intrusion_detection.c @@ -154,7 +154,7 @@ double Dos_goldeneye_score(struct ndpi_flow_info* flow){ } double Dos_hulk_score(struct ndpi_flow_info* flow){ - double f = (double)flow->first_seen/1000.0, l = (double)flow->last_seen/1000.0; + double f = (double)flow->first_seen_ms/1000.0, l = (double)flow->last_seen_ms/1000.0; int n_metrics = 6; ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value)); /* duration */ @@ -308,7 +308,7 @@ double Ftp_patator_score(struct ndpi_flow_info* flow){ } double Hearthbleed_score(struct ndpi_flow_info* flow){ - double f = (double)flow->first_seen/1000.0, l = (double)flow->last_seen/1000.0; + double f = (double)flow->first_seen_ms/1000.0, l = (double)flow->last_seen_ms/1000.0; int n_metrics = 6; ndpi_norm_value* scores = malloc(n_metrics * sizeof(ndpi_norm_value)); /* iat_flow_max */ diff --git a/example/ndpiReader.c b/example/ndpiReader.c index b40b7d30e..211019e3b 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -998,7 +998,7 @@ static void printFlow(u_int16_t id, struct ndpi_flow_info *flow, u_int16_t threa if(csv_fp != NULL) { float data_ratio = ndpi_data_ratio(flow->src2dst_bytes, flow->dst2src_bytes); - double f = (double)flow->first_seen, l = (double)flow->last_seen; + double f = (double)flow->first_seen_ms, l = (double)flow->last_seen_ms; /* PLEASE KEEP IN SYNC WITH printCSVHeader() */ dos_ge_score = Dos_goldeneye_score(flow); @@ -1164,8 +1164,8 @@ static void printFlow(u_int16_t id, struct ndpi_flow_info *flow, u_int16_t threa 100.0*((float)flow->src2dst_goodput_bytes / (float)(flow->src2dst_bytes+1)), 100.0*((float)flow->dst2src_goodput_bytes / (float)(flow->dst2src_bytes+1))); - if(flow->last_seen > flow->first_seen) - fprintf(out, "[%.2f sec]", ((float)(flow->last_seen - flow->first_seen))/(float)1000); + if(flow->last_seen_ms > flow->first_seen_ms) + fprintf(out, "[%.2f sec]", ((float)(flow->last_seen_ms - flow->first_seen_ms))/(float)1000); else fprintf(out, "[< 1 sec]"); @@ -1761,7 +1761,7 @@ static void node_idle_scan_walker(const void *node, ndpi_VISIT which, int depth, return; if((which == ndpi_preorder) || (which == ndpi_leaf)) { /* Avoid walking the same node multiple times */ - if(flow->last_seen + MAX_IDLE_TIME < ndpi_thread_info[thread_id].workflow->last_time) { + if(flow->last_seen_ms + MAX_IDLE_TIME < ndpi_thread_info[thread_id].workflow->last_time) { /* update stats */ node_proto_guess_walker(node, which, depth, user_data); @@ -3182,7 +3182,7 @@ void serializerUnitTest() { break; default: printf("ERROR: Unsupported TLV key type %u\n", kt); - // exit(0); + //exit(0); return; } diff --git a/example/reader_util.c b/example/reader_util.c index 833f200bf..b4e2c943a 100644 --- a/example/reader_util.c +++ b/example/reader_util.c @@ -1222,7 +1222,7 @@ void update_tcp_flags_count(struct ndpi_flow_info* flow, struct ndpi_tcphdr* tcp @Note: ipsize = header->len - ip_offset ; rawsize = header->len */ static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow, - const u_int64_t time, + const u_int64_t time_ms, u_int16_t vlan_id, ndpi_packet_tunnel tunnel_type, const struct ndpi_iphdr *iph, @@ -1355,10 +1355,10 @@ static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow, } } - if(flow->first_seen == 0) - flow->first_seen = time; + if(flow->first_seen_ms == 0) + flow->first_seen_ms = time_ms; - flow->last_seen = time; + flow->last_seen_ms = time_ms; /* Copy packets entropy if num packets count == 10 */ ndpi_clear_entropy_stats(flow); @@ -1410,7 +1410,7 @@ static struct ndpi_proto packet_processing(struct ndpi_workflow * workflow, flow->detected_protocol = ndpi_detection_process_packet(workflow->ndpi_struct, ndpi_flow, iph ? (uint8_t *)iph : (uint8_t *)iph6, - ipsize, time, src, dst); + ipsize, time_ms, src, dst); if(enough_packets || (flow->detected_protocol.app_protocol != NDPI_PROTOCOL_UNKNOWN)) { if((!enough_packets) @@ -1484,7 +1484,7 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow, int wifi_len = 0; int pyld_eth_len = 0; int check; - u_int64_t time; + u_int64_t time_ms; u_int16_t ip_offset = 0, ip_len; u_int16_t frag_off = 0, vlan_id = 0; u_int8_t proto = 0, recheck_type; @@ -1497,15 +1497,15 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow, workflow->stats.raw_packet_count++; /* setting time */ - time = ((uint64_t) header->ts.tv_sec) * TICK_RESOLUTION + header->ts.tv_usec / (1000000 / TICK_RESOLUTION); + time_ms = ((uint64_t) header->ts.tv_sec) * TICK_RESOLUTION + header->ts.tv_usec / (1000000 / TICK_RESOLUTION); /* safety check */ - if(workflow->last_time > time) { + if(workflow->last_time > time_ms) { /* printf("\nWARNING: timestamp bug in the pcap file (ts delta: %llu, repairing)\n", ndpi_thread_info[thread_id].last_time - time); */ - time = workflow->last_time; + time_ms = workflow->last_time; } /* update last time value */ - workflow->last_time = time; + workflow->last_time = time_ms; /*** check Data Link type ***/ int datalink_type; @@ -1863,7 +1863,7 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow, } /* process the packet */ - return(packet_processing(workflow, time, vlan_id, tunnel_type, iph, iph6, + return(packet_processing(workflow, time_ms, vlan_id, tunnel_type, iph, iph6, ip_offset, header->caplen - ip_offset, header->caplen, header, packet, header->ts)); } diff --git a/example/reader_util.h b/example/reader_util.h index f8302866f..bcfc1b5b6 100644 --- a/example/reader_util.h +++ b/example/reader_util.h @@ -174,7 +174,7 @@ typedef struct ndpi_flow_info { u_int32_t fin_count, src2dst_fin_count, dst2src_fin_count; u_int32_t rst_count, src2dst_rst_count, dst2src_rst_count; u_int32_t c_to_s_init_win, s_to_c_init_win; - u_int64_t first_seen, last_seen; + u_int64_t first_seen_ms, last_seen_ms; u_int64_t src2dst_bytes, dst2src_bytes; u_int64_t src2dst_goodput_bytes, dst2src_goodput_bytes; u_int32_t src2dst_packets, dst2src_packets; |