NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
psp_gw_utils.cpp File Reference
#include <netinet/in.h>
#include <arpa/inet.h>
#include <rte_ether.h>
#include "psp_gw_utils.h"
Include dependency graph for psp_gw_utils.cpp:

Go to the source code of this file.

Functions

std::string mac_to_string (const rte_ether_addr &mac_addr)
 Converts a MAC/ethernet address to a C++ string. More...
 
bool is_empty_mac_addr (const rte_ether_addr &addr)
 Tests whether a MAC address has been set (is non-zero) More...
 
std::string ipv4_to_string (rte_be32_t ipv4_addr)
 Converts an IPv4 address to a C++ string. More...
 
std::string ipv6_to_string (const uint32_t ipv6_addr[])
 Converts an IPv6 address to a C++ string. More...
 
std::string ip_to_string (const struct doca_flow_ip_addr &ip_addr)
 Converts a DOCA Flow IP address struct to a C++ string. More...
 
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. More...
 
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. More...
 
void copy_ip_addr (const struct doca_flow_ip_addr &src, struct doca_flow_ip_addr &dst)
 Copy an IP address struct. More...
 
psp_gw_peerlookup_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. More...
 

Function Documentation

◆ copy_ip_addr()

void copy_ip_addr ( const struct doca_flow_ip_addr src,
struct doca_flow_ip_addr dst 
)

Copy an IP address struct.

@src [in]: the source IP address @dst [out]: the destination IP address

Definition at line 110 of file psp_gw_utils.cpp.

◆ ip_to_string()

std::string ip_to_string ( const struct doca_flow_ip_addr ip_addr)

Converts a DOCA Flow IP address struct to a C++ string.

Definition at line 63 of file psp_gw_utils.cpp.

◆ ipv4_to_string()

std::string ipv4_to_string ( rte_be32_t  ipv4_addr)

Converts an IPv4 address to a C++ string.

Definition at line 47 of file psp_gw_utils.cpp.

◆ ipv6_to_string()

std::string ipv6_to_string ( const uint32_t  ipv6_addr[])

Converts an IPv6 address to a C++ string.

Definition at line 55 of file psp_gw_utils.cpp.

◆ is_empty_mac_addr()

bool is_empty_mac_addr ( const rte_ether_addr &  addr)

Tests whether a MAC address has been set (is non-zero)

@addr [in]: the mac addr to test

Returns
: true if all bits are zero; false otherwise

Definition at line 41 of file psp_gw_utils.cpp.

◆ is_ip_equal()

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.

@ip_a [in]: first IP address @ip_b [in]: second IP address

Returns
: true if both addresses is the same

Definition at line 72 of file psp_gw_utils.cpp.

◆ lookup_vip_pair()

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.

@peers [in]: vector of peers to search @vip_pair [in]: IP pair to search for

Returns
: pointer to the peer if found, nullptr otherwise

Definition at line 122 of file psp_gw_utils.cpp.

◆ mac_to_string()

std::string mac_to_string ( const rte_ether_addr &  mac_addr)

Converts a MAC/ethernet address to a C++ string.

Definition at line 33 of file psp_gw_utils.cpp.

◆ parse_ip_addr()

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.

@ip_str [in]: the IP address string to parse @enforce_l3_type [in]: the L3 type to enforce @ip_addr [out]: the parsed IP address

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 85 of file psp_gw_utils.cpp.