From 76424950e373d3b04ac3dd13019151bfba3e8423 Mon Sep 17 00:00:00 2001 From: sumuel Date: Mon, 17 Aug 2026 20:44:55 +0000 Subject: Add the files --- src/detection/netio/netio_haiku.cpp | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/detection/netio/netio_haiku.cpp (limited to 'src/detection/netio/netio_haiku.cpp') diff --git a/src/detection/netio/netio_haiku.cpp b/src/detection/netio/netio_haiku.cpp new file mode 100644 index 0000000..88a123d --- /dev/null +++ b/src/detection/netio/netio_haiku.cpp @@ -0,0 +1,52 @@ +extern "C" { +#include "netio.h" +#include "common/netif.h" +} + +#include +#include + +const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) { + BNetworkRoster& roster = BNetworkRoster::Default(); + + BNetworkInterface interface; + uint32 cookie = 0; + + uint32_t defaultRouteIfIndex = ffNetifGetDefaultRouteV4()->ifIndex; + + while (roster.GetNextInterface(&cookie, interface) == B_OK) { + if (!interface.Exists()) { + continue; + } + + bool defaultRoute = interface.Index() == defaultRouteIfIndex; + if (options->defaultRouteOnly && !defaultRoute) { + continue; + } + + if (options->namePrefix.length && strncmp(interface.Name(), options->namePrefix.chars, options->namePrefix.length) != 0) { + continue; + } + + ifreq_stats stats = {}; + if (interface.GetStats(stats) != B_OK) { + continue; + } + + FFNetIOResult* counters = FF_LIST_ADD(FFNetIOResult, *result); + *counters = (FFNetIOResult) { + .name = ffStrbufCreateS(interface.Name()), + .defaultRoute = defaultRoute, + .txBytes = stats.send.bytes, + .rxBytes = stats.receive.bytes, + .txPackets = stats.send.packets, + .rxPackets = stats.receive.packets, + .rxErrors = stats.receive.errors, + .txErrors = stats.send.errors, + .rxDrops = stats.receive.dropped, + .txDrops = stats.send.dropped + }; + } + + return NULL; +} -- cgit v1.2.3