Commit Graph

385 Commits

Author SHA1 Message Date
James Prestwood 95fa101861 wiphy: parse/store frequency info in band object
As additional frequency info is needed it doesn't make sense to
store a full list of frequencies for every attribute (i.e.
supported, disabled, no-IR, etc).

This changes nl80211_parse_supported_frequencies to take a list
of frequency attributes where each index corresponds to a channel,
and each value can be filled with flag bits to signal any
limitations on that frequency.

wiphy.c then had to be updated to use this rather than the existing
scan_freq_set lists. This, as-is, will break anything using
wiphy_get_disabled_freqs().
2022-12-16 16:36:46 -06:00
James Prestwood 3cd93505d6 wiphy: use enum band_freq with rates getter
wiphy_get_supported_rates expected an enum defined in the nl80211
header but the argument type was an unsigned int, not exactly
intuitive to anyone using the API. Since the nl80211 enum value
was only used in a switch statement it could just as well be IWD's
internal enum band_freq.

This also allows modules which do not reference nl80211.h to use
wiphy_get_supported_rates().
2022-12-09 14:58:42 -06:00
James Prestwood a4678949f9 wiphy: add wiphy_get_supported_ciphers
Similar to wiphy_select_cipher but returns all supported ciphers
included in the mask rather than just one.
2022-11-03 09:21:27 -05:00
Denis Kenzior 7584b38562 wiphy: Support more group management cipher suites 2022-10-24 11:05:24 -05:00
Denis Kenzior ecadc72bcd wiphy: Support GCMP|CCMP-256 cipher suites 2022-10-24 11:05:24 -05:00
Denis Kenzior 81b9eb515e wiphy: Support GCMP cipher suite 2022-10-24 11:05:24 -05:00
Denis Kenzior 4c30bd68ea wiphy: Generalize supported cipher dumper
To make it easier to support additional ciphers in the future.
2022-10-24 11:05:24 -05:00
Denis Kenzior 94ecdc799a ie: Rename _BIP to _BIP_CMAC 2022-10-24 11:05:24 -05:00
Denis Kenzior 201b85e8da crypto: Rename BIP to BIP_CMAC
To match the spec more closely.  Several additional BIP algorithms are
being introduced, including BIP_GMAC_128|256 and BIP_CMAC_256.
2022-10-24 11:05:24 -05:00
James Prestwood 06ec89d6b8 wiphy: add wiphy_supports_probe_resp_offload
Parse the AP probe response offload attribute during the dump. If
set this indicates the driver expects the probe response attribute
to be included with START_AP.
2022-09-28 16:23:00 -05:00
James Prestwood 911572f09a wiphy: don't re-dump wiphy if the regdom didn't change
For whatever reason the kernel will send regdom updates even if
the regdom didn't change. This ends up causing wiphy to dump
which isn't needed since there should be no changes in disabled
frequencies.

Now the previous country is checked against the new one, and if
they match the wiphy is not dumped again.
2022-08-04 14:03:28 -05:00
James Prestwood 1709148484 wiphy: add wiphy_regdom_is_updating
This allows a module to check the current status of the regdom
in case it misses the wiphy event (e.g. registers after the
STARTED event).
2022-08-04 14:03:15 -05:00
James Prestwood 83a5f6edd1 wiphy: dump wiphy's on regulatory domain change
A change in regulatory domain can result in frequencies being
enabled or disabled depending on the domain. This effects the
frequencies stored in wiphy which other modules depend on
such as scanning, offchannel work etc.

When the regulatory domain changes re-dump the wiphy in order
to update any frequency restrictions.
2022-08-04 14:02:39 -05:00
James Prestwood dfcba7c83c wiphy: track GET_REG ID
Keep track of the GET_REG call so it can be canceled if the wiphy
goes down.
2022-08-04 14:02:25 -05:00
James Prestwood 544aafb675 wiphy: add wiphy_country_is_unknown
A helper to check whether the country code corresponds to a
real country, or some special code indicating the country isn't
yet set. For now, the special codes are OO (world roaming) and
XX (unknown entity).
2022-08-04 11:48:08 -05:00
James Prestwood 9b628dd02d wiphy: use nl80211_parse_supported_frequencies
Removes the parser in wiphy and uses the helper instead
2022-08-04 10:25:58 -05:00
James Prestwood 471d34704f wiphy: track self-managed flag
Check if the SELF_MANAGED_REG flag is set and set into wiphy.
2022-08-04 10:25:52 -05:00
James Prestwood f555e5dda2 wiphy: fix runtime error from bit shift
The compiler treated the '1' as an int type which was not big enough
to hold a bit shift of 31:

runtime error: left shift of 1 by 31 places cannot be represented in
		type 'int'

Instead of doing the iftype check manually, refactor
wiphy_get_supported_iftypes by adding a subroutine which just parses
out iftypes from a mask into a char** list. This removes the need to
case each iftype into a string.
2022-08-04 10:20:59 -05:00
James Prestwood f2961cd63a wiphy: constrain scan set by disabled frequencies
With the addition of disabled_freqs, wiphy_constrain_freq_set needs
to also remove any frequencies which are disabled.
2022-07-26 15:31:31 -05:00
James Prestwood 98620ecd11 wiphy: add disabled_freqs list
If a frequency is disabled IWD should keep track and disallow any
operations on that channel such as scanning. A new list has been added
which contains only disabled frequencies.
2022-07-26 15:31:08 -05:00
James Prestwood 4e55447a60 wiphy: use HE element for data rate estimation
If an HE element is found, prefer using this for the rate estimation
since it will likely yield the fastest rate.
2022-07-20 17:19:25 -05:00
James Prestwood a3521ff172 wiphy: fix strange compiler bug with gcc 11.2
There appears to be a compiler bug with gcc 11.2 which thinks the vht_mcs_set
is a zero length array, and the memset of size 8 is out of bounds. This is only
seen once an element is added to 'struct band'.

In file included from /usr/include/string.h:519,
                 from src/wiphy.c:34:
In function ‘memset’,
    inlined from ‘band_new_from_message’ at src/wiphy.c:1300:2,
    inlined from ‘parse_supported_bands’ at src/wiphy.c:1423:11,
    inlined from ‘wiphy_parse_attributes’ at src/wiphy.c:1596:5,
    inlined from ‘wiphy_update_from_genl’ at src/wiphy.c:1773:2:
/usr/include/bits/string_fortified.h:59:10: error: ‘__builtin_memset’ offset [0, 7] is out of the bounds [0, 0] [-Werror=array-bounds]
   59 |   return __builtin___memset_chk (__dest, __ch, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   60 |                                  __glibc_objsize0 (__dest));
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-07-19 17:45:19 -05:00
James Prestwood 9baaaebd38 wiphy: parse HE capabilities from band info
The HE capabilities information is contained in
NL80211_BAND_ATTR_IFTYPE_DATA where each entry is a set of attributes
which define the rules for one or more interface types. This patch
specifically parses the HE PHY and HE MCS data which will be used for
data rate estimation.

Since the set of info is per-iftype(s) the data is stored in a queue
where each entry contains the PHY/MCS info, and a uint32 bit mask where
each bit index signifies an interface type.
2022-07-19 15:47:35 -05:00
James Prestwood 3d48d147ca wiphy: make MCS info print more generic
With the addition of HE, the print function for MCS sets needs to change
slightly. The maps themselves are the same format, but the values indicate
different MCS ranges. Now the three MCS max values are passed in.
2022-07-19 15:46:49 -05:00
James Prestwood bdcbccbb9f wiphy: use a 16 bit tag for extended IEs
If an extended IE is needed a uint8_t tag would overflow.
2022-07-19 15:46:44 -05:00
James Prestwood d46fac6e93 wiphy: set band->freq when parsing band info
This sets the band into the 'band' structure in order to support
HE data rates.
2022-07-19 15:46:10 -05:00
James Prestwood 7882621ca9 wiphy: add 6Ghz support 2022-02-25 13:04:33 -06:00
Denis Kenzior 073346ee37 treewide: Remove unneeded else statements
The code is more readable without the unnecessary nesting
2022-01-11 11:07:33 -06:00
Denis Kenzior fe95cbe077 treewide: Various style fixups
- Mostly problems with whitespace:
	- Use of spaces instead of tabs
	- Stray spaces before closing ')
	- Missing spaces

- Missing 'void' from function declarations & definitions that
  take no arguments.

- Wrong indentation level
2022-01-11 11:07:05 -06:00
James Prestwood e6b4354530 wiphy: update wiphy_radio_work_is_running to return int
This differentiates between pending, running, and non-existent:
false, true, -ENOENT respectively
2021-12-06 14:10:03 -06:00
James Prestwood 56ea2c4d15 treewide: update scan utility usage to use band_* 2021-11-29 17:07:44 -06:00
James Prestwood aed383b037 wiphy: make wiphy work queue reentrancy safe
Now both the do_work and destroy callback can safely insert new
work items without causing problems.
2021-11-22 15:29:51 -06:00
James Prestwood 747cb00c31 wiphy: add wiphy_can_offload
This is a convenience method for detecting any supported offload
extended features (4way/1x/SAE).
2021-10-19 17:04:39 -05:00
James Prestwood 898c7e636e wiphy: change wiphy_control_port_capable -> enabled
Move the reading of ControlPortOverNL80211 into wiphy itself and
renamed wiphy_control_port_capable to wiphy_control_port_enabled.
This makes things easier for any modules interested in control
port support since they will only have to check this one API rather
than read the settings and check capability.
2021-10-08 08:38:35 -05:00
James Prestwood d2f52a6723 wiphy: add wiphy_supports_ext_key_id 2021-10-04 13:39:29 -05:00
Denis Kenzior 9766426b59 wiphy/netdev: Add & use wiphy_control_port_capable
Some drivers might not actually support control port properly even if
advertised by mac80211.  Introduce a new method to wiphy that will take
care of looking up any driver quirks that override the presence of
NL80211_EXT_FEATURE_CONTROL_PORT_OVER_NL80211
2021-10-01 09:38:38 -05:00
Denis Kenzior 6f925c4dae manager/wiphy: Move default if determination
Move the driver database into wiphy.c so it can be extended with other
potential driver quirks.
2021-10-01 09:28:56 -05:00
Denis Kenzior 78b9328db6 scan: Quiet down warning
Under certain conditions, access points with very low signal could be
detected.  This signal is too low to estimate a data rate and causes
this L_WARN to fire.  Fix this by returning a -ENETUNREACH error code in
case the signal is too low for any of the supported rates.
2021-07-28 09:53:21 -05:00
Denis Kenzior 2e777a0d31 network: Enforce Transition Disable settings
Transition Disable indications and information stored in the network
profile needs to be enforced.  Since Transition Disable information is
now stored inside the network object, add a new method
'network_can_connect_bss' that will take this information into account.
wiphy_can_connect method is thus deprecated and removed.

Transition Disable can also result in certain AKMs and pairwise ciphers
being disabled, so wiphy_select_akm method's signature is changed and
takes the (possibly overriden) ie_rsn_info as input.
2021-07-27 17:43:38 -05:00
Denis Kenzior ca8f3edc33 wiphy: Add wiphy_can_transition_disable 2021-07-27 17:43:38 -05:00
Denis Kenzior 57a57646d8 wiphy: Add wiphy_get_rsnxe
Returns a template RSNX element that can be further modified by callers
to set any additional capabilities if required.  wiphy will fill in
those capabilities that are driver / firmware dependent.
2021-07-14 09:55:49 -05:00
Denis Kenzior 667023b01b wiphy: ensure CCMP support when considering SAE 2021-07-05 19:53:52 -05:00
Denis Kenzior 43692cb377 wiphy: Use new data rate estimation utilities 2021-06-04 10:14:04 -05:00
Denis Kenzior e41bee377d band: Add band.[ch]
Move the band definition out of wiphy.c and into band.[ch].  This is
done to make certain utilities that depend on band information capable
of being tested from unit tests.

The band concept will most likely grow over time.  For now, the only
user will be wiphy.c and unit tests, so the structures are kept public.
2021-06-04 10:14:04 -05:00
Denis Kenzior e39cdc7a29 wiphy: Print basic VHT info for each band 2021-06-04 10:14:04 -05:00
Denis Kenzior 683ff1a4e4 wiphy: Return -errno instead of false 2021-06-01 16:46:23 -05:00
Denis Kenzior dbd66bd497 wiphy: Print more basic wiphy info 2021-06-01 13:41:56 -05:00
Denis Kenzior 74761fcdd3 wiphy: Add wiphy_estimate_data_rate
The data rate estimation belongs in wiphy since it should take hardware
capabilities into account.  Right now the data rate calculation simply
assumes the hardware is as capable as the AP.  scan.c will be ported to
use this utility and the data rate estimation will be expanded to take
wiphy capabilities into account.
2021-06-01 13:41:56 -05:00
Denis Kenzior 10ac107ba6 wiphy: Parse HT Capabilities & MCS Set 2021-06-01 13:41:56 -05:00
Denis Kenzior ea9bc11fc8 wiphy: Parse VHT Capabilities & MCS Set 2021-06-01 13:41:56 -05:00