diff --git a/libebpfdiscovery/headers/ebpfdiscovery/IpAddressChecker.h b/libebpfdiscovery/headers/ebpfdiscovery/IpAddressChecker.h index 89720082..c55408a6 100644 --- a/libebpfdiscovery/headers/ebpfdiscovery/IpAddressChecker.h +++ b/libebpfdiscovery/headers/ebpfdiscovery/IpAddressChecker.h @@ -7,11 +7,11 @@ namespace ebpfdiscovery { -using IPv4 = uint32_t; +using IPv4int = uint32_t; struct IpIfce { - std::vector ip; - std::vector broadcast; + std::vector ip; + std::vector broadcast; uint32_t mask; int index; bool isLocalBridge; @@ -32,7 +32,7 @@ class IpAddressChecker { public: IpAddressChecker(const NetlinkCalls &calls); IpAddressChecker(std::initializer_list config, const NetlinkCalls &calls); - bool isAddressExternalLocal(IPv4 addr); + bool isAddressExternalLocal(IPv4int addr); bool readNetworks(); }; } // namespace ebpfdiscovery diff --git a/libebpfdiscovery/src/IpAddressChecker.cpp b/libebpfdiscovery/src/IpAddressChecker.cpp index 4f705aa0..e75ff06e 100644 --- a/libebpfdiscovery/src/IpAddressChecker.cpp +++ b/libebpfdiscovery/src/IpAddressChecker.cpp @@ -13,7 +13,7 @@ #include #include -static constexpr uint32_t BUFFLEN{4096}; +static constexpr uint32_t BUFLEN{4096}; static constexpr uint32_t IP_CLASS_C{0x0000a8c0}; // 192.168.*.* static constexpr uint32_t MASK_CLASS_C{0x0000ffff}; static constexpr uint32_t IP_CLASS_B{0x000010ac}; // 172.16-31.*.* @@ -29,7 +29,6 @@ static void logErrorFromErrno(std::string_view prefix) { std::cout << prefix << ": " << strerror(errno) << "\n"; } - static ebpfdiscovery::IpIfce parseIfceIPv4(void* data, size_t len) { ebpfdiscovery::IpIfce ifce{}; ifaddrmsg* ifa = reinterpret_cast(data); @@ -67,7 +66,6 @@ static int getIfIndex(void* data) { namespace ebpfdiscovery { - IpAddressChecker::IpAddressChecker(std::initializer_list config, const NetlinkCalls &calls) :netlink(calls) { interfaces.insert(interfaces.end(), config.begin(), config.end()); } @@ -128,8 +126,8 @@ static bool handleNetlink(S send, R receive, P parse, int domain) { uint32_t nlMsgType; do { - std::array buf{}; - len = receive(fd, &sa, buf.data(), BUFFLEN); + std::array buf{}; + len = receive(fd, &sa, buf.data(), BUFLEN); if (len <= 0) { logErrorFromErrno("receive"); break; @@ -177,7 +175,7 @@ bool IpAddressChecker::isLoopback(const IpIfce& ifce) { }); } -bool IpAddressChecker::isAddressExternalLocal(IPv4 addr) { +bool IpAddressChecker::isAddressExternalLocal(IPv4int addr) { const bool isPublic = ((addr & MASK_CLASS_A) != IP_CLASS_A) && ((addr & MASK_CLASS_B) != IP_CLASS_B) && ((addr & MASK_CLASS_C) != IP_CLASS_C); if (isPublic) {