wifi(linux): query associated station directly

mdlayher/wifi only dumps stations, which some full-MAC drivers (e.g.
out-of-tree Realtek USB) answer with an empty list, leaving RSSI
unavailable. Request the associated BSSID's station directly, as
`iw link` does, and parse it with native.ParseStationInfo.
This commit is contained in:
henrygd
2026-09-25 19:53:35 -04:00
parent fe83f5b831
commit a042e19549
3 changed files with 79 additions and 14 deletions

View File

@@ -3,6 +3,7 @@
package wifi
import (
"bytes"
"context"
"errors"
"net"
@@ -27,9 +28,17 @@ func (f *fakeLinuxClient) Interfaces() ([]*native.Interface, error) {
func (f *fakeLinuxClient) BSS(i *native.Interface) (*native.BSS, error) {
return f.bss[i.Name], f.bssErr
}
func (f *fakeLinuxClient) StationInfo(i *native.Interface) ([]*native.StationInfo, error) {
func (f *fakeLinuxClient) Station(i *native.Interface, mac net.HardwareAddr) (*native.StationInfo, error) {
f.stationCalls++
return f.stations[i.Name], f.stationErr
if f.stationErr != nil {
return nil, f.stationErr
}
for _, station := range f.stations[i.Name] {
if bytes.Equal(station.HardwareAddr, mac) {
return station, nil
}
}
return nil, errors.New("no such station")
}
func (f *fakeLinuxClient) SetDeadline(d time.Time) error { f.deadline = d; return f.deadlineErr }
func (f *fakeLinuxClient) Close() error { return nil }