|
| 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