mirror of
https://github.com/falcosecurity/falco.git
synced 2025-09-12 21:16:33 +00:00
update(metrics): use new libs addr_to_string methods for host_ifinfo_json
Signed-off-by: Melissa Kilby <melissa.kilby.oss@gmail.com>
This commit is contained in:
@@ -257,38 +257,6 @@ bool is_unix_scheme(const std::string& url)
|
||||
{
|
||||
return sinsp_utils::startswith(url, UNIX_SCHEME);
|
||||
}
|
||||
|
||||
#if defined(__linux__) and !defined(MINIMAL_BUILD) and !defined(__EMSCRIPTEN__)
|
||||
std::string ipv4addr_to_string(uint32_t addr)
|
||||
{
|
||||
char dest[16];
|
||||
snprintf(
|
||||
dest,
|
||||
sizeof(dest),
|
||||
"%d.%d.%d.%d",
|
||||
(addr & 0xFF),
|
||||
((addr & 0xFF00) >> 8),
|
||||
((addr & 0xFF0000) >> 16),
|
||||
((addr & 0xFF000000) >> 24));
|
||||
return std::string(dest);
|
||||
}
|
||||
|
||||
std::string ipv6addr_to_string(const ipv6addr& addr)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
const uint16_t* words = reinterpret_cast<const uint16_t*>(addr.m_b);
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
oss << ':';
|
||||
}
|
||||
oss << std::hex << ntohs(words[i]);
|
||||
}
|
||||
return oss.str();
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace network
|
||||
} // namespace utils
|
||||
} // namespace falco
|
||||
|
@@ -22,10 +22,6 @@ limitations under the License.
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#if defined(__linux__) and !defined(MINIMAL_BUILD) and !defined(__EMSCRIPTEN__)
|
||||
#include <arpa/inet.h>
|
||||
#include <libsinsp/tuples.h>
|
||||
#endif
|
||||
|
||||
namespace falco::utils
|
||||
{
|
||||
@@ -49,11 +45,5 @@ namespace network
|
||||
{
|
||||
static const std::string UNIX_SCHEME("unix://");
|
||||
bool is_unix_scheme(const std::string& url);
|
||||
#if defined(__linux__) and !defined(MINIMAL_BUILD) and !defined(__EMSCRIPTEN__)
|
||||
// todo: consider extending libs and expose API for ipv4 and ipv6 to string conversion
|
||||
std::string ipv4addr_to_string(uint32_t addr);
|
||||
std::string ipv6addr_to_string(const ipv6addr& addr);
|
||||
#endif
|
||||
|
||||
} // namespace network
|
||||
} // namespace falco::utils
|
||||
|
Reference in New Issue
Block a user