Skip to content

Commit 769e585

Browse files
committed
NetIO (Haiku): add support
Missing default route flag.
1 parent c395f2e commit 769e585

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

src/detection/netio/netio.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
#include "common/time.h"
44

5-
const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options);
6-
75
static FFlist ioCounters1;
86
static uint64_t time1;
97

src/detection/netio/netio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ typedef struct FFNetIOResult
1717
} FFNetIOResult;
1818

1919
const char* ffDetectNetIO(FFlist* result, FFNetIOOptions* options);
20+
const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
extern "C" {
2+
#include "netio.h"
3+
4+
#include "common/netif/netif.h"
5+
#include "util/mallocHelper.h"
6+
}
7+
8+
#include <NetworkInterface.h>
9+
#include <NetworkRoster.h>
10+
11+
const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options)
12+
{
13+
BNetworkRoster& roster = BNetworkRoster::Default();
14+
15+
BNetworkInterface interface;
16+
uint32 cookie = 0;
17+
18+
while (roster.GetNextInterface(&cookie, interface) == B_OK)
19+
{
20+
if (!interface.Exists())
21+
continue;
22+
23+
ifreq_stats stats;
24+
memset(&stats, 0, sizeof(stats));
25+
status_t err = interface.GetStats(stats);
26+
27+
FFNetIOResult* counters = (FFNetIOResult*) ffListAdd(result);
28+
*counters = (FFNetIOResult) {
29+
.name = ffStrbufCreateS(interface.Name()),
30+
.defaultRoute = false, // TODO
31+
.txBytes = stats.send.bytes,
32+
.rxBytes = stats.receive.bytes,
33+
.txPackets = stats.send.packets,
34+
.rxPackets = stats.receive.packets,
35+
.rxErrors = stats.receive.errors,
36+
.txErrors = stats.send.errors,
37+
.rxDrops = stats.receive.dropped,
38+
.txDrops = stats.send.dropped
39+
};
40+
}
41+
42+
return NULL;
43+
}

0 commit comments

Comments
 (0)