aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorLuca Deri <lucaderi@users.noreply.github.com>2020-06-28 21:32:08 +0200
committerGitHub <noreply@github.com>2020-06-28 21:32:08 +0200
commit93a4a4387af951a4680061bf4e1effa87fa65406 (patch)
tree5cf4f6cf539587d2e73dd751ac38b7547a3a1533 /example
parentb2e89e67361a931672281f680faede0551542eea (diff)
parentf39e3c98f05e84f263af7d74bcedb1051efa7169 (diff)
Merge pull request #938 from IvanNardi/errors
Errors
Diffstat (limited to 'example')
-rw-r--r--example/ndpiReader.c16
-rw-r--r--example/reader_util.c37
-rw-r--r--example/reader_util.h4
3 files changed, 36 insertions, 21 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 57f8048df..2ded09888 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -843,9 +843,6 @@ static void parseOptions(int argc, char **argv) {
}
}
- if(_pcap_file[0] == NULL)
- help(0);
-
if(csv_fp)
printCSVHeader();
@@ -855,6 +852,9 @@ static void parseOptions(int argc, char **argv) {
extcap_capture();
}
+ if(_pcap_file[0] == NULL)
+ help(0);
+
if(strchr(_pcap_file[0], ',')) { /* multiple ingress interfaces */
num_threads = 0; /* setting number of threads = number of interfaces */
__pcap_file = strtok(_pcap_file[0], ",");
@@ -1823,13 +1823,13 @@ static void node_idle_scan_walker(const void *node, ndpi_VISIT which, int depth,
/* update stats */
node_proto_guess_walker(node, which, depth, user_data);
+ if(verbose == 3)
+ port_stats_walker(node, which, depth, user_data);
if((flow->detected_protocol.app_protocol == NDPI_PROTOCOL_UNKNOWN) && !undetected_flows_deleted)
undetected_flows_deleted = 1;
- ndpi_free_flow_info_half(flow);
- ndpi_free_flow_data_analysis(flow);
- ndpi_free_flow_tls_data(flow);
+ ndpi_flow_info_free_data(flow);
ndpi_thread_info[thread_id].workflow->stats.ndpi_flow_count--;
/* adding to a queue (we can't delete it from the tree inline ) */
@@ -3089,6 +3089,10 @@ void test_lib() {
}
}
+#ifdef USE_DPDK
+ dpdk_port_deinit(dpdk_port_id);
+#endif
+
gettimeofday(&end, NULL);
processing_time_usec = end.tv_sec*1000000 + end.tv_usec - (begin.tv_sec*1000000 + begin.tv_usec);
setup_time_usec = begin.tv_sec*1000000 + begin.tv_usec - (startup_time.tv_sec*1000000 + startup_time.tv_usec);
diff --git a/example/reader_util.c b/example/reader_util.c
index 753c78cf1..508777ec2 100644
--- a/example/reader_util.c
+++ b/example/reader_util.c
@@ -459,23 +459,13 @@ struct ndpi_workflow* ndpi_workflow_init(const struct ndpi_workflow_prefs * pref
void ndpi_flow_info_freer(void *node) {
struct ndpi_flow_info *flow = (struct ndpi_flow_info*)node;
- ndpi_free_flow_info_half(flow);
- ndpi_free_flow_data_analysis(flow);
- ndpi_free_flow_tls_data(flow);
-
-#ifdef DIRECTION_BINS
- ndpi_free_bin(&flow->payload_len_bin_src2dst);
- ndpi_free_bin(&flow->payload_len_bin_dst2src);
-#else
- ndpi_free_bin(&flow->payload_len_bin);
-#endif
-
+ ndpi_flow_info_free_data(flow);
ndpi_free(flow);
}
/* ***************************************************** */
-void ndpi_free_flow_tls_data(struct ndpi_flow_info *flow) {
+static void ndpi_free_flow_tls_data(struct ndpi_flow_info *flow) {
if(flow->ssh_tls.server_names) {
ndpi_free(flow->ssh_tls.server_names);
@@ -510,7 +500,7 @@ void ndpi_free_flow_tls_data(struct ndpi_flow_info *flow) {
/* ***************************************************** */
-void ndpi_free_flow_data_analysis(struct ndpi_flow_info *flow) {
+static void ndpi_free_flow_data_analysis(struct ndpi_flow_info *flow) {
if(flow->iat_c_to_s) ndpi_free_data_analysis(flow->iat_c_to_s);
if(flow->iat_s_to_c) ndpi_free_data_analysis(flow->iat_s_to_c);
@@ -522,6 +512,22 @@ void ndpi_free_flow_data_analysis(struct ndpi_flow_info *flow) {
/* ***************************************************** */
+void ndpi_flow_info_free_data(struct ndpi_flow_info *flow) {
+
+ ndpi_free_flow_info_half(flow);
+ ndpi_free_flow_data_analysis(flow);
+ ndpi_free_flow_tls_data(flow);
+
+#ifdef DIRECTION_BINS
+ ndpi_free_bin(&flow->payload_len_bin_src2dst);
+ ndpi_free_bin(&flow->payload_len_bin_dst2src);
+#else
+ ndpi_free_bin(&flow->payload_len_bin);
+#endif
+}
+
+/* ***************************************************** */
+
void ndpi_workflow_free(struct ndpi_workflow * workflow) {
u_int i;
@@ -2032,4 +2038,9 @@ int dpdk_port_init(int port, struct rte_mempool *mbuf_pool) {
return 0;
}
+int dpdk_port_deinit(int port) {
+ rte_eth_dev_stop(port);
+ rte_eth_dev_close(port);
+}
+
#endif
diff --git a/example/reader_util.h b/example/reader_util.h
index 8298e2ef8..c94998496 100644
--- a/example/reader_util.h
+++ b/example/reader_util.h
@@ -50,6 +50,7 @@
#define PREFETCH_OFFSET 3
extern int dpdk_port_init(int port, struct rte_mempool *mbuf_pool);
+extern int dpdk_port_deinit(int port);
#endif
/* ETTA Spec defiintions for feature readiness */
@@ -328,9 +329,8 @@ static inline void ndpi_workflow_set_flow_giveup_callback(struct ndpi_workflow *
int ndpi_workflow_node_cmp(const void *a, const void *b);
void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_flow_info *flow);
u_int32_t ethernet_crc32(const void* data, size_t n_bytes);
+void ndpi_flow_info_free_data(struct ndpi_flow_info *flow);
void ndpi_flow_info_freer(void *node);
-void ndpi_free_flow_data_analysis(struct ndpi_flow_info *flow);
-void ndpi_free_flow_tls_data(struct ndpi_flow_info *flow);
const char* print_cipher_id(u_int32_t cipher);
float ndpi_flow_get_byte_count_entropy(const uint32_t byte_count[256], unsigned int num_bytes);