@@ -9,48 +9,9 @@ static inline double rssiToSignalQuality(int rssi)
9
9
return (double ) (rssi >= -50 ? 100 : rssi <= -100 ? 0 : (rssi + 100 ) * 2 );
10
10
}
11
11
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
54
15
55
16
const char * ffDetectWifi (FFlist* result)
56
17
{
@@ -85,17 +46,19 @@ static bool getWifiInfoByIpconfig(FFstrbuf* ipconfig, const char* prefix, FFstrb
85
46
86
47
FF_STRBUF_AUTO_DESTROY ipconfig = ffStrbufCreate ();
87
48
49
+ CWNetworkProfile* networkProfile = inf.configuration .networkProfiles .firstObject ;
50
+
88
51
if (inf.ssid ) // https://developer.apple.com/forums/thread/732431
89
52
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 );
92
55
else
93
56
ffStrbufSetStatic (&item->conn .ssid , " <redacted>" ); // https://developer.apple.com/forums/thread/732431
94
57
95
58
if (inf.bssid )
96
59
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 ] );
99
62
else
100
63
ffStrbufSetStatic (&item->conn .bssid , " <redacted>" );
101
64
@@ -183,11 +146,6 @@ static bool getWifiInfoByIpconfig(FFstrbuf* ipconfig, const char* prefix, FFstrb
183
146
case 15 /* kCWSecurityOWETransition*/ :
184
147
ffStrbufSetStatic (&item->conn .security , " OWE Transition" );
185
148
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 ;
191
149
default :
192
150
ffStrbufAppendF (&item->conn .security , " Unknown (%ld )" , inf.security );
193
151
break ;
0 commit comments