@@ -9,48 +9,9 @@ static inline double rssiToSignalQuality(int rssi)
99 return (double ) (rssi >= -50 ? 100 : rssi <= -100 ? 0 : (rssi + 100 ) * 2 );
1010}
1111
12- static bool queryIpconfig (const char * ifName, FFstrbuf* result)
13- {
14- if (@available (macOS 15.6 , *))
15- {
16- // ipconfig reports <redacted> too
17- return false ;
18- }
19-
20- return ffProcessAppendStdOut (result, (char * const []) {
21- " /usr/sbin/ipconfig" ,
22- " getsummary" ,
23- (char * const ) ifName,
24- NULL
25- }) == NULL ;
26- }
27-
28- static bool getWifiInfoByIpconfig (FFstrbuf* ipconfig, const char * prefix, FFstrbuf* result)
29- {
30- // `ipconfig getsummary <interface>` returns a string like this:
31- // <dictionary> {
32- // BSSID : <redacted>
33- // IPv4 : <array> {
34- // ...
35- // }
36- // IPv6 : <array> {
37- // ...
38- // }
39- // InterfaceType : WiFi
40- // LinkStatusActive : TRUE
41- // NetworkID : XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
42- // SSID : XXXXXX
43- // Security : WPA2_PSK
44- // }
45-
46- const char * start = memmem (ipconfig->chars , ipconfig->length , prefix, strlen (prefix));
47- if (!start) return false ;
48- start += strlen (prefix);
49- const char * end = strchr (start, ' \n ' );
50- if (!end) return false ;
51- ffStrbufSetNS (result, (uint32_t ) (end - start), start);
52- return true ;
53- }
12+ @interface CWNetworkProfile ()
13+ @property (readonly , retain , nullable ) NSArray <NSDictionary *> *bssidList;
14+ @end
5415
5516const char * ffDetectWifi (FFlist* result)
5617{
@@ -85,17 +46,19 @@ static bool getWifiInfoByIpconfig(FFstrbuf* ipconfig, const char* prefix, FFstrb
8546
8647 FF_STRBUF_AUTO_DESTROY ipconfig = ffStrbufCreate ();
8748
49+ CWNetworkProfile* networkProfile = inf.configuration .networkProfiles .firstObject ;
50+
8851 if (inf.ssid ) // https://developer.apple.com/forums/thread/732431
8952 ffStrbufAppendS (&item->conn .ssid , inf.ssid .UTF8String );
90- else if (ipconfig. length || ( queryIpconfig (item-> inf . description . chars , &ipconfig)) )
91- getWifiInfoByIpconfig (&ipconfig, " \n SSID : " , & item->conn .ssid );
53+ else if (networkProfile. ssid )
54+ ffStrbufSetStatic (& item->conn .ssid , inf. configuration . networkProfiles . firstObject . ssid . UTF8String );
9255 else
9356 ffStrbufSetStatic (&item->conn .ssid , " <redacted>" ); // https://developer.apple.com/forums/thread/732431
9457
9558 if (inf.bssid )
9659 ffStrbufAppendS (&item->conn .bssid , inf.bssid .UTF8String );
97- else if (ipconfig. length || ( queryIpconfig (item-> inf . description . chars , &ipconfig)) )
98- getWifiInfoByIpconfig (&ipconfig, " \n BSSID : " , & item->conn .bssid );
60+ else if (networkProfile. bssidList )
61+ ffStrbufSetStatic (& item->conn .bssid , [networkProfile.bssidList.firstObject[ @" BSSID " ] UTF8String ] );
9962 else
10063 ffStrbufSetStatic (&item->conn .bssid , " <redacted>" );
10164
@@ -183,11 +146,6 @@ static bool getWifiInfoByIpconfig(FFstrbuf* ipconfig, const char* prefix, FFstrb
183146 case 15 /* kCWSecurityOWETransition*/ :
184147 ffStrbufSetStatic (&item->conn .security , " OWE Transition" );
185148 break ;
186- case kCWSecurityUnknown :
187- // Sonoma?
188- if (ipconfig.length || (queryIpconfig (item->inf .description .chars , &ipconfig)))
189- getWifiInfoByIpconfig (&ipconfig, " \n Security : " , &item->conn .security );
190- break ;
191149 default :
192150 ffStrbufAppendF (&item->conn .security , " Unknown (%ld )" , inf.security );
193151 break ;
0 commit comments