26 #include <netinet/in.h>
27 #include <arpa/inet.h>
29 #include <rte_ether.h>
35 std::string addr_str(RTE_ETHER_ADDR_FMT_SIZE,
'\0');
36 rte_ether_format_addr(addr_str.data(), RTE_ETHER_ADDR_FMT_SIZE, &mac_addr);
37 addr_str.resize(strlen(addr_str.c_str()));
43 rte_ether_addr empty_ether_addr = {};
44 return !memcmp(empty_ether_addr.addr_bytes,
addr.addr_bytes, RTE_ETHER_ADDR_LEN);
49 std::string addr_str(INET_ADDRSTRLEN,
'\0');
50 inet_ntop(AF_INET, &ipv4_addr, addr_str.data(), INET_ADDRSTRLEN);
51 addr_str.resize(strlen(addr_str.c_str()));
57 std::string addr_str(INET6_ADDRSTRLEN,
'\0');
58 inet_ntop(AF_INET6, ipv6_addr, addr_str.data(), INET6_ADDRSTRLEN);
59 addr_str.resize(strlen(addr_str.c_str()));
69 return "Invalid IP type";
78 for (
int i = 0; i < 4; i++) {
92 if (inet_pton(AF_INET, ip_str.c_str(), &ip_addr->
ipv4_addr) != 1)
96 if (inet_pton(AF_INET6, ip_str.c_str(), ip_addr->
ipv6_addr) != 1)
99 if (inet_pton(AF_INET, ip_str.c_str(), &ip_addr->
ipv4_addr) == 1) {
101 }
else if (inet_pton(AF_INET6, ip_str.c_str(), ip_addr->
ipv6_addr) == 1) {
124 for (
auto &peer : *peers) {
125 for (
auto peer_vip_pair : peer.vip_pairs) {
static uint64_t *restrict src
enum doca_error doca_error_t
DOCA API return codes.
@ DOCA_ERROR_INVALID_VALUE
doca_flow_l3_type
doca flow layer 3 packet type
bool is_ip_equal(struct doca_flow_ip_addr *ip_a, struct doca_flow_ip_addr *ip_b)
Compare DOCA Flow IP address struct, return true if addresses are equal.
doca_error_t parse_ip_addr(const std::string &ip_str, doca_flow_l3_type enforce_l3_type, struct doca_flow_ip_addr *ip_addr)
Parse an IP address string into a DOCA Flow IP address struct.
std::string ipv4_to_string(rte_be32_t ipv4_addr)
Converts an IPv4 address to a C++ string.
psp_gw_peer * lookup_vip_pair(std::vector< psp_gw_peer > *peers, ip_pair &vip_pair)
Search for a peer in a vector of peers that holds the same IP pair.
bool is_empty_mac_addr(const rte_ether_addr &addr)
Tests whether a MAC address has been set (is non-zero)
std::string mac_to_string(const rte_ether_addr &mac_addr)
Converts a MAC/ethernet address to a C++ string.
void copy_ip_addr(const struct doca_flow_ip_addr &src, struct doca_flow_ip_addr &dst)
Copy an IP address struct.
std::string ip_to_string(const struct doca_flow_ip_addr &ip_addr)
Converts a DOCA Flow IP address struct to a C++ string.
std::string ipv6_to_string(const uint32_t ipv6_addr[])
Converts an IPv6 address to a C++ string.
enum doca_flow_l3_type type
doca_flow_ip_addr dst_vip
doca_flow_ip_addr src_vip
Describes a peer which is capable of exchanging traffic flows over a PSP tunnel.