Commit graph

86 commits

Author SHA1 Message Date
Jo-Philipp Wich
14f864eb72 nl80211: add ability to describe USB devices
Treat USB vendor and product IDs like PCI subsystem vendor and device IDs
respectively to allow describing USB devices as `0000 0000 $vid $pid` in
the hardware database.

As a side effect, this also skips potentially expensive MTD lookups on
embedded devices with plugged in USB radios.

With a 5.15 kernel, such MTD lookups even spam dmesg with:

    mtdblock: MTD device 'factory' is NAND, please consider using UBI block devices instead.

This fix speeds up iwinfo considerably on affected systems:

Before:
sys     0m 3.56s

After:
sys     0m 0.09s

Suggested-by: Andre Heider <a.heider@gmail.com>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2022-12-15 21:14:57 +01:00
Andre Heider
a5a75fd661 nl80211: remove ancient wpa_supplicant ctrl socket path
This isn't required nor used anymore, and it's been +8 years.

See
"735a03be: iwinfo: adjust for changed wpa_supplicant control socket path"
on the main repository.

Signed-off-by: Andre Heider <a.heider@gmail.com>
2022-12-15 20:12:41 +01:00
Andre Heider
dd4e1ffeac nl80211: fix wpa supplicant ctrl socket permissions
No data at all can currently be read from the control socket.
Set up the permission exactly like hostapd's wpa_cli utility to fix it.

Among other this fixes a mesh's encryption being shown as "None".

Signed-off-by: Andre Heider <a.heider@gmail.com>
2022-12-15 20:11:12 +01:00
Andre Heider
4aa6c5a45c fix -Wreturn-type warning
The function doesn't return anything nor does any caller expect
anything.

Signed-off-by: Andre Heider <a.heider@gmail.com>
2022-12-15 20:07:49 +01:00
Andre Heider
311272660d fix -Wpointer-sign warning
sb.ssid is buf casted to unsigned char, just use that instead of casting
it back.

Signed-off-by: Andre Heider <a.heider@gmail.com>
2022-12-15 20:07:49 +01:00
Andre Heider
ebd5f84955 fix -Wmaybe-uninitialized warning
All previous cases not hit, which means no scan was possible.
Indicate that.

Signed-off-by: Andre Heider <a.heider@gmail.com>
2022-12-15 20:07:49 +01:00
Andre Heider
5469898e8b fix -Wunused-variable warnings
Remove them.

Signed-off-by: Andre Heider <a.heider@gmail.com>
2022-12-15 20:07:49 +01:00
Andre Heider
ccaabb4ea4 fix -Wformat-truncation warnings
Increase buffer sizes to get rid of e.g.:
iwinfo_nl80211.c:797:41: note: 'snprintf' output between 24 and 279 bytes into a destination of size 64

Signed-off-by: Andre Heider <a.heider@gmail.com>
2022-12-15 20:07:49 +01:00
Joerg Werner
00aab871c5 Correctly identify key management algorithms starting with "FT-"
Correctly categorize FT-EAP-SHA384 as WPA3

Signed-off-by: Joerg Werner <schreibubi@gmail.com>
2022-11-01 17:11:32 +01:00
Felix Fietkau
0496c722f1 nl80211: fix issues with renamed wiphy and multiple phy per device
Remove the assumption that phy names follow the format phy%d and instead look
up the phy index from sysfs properly

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-10-14 10:59:08 +02:00
Felix Fietkau
4a43b0d40b nl80211: look up the phy name instead of assuming name == phy<idx>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-09-22 14:42:45 +02:00
Felix Fietkau
b7f9f06e15 nl80211: fix phy/netdev index lookup
Don't assume a fixed naming pattern. Check all options in this order:

- netdev
- phy name
- wifi device in uci

Use the first one that matches

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-09-22 14:42:45 +02:00
Felix Fietkau
1f695d9c7f nl80211: allow phy names that don't start with 'phy'
This is needed for dealing with wiphy renaming

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-09-22 13:28:59 +02:00
Daniel Golle
46f04f3808 devices: add MediaTek MT7986 WiSoC
Add detection of the MediaTek MT7986 WiSoC using the compatible string
from device tree.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2022-08-31 14:08:39 +01:00
Joerg Werner
0dad3e6660 Add support for CCMP-256 and GCMP-256 ciphers
Signed-off-by: Joerg Werner <schreibubi@gmail.com>
2022-08-20 17:59:11 +02:00
David Bauer
dc6847eb5e iwinfo: nl80211: omit A-hwmode on non-5GHz hardware
Don't add the hwmode A for radios which do not support 5GHz operation.
Before, this hwmode was added to all non-VHT radios regardless of their
supported bands.

Fixes commit 562d015326 ("iwinfo: nl80211: fix hwmode parsing for multi-band NICs")

Signed-off-by: David Bauer <mail@david-bauer.net>
2022-04-27 00:51:14 +02:00
David Bauer
562d015326 iwinfo: nl80211: fix hwmode parsing for multi-band NICs
In case a NIC supports multiple frequency bands, the supported
hw-modelist might not contain all valid hwmodes, as B/G/AD hwmodes are
only included based on the last parsed supported frequency.

In case a radio supports multiple bands, this might result in these
hwmodes not being flagged as supported.

Circumvent this by tracking all seen frequency bands using a bitmask
which later determined which HW modes are listed as supported.

Signed-off-by: David Bauer <mail@david-bauer.net>
2022-04-23 11:59:29 +02:00
Felix Fietkau
c9b1672f5a nl80211: fix path compatibility issue
The previous shell script implementation accepted shorter path values
that omitted initial parts before the pcie bus node by only checking if
the configured path is included in the determined path
Add support for doing the same thing here

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-06-28 15:39:22 +02:00
Felix Fietkau
c0414642fe iwinfo: nl80211: fix typo
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-06-09 22:12:08 +02:00
Felix Fietkau
268bb26d2e iwinfo: nl80211: support looking up phy by path=.. and macaddr=...
Can be used from within mac80211.sh without the need to reference the uci
config directly

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-06-09 14:21:55 +02:00
Felix Fietkau
dd6d6d2dec iwinfo: nl80211: use new path lookup function for nl80211_phy_idx_from_uci_path
Fixes issues with multiple phy instances of one device

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-06-09 14:05:05 +02:00
Felix Fietkau
aa0e3c4bbe iwinfo: nl80211: add support for printing the device path for a phy
Will be used to replace the shell code from mac80211.sh

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-06-09 13:57:26 +02:00
David Bauer
c45f0b584b iwinfo: add 802.11ax HE rate information
This adds 802.11ax HE specific rate information to iwinfo.

Add fields for HE status of a STA as well as DCM and guard interval
fields specific to HE operation.

Signed-off-by: David Bauer <mail@david-bauer.net>
2021-05-02 00:20:54 +02:00
David Bauer
70d2136069 iwinfo: nl80211: perform split wiphy dump
Perform a split wiphy dump when acquiring the hw modelist of a mac80211
device. Otherwise HE capabilities are missing from the message.

This is necessary since upstream commit f8d504caa ("nl80211: reduce
non-split wiphy dump size")  (Kernel 5.9).

Signed-off-by: David Bauer <mail@david-bauer.net>
2021-04-20 18:04:06 +02:00
David Bauer
50b64a63e3 iwinfo: add basic IEEE 802.11ax support
This adds basic support for IEEE 802.11ax when requesting HW or HT
Modelist for a PHY from iwinfo. This way, applications using iwinfo can
detect HE phys.

Signed-off-by: David Bauer <mail@david-bauer.net>
2021-04-12 23:45:42 +02:00
Daniel Golle
5a2dd180f7 iwinfo: add hardware description for MediaTek MT7622
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-01-28 22:37:45 +00:00
Ansuel Smith
0702f32294 iwinfo: improve center channel handling
- Improve iwinfo center channel struct position
- Prevent read beyond buffer on malformed data

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
2021-01-06 17:38:07 +00:00
Daniel Golle
618c1e86f0 iwinfo: add hardware description for QCA MIPS WiSoCs
Add description strings and detection logic for all 6
types of WiFi NICs integrated in QCA MIPS WiSoCs.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-01-06 17:19:19 +00:00
Daniel Golle
8bfd8d8800 iwinfo: add support for GCMP cipher
Extend support for WPA ciphers by GCMP which is required for 802.11ad.
Breaks ABI as ciphers now needs to be a field of 16 bits instead of 8.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-01-05 22:19:43 +00:00
Ansuel Smith
4e22953eb1 iwinfo: export center_chan info for local wifi
Iwinfo already export the htmode but there is no way to know where the
channel expan in case a 40Mhz+ channel width is used. Export the center
channels used by the driver to better know the channel utilizzation of
the wifi.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
2021-01-05 22:19:43 +00:00
Ansuel Smith
ea28dfb5f9 iwinfo: export ht and vht operation in scan results
Export ht and vht operation data in scan results. These additional data
can be usefull to check wifi channel utilizzation by neraby stations.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
2021-01-05 22:19:42 +00:00
Daniel Golle
a17f5613c3 iwinfo: detect QCA IPQ4019 WiSoC from FDT
As it's the most reliable and straight forward way on modern platforms,
detect the hardware ID by checking the 'compatible'-string of non-PCI
(ie. built-in) devices.
As this is only relevant for WiSoCs, there won't be that many records,
so it's not worth making any larger structural changes. Hence just
match the compatible string and translate it into fake PCI IDs.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-01-05 22:19:42 +00:00
David Bauer
06a03c9e3b Revert "iwinfo: add BSS load element to scan result"
This reverts commit a6914dc0dc.

iwinfo currently misses ABI version tracking in OpenWrt, potentially
breaking other packages unintentionally.

Revert this commit for now  until this is implemented.
Otherwise, we are not able to safely bump iwinfo at the moment.

Signed-off-by: David Bauer <mail@david-bauer.net>
2020-03-22 01:06:36 +01:00
David Bauer
a6914dc0dc iwinfo: add BSS load element to scan result
This adds support for the BSS load information element. With this patch,
the BSS load information is visible when using the CLI as well as when
accessing scan results using the LUA binding.

Signed-off-by: David Bauer <mail@david-bauer.net>
2020-02-04 14:44:14 +01:00
Daniel Danzberger
bf2c1069a7 nl80211: add htmode to iwinfo_ops
This callback shows the currently active HTMODE of the device.

Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
2020-01-05 17:17:40 +01:00
Jo-Philipp Wich
a6f6c05348 nl80211: properly handle netdev names starting with "radio"
This fixes VAPs not being queried correctly when the netdev name starts
with "radio".

Fixes: FS#2629

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Signed-off-by: David Bauer <mail@david-bauer.net>
2019-12-27 13:32:03 +01:00
Jo-Philipp Wich
07315b6fdb nl80211: handle hidden SSIDs in wpa_supplicant scan results
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-16 16:41:55 +02:00
Jo-Philipp Wich
a29b7d4e26 nl80211: align path to phy mapping logic with mac80211.sh
The mac80211.sh implementation of the uci "path" option compares the
readlink() results of each /sys/class/ieee80211/*/device link to find
the proper phy directory while iwinfo so far tried to construct a full
path out of the uci value.

The iwinfo approach appears to fail under certain circumstances, e.g.
with Hyper-V systems utilizing PCI passthrough for the radio devices.

This commit mimicks the behaviour of mac80211.sh more closely to
achieve the same results.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-10-15 14:50:56 +02:00
Jo-Philipp Wich
2a95086db2 nl80211: recognize SAE encrypted mesh
Also report open Ad-Hoc and Mesh network encryption as "none" and
not as "unknown".

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-30 12:41:26 +02:00
Jo-Philipp Wich
313e82709b nl80211: keep awaiting wpa_supplicant scan results on busy response
When wpa_supplicant responds with FAIL-BUSY in response to the SCAN
command, a scan process is already in process. Instead of failing in
this case, simply keep awaiting the result list.

This also significantly speeds up the scan operation in many cases.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-22 18:49:26 +02:00
Jo-Philipp Wich
a766751369 nl80211: fix parsing of mixed wpa encryption in wpa_supp scan results
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-22 18:12:47 +02:00
Jo-Philipp Wich
7faeaeafe1 nl80211: properly detect WEP encryption in wpa_supp scan results
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-20 13:12:56 +02:00
Jo-Philipp Wich
629b5ffdd9 nl80211: do not confuse open connections with WEP ones
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-20 13:12:56 +02:00
Jo-Philipp Wich
3d47ddda0c nl80211: rework hostapd and wpa_supplicant wpa suite parsing
Refactor the parsing of wpa_supplicant scan list results, the wpa_supplicant
status output and the hostapd configuration file format to properly detect
WPA3 key management protocols like SAE, OWE or EAP Suite B.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-09-20 13:12:53 +02:00
Hauke Mehrtens
71ec9be506 iwinfo: Fix buffer size
With WPA3 the wpa_key_mgmt string can be longer than 16 bytes. The
sea-mixed setting for example is 27 bytes long:
wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256 SAE

Increase the buffer to better detect more complicated authentication methods.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2019-09-01 19:38:03 +02:00
Robert Marko
f8ef450652 iwinfo: Add support for WPA3
This patch adds support for WPA3, meaning SAE and OWE are now properly identified.
This fixes iwinfo and LuCi showing WPA2 NONE for WPA3 SAE and OWE.

Signed-off-by: Robert Marko <robimarko@gmail.com>
2019-09-01 12:38:57 +02:00
Jo-Philipp Wich
a9f9557034 nl80211: support reading hardware id from phy directly
Do not require a temporary interface just to read the hardware ID numbers
from a given phy name, instead read the data from the ieee80211 sysfs
directory.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-08-28 11:31:32 +02:00
Robert Marko
c2cfe9d96c iwinfo: Fix 802.11ad channel to frequency
This patch enables proper identification of ad hwmode in channel2frequency function.
Now iwinfo will properly calculate frequency for a channels 1-6 in 802.11ad.

Fixes a8e8275923

Signed-off-by: Robert Marko <robimarko@gmail.com>
2019-03-28 15:02:58 +01:00
Robert Marko
a8e8275923 iwinfo: Add support for 802.11ad
This patch adds support for identifying, calculating channels from
frequency and vice versa as well as Lua hwmode for 802.11ad.

Support has been added for channels 1-6.

Signed-off-by: Robert Marko <robimarko@gmail.com>
[Increase buffer size for hwmodes]
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2019-03-21 16:28:39 +01:00
Daniel Danzberger
5aa8c5496c libiwinfo: nl80211: add mesh stats on assoclist.
Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
2018-11-26 11:03:17 +01:00