Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(userspace/libsinsp): restore windows build #1658

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions userspace/libsinsp/ifinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ limitations under the License.
#include <string>
#include <vector>

#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;
Expand Down Expand Up @@ -85,13 +81,13 @@ class SINSP_PUBLIC sinsp_network_interfaces
std::vector<sinsp_ipv6_ifinfo>* 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<sinsp_ipv4_ifinfo> m_ipv4_interfaces;
std::vector<sinsp_ipv6_ifinfo> m_ipv6_interfaces;
};
Expand Down
16 changes: 7 additions & 9 deletions userspace/libsinsp/test/ifinfo.ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ limitations under the License.

*/

#define VISIBILITY_PRIVATE

#include <libsinsp/sinsp.h>
#include <libsinsp/sinsp_int.h>
#include <libsinsp/ifinfo.h>
Expand Down Expand Up @@ -105,25 +103,25 @@ 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")));
}

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")));
}
Loading