aboutsummaryrefslogtreecommitdiff
path: root/example/reader_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'example/reader_util.c')
-rw-r--r--example/reader_util.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/example/reader_util.c b/example/reader_util.c
index fa90b7000..43afcd402 100644
--- a/example/reader_util.c
+++ b/example/reader_util.c
@@ -454,23 +454,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);
@@ -505,7 +495,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);
@@ -517,6 +507,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;
@@ -1708,7 +1714,7 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow,
workflow->stats.mpls_count++;
type = ETH_P_IP, ip_offset += 4;
- while(!mpls.mpls.s) {
+ while(!mpls.mpls.s && (((bpf_u_int32)ip_offset) + 4 < header->caplen)) {
mpls.u32 = *((uint32_t *) &packet[ip_offset]);
mpls.u32 = ntohl(mpls.u32);
ip_offset += 4;
@@ -2027,4 +2033,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