88#include <sys/ioctl.h>
99#include <sys/types.h>
1010#include <net/if.h>
11- #include <linux/genetlink.h>
12- #include <linux/nl80211.h>
1311#include <linux/wireless.h>
1412#include <unistd.h>
1513
16- // Silence warning of `NLA_HDRLEN` and `NLA_ALIGN`
17- #pragma GCC diagnostic ignored "-Wsign-conversion"
14+ #if !__BIG_ENDIAN__
15+ #include <linux/genetlink.h>
16+ #include <linux/nl80211.h>
17+
18+ // Silence warning of `NLA_HDRLEN` and `NLA_ALIGN`
19+ #pragma GCC diagnostic ignored "-Wsign-conversion"
1820
1921typedef struct FFWifiNlContext {
2022 int sockFd ;
@@ -23,10 +25,6 @@ typedef struct FFWifiNlContext {
2325 uint32_t seq ;
2426} FFWifiNlContext ;
2527
26- typedef struct FFWifiIcContext {
27- int sockFd ;
28- } FFWifiIcContext ;
29-
3028typedef struct FFWifiSecurityFlags {
3129 bool privacy : 1 ;
3230 bool wep : 1 ;
@@ -199,7 +197,7 @@ static bool ffWifiNlInit(FFWifiNlContext* ctx) {
199197 ctx -> sockFd ,
200198 SOL_SOCKET ,
201199 SO_RCVTIMEO ,
202- & (struct timeval ) { .tv_sec = 0 , .tv_usec = 250000 },
200+ & (struct timeval ){ .tv_sec = 0 , .tv_usec = 250000 },
203201 sizeof (struct timeval )) < 0 ) {
204202 FF_DEBUG ("Failed to set netlink receive timeout: %s" , strerror (errno ));
205203 return false;
@@ -694,6 +692,11 @@ static const char* detectWithNetlink(FFWifiNlContext* ctx, FFWifiResult* item, u
694692 FF_DEBUG ("Netlink wifi detection completed" );
695693 return NULL ;
696694}
695+ #endif
696+
697+ typedef struct FFWifiIcContext {
698+ int sockFd ;
699+ } FFWifiIcContext ;
697700
698701static const char * detectWithIoctl (FFWifiIcContext * ctx , FFWifiResult * item , char ifName [static IFNAMSIZ ]) {
699702 int sock = -1 ;
@@ -893,7 +896,9 @@ const char* ffDetectWifi(FFlist* result) {
893896 return "if_nameindex() failed" ;
894897 }
895898
899+ #if !__BIG_ENDIAN__
896900 FFWifiNlContext nl = { .sockFd = -1 };
901+ #endif
897902 FFWifiIcContext ic = { .sockFd = -1 };
898903
899904 FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate ();
@@ -930,7 +935,10 @@ const char* ffDetectWifi(FFlist* result) {
930935
931936 if (operstate == 'u' ) {
932937 ffStrbufSetStatic (& item -> inf .status , "up" );
938+
939+ #if !__BIG_ENDIAN__
933940 detectWithNetlink (& nl , item , i -> if_index );
941+ #endif
934942 detectWithIoctl (& ic , item , i -> if_name );
935943 } else {
936944 ffStrbufSetStatic (& item -> conn .status , "disconnected" );
@@ -954,9 +962,11 @@ const char* ffDetectWifi(FFlist* result) {
954962 }
955963
956964 if_freenameindex (infs );
965+ #if !__BIG_ENDIAN__
957966 if (nl .sockFd >= 0 ) {
958967 close (nl .sockFd );
959968 }
969+ #endif
960970 if (ic .sockFd >= 0 ) {
961971 close (ic .sockFd );
962972 }
0 commit comments