diff --git a/src/detection/localip/localip.h b/src/detection/localip/localip.h index 6fea95a79..994debec5 100644 --- a/src/detection/localip/localip.h +++ b/src/detection/localip/localip.h @@ -5,6 +5,18 @@ #include "fastfetch.h" +typedef struct FFLocalIpIoCounters +{ + uint64_t txBytes; + uint64_t rxBytes; + uint64_t txPackets; + uint64_t rxPackets; + uint64_t rxErrors; + uint64_t txErrors; + uint64_t rxDrops; + uint64_t txDrops; +} FFLocalIpIoCounters; + typedef struct FFLocalIpResult { FFstrbuf name; @@ -13,6 +25,8 @@ typedef struct FFLocalIpResult FFstrbuf mac; bool defaultRoute; + FFLocalIpIoCounters ioCounters; + #ifdef _WIN32 uint32_t ifIndex; #endif diff --git a/src/detection/localip/localip_windows.c b/src/detection/localip/localip_windows.c index 841a608e3..09071d275 100644 --- a/src/detection/localip/localip_windows.c +++ b/src/detection/localip/localip_windows.c @@ -46,6 +46,7 @@ static void addNewIp(FFlist* list, const char* name, const char* value, int type ffStrbufInit(&ip->mac); ip->defaultRoute = false; ip->ifIndex = ifIndex; + ip->ioCounters = (FFLocalIpIoCounters) {}; } else { @@ -141,6 +142,24 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results) newIp = false; } } + + if (newIp) + { + MIB_IF_ROW2 ifRow = { .InterfaceIndex = adapter->IfIndex }; + if (GetIfEntry2(&ifRow) == NO_ERROR) + { + ((FFLocalIpResult*) ffListGet(results, results->length - 1))->ioCounters = (FFLocalIpIoCounters) { + .txBytes = ifRow.OutOctets, + .rxBytes = ifRow.InOctets, + .txPackets = (ifRow.OutUcastPkts + ifRow.OutNUcastPkts), + .rxPackets = (ifRow.InUcastPkts + ifRow.InNUcastPkts), + .rxErrors = ifRow.InErrors, + .txErrors = ifRow.OutErrors, + .rxDrops = ifRow.InDiscards, + .txDrops = ifRow.OutDiscards, + }; + } + } } setDefaultRoute(results);