Commit Graph

336 Commits

Author SHA1 Message Date
Andrew Zaborowski a90c4025f1 handshake: Add HANDSHAKE_EVENT_P2P_IP_REQUEST
Add a handshake event for use by the AP side for mechanisms that
allocate client IPs during the handshake: P2P address allocation and
FILS address assignment.  This is emitted only when EAPOL or the
auth_proto is actually about to send the network configuration data to
the client so that ap.c can skip allocating a DHCP leases altogether if
the client doesn't send the required KDE or IE.
2021-08-25 08:01:23 -05:00
James Prestwood cd2dd4e2dc station: Add generic Event signal
This is meant to be used as a generic notification to autotests. For
now 'no-roam-candidates' is the only event being sent. The idea
is to extend these events to signal conditions that are otherwise
undiscoverable in autotesting.
2021-08-13 14:44:24 -05:00
James Prestwood dffff73e89 station: implement Scan on debug interface
This is to support the autotesting framework by allowing a smaller
scan subset. This will cut down on the amount of time spent scanning
via normal DBus scans (where the entire spectrum is scanned).
2021-08-13 10:44:26 -05:00
James Prestwood ea3ce7a119 station: set autoconnect via setter
This updates the autoconnect property for the debug interface
2021-08-13 10:41:25 -05:00
James Prestwood f6f08f9b96 station: disable autoconnect when in developer mode
Most autotests do not want autoconnect behavior so it is being
turned off by default. There are a few tests where it is needed
and in these few cases the test can enable autoconnect through
the new station debug property.
2021-08-12 16:53:58 -05:00
James Prestwood 249a1ef1c0 station: make autoconnect settable via debug interface
This adds the property "AutoConnect" to the station debug interface
which can be read/written to disable or enable autoconnect globally.
As one would expect this property is only going to be used for testing
hence why it was put on the debug interface. Mosts tests disable
autoconnect (or they should) because it leads to unexpected connections.
2021-08-12 15:57:00 -05:00
James Prestwood 77c4d311ff station: move Roam() under station debug interface 2021-08-12 14:59:19 -05:00
James Prestwood 3afa5e570d station: add ConnectBssid() developer method
This method will initiate a connection to a specific BSS rather
than relying on a network based connection (which the user has
no control over which specific BSS is selected).
2021-08-12 14:46:08 -05:00
James Prestwood b33d100f7b station: set preparing_roam flag on Roam()
The preparing_roam flag is expected to be set by a few roam
routines and normally this is done prior to the roam scan.
The Roam() developer option was not doing this and would
cause failed roams in some cases.
2021-08-06 22:29:52 -05:00
Denis Kenzior da0fa4e012 station: Set network's vendor IEs into handshake
This guarantees that the vendor IEs will be used on ReAssociate and
Fast-Transition paths, as well as on all non-CMD_CONNECT based
connections.
2021-08-06 14:23:45 -05:00
Denis Kenzior 317e345a6a netdev: Remove prev_bssid member
This variable ended up being used only on the fast-transition path.  On
the re-associate path it was never used, but memcpy-ied nevertheless.
Since its only use is by auth_proto based protocols, move it to the
auth_proto object directly.

Due to how prepare_ft works (we need prev_bssid from the handshake, but
the handshake is reset), have netdev_ft_* methods take an 'orig_bss'
parameter, similar to netdev_reassociate.
2021-08-04 23:08:34 -05:00
James Prestwood 630c2c2a08 station: network: rework ERP/FILS code path
This refactors some code to eliminate getting the ERP entry twice
by simply returning it from network_has_erp_identity (now renamed
to network_get_erp_cache). In addition this code was moved into
station_build_handshake_rsn and properly cleaned up in case there
was an error or if a FILS AKM was not chosen.
2021-08-03 16:29:08 -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 47ba837e98 network: Store Transition Disable info
This indication can come in via EAPoL message 3 or during
FILS Association.  It carries information as to whether certain
transition mode options should be disabled.  See WPA3 Specification,
version 3 for more details.
2021-07-27 16:55:58 -05:00
Denis Kenzior 10fd485d7d station: Set authenticator's RSNXE if present 2021-07-14 09:55:49 -05:00
Denis Kenzior 2a66b3bfe5 network: Move handshake parameter setup from station
Most parameters set into the handshake object are actually known by the
network object itself and not station.  This includes address
randomization settings, EAPoL settings, passphrase/psk/8021x settings,
etc.  Since the number of these settings will only keep growing, move
the handshake setup into network itself.  This also helps keep network
internals better encapsulated.
2021-07-14 09:55:49 -05:00
Denis Kenzior dfdc8716be network: Rename _sync_psk to _sync_settings
There will be additional security-related settings that will be
introduced for settings files.  In particular, Hash-to-Curve PT
elements, Transition Disable settings and potentially others in the
future.  Since PSK is now not the only element that would require
update, rename this function to better reflect this.
2021-07-06 11:46:33 -05:00
Andrew Zaborowski 19e5cc9b0d station: Remove diagnostics interface reliably
If the idea is that the interface should only be present when connected
then don't do this in the DISCONNECTING state as there are various
possible transitions from CONNECTED or ROAMING directly to DISCONNECTED.
2021-06-18 10:06:57 -05:00
Andrew Zaborowski 002fc2d632 station: Check if busy in station_get_diagnostics 2021-06-18 09:58:42 -05:00
Denis Kenzior 03b48b5621 station: Pretty-print the estimated BSS data rate 2021-06-04 10:14:04 -05:00
Denis Kenzior cf950f6d3f station: Do not call netdev_disconnect on in station_free
station_free() is invoked when one of two possibilities happen:
- Device has been powered down, and EVENT_DOWN has been emitted
- Device has been removed, and EVENT_DEL has been emitted

In both cases there is not much point for netdev_disconnect to be
invoked as that tries to cleanly shut down an existing connection.  The
only thing the ABORTED error accomplishes in this case is to send a
dbus_aborted_error for the pending_connect message, if it exists.
There's already code for doing this in station_free().

src/station.c:station_enter_state() Old State: autoconnect_quick, new state: connecting (auto)
src/scan.c:scan_cancel() Trying to cancel scan id 1 for wdev 7
src/wiphy.c:wiphy_radio_work_done() Work item 1 done
src/wiphy.c:wiphy_radio_work_next() Starting work item 2
Terminate
src/netdev.c:netdev_free() Freeing netdev wlan0[9]
src/device.c:device_free()
src/station.c:station_free()
src/wiphy.c:wiphy_radio_work_done() Work item 2 done
src/station.c:station_connect_cb() 9, result: 5
src/netconfig.c:netconfig_destroy()
Removing scan context for wdev 7
src/scan.c:scan_context_free() sc: 0x4a39490
src/netdev.c:netdev_mlme_notify() MLME notification New Station(19)
src/netdev.c:netdev_link_notify() event 16 on ifindex 9
src/netdev.c:netdev_link_notify() event 16 on ifindex 9
src/netdev.c:netdev_mlme_notify() MLME notification Authenticate(37)
src/netdev.c:netdev_link_notify() event 16 on ifindex 9
src/netdev.c:netdev_mlme_notify() MLME notification Associate(38)
src/netdev.c:netdev_link_notify() event 16 on ifindex 9
src/netdev.c:netdev_mlme_notify() MLME notification Connect(46)
src/netdev.c:netdev_link_notify() event 16 on ifindex 9
src/wiphy.c:wiphy_reg_notify() Notification of command Reg Change(36)
src/wiphy.c:wiphy_update_reg_domain() New reg domain country code for (global) is US
src/netdev.c:netdev_link_notify() event 16 on ifindex 9
src/netdev.c:netdev_unicast_notify() Unicast notification 129
src/netdev.c:netdev_mlme_notify() MLME notification Del Station(20)
src/netdev.c:netdev_mlme_notify() MLME notification Deauthenticate(39)
src/netdev.c:netdev_mlme_notify() MLME notification Disconnect(48)
src/wiphy.c:wiphy_reg_notify() Notification of command Reg Change(36)
src/wiphy.c:wiphy_update_reg_domain() New reg domain country code for (global) is XX
==20311== Invalid write of size 4
==20311==    at 0x406E74: netdev_cmd_disconnect_cb (netdev.c:1130)
==20311==    by 0x4A78A8: process_unicast (genl.c:986)
==20311==    by 0x4A7C6A: received_data (genl.c:1098)
==20311==    by 0x4A2E1F: io_callback (io.c:120)
==20311==    by 0x4A17BB: l_main_iterate (main.c:478)
==20311==    by 0x4A18FC: l_main_run (main.c:525)
==20311==    by 0x4A1C14: l_main_run_with_signal (main.c:647)
==20311==    by 0x404D27: main (main.c:542)
==20311==  Address 0x4a37a0c is 156 bytes inside a block of size 472 free'd
==20311==    at 0x48399CB: free (vg_replace_malloc.c:538)
==20311==    by 0x498991: l_free (util.c:136)
==20311==    by 0x406651: netdev_free (netdev.c:883)
==20311==    by 0x412976: netdev_shutdown (netdev.c:5970)
==20311==    by 0x403A14: iwd_shutdown (main.c:79)
==20311==    by 0x403A7D: signal_handler (main.c:90)
==20311==    by 0x4A1B1D: sigint_handler (main.c:612)
==20311==    by 0x4A1F5D: handle_callback (signal.c:78)
==20311==    by 0x4A2052: signalfd_read_cb (signal.c:104)
==20311==    by 0x4A2E1F: io_callback (io.c:120)
==20311==    by 0x4A17BB: l_main_iterate (main.c:478)
==20311==    by 0x4A18FC: l_main_run (main.c:525)
2021-06-01 13:41:56 -05:00
Denis Kenzior f1bc1ed4be station: Do not check deprecated enable_network_config
Enough time has passed where everyone should have had the chance to
update this to the new setting.
2021-06-01 10:26:18 -05:00
Alvin Šipraga 920ac37a40 station: update current BSS frequency on netdev channel switch event
If the connected BSS changes channel, netdev will emit an event with the
new channel's frequency. In response, have station change the frequency
of the connected scan_bss struct and inform network about the update.
2021-05-27 13:53:51 -05:00
Denis Kenzior 1822062d55 station: Continue trying to autoconnect on failure
Right now, if a connection to a network selected by auto-connect fails,
the entire autoconnect process is restarted.  This means that scans are
kicked off again, auto-connect list is rebuilt, etc.  This was due to
auto-connect reusing the same failure path as connections triggered via
D-Bus.

The above behavior can lead to weird situations in certain corner cases.
For example, a highly preferred network configured with the wrong
password would result in auto-connect entering an infinite loop.

Fix this by making sure that all auto-connect entries are tried and
exhausted prior to re-scanning again.
2021-05-25 18:42:57 -05:00
Denis Kenzior db3024eed6 station: Introduce CONNECTING_AUTO state
This will be effectively the same as the CONNECTING state, but can be
used to enable differing behavior, depending on whether connection was
triggered by autoconnect or via D-Bus.
2021-05-25 18:42:57 -05:00
Denis Kenzior 00763fde0d station: Break up station_connect_cb
Break this up into two parts, one handling the successful connect case,
the other for handling error conditions
2021-05-25 18:42:57 -05:00
Denis Kenzior 66b73262df station: Check return of network_bss_select
network_bss_select can return NULL if no suitable BSSes are found, or if
all of them are blacklisted.  Make sure to skip the network if this
happens.
2021-05-19 09:56:59 -05:00
James Prestwood 877d910a44 station: autoconnect based on network, not BSS
Prior to the BSS blacklist a BSS based autoconnect list made
the most sense, but now station actually retries all BSS's upon
failure. This means that for each BSS in the autoconnect list
every other BSS under that SSID will be attempted to connect to
if there is a failure. Essentially this is a network based
autoconnect list, just an indirect way of doing it.

Intead the autoconnect list can be purely network based, using
the network rank for sorting. This avoids the need for a special
autoconnect_entry struct as well as ensures the last connected
network is chosen first (simply based on existing network ranking
logic).
2021-05-19 09:44:18 -05:00
James Prestwood df04877a67 station: use IE_AKM_IS_FT when possible
Update a check to use IE_AKM_IS_FT as the condition is identical
to the macro.
2021-05-12 18:04:30 -05:00
James Prestwood 7fc0a8fc0f station: make station_can_fast_transition more robust
Check that the current handshake is using an FT AKM and that the
target BSS AKM suites contain an FT AKM.
2021-05-12 18:04:30 -05:00
James Prestwood e5fcc93a9e netdev: remove callback/userdata/timeout from FT-over-DS action
Since netdev maintains the list of FT over DS info structs there is not
any need for station to get callbacks when the initial action frame
is received, or not. This removes the need for the callback handler,
user data, and response timeout.
2021-05-12 18:04:30 -05:00
James Prestwood 7385e2c90e station: send FT-over-DS actions upon connection
Roam times can be slightly improved by sending out the FT-over-DS
action frames to any BSS in the mobility domain immediately after
connecting. This preauthenticates IWD to each AP which means
Reassociation can happen right away when a roam is needed.

When a roam is needed station_transition_start will first try
FT-over-DS (if supported) via netdev_fast_transtion_over_ds. The
return is checked and if netdev has no cached entries FT-over-Air
will be used instead.
2021-05-12 18:04:30 -05:00
James Prestwood 80712face4 station: remove ap_directed_roam check for over-DS
This flag was being checked but it is explicitly being set to
false prior.
2021-05-12 18:04:30 -05:00
James Prestwood f95e3a02e8 station: factor out logic for choosing FT 2021-05-12 18:04:30 -05:00
James Prestwood 694ccf62d0 station: add Roam() diagnostics method
This is being added as a developer method and should not be used
in production. For testing purposes though, it is quite useful as
it forces IWD to roam to a provided BSS and bypasses IWD's roaming
and ranking logic for choosing a roam candidate.

To use this a BSSID is provided as the only parameter. If this
BSS is not in IWD's current scan results -EINVAL will be returned.
If IWD knows about the BSS it will attempt to roam to it whether
that is via FT, FT-over-DS, or Reassociation. These details are
still sorted out in IWDs station_transition_start() logic.
2021-05-07 08:45:42 -05:00
James Prestwood a3906272cc station: print reason why autoconnect failed 2021-05-04 10:30:55 -05:00
James Prestwood 1b5a58233c station: separate FT-over-DS stages
FT-over-DS was refactored to separate the FT action frame and
reassociation. From stations standpoint IWD needs to call
netdev_fast_transition_over_ds_action prior to actually roaming.
For now these two stages are being combined and the action
roam happens immediately after the action response callback.
2021-04-30 13:09:13 -05:00
James Prestwood 0531e9ab08 station: remove diagnostic interface on station_free
If station gets removed ungracefully (e.g. rfkill/hotplug) it
may not have a chance to disconnect, meaning the diagnostic
interface would remain up.
2021-04-28 14:46:16 -05:00
James Prestwood 3b3f6d33fe station: tie diagnostic interface cleanup to DISCONNECTING
Prior to this the diagnostic interface was taken down when station
transitioned to DISCONNECTED. This worked but once station is in
a DISCONNECTING state it then calls netdev_disconnect(). Trying to
get any diagnostic data during this time may not work as its
unknown what state exactly the kernel is in. To be safe take the
interface down when station is DISCONNECTING.
2021-04-28 14:31:33 -05:00
Denis Kenzior a0911ca778 station: Make sure roam_scan_id is always canceled
Under very rare circumstances the roaming scan triggered might not be
canceled properly.  This is because we issue the roam scan recursively
from within a scan callback and re-use the id of the scan for the
subsequent request.  The destroy callback is invoked right after the
callback and resets the id.  This leads to the scan not being canceled
properly in roam_state_clear().

src/netdev.c:netdev_mlme_notify() MLME notification Notify CQM(64)
src/station.c:station_roam_trigger_cb() 37
src/station.c:station_roam_scan() ifindex: 37
src/station.c:station_roam_trigger_cb() Using cached neighbor report for roam
...
src/scan.c:get_scan_done() get_scan_done
src/station.c:station_roam_failed() 37
src/station.c:station_roam_scan() ifindex: 37
src/scan.c:scan_request_triggered() Active scan triggered for wdev 22
^CTerminate
src/netdev.c:netdev_free() Freeing netdev wlan0[37]
src/device.c:device_free()
src/station.c:station_free()
...
Removing scan context for wdev 22
src/scan.c:scan_context_free() sc: 0x4a362a0
src/wiphy.c:wiphy_radio_work_done() Work item 14 done
==19542== Invalid write of size 4
==19542==    at 0x411500: station_roam_scan_destroy (station.c:2010)
==19542==    by 0x420B5B: scan_request_free (scan.c:156)
==19542==    by 0x410BAC: destroy_work (wiphy.c:294)
==19542==    by 0x410BAC: wiphy_radio_work_done (wiphy.c:1613)
==19542==    by 0x46C66E: l_queue_clear (queue.c:107)
==19542==    by 0x46C6B8: l_queue_destroy (queue.c:82)
==19542==    by 0x420BAE: scan_context_free (scan.c:205)
==19542==    by 0x424135: scan_wdev_remove (scan.c:2272)
==19542==    by 0x408754: netdev_free (netdev.c:847)
==19542==    by 0x40E18C: netdev_shutdown (netdev.c:5773)
==19542==    by 0x404756: iwd_shutdown (main.c:78)
==19542==    by 0x404756: iwd_shutdown (main.c:65)
==19542==    by 0x470E21: handle_callback (signal.c:78)
==19542==    by 0x470E21: signalfd_read_cb (signal.c:104)
==19542==    by 0x47166B: io_callback (io.c:120)
==19542==  Address 0x4d81f98 is 200 bytes inside a block of size 288 free'd
==19542==    at 0x48399CB: free (vg_replace_malloc.c:538)
==19542==    by 0x47F3E5: interface_instance_free (dbus-service.c:510)
==19542==    by 0x481DEA: _dbus_object_tree_remove_interface (dbus-service.c:1694)
==19542==    by 0x481F1C: _dbus_object_tree_object_destroy (dbus-service.c:795)
==19542==    by 0x40894F: netdev_free (netdev.c:844)
==19542==    by 0x40E18C: netdev_shutdown (netdev.c:5773)
==19542==    by 0x404756: iwd_shutdown (main.c:78)
==19542==    by 0x404756: iwd_shutdown (main.c:65)
==19542==    by 0x470E21: handle_callback (signal.c:78)
==19542==    by 0x470E21: signalfd_read_cb (signal.c:104)
==19542==    by 0x47166B: io_callback (io.c:120)
==19542==    by 0x47088C: l_main_iterate (main.c:478)
==19542==    by 0x47095B: l_main_run (main.c:525)
==19542==    by 0x47095B: l_main_run (main.c:507)
==19542==    by 0x470B6B: l_main_run_with_signal (main.c:647)
==19542==  Block was alloc'd at
==19542==    at 0x483879F: malloc (vg_replace_malloc.c:307)
==19542==    by 0x46AB2D: l_malloc (util.c:62)
==19542==    by 0x416599: station_create (station.c:3448)
==19542==    by 0x406D55: netdev_newlink_notify (netdev.c:5324)
==19542==    by 0x46D4BC: l_hashmap_foreach (hashmap.c:612)
==19542==    by 0x472F46: process_broadcast (netlink.c:158)
==19542==    by 0x472F46: can_read_data (netlink.c:279)
==19542==    by 0x47166B: io_callback (io.c:120)
==19542==    by 0x47088C: l_main_iterate (main.c:478)
==19542==    by 0x47095B: l_main_run (main.c:525)
==19542==    by 0x47095B: l_main_run (main.c:507)
==19542==    by 0x470B6B: l_main_run_with_signal (main.c:647)
==19542==    by 0x403EDB: main (main.c:490)
==19542==
2021-04-28 13:15:45 -05:00
James Prestwood 9d9c516596 wiphy: add fils_hint to wiphy_can_connect
A prior commit refactored the AKM selection in wiphy.c. This
ended up breaking FILS tests due to the hard coding of a
false fils_hint in wiphy_select_akm. Since our FILS tests
only advertise FILS AKMs wiphy_can_connect would return false
for these networks.

Similar to wiphy_select_akm, add a fils hint parameter to
wiphy_can_connect and pass that down directly to wiphy_select_akm.
2021-04-27 14:48:23 -05:00
James Prestwood bba47527d3 station: update to use network_has_erp_identity 2021-04-27 14:48:09 -05:00
Denis Kenzior 4a1dafb907 station: Move AP directed roam watch to station
Logically this frame watch belongs in station.  It was kept in device.c
for the purported reason that the station object was removed with
ifdown/ifup changes and hence the frame watch might need to be removed
and re-added unnecessarily.  Since the kernel does not actually allow to
unregister a frame watch (only when the netdev is removed or its iftype
changes), re-adding a frame watch might trigger a -EALREADY or similar
error.

Avoid this by registering the frame watch when a new netdev is detected
in STATION mode, or when the interface type changes to STATION.
2021-04-23 09:51:46 -05:00
Denis Kenzior ca085d799d station: Do not set or use the offload bit
station should be isolated as much as possible from the details of the
driver type and how a particular AKM is handled under the hood.  It will
be up to wiphy to pick the best AKM for a given bss.  netdev in turn
will pick how to drive the particular AKM that was picked.
2021-03-31 11:27:10 -05:00
James Prestwood 28a7dd7fba station: get neighbor report after roaming
In the same vein as requesting a neighbor report after
connecting for the first time, it should also be done
after a roam to obtain the latest neighbor information.
2021-03-29 14:12:02 -05:00
James Prestwood 9b682d43db station: unify firmware/normal roaming
This doesn't change much functionally but does unify the
two roaming paths by ending with 'station_roamed()'.
2021-03-29 14:11:45 -05:00
James Prestwood 21e95dd2d8 station: clear out roam frequencies after roam 2021-03-29 14:11:37 -05:00
James Prestwood c2330c5332 station: add Security key to GetDiagnostics 2021-03-29 13:18:01 -05:00
Denis Kenzior e730baac4a station: Make sure to reset scanning property
When we cancel a quick scan that has already been triggered, the
Scanning property is never reset to false.  This doesn't fully reflect
the actual scanning state of the hardware since we don't (yet) abort
the scan, but at least corrects the public API behavior.

{Network} [/net/connman/iwd/0/7/73706733_psk] Connected = False
{Station} [/net/connman/iwd/0/7] Scanning = True
{Station} [/net/connman/iwd/0/7] State = connecting
{Station} [/net/connman/iwd/0/7] ConnectedNetwork =
/net/connman/iwd/0/7/73706733_psk
{Network} [/net/connman/iwd/0/7/73706733_psk] Connected = True
2021-03-29 10:44:02 -05:00
Denis Kenzior 9a67a21bd2 station: Add a warning of rekey fails 2021-03-24 13:10:32 -05:00
James Prestwood 0b38aabde3 station: set handshake offload if required
If IWD is connecting to a SAE/WPA3 BSS and Auth/Assoc commands
are not supported the only option is SAE offload. At this point
network_connect should have verified that the extended feature
for SAE offload exists so we can simply enable offload if these
commands are not supported.
2021-03-22 14:16:31 -05:00
James Prestwood 2b5e566c9d station: use network_bss_update
This fixes a dangling pointer in network where station was
freeing the scan_bss but network still had a pointer to it
in its own bss_list.
2021-03-15 14:47:42 -05:00
James Prestwood 97de24e694 station: disable roaming logic for auto-roaming cards
If the hardware roams automatically we want to be sure to not
react to CQM events and attempt to roam/disconnect on our own.

Note: this is only important for very new kernels where CQM
events were recently added to brcmfmac.
2021-03-15 13:32:35 -05:00
James Prestwood 133347440e netdev: station: support full mac roaming
Roaming on a full mac card is quite different than soft mac
and needs to be specially handled. The process starts with
the CMD_ROAM event, which tells us the driver is already
roamed and associated with a new AP. After this it expects
the 4-way handshake to be initiated. This in itself is quite
simple, the complexity comes with how this is piped into IWD.

After CMD_ROAM fires its assumed that a scan result is
available in the kernel, which is obtained using a newly
added scan API scan_get_firmware_scan. The only special
bit of this is that it does not 'schedule' a scan but simply
calls GET_SCAN. This is treated special and will not be
queued behind any other pending scan requests. This lets us
reuse some parsing code paths in scan and initialize a
scan_bss object which ultimately gets handed to station so
it can update connected_bss/bss_list.

For consistency station must also transition to a roaming state.
Since this roam is all handled by netdev two new events were
added, NETDEV_EVENT_ROAMING and NETDEV_EVENT_ROAMED. Both allow
station to transition between roaming/connected states, and ROAMED
provides station with the new scan_bss to replace connected_bss.
2021-03-15 13:14:39 -05:00
James Prestwood c026337792 station: move scan cancelation to __station_connect_network
An earlier patch fixed a problem where a queued quick scan would
be triggered and fail once already connected, resulting in a state
transition from connected --> autoconnect_full. This fixed the
Connect() path but this could also happen via autoconnect. Starting
from a connected state, the sequence goes:

 - DBus scan is triggered
 - AP disconnects IWD
 - State transition from disconnected --> autoconnect_quick
 - Queue quick scan
 - DBus scan results come in and used to autoconnect
 - A connect work item is inserted ahead of all others, transition
   from autoconnect_quick --> connecting.
 - Connect completes, transition from connecting --> connected
 - Quick scan can finally get triggered, which the kernel fails to
   do since IWD is connected, transition from connected -->
   autoconnect_full.

This can be fixed by checking for a pending quick scan in the
autoconnect path.
2021-02-04 20:56:34 -06:00
Denis Kenzior 0c277e442e station: Remove unneeded logic from dbus_scan_done
Commit eac2410c83 ("station: Take scanned frequencies into account")
has made it unnecessary to explicitly invoke station_set_scan_results
with the expire to true in case a dbus scan finished prematurely or a
subset was not able to be started.  Remove this no-longer needed logic.

Fixes: eac2410c83 ("station: Take scanned frequencies into account")
2021-02-03 14:39:42 -06:00
James Prestwood c3e160880f station: only add diagnostic interface when connected
The diagnostic interface returns an error anyways if station is
not connected so it makes more sense to only bring the interface
up when its actually usable. This also removes the interface
when station disconnects, which was never done before (the
interface stayed up indefinitely due to a forgotten remove call).
2021-02-03 13:37:19 -06:00
Denis Kenzior 6ced1ec9de station: Use active scan in autoconnect mode
When we're auto-connecting and have hidden networks configured, use
active scans regardless of whether we see any hidden BSSes in our
existing scan results.

This allows us to more effectively see/connect to hidden networks
when first powering up or after suspend.
2021-02-03 13:36:36 -06:00
Denis Kenzior 73309686bd station: Use flush flag for all scans 2021-02-03 13:36:27 -06:00
Denis Kenzior ab5fd961c8 station: Also reset the SSID when hiding
Make the SSID all zeros when hiding a network.  This makes sure that the
BSS isn't inadvertently confused for a non-hidden one
2021-02-03 13:36:19 -06:00
Denis Kenzior 9af25d937d station: Make sure bss_match also matches the ssid
Kernel might report hidden BSSes that are reported from beacon frames
separately than ones reported due to probe responses.  This may confuse
the station network collation logic since the scan_bss generated by the
probe response might be removed erroneously when processing the scan_bss
that was generated due to a beacon.

Make sure that bss_match also takes the SSID into account and only
matches scan_bss structures that have the same BSSID and SSID contents.
2021-02-03 13:36:09 -06:00
Denis Kenzior 8fd6985214 station: move filtering of non-utf8 scan_bss entries
Instead of silently ignoring entries with non-utf8 SSIDs, drop them from
the new_bss_list entirely.
2021-02-03 13:35:58 -06:00
Denis Kenzior eac2410c83 station: Take scanned frequencies into account
Instead of manually managing whether to expire BSSes or not, use the
scanned frequency set instead.  This makes the API slightly easier to
understand (dropping two boolean arguments in a row) and also a bit more
future-proof.
2021-02-03 13:35:03 -06:00
Denis Kenzior ccbd32503b scan: Pass the frequencies scanned to notify cb 2021-02-03 13:34:44 -06:00
James Prestwood 1c80672983 station: add Frequency to diagnostics dictionary 2021-02-03 12:54:59 -06:00
Denis Kenzior c3f76cb5a5 station: Return NotHidden error
Commit d372d59bea checks whether a hidden network had a previous
connection attempt and re-tries.  However, it inadvertently dropped
handling of a condition where a non-hidden network SSID is provided to
ConnectHiddenNetwork.  Fix that.

Fixes: d372d59bea ("station: Allow ConnectHiddenNetwork to be retried")
2021-02-03 09:12:08 -06:00
Denis Kenzior c319bca477 station: correctly set mac randomization hint
Now that ConnectHiddenNetwork can be invoked while we're connected, set
the mac randomization hint parameter properly.  The kernel will reject
requests if randomization is enabled while we're connected to a network.
2021-02-02 09:54:34 -06:00
Denis Kenzior 06ca8e20a9 station: Hide forgotten hidden networks
If we forget a hidden network, then make sure to remove it from the
network list completely.  Otherwise it would be possible to still
issue a Network.Connect to that particular object, but the fact that the
network is hidden would be lost.
2021-02-02 09:36:37 -06:00
Denis Kenzior add3d43dad station: expire networks found by hidden scan sooner 2021-02-01 15:30:15 -06:00
Denis Kenzior 08a295c348 station: Fix leaking of roam_freqs on shutdown
==17639== 72 (16 direct, 56 indirect) bytes in 1 blocks are definitely
lost in loss record 3 of 3
==17639==    at 0x4C2F0CF: malloc (vg_replace_malloc.c:299)
==17639==    by 0x4670AD: l_malloc (util.c:61)
==17639==    by 0x4215AA: scan_freq_set_new (scan.c:1906)
==17639==    by 0x412A9C: parse_neighbor_report (station.c:1910)
==17639==    by 0x407335: netdev_neighbor_report_frame_event
(netdev.c:3522)
==17639==    by 0x44BBE6: frame_watch_unicast_notify (frame-xchg.c:233)
==17639==    by 0x470C04: dispatch_unicast_watches (genl.c:961)
==17639==    by 0x470C04: process_unicast (genl.c:980)
==17639==    by 0x470C04: received_data (genl.c:1101)
==17639==    by 0x46D9DB: io_callback (io.c:118)
==17639==    by 0x46CC0C: l_main_iterate (main.c:477)
==17639==    by 0x46CCDB: l_main_run (main.c:524)
==17639==    by 0x46CF01: l_main_run_with_signal (main.c:656)
==17639==    by 0x403EDE: main (main.c:490)
2021-02-01 15:12:17 -06:00
Denis Kenzior d372d59bea station: Allow ConnectHiddenNetwork to be retried
In the case that ConnectHiddenNetwork scans successfully, but fails for
some other reason, the network object is left in the scan results until
it expires.  This will prevent subsequent attempts to use
ConnectHiddenNetwork with a .NotHidden error.  Fix that by checking
whether a found network is hidden, and if so, allow the request to
proceed.
2021-02-01 14:19:37 -06:00
Denis Kenzior e04ae506a3 network: rework network_connect_new_hidden_network
Rework the logic slightly so that this function returns an error message
on error and NULL on success, just like other D-Bus method
implementations.  This also simplifies the code slightly.
2021-02-01 13:37:07 -06:00
Denis Kenzior 56538bf75b station: Allow ConnectHiddenNetwork while connected
We used to not allow to connect to a different network while already
connected.  One had to disconnect first.  This also applied to
ConnectHiddenNetwork calls.

This restriction can be dropped now.  station will intelligently
disconnect from the current AP when a station_connect_network() is
issued.
2021-02-01 13:37:07 -06:00
Denis Kenzior fc10ee8745 station: Fix not cleaning up pending_connect
If the disconnect fails and station_disconnect_onconnect_cb is called
with an error, we reply to the original message accordingly.
Unfortunately pending_connect is not unrefed or cleared in this case.
Fix that.

Fixes: d0ee923dda ("station: Disconnect, if needed, on a new connection attempt")
2021-02-01 13:37:07 -06:00
James Prestwood 7b2ce98abd station: fix leak on parse_neighbor_report 2021-01-29 17:22:20 -06:00
James Prestwood a9c32d85ea station: cancel quick scans on Connect()
At some point the non-interactive client tests began failing.
This was due to a bug in station where it would transition from
'connected' to 'autoconnect' due to a failed scan request. This
happened because a quick scan got scheduled during an ongoing
scan, then a Connect() gets issued. The work queue treats the
Connect as a priority so it delays the quick scan until after the
connection succeeds. This results in a failed quick scan which
IWD does not expect to happen when in a 'connected' state. This
failed scan actually triggers a state transition which then
gets IWD into a strange state where its connected from the
kernel point of view but does not think it is:

src/station.c:station_connect_cb() 13, result: 0
src/station.c:station_enter_state() Old State: connecting, new state: connected
src/wiphy.c:wiphy_radio_work_done() Work item 6 done
src/wiphy.c:wiphy_radio_work_next() Starting work item 5
src/station.c:station_quick_scan_triggered() Quick scan trigger failed: -95
src/station.c:station_enter_state() Old State: connected, new state: autoconnect_full

To fix this IWD should simply cancel any pending quick scans
if/when a Connect() call comes in.
2021-01-26 14:45:00 -06:00
James Prestwood 158dc40340 station: refactor to use diagnostic_info_to_dict 2021-01-22 14:59:47 -06:00
James Prestwood 5a6b474a14 netdev: move netdev_station_info to diagnostic.h
With AP now getting its own diagnostic interface it made sense
to move the netdev_station_info struct definition into its own
header which eventually can be accompanied by utilities in
diagnostic.c. These utilities can then be shared with AP and
station as needed.
2021-01-22 14:40:45 -06:00
Alvin Šipraga 4266b88658 station: add RoamRetryInterval setting 2021-01-22 13:46:25 -06:00
Alvin Šipraga f456501b9e station: retry roaming unless notified of a high RSSI
Following a successful roaming sequence, schedule another attempt unless
the driver has sent a high RSSI notification. This makes the behaviour
analogous to a failed roaming attempt where we remained connected to the
same BSS.

This makes iwd compatible with wireless drivers which do not necessarily
send out a duplicate low RSSI notification upon reassociation. Without
this change, iwd risks getting indefinitely stuck to a BSS with low
signal strength, even though a better BSS might later become available.

In the case of a high RSSI notification, the minimum roam time will also
be reset to zero. This preserves the original behaviour in the case
where a high RSSI notification is processed after station_roamed().
Doing so also gives a chance for faster roaming action in the following
example scenario:

    1. RSSI LOW
    2. schedule roam in 5 seconds
        (5 seconds pass)
    3. try roaming
    4. roaming fails, same BSS
    5. schedule roam in 60 seconds
        (20 seconds pass)
    6. RSSI HIGH
    7. cancel scheduled roam
        (20 seconds pass)
    8. RSSI LOW
    9. schedule roam in 5 seconds or 20 seconds?

By resetting the minimum roam time, we can avoid waiting 20 seconds when
the station may have moved considerably. And since the high/low RSSI
notifications are configured with a hysteresis, we should still be
protected against too frequent spurious roaming attempts.
2021-01-22 13:41:07 -06:00
Alvin Šipraga 9edd941bc2 station: remove unused roam_no_orig_ap state variable
Since commit 836beb1276 removed beacon
loss handling, the roam_no_orig_ap variable has no use and is always set
to false. This commit removes it.
2021-01-20 11:14:06 -06:00
James Prestwood a17e5e0f7f station: create StationDiagnostic interface
This interface sits aside the regular station interface but
provides low level connection details for diagnostic and
testing purposes.
2021-01-14 15:02:13 -06:00
Andrew Zaborowski f5a30a1cfc station: Don't expire BSSes between freq subset scans
Add a parameter to station_set_scan_results to allow skipping the
removal of old BSSes.  In the DBus-triggered scan only expire BSSes
after having gone through the full supported frequency set.

It should be safe to pass partial scan results to
station_set_scan_results() when not expiring BSSes so using this new
parameter I guess we could also call it for roam scan results.
2020-12-17 20:22:47 -06:00
Andrew Zaborowski e3bece76f9 station: Split DBus scans into 3 frequency subsets
A scan normally takes about 2 seconds on my dual-band wifi adapter when
connected.  The drivers will normally probe on each supported channel in
some unspecified order and will have new partial results after each step
but the kernel sends NL80211_CMD_NEW_SCAN_RESULTS only when the full
scan request finishes, and for segmented scans we will wait for all
segments to finish before calling back from scan_active() or
scan_passive().

To improve user experience define our own channel order favouring the
2.4 channels 1, 6 and 11 and probe those as an individual scan request
so we can update most our DBus org.connman.iwd.Network objects more
quickly, before continuing with 5GHz band channels, updating DBus
objects again and finally the other 2.4GHz band channels.

The overall DBus-triggered scan on my wifi adapter takes about the same
time but my measurements were not very strict, and were not very
consistent with and without this change.  With the change most Network
objects are updated after about 200ms though, meaning that I get most
of the network updates in the nm-applet UI 200ms from opening the
network list.  The 5GHz band channels take another 1 to 1.5s to scan and
remaining 2.4GHz band channels another ~300ms.

Hopefully this is similar when using other drivers although I can easily
imagine a driver that parallelizes 2.4GHz and 5GHz channel probing using
two radios, or uses 2, 4 or another number of dual-band radios to probe
2, 4, ... channels simultanously.  We'd then lose some of the
performance benefit.  The faster scan results may be worth the longer
overall scan time anyway.
I'm also assuming that the wiphy's supported frequency list is exactly
what was scanned when we passed no frequency list to
NL80211_CMD_TRIGGER_SCAN and we won't get errors for passing some
frequency that shouldn't have been scanned.
2020-12-17 20:15:37 -06:00
James Prestwood 845658bd32 station: get neighbor reports early
Waiting to request neighbor reports until we are in need of a roam
delays the roam time, and probably isn't as reliable since we are
most likely in a low RSSI state. Instead the neighbor report can
be requested immediately after connecting, saved, and used if/when
a roam is needed. The existing behavior is maintained if the early
neighbor report fails where a neighbor report is requested at the
time of the roam.

The code which parses the reports was factored out and shared
between the existing (late) neighbor report callback and the early
neighbor report callback.
2020-11-16 18:14:07 -06:00
James Prestwood 836beb1276 station/wsc: remove beacon loss handling
Modern kernels ~5.4+ have changed the way lost beacons are
reported and effectively make the lost beacon event useless
because it is immediately followed by a disconnect event. This
does not allow IWD enough time to do much of anything before
the disconnect comes in and we are forced to fully re-connect
to a different AP.
2020-11-04 13:40:25 -06:00
Andrew Zaborowski 1f89ebb86a station: Fix .Scanning being reset early
periodic_scan_stop is called whenever we exit the autoscan state but a
periodic scan may not be running at the time.  If we have a
user-triggered scan running, or the autoconnect_quick scan, and we reset
Scanning to false before that scan finished, a client could en up
calling GetOrderedNetwork too early and not receiving the scan results.
2020-10-14 13:01:18 -05:00
Andrew Zaborowski 758dba214e station: Make Disconnect() cancel ConnectHiddenNetwork()
ConnectHiddenNetwork can be seen a triggering this sequence:
1. the active scan,
2. the optional agent request,
3. the Authentication/Association/4-Way Handshake/netconfig,
4. connected state

Currently Disconnect() interrupts 3 and 4, allow it to also interrupt
state 1.  It's difficult to tell whether we're in state 2 from within
station.c.
2020-10-08 08:54:01 -05:00
James Prestwood ffe9ce8034 station: print which BSS is being connected to
For multi-bss networks its nice to know which BSS is being connected
to. The ranking can hint at it, but blacklisting or network capabilities
could effect which network is actually chosen. An explicit debug print
makes debugging much easier.
2020-09-14 16:03:04 -05:00
Denis Kenzior ac5ddda56f treewide: Add missing netdev module dependencies 2020-08-20 11:49:01 -05:00
Andrew Zaborowski 49f38b0d2e station: Don't call network_rank_update with NULL network
Move the update of station->networks_sorted order to before we set
station->connected_network NULL to avoid a crash when we attempt to
use the NULL pointer.
2020-08-17 09:25:33 -05:00
Alvin Šipraga bfd8cead95 treewide: guard compare functions against signed integer overflow
Besides being undefined behaviour, signed integer overflow can cause
unexpected comparison results. In the case of network_rank_compare(),
a connected network with rank INT_MAX would cause newly inserted
networks with negative rank to be inserted earlier in the ordered
network list. This is reflected in the GetOrderedMethods() DBus method
as can be seen in the following iwctl output:

  [iwd]# station wlan0 get-networks
    Network name                    Security  Signal
  ----------------------------------------------------
    BEOLAN                          8021x     **** }
    BeoBlue                         psk       ***  } all unknown,
    UI_Test_Network                 psk       ***  } hence assigned
    deneb_2G                        psk       ***  } negative rank
    BEOGUEST                        open      **** }
  > titan                           psk       ****
    Linksys05274_5GHz_dmt           psk       ****
    Lyngby-4G-4 5GHz                psk       ****
2020-08-14 10:55:30 -05:00
Alvin Šipraga 94d4b341e3 station: refresh ordered network list on (dis)connect
Doing so ensures that the currently connected network is always at the
beginning of the list. Previously, the list would only get updated after
a scan.

This fixes the documented behaviour of GetOrderedNetworks() DBus method,
which states that the currently connected network is always at the
beginning of the returned array.
2020-08-14 10:55:22 -05:00
Andrew Zaborowski 914a03c4bf station: Comment/whitespace fix 2020-07-31 10:38:59 -05:00
James Prestwood 4165d9414f netdev: use wiphy radio work queue for connections
This adds connection/FT attempts to the radio work queue. This
will ensure that connections aren't delayed or done concurrently
with scanning.
2020-07-15 17:10:36 -05:00
James Prestwood 5f7b28d501 scan: refactor to use wiphy radio work queue
To use the wiphy radio work queue, scanning mostly remained the same.
start_next_scan_request was modified to be used as the work callback,
as well as not start the next scan if the current one was done
(since this is taken care of by wiphy work queue now). All
calls to start_next_scan_request were removed, and more or less
replaced with wiphy_radio_work_done.

scan_{suspend,resume} were both removed since radio management
priorities solve this for us. ANQP requests can be inserted ahead of
scan requests, which accomplishes the same thing.
2020-07-10 13:23:58 -05:00
James Prestwood a3d0eebe74 station: cancel hidden network scan when connecting
Before connecting to a hidden network we must scan. During this scan
if another connection attempt comes in the expected behavior is to
abort the original connection. Rather than waiting for the scan to
complete, then canceling the original hidden connection we can just
cancel the hidden scan immediately, reply to dbus, and continue with
the new connection attempt.
2020-07-09 10:00:55 -05:00
James Prestwood 7e0084e6ae anqp: refactor to use frame-xchg
The new frame-xchg module now handles a lot of what ANQP used to do. ANQP
now does not need to depend on nl80211/netdev for building and sending
frames. It also no longer needs any of the request lookups, frame watches
or to maintain a queue of requests because frame-xchg filters this for us.

From an API perspective:
 - anqp_request() was changed to take the wdev_id rather than ifindex.
 - anqp_cancel() was added so that station can properly clean up ANQP
   requests if the device disappears.

During testing a bug was also fixed in station on the timeout path
where the request queue would get popped twice.
2020-07-09 09:58:21 -05:00
Denis Kenzior a1b41f786e station: Re-attempt roam with a full scan
When roaming, iwd tries to scan a limited number of frequencies to keep
the roaming latency down.  Ideally the frequency list would come in from
a neighbor report, but if neighbor reports are not supported, we fall
back to our internal database for known frequencies of this network.

iwd tries to keep the number of scans down to a bare minimum, which
means that we might miss APs that are in range.  This could happen
because the user might have moved physically and our frequency list is
no longer up to date, or if the AP frequencies have been reconfigured.

If a limited scan fails to find any good roaming candidates, re-attempt
a full scan right away.
2020-06-30 12:34:41 -05:00
Denis Kenzior b026e6740b station: Return errno from station_roam_scan 2020-06-30 12:29:22 -05:00
Denis Kenzior 10e83aa347 station: Return errno from station_roam_scan_known_freqs 2020-06-30 12:05:51 -05:00
Denis Kenzior 05b803cb76 station: reflow station_roam_failed
If the roam failed and we are no longer connected, station_disassociated
is called which ends up calling station_roam_state_clear.  Thus
resetting the variables is not needed.  Reflow the logic to make this a
bit more explicit.
2020-06-30 10:58:05 -05:00
Denis Kenzior faa31802c5 station: Don't reset roam_no_orig_ap on roam failure
If the roam attempt fails, do not reset this to false.  Generally this
is set by the fact that we lost beacon and to not attempt neighbor
reports, etc.  This hint should be preserved across roam attempts.
2020-06-30 10:23:40 -05:00
Denis Kenzior 254cefcc96 station: Give network a connection failed hint
Right now, if the connection fails, then network always thinks that the
password should be re-asked.  Loosen this to only do so if the
connection failed at least in the handshake phase.  If the connection
failed due to Association / Authentication timeout, it is likely that
something is wrong with the AP and it can't respond.
2020-06-12 15:21:39 -05:00
James Prestwood 60e2c4647c station: add ANQP state watch API
This is to allow network to watch for ANQP activity in order to
fix the race condition between scanning finishing and ANQP finishing.
Without this it is possible for a DBus Connect() to come in before
ANQP has completed and causing the network to return NotConfigured,
when its actually in the process of obtaining all the network info.

The watch was made globally in station due to network not having
a station object until each individual network is created. Adding a
watch during network creation would result in many watchers as well
as a lot of removal/addition as networks are found and lost.
2020-06-12 14:58:56 -05:00
Tim Kourt ecd39dcf0d network: Don't crash when network_connect_new_hidden_network fails
Change signature of network_connect_new_hidden_network to take
reference to the caller's l_dbus_message struct. This allows to
set the caller's l_dbus_message struct to NULL after replying in
the case of a failure.

==201==    at 0x467C15: l_dbus_message_unref (dbus-message.c:412)
==201==    by 0x412A51: station_hidden_network_scan_results (station.c:2504)
==201==    by 0x41EAEA: scan_finished (scan.c:1505)
==201==    by 0x41EC10: get_scan_done (scan.c:1535)
==201==    by 0x462592: destroy_request (genl.c:673)
==201==    by 0x462987: process_unicast (genl.c:988)
==201==    by 0x462987: received_data (genl.c:1087)
==201==    by 0x45F5A2: io_callback (io.c:126)
==201==    by 0x45E8FD: l_main_iterate (main.c:474)
==201==    by 0x45E9BB: l_main_run (main.c:521)
==201==    by 0x45EBCA: l_main_run_with_signal (main.c:643)
==201==    by 0x403B15: main (main.c:512)
2020-06-09 21:59:36 -05:00
Tim Kourt 61ee99f632 station: Use separate msg holder for hidden connections
Introduce hidden_pending to keep reference to the dbus message object
while we wait for the scan results to be returned while trying to
connect to a hidden network. This simplifies the logic by separating it
into two independent logical units: scanning, connecting and eliminates
a possibility of a memory leak in the case when Network.Connect being
initiated while Station.ConnectHiddenNetwork is in progress.
2020-06-09 21:58:52 -05:00
Denis Kenzior 532f6b154e station: Do not enter autoconnect_full erroneously
If a connection is initiated (via dbus) while a quick scan is in
progress, the quick scan will be aborted.  In this case,
station_quick_scan_results will always transition to the
AUTOCONNECT_FULL state regardless of whether it should or not.

Fix this by making sure that we only enter AUTOCONNECT_FULL if we're
still in the AUTOCONNECT_QUICK state.

Reported-by: Alvin Šipraga <alsi@bang-olufsen.dk>
2020-06-09 10:03:33 -05:00
Andrew Zaborowski c8edd36234 netconfig: Move EnableNetworkConfiguration check to station
Allow p2p to use netconfig even if not enabled for Infrastructure mode
connections.
2020-05-01 11:30:42 -05:00
Tim Kourt 001b9035e0 station: Fix init return type 2020-04-17 12:22:48 -05:00
Rosen Penev a47609acbe iwd: remove unnecessary semicolons
Found with clang's -Wextra-semi-stmt
2020-04-08 21:02:15 -05:00
James Prestwood e7777c3422 station: support full MAC randomization and override
This patch adds two new options to a network provisioning file:

AlwaysRandomizeAddress={true,false}

If true, IWD will randomize the MAC address on each connection to this
network. The address does not persists between connections, any new
connection will result in a different MAC.

AddressOverride=<MAC>

If set, the MAC address will be set to <MAC> assuming its a valid MAC
address.

These two options should not be used together, and will only take effect
if [General].AddressRandomization is set to 'network' in the IWD
config file.

If neither of these options are set, and [General].AddressRandomization
is set to 'network', the default behavior remains the same; the MAC
will be generated deterministically on a per-network basis.
2020-03-18 18:15:16 -05:00
Andrew Zaborowski 9ff1c4da3a cleanup: Remove extra empty lines 2020-03-17 15:35:22 -05:00
Torstein Husebø 759dbdd37f treewide: fix typos 2020-01-21 16:03:28 -06:00
Andrew Zaborowski 3ffb645f22 device: Make functions static, drop device.h 2019-11-20 20:26:55 -06:00
James Prestwood 90fb7eff7d station: fail if trying to scan while connecting
If a scan is requested during the middle of a connection we should
return busy instead of attempting the scan. The kernel ends up coming
back with not supported in this case, which is misleading and
difficult to debug.
2019-11-14 15:23:03 -06:00
Marcel Holtmann ab5742bb32 module: Move declarations into separate header file 2019-11-07 23:40:13 +01:00
James Prestwood 2962a80e14 station: add APIs to get connected BSS and BSS list
For Radio Resource Management (RRM) we will need access to the currently
connected BSS as well as the last scan results in order to do certain
kinds of requested measurements.
2019-11-04 14:43:38 -06:00
Andrew Zaborowski dcf419ee7f eapol: Move the EAP events to handshake event handler
On EAP events, call the handshake_event handler with the new event type
HANDSHAKE_EVENT_EAP_NOTIFY isntead of the eapol_event callback.

This allows the handler to be set before calling
netdev_connect/netdev_connect_wsc.  It's also in theory more type-safe
because we don't need the cast in netdev_connect_wsc anymore.
2019-10-30 14:26:09 -05:00
Andrew Zaborowski 0cccbea904 handshake: Convert handshake event callbacks variadic functions
Convert the handshake event callback type to use variable argument
list to allow for more flexibility in event-specific arguments
passed to the callbacks.

Note the uint16_t reason code is promoted to an int when using variable
arguments so va_arg(args, int) has to be used.
2019-10-30 14:24:05 -05:00
Denis Kenzior d12ee292aa treewide: Use CamelCase for disable_anqp setting 2019-10-24 23:18:23 -05:00
Denis Kenzior 1fbf64b667 station: use CamelCase for MFP setting 2019-10-24 21:36:50 -05:00
Denis Kenzior e540978633 treewide: Use CamelCase for [Scan] settings 2019-10-24 15:58:08 -05:00
Tim Kourt 2d02816efd station: Subscribe to netconfig event notifier 2019-10-09 17:52:36 -05:00
Tim Kourt 624933fab0 station: Move 'connected' logic out of enter state func
Previously, station state 'connected' used to identify an interface associated
with AP. With the introduction of netconfig, an interface is assumed to be
connected after the IP addresses have been assigned to it. If netconfig is
disabled, the behavior remains unchanged.
2019-10-09 17:05:42 -05:00
Tim Kourt 48be2c0252 station: Simplify and comply with coding style 2019-10-09 14:18:02 -05:00
Will Dietz 44ae6a46da station: don't reset/(re)configure/destroy NULL netconfig's
Fixes crashes when `enable_network_config` is false (default).
2019-10-03 12:34:56 -05:00
Will Dietz 6672bc2a37 station: record dependency on netconfig module
The netconfig module must be initialized (netconfig_list, for example)
before station module can be used, record this to ensure that happens.
2019-10-03 12:30:43 -05:00
Tim Kourt d7c52b8280 station: netconfig devices based on station state 2019-09-30 14:57:21 -05:00
Tim Kourt d954eee0cc netconfig: Change public API
As a first step to enable the usage of netconfig in ead and
prospective transition to be a part of ell, the public API for
creation and destruction of the netconfig objects has been
renamed and changed. Instead of hiding the netconfig objects inside
of netconfig module, the object is now passed back to the caller.
The internal queue of netconfig objects remains untouched, due
to limitations in ell’s implementation of rtnl. After the proper
changes are done to ell, netconfig_list is expected to be removed
from netconfig module.
2019-09-27 16:32:05 -05:00
James Prestwood a8187468b5 station: optimize roam scanning
If neighbor reports are unavailable, or the report yielded no
results we can quickly scan for only known frequencies. This
changes the original behavior where we would do a full scan
in this case.
2019-09-17 11:52:55 -05:00
James Prestwood d2162a7491 station: fix NAI realms leak
After the known network refactor this string list was no longer set
into the network object. Now it should be freed in all cases after
the search.
2019-09-11 11:55:25 -05:00
James Prestwood 45c059ccf8 station: use network_get_vendor_ies
Station was building up the HS20 elements manually. Now we can
use this new API and let network take care of the complexity
of building network specific vendor IEs.
2019-09-09 15:36:53 -05:00
James Prestwood a3a48da542 station: allow autoconnect to hotspot networks
Since hotspot networks may require ANQP the autoconnect loop needed to
be delayed until after the ANQP results came back and the network
objects were updated. If there are hotspot networks in range ANQP will
be performed and once complete autoconnect will begin for all networks
including hotspots. If no hotspots are in range autoconnect will
proceed as it always has.

Note: Assuming hotspots are in range this will introduce some delay
in autoconnecting to any network since ANQP must come back. The full
plan is to intellegently decide when and when not to do ANQP in order
to minimize delays but since ANQP is disabled by default the behavior
introduced with this patch is acceptable.
2019-08-28 11:27:09 -05:00
James Prestwood 8242b7e9f3 station: add network_info after ANQP
Once ANQP is complete we can try matching the NAI realm with any
known networks.
2019-08-19 13:58:18 -05:00
James Prestwood c4771c4c5d station: introduce station_network_foreach
Iterates all networks for a given station object.
2019-08-19 12:40:18 -05:00
Denis Kenzior 30315cba0d station: Add some additional roaming debugs 2019-08-04 04:49:24 -05:00
James Prestwood 37369f1d5e iwd: station: deprecate ManagementFrameProtection
management_frame_protection should now be used instead.
2019-07-30 14:41:49 -05:00
James Prestwood 1fdea9b2d3 scan: station: parse HS20 version in scan results
For (Re)Association the HS20 indication element was passed exactly as
it was found in the scan results. The spec defines what bits can be
set and what cannot when this IE is used in (Re)Association. Instead
of assuming the AP's IE conforms to the spec, we now parse the IE and
re-build it for use with (Re)Association.

Since the full IE is no longer used, it was removed from scan_bss, and
replaced with a bit for HS20 support (hs20_capable). This member is
now used the same as hs20_ie was.

The version parsed during scan results is now used when building the
(Re)Association IE.
2019-07-24 00:22:46 -05:00
Tim Kourt d0ee923dda station: Disconnect, if needed, on a new connection attempt
Previously, iwd used to throw net.connman.iwd.Busy when connection
attempt was made while connected. The new behavior allows iwd to
seamlessly disconnect from the connected network and attempt a new
connection.
2019-07-23 17:19:12 -05:00
Denis Kenzior fe3858f738 station: Fix typo 2019-07-17 09:00:39 -05:00
James Prestwood 3c27528523 scan: station: add HS20 indication element to (Re)Association
The HS20 indication element should always be included during
(Re)Association per the spec. This removes the need for a
dedicated boolean, and now the hs20_ie can be used instead.
2019-07-16 21:14:41 -05:00
Denis Kenzior 4948bfac20 station: Add support for ProtocolVersion
ProtocolVersion in the EAPoL group can be used to force a particular
EAPoL version if the RADIUS server on a given network requires it
2019-07-16 12:00:45 -05:00
James Prestwood 2c19085ccd anqp: move ANQP parsers into anqputil
This allows monitor to use the ANQP parser utils without depending
on netdev.
2019-07-15 14:53:44 -05:00
James Prestwood 993d9cbf6b station: check hs20_capable first before ANQP
If a BSS is not a hotspot 2.0 BSS then there is no reason to bother
checking configuration files.
2019-07-12 18:51:36 -05:00
James Prestwood b406a57ca4 station: anqp: add more debug logging 2019-07-12 16:41:56 -05:00
James Prestwood 7286a12240 station: build roaming consortium IE for netdev_connect
Per the hotspot 2.0 spec, if a matching roaming consortium OI is
found it should be added to the (Re)Association request. vendor_ies
can now be provided to netdev_connect, which get appended to the IE
attribute.
2019-07-12 16:13:50 -05:00
James Prestwood f57ba70235 netdev: Allow to send extra vendor IEs when connecting 2019-07-12 16:13:01 -05:00
Andrew Zaborowski b3a395091d scan: Switch all uses of ifindex to wdev_id
The ifindex is used to index the netdevs in the system (wlan, ethernet,
etc.) but we can also do wifi scanning on interfaces that have no
corresponding netdev object, like the P2P-device virtual interfaces.
Use the wdev id's to reference interfaces, the nl80211 api doesn't care
whether we use a NL80211_ATTR_IFINDEX or NL80211_ATTR_WDEV.  Only
wireless interfaces have a wdev id.
2019-07-08 11:53:00 -05:00
James Prestwood 23a7a5a614 station: allow connections to Hotspot networks
After a scan, station can now pause future scans and start ANQP requests
to discover Hotspot's NAI realm. This lets us check if the AP's NAI realm
matches any stored hotspot configuration files. If so we can connect to
this network. If the network provides an HESSID and a matching one is
found in a hotspot provisioning file we can skip ANQP and directly connect
as this is expected to be our 'home network'
2019-06-26 23:16:23 -05:00