diff --git a/userspace/libsinsp/ifinfo.h b/userspace/libsinsp/ifinfo.h index c861273013..b0675d53fc 100644 --- a/userspace/libsinsp/ifinfo.h +++ b/userspace/libsinsp/ifinfo.h @@ -26,10 +26,6 @@ limitations under the License. #include #include -#ifndef VISIBILITY_PRIVATE -#define VISIBILITY_PRIVATE private: -#endif - typedef struct scap_addrlist scap_addrlist; typedef struct scap_ifinfo_ipv4 scap_ifinfo_ipv4; typedef struct scap_ifinfo_ipv6 scap_ifinfo_ipv6; @@ -85,13 +81,13 @@ class SINSP_PUBLIC sinsp_network_interfaces std::vector* get_ipv6_list(); inline void clear(); - ipv6addr m_ipv6_loopback_addr; - -VISIBILITY_PRIVATE uint32_t infer_ipv4_address(uint32_t destination_address); void import_ipv4_ifaddr_list(uint32_t count, scap_ifinfo_ipv4* plist); ipv6addr infer_ipv6_address(ipv6addr &destination_address); void import_ipv6_ifaddr_list(uint32_t count, scap_ifinfo_ipv6* plist); + +private: + ipv6addr m_ipv6_loopback_addr; std::vector m_ipv4_interfaces; std::vector m_ipv6_interfaces; }; diff --git a/userspace/libsinsp/test/ifinfo.ut.cpp b/userspace/libsinsp/test/ifinfo.ut.cpp index ebe754e316..9aa8695c32 100644 --- a/userspace/libsinsp/test/ifinfo.ut.cpp +++ b/userspace/libsinsp/test/ifinfo.ut.cpp @@ -16,8 +16,6 @@ limitations under the License. */ -#define VISIBILITY_PRIVATE - #include #include #include @@ -105,8 +103,8 @@ TEST(sinsp_network_interfaces, sip_and_dip_are_not_zero) TEST(sinsp_network_interfaces, infer_finds_exact_match) { sinsp_network_interfaces interfaces; - interfaces.m_ipv4_interfaces.push_back(make_ipv4_localhost()); - interfaces.m_ipv4_interfaces.push_back(make_ipv4_interface("192.168.22.149", "255.255.255.0", "192.168.22.255", "eth0")); + interfaces.get_ipv4_list()->push_back(make_ipv4_localhost()); + interfaces.get_ipv4_list()->push_back(make_ipv4_interface("192.168.22.149", "255.255.255.0", "192.168.22.255", "eth0")); EXPECT_ADDR_EQ("127.0.0.1",interfaces.infer_ipv4_address(parse_ipv4_addr("127.0.0.1"))); EXPECT_ADDR_EQ("192.168.22.149",interfaces.infer_ipv4_address(parse_ipv4_addr("192.168.22.149"))); } @@ -114,16 +112,16 @@ TEST(sinsp_network_interfaces, infer_finds_exact_match) TEST(sinsp_network_interfaces, infer_finds_same_subnet) { sinsp_network_interfaces interfaces; - interfaces.m_ipv4_interfaces.push_back(make_ipv4_localhost()); - interfaces.m_ipv4_interfaces.push_back(make_ipv4_interface("192.168.22.149", "255.255.255.0", "192.168.22.255", "eth0")); + interfaces.get_ipv4_list()->push_back(make_ipv4_localhost()); + interfaces.get_ipv4_list()->push_back(make_ipv4_interface("192.168.22.149", "255.255.255.0", "192.168.22.255", "eth0")); EXPECT_ADDR_EQ("192.168.22.149",interfaces.infer_ipv4_address(parse_ipv4_addr("192.168.22.11"))); } TEST(sinsp_network_interfaces, infer_defaults_to_first_non_loopback) { sinsp_network_interfaces interfaces; - interfaces.m_ipv4_interfaces.push_back(make_ipv4_localhost()); - interfaces.m_ipv4_interfaces.push_back(make_ipv4_interface("192.168.22.149", "255.255.255.0", "192.168.22.255", "eth0")); - interfaces.m_ipv4_interfaces.push_back(make_ipv4_interface("192.168.22.150", "255.255.255.0", "192.168.22.255", "eth1")); + interfaces.get_ipv4_list()->push_back(make_ipv4_localhost()); + interfaces.get_ipv4_list()->push_back(make_ipv4_interface("192.168.22.149", "255.255.255.0", "192.168.22.255", "eth0")); + interfaces.get_ipv4_list()->push_back(make_ipv4_interface("192.168.22.150", "255.255.255.0", "192.168.22.255", "eth1")); EXPECT_ADDR_EQ("192.168.22.149",interfaces.infer_ipv4_address(parse_ipv4_addr("193.168.22.11"))); }