From 2c705c638e6d36073fe087fd198754fca99a0bd6 Mon Sep 17 00:00:00 2001 From: Alessandro Thea Date: Tue, 8 Oct 2024 15:52:53 +0200 Subject: [PATCH] Adding support for NICReceivers having multiple ips --- src/IfaceWrapper.cpp | 24 +++++++++++++++--------- src/IfaceWrapper.hpp | 4 ++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/IfaceWrapper.cpp b/src/IfaceWrapper.cpp index fc9dd76..dc8b1fb 100644 --- a/src/IfaceWrapper.cpp +++ b/src/IfaceWrapper.cpp @@ -71,13 +71,17 @@ IfaceWrapper::IfaceWrapper( m_iface_id = iface_id; m_mac_addr = net_device->get_mac_address(); m_ip_addr = net_device->get_ip_address(); - IpAddr ip_addr_struct(m_ip_addr); - m_ip_addr_bin = udp::ip_address_dotdecimal_to_binary( - ip_addr_struct.addr_bytes[3], - ip_addr_struct.addr_bytes[2], - ip_addr_struct.addr_bytes[1], - ip_addr_struct.addr_bytes[0] - ); + + for( const std::string& ip_addr : m_ip_addr) { + IpAddr ip_addr_struct(ip_addr); + m_ip_addr_bin.push_back(udp::ip_address_dotdecimal_to_binary( + ip_addr_struct.addr_bytes[3], + ip_addr_struct.addr_bytes[2], + ip_addr_struct.addr_bytes[1], + ip_addr_struct.addr_bytes[0] + )); + } + auto iface_cfg = receiver->get_configuration(); @@ -109,7 +113,7 @@ IfaceWrapper::IfaceWrapper( for( auto nw_sender : nw_senders ) { auto sender_ni = nw_sender->get_uses(); - std::string tx_ip = sender_ni->get_ip_address(); + std::string tx_ip = sender_ni->get_ip_address().at(0); for ( auto res : nw_sender->get_contains() ) { @@ -385,7 +389,9 @@ IfaceWrapper::garp_func() { TLOG() << "Launching GARP sender..."; while(m_run_marker.load()) { - arp::pktgen_send_garp(m_garp_bufs[0][0], m_iface_id, m_ip_addr_bin); + for( const auto& ip_addr_bin : m_ip_addr_bin ) { + arp::pktgen_send_garp(m_garp_bufs[0][0], m_iface_id, ip_addr_bin); + } ++m_garps_sent; std::this_thread::sleep_for(std::chrono::seconds(1)); } diff --git a/src/IfaceWrapper.hpp b/src/IfaceWrapper.hpp index c620bb5..1067db4 100644 --- a/src/IfaceWrapper.hpp +++ b/src/IfaceWrapper.hpp @@ -86,8 +86,8 @@ namespace dpdklibs { bool m_with_flow; bool m_prom_mode; - std::string m_ip_addr; - rte_be32_t m_ip_addr_bin; + std::vector m_ip_addr; + std::vector m_ip_addr_bin; std::string m_mac_addr; int m_socket_id; int m_mtu;