NetIO (BSD): add txDrops detection if supported

This commit is contained in:
李通洲
2024-11-15 14:48:17 +08:00
parent 56eb8b80c6
commit 9f314a208b
3 changed files with 13 additions and 4 deletions
+1
View File
@@ -13,6 +13,7 @@ Features:
* Detect WM / DE by enumerating running processes (WM / DE, NetBSD)
* Generate manual pages from `help.json` (Doc)
* Detect marketing name of vivo smartphone (Host, Android)
* Add txDrops detection if supported (NetIO, *BSD)
* Support percent type config in module level. Example:
```json
+10
View File
@@ -1180,6 +1180,16 @@ elseif(NetBSD)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,/usr/X11R7/lib -Wl,-rpath,/usr/pkg/lib") # ditto
endif()
if(FreeBSD OR OpenBSD OR NetBSD)
include(CheckStructHasMember)
set(CMAKE_REQUIRED_DEFINITIONS "-D_IFI_OQDROPS=1")
CHECK_STRUCT_HAS_MEMBER("struct if_data" ifi_oqdrops net/if.h HAVE_IFI_OQDROPS LANGUAGE C)
if(HAVE_IFI_OQDROPS)
target_compile_definitions(libfastfetch PUBLIC _IFI_OQDROPS FF_HAVE_IFI_OQDROPS)
endif()
unset(CMAKE_REQUIRED_DEFINITIONS)
endif()
if(HAVE_STATX)
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_STATX)
endif()
+2 -4
View File
@@ -1,8 +1,6 @@
#include "netio.h"
#include "common/io/io.h"
#include "common/netif/netif.h"
#include "util/stringUtils.h"
#include "util/mallocHelper.h"
#include <net/if.h>
@@ -48,8 +46,8 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options)
.rxPackets = ifm->ifm_data.ifi_ipackets,
.txErrors = ifm->ifm_data.ifi_oerrors,
.rxErrors = ifm->ifm_data.ifi_ierrors,
#ifdef _IFI_OQDROPS
.txDrops = if2m->ifm_data.ifi_oqdrops,
#ifdef FF_HAVE_IFI_OQDROPS
.txDrops = ifm->ifm_data.ifi_oqdrops,
#else
.txDrops = 0, // unsupported
#endif