mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
NetIO (Haiku): add support
This commit is contained in:
parent
5ebf984e9a
commit
1d2b6c0b1a
@ -1159,7 +1159,7 @@ elseif(Haiku)
|
||||
src/detection/media/media_linux.c
|
||||
src/detection/memory/memory_haiku.c
|
||||
src/detection/mouse/mouse_haiku.cpp
|
||||
src/detection/netio/netio_nosupport.c
|
||||
src/detection/netio/netio_haiku.cpp
|
||||
src/detection/opengl/opengl_linux.c
|
||||
src/detection/os/os_haiku.c
|
||||
src/detection/packages/packages_haiku.c
|
||||
@ -1646,6 +1646,7 @@ elseif(ANDROID)
|
||||
elseif(Haiku)
|
||||
target_link_libraries(libfastfetch
|
||||
PRIVATE "network"
|
||||
PRIVATE "bnetapi"
|
||||
PRIVATE "media"
|
||||
PRIVATE "be"
|
||||
PRIVATE "gnu"
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
#include "common/time.h"
|
||||
|
||||
const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options);
|
||||
|
||||
static FFlist ioCounters1;
|
||||
static uint64_t time1;
|
||||
|
||||
|
@ -17,3 +17,4 @@ typedef struct FFNetIOResult
|
||||
} FFNetIOResult;
|
||||
|
||||
const char* ffDetectNetIO(FFlist* result, FFNetIOOptions* options);
|
||||
const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options);
|
||||
|
51
src/detection/netio/netio_haiku.cpp
Normal file
51
src/detection/netio/netio_haiku.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
extern "C" {
|
||||
#include "netio.h"
|
||||
|
||||
#include "common/netif/netif.h"
|
||||
#include "util/mallocHelper.h"
|
||||
}
|
||||
|
||||
#include <NetworkInterface.h>
|
||||
#include <NetworkRoster.h>
|
||||
|
||||
const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options)
|
||||
{
|
||||
BNetworkRoster& roster = BNetworkRoster::Default();
|
||||
|
||||
BNetworkInterface interface;
|
||||
uint32 cookie = 0;
|
||||
|
||||
const char* defaultRouteIfName = ffNetifGetDefaultRouteIfName();
|
||||
|
||||
while (roster.GetNextInterface(&cookie, interface) == B_OK)
|
||||
{
|
||||
if (!interface.Exists())
|
||||
continue;
|
||||
|
||||
if (options->defaultRouteOnly && strcmp(interface.Name(), defaultRouteIfName) != 0)
|
||||
continue;
|
||||
|
||||
if (options->namePrefix.length && strncmp(interface.Name(), options->namePrefix.chars, options->namePrefix.length) != 0)
|
||||
continue;
|
||||
|
||||
ifreq_stats stats;
|
||||
memset(&stats, 0, sizeof(stats));
|
||||
interface.GetStats(stats);
|
||||
|
||||
FFNetIOResult* counters = (FFNetIOResult*) ffListAdd(result);
|
||||
*counters = (FFNetIOResult) {
|
||||
.name = ffStrbufCreateS(interface.Name()),
|
||||
.defaultRoute = strcmp(interface.Name(), defaultRouteIfName) == 0,
|
||||
.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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user