Fix potential core dump when closing ports at exit
[samplevnf.git] / VNFs / DPPD-PROX / prox_compat.h
index 9c18e36..091c2cc 100644 (file)
@@ -1,5 +1,5 @@
 /*
-// Copyright (c) 2010-2017 Intel Corporation
+// Copyright (c) 2010-2020 Intel Corporation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
 #include <rte_hash_crc.h>
 #include <rte_cryptodev.h>
 #include "hash_utils.h"
-#include "quit.h"
 
 /* This is a copy of the rte_table_hash_params from DPDK 17.11  *
  * So if DPDK decides to change the structure the modifications *
@@ -37,6 +36,12 @@ struct prox_rte_table_params {
        uint64_t seed;
 };
 
+#if RTE_VERSION < RTE_VERSION_NUM(16,4,0,1)
+typedef uint8_t prox_next_hop_index_type;
+#else
+typedef uint32_t prox_next_hop_index_type;
+#endif
+
 #if RTE_VERSION < RTE_VERSION_NUM(17,11,0,0)
 
 static void *prox_rte_table_create(struct prox_rte_table_params *params, int socket_id, uint32_t entry_size)
@@ -161,6 +166,8 @@ typedef struct vxlan_gpe_hdr prox_rte_vxlan_gpe_hdr;
 #define PROX_RTE_TCP_FIN_FLAG TCP_FIN_FLAG
 #define PROX_RTE_TCP_RST_FLAG TCP_RST_FLAG
 #define PROX_RTE_TCP_ACK_FLAG TCP_ACK_FLAG
+#define PROX_RTE_IP_ICMP_ECHO_REPLY IP_ICMP_ECHO_REPLY
+#define PROX_RTE_IP_ICMP_ECHO_REQUEST IP_ICMP_ECHO_REQUEST
 
 #define prox_rte_ether_addr_copy ether_addr_copy
 #define prox_rte_eth_random_addr eth_random_addr
@@ -172,6 +179,7 @@ typedef struct ether_hdr prox_rte_ether_hdr;
 typedef struct vlan_hdr prox_rte_vlan_hdr;
 typedef struct udp_hdr prox_rte_udp_hdr;
 typedef struct tcp_hdr prox_rte_tcp_hdr;
+typedef struct icmp_hdr prox_rte_icmp_hdr;
 
 #ifndef RTE_SCHED_BE_QUEUES_PER_PIPE
 #define RTE_SCHED_BE_QUEUES_PER_PIPE RTE_SCHED_QUEUES_PER_PIPE
@@ -179,6 +187,7 @@ typedef struct tcp_hdr prox_rte_tcp_hdr;
 
 #define PROX_RTE_IS_IPV4_MCAST IS_IPV4_MCAST
 #define prox_rte_is_same_ether_addr is_same_ether_addr
+#define prox_rte_is_zero_ether_addr is_zero_ether_addr
 #else
 
 #define PROX_RTE_ETHER_CRC_LEN RTE_ETHER_CRC_LEN
@@ -189,6 +198,8 @@ typedef struct tcp_hdr prox_rte_tcp_hdr;
 #define PROX_RTE_TCP_FIN_FLAG RTE_TCP_FIN_FLAG
 #define PROX_RTE_TCP_RST_FLAG RTE_TCP_RST_FLAG
 #define PROX_RTE_TCP_ACK_FLAG RTE_TCP_ACK_FLAG
+#define PROX_RTE_IP_ICMP_ECHO_REPLY RTE_IP_ICMP_ECHO_REPLY
+#define PROX_RTE_IP_ICMP_ECHO_REQUEST RTE_IP_ICMP_ECHO_REQUEST
 
 #define prox_rte_ether_addr_copy rte_ether_addr_copy
 #define prox_rte_eth_random_addr rte_eth_random_addr
@@ -201,22 +212,16 @@ typedef struct rte_vlan_hdr prox_rte_vlan_hdr;
 typedef struct rte_vxlan_gpe_hdr prox_rte_vxlan_gpe_hdr;
 typedef struct rte_udp_hdr prox_rte_udp_hdr;
 typedef struct rte_tcp_hdr prox_rte_tcp_hdr;
+typedef struct rte_icmp_hdr prox_rte_icmp_hdr;
 
 #define PROX_RTE_IS_IPV4_MCAST  RTE_IS_IPV4_MCAST
 #define prox_rte_is_same_ether_addr rte_is_same_ether_addr
+#define prox_rte_is_zero_ether_addr rte_is_zero_ether_addr
 
 #endif
 
-static inline char *prox_strncpy(char * dest, const char * src, size_t count)
-{
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpragmas"
-#pragma GCC diagnostic ignored "-Wstringop-truncation"
-       strncpy(dest, src, count);
-#pragma GCC diagnostic pop
-       PROX_PANIC(dest[count - 1] != 0, "\t\tError in strncpy: buffer overrun (%lu bytes)", count);
-       return dest;
-}
+char *prox_strncpy(char * dest, const char * src, size_t count);
+
 #ifdef RTE_LIBRTE_PMD_AESNI_MB
 #if RTE_VERSION < RTE_VERSION_NUM(19,5,0,0)
 //RFC4303
@@ -253,4 +258,10 @@ static int prox_rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pa
 #endif
 #endif // CONFIG_RTE_LIBRTE_PMD_AESNI_MB
 
+#if RTE_VERSION < RTE_VERSION_NUM(19,11,0,0)
+#define prox_rte_eth_dev_count_avail() rte_eth_dev_count()
+#else
+#define prox_rte_eth_dev_count_avail() rte_eth_dev_count_avail()
+#endif
+
 #endif // _PROX_COMPAT_H