Commit Graph

2255 Commits

Author SHA1 Message Date
James Prestwood 85131f4827 hotspot: make hotspot dir not hidden 2019-07-15 11:13:55 -05:00
James Prestwood 8bcb8e870e ie: fix incorrect length check for hotspot indication
The length check was incorrectly assuming that PPS MO ID or
ANQP Domain ID would be present in the IE. Both these are optional
and without then the minimum length is 5 bytes, not 7.
2019-07-12 18:51:57 -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
James Prestwood 79a9fdf123 hotspot: add API to get a matching roaming consortium
This API will attempt to find a matching roaming consortium OI
if present in the config file. A single matching OI is returned
or NULL if one was not found.
2019-07-12 14:13:25 -05:00
James Prestwood 27d670f432 hotspot: allow roaming consortium OI matching
Hotspot 2.0 network providers allow 'roaming' between a users home
network and other providers networks, assuming they are part of the
same roaming consortium. The roaming consortium is advertised as an
IE in beacon/probe frames.

In terms of the hotspot config files this is similar to HESSID, where
if the AP advertises the roaming consortium IE, and the config file
matches we do not need to do ANQP in order to connect.
2019-07-12 14:10:57 -05:00
James Prestwood aeae6abcbb network: add roaming consortium IE to network object
This is duplicated when the first scan_bss is added to a network
object that contains the IE. Any future BSS's added will not re-add
the IE. Its assumed that all BSS's under a network will contain the
same roaming consortium OIs.
2019-07-12 14:05:36 -05:00
James Prestwood 9dcb6946c5 scan: parse roaming consortium IE 2019-07-12 14:03:36 -05:00
James Prestwood ac933ad966 ie: add parsing/building for roaming consortium
Parses up to 3 (the max) roaming consortium OIs out of the roaming
consortium IE. If more OIs are available via ANQP the 'num_anqp_out'
value will be set to indicate how many more OIs are available.

Builds according to the hotspot 2.0 spec using the vendor specific
IE.
2019-07-12 14:02:18 -05:00
Eduardo Abinader 094a9ecdfa main: print version arg 2019-07-12 09:36:34 -05:00
Denis Kenzior de131b54b8 netdev: Use RRM & send RM Enabled Capabilities IE
If supported by the wiphy and if the target AP supports Radio Management
capability, then send the relevant IE and set the USE_RRM flag on
nl80211
2019-07-10 17:01:31 -05:00
Denis Kenzior fcb2d123bc netdev: Send extended capabilities IE on connect 2019-07-10 17:01:31 -05:00
Denis Kenzior 37610cf868 wiphy: Parse driver extended capabilities 2019-07-10 17:01:31 -05:00
Denis Kenzior eb86da3b4b wiphy: Add wiphy_rrm_capable 2019-07-10 16:46:29 -05:00
Denis Kenzior 7b48da5df2 ie: Update Capability field defines 2019-07-10 16:46:05 -05:00
Andrew Zaborowski 14a1e322b4 p2putil: Builders for P2P action frames 2019-07-08 22:08:36 -05:00
Andrew Zaborowski cd3c0ad155 p2putil: Builders for management frames P2P payloads 2019-07-08 22:08:15 -05:00
Andrew Zaborowski 67f91605eb p2putil: Parsers for P2P action frames
Add parsers for P2P-related Action frames and Public Action frames.
2019-07-08 22:04:12 -05:00
Andrew Zaborowski 81d17b3d43 p2putil: Parsers for management frames P2P payloads 2019-07-08 22:03:53 -05:00
Andrew Zaborowski 1f637cb054 p2putil: Add P2P frame type structures and utilities
Declare structures to hold the parsed contents of the P2P IEs and WSC
IEs in P2P-related frames and add functions to free memory used by
those structures.
2019-07-08 22:03:20 -05:00
Andrew Zaborowski 42c7ab0bae p2putil: Add P2P attribute parsers
Define structs and types for most P2P attributes and p2p_parse_attrs
similar to wsc_parse_attrs -- a generic parser for attributes in a P2P
IE payload.  This parser may write into the provided buffer even on
error but it's private to p2putil.c.  The local callers will take care
of keeping the user-provided buffers untouched on error.
2019-07-08 21:39:59 -05:00
Andrew Zaborowski 614fc0261f p2putil: Add P2P-related declarations and iterator
Add enums defining the values from the spec that we're going to be using
and add an iterator for P2P payload attributes similar to wsc_attr_iter.
2019-07-08 13:58:35 -05:00
Andrew Zaborowski 79dd14cb24 wscutil: Add wsc_build_p2p_attrs
Add a utility for building the simplified WSC IEs used in P2P action
frames and public action frames.  Only three types of WSC attributes are
mandatory in those frames (but different subsets are needed by different
frame types) so add a single utility for building those IEs.  We may
need to add some more optional attributes to those IEs later.
2019-07-08 13:46:53 -05:00
Andrew Zaborowski cc913a6ff6 wscutil: Make wsc_parse_attrs public for P2P 2019-07-08 13:45:54 -05:00
Andrew Zaborowski f8a51fe4c1 wscutil: Make the primary device type parser public
The P2P IE parsers can take advantage of this function
2019-07-08 13:43:24 -05:00
Andrew Zaborowski 5a40c49c44 mpdu: Validate action frame minimum length
Action frames must at least have the Category byte
2019-07-08 13:42:22 -05:00
Andrew Zaborowski 3bd265e02f ie: Add ie_tlv_encapsulate_p2p_payload 2019-07-08 13:41:18 -05:00
Andrew Zaborowski 5cb07ff116 ie: Add ie_tlv_extract_p2p_payload 2019-07-08 13:37:47 -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
Andrew Zaborowski ec60b51d01 scan: Fix sc->get_scan_cmd_id logic
Save the actual cmd_id returned from l_genl_family_dump and zero it in
the get_scan_done.  There's no need to zero it in scan_cancel because
get_scan_done gets called automatically.
2019-07-08 11:30:51 -05:00
Andrew Zaborowski 5223dee050 scan: Reference scan_context directly from scan_results
Store the scan_context pointer in scan_results directly instead of
storing the ifindex.  We now cancel ongoing GET_SCAN commands when the
scan_context is being freed so there's no point going through the extra
step of looking up the scan_context by ifindex inside the command
callback to guard against non-existent scan_contexts.
2019-07-08 11:23:21 -05:00
Andrew Zaborowski 8cada9d1fc netdev: Add netdev_get_wdev_id 2019-07-08 11:19:32 -05:00
Tim Kourt bc45f98f36 resolve: systemd reset DNS names for interface 2019-07-03 17:10:24 -05:00
James Prestwood 5ca3c4495e resolve: fix crash in resolve_exit
method.ops is NULL, which causes method.ops->exit to crash. This
adds a check that method.ops is not NULL before dereferencing.

Fixes:

Aborting (signal 11) [/home/jprestwo/iwd/src/iwd]
++++++++ backtrace ++++++++
0  0x7f016b59cf20 in /lib/x86_64-linux-gnu/libc.so.6
1  0x432057 in resolve_exit() at /home/jprestwo/iwd/src/resolve.c:295
2  0x403b61 in iwd_modules_exit() at /home/jprestwo/iwd/src/main.c:195
3  0x7f016b57fb97 in /lib/x86_64-linux-gnu/libc.so.6
+++++++++++++++++++++++++++
2019-07-03 13:02:28 -05:00
James Prestwood e8d91f15a1 hotspot: allow HESSID without NAIRealmNames
The original idea was to allow the provisioning file to include HESSID
without the NAIRealmNames. Configuring this way would allow for ANQP
to be skipped completely, assuming the AP advertises its HESSID.

The way the code was written still required NAIRealmNames to be
provided in the provisioning file.
2019-07-03 13:02:28 -05:00
Tim Kourt 25ec69b358 resolve: systemd set DNS names 2019-07-02 19:12:49 -05:00
Tim Kourt c1a1828872 resolve: Add systemd plugin skeleton
Systemd plugin is using systemd-resolved Dbus service to
manage the address resolution entries.
2019-07-02 19:11:52 -05:00
Tim Kourt 01fe343825 resolve: Add framework for resolution services
The framework enables the service specific implementations
to provide its own variations for the DNS installation tasks.
The selection of the address resolution service can be done
through dns_resolve_method setting.
2019-07-02 19:11:14 -05:00
Tim Kourt 20466cd735 resolve: Introduce resolve module
The module is responsible for the configuration of the address
resolution services. It will consist of the multiple service
specific plugins such as: systemd-resolved plugin, dnsmasq
plugin, etc.
2019-07-02 19:09:57 -05:00
Denis Kenzior bd4446070f manager: Create interfaces with a random mac
If supported by the driver, we can create an interface directly with a
random MAC if configured to do so.  If the driver does not have this
capability, then tell netdev to perform the necessary logic as part of
the interface initialization procedure.
2019-07-02 15:47:05 -05:00
Denis Kenzior 8b375e1b28 netdev: Add logic to randomize address on creation 2019-07-02 15:47:05 -05:00
Denis Kenzior ec38545a68 rtnlutil: Add utility to set MAC address 2019-07-02 15:47:05 -05:00
Denis Kenzior f4402ef56e wiphy: Add wiphy_generate_random_address 2019-07-02 15:47:05 -05:00
Denis Kenzior f72d9c2999 wiphy: Add wiphy_get_name 2019-07-02 15:47:05 -05:00
Denis Kenzior 209cdce51c hotspot: Fix crash
#0  0x7f5e25e71930 in /lib64/libc.so.6
 #1  0x446faa in hs20_config_free() at src/hotspot.c:63
 #2  0x469542 in l_queue_clear() at ell/queue.c:109
 #3  0x4694e7 in l_queue_destroy() at ell/queue.c:83
 #4  0x4475c1 in hotspot_exit() at src/hotspot.c:273
 #5  0x403170 in iwd_modules_exit() at src/main.c:195
 #6  0x404085 in main() at src/main.c:531
 #7  0x7f5e25e5cbde in /lib64/libc.so.6
2019-07-02 15:47:05 -05:00
Denis Kenzior 1c22847cf2 wiphy: Obtain permanent mac address from sysfs 2019-07-02 15:47:05 -05:00
Denis Kenzior 1e9f9e61f1 wiphy: Remove unused regulatory query / notifications
Regulatory domain management is now completely handled by the kernel, so
iwd doesn't really need to query or be aware of changes to this.  This
may change in the future, but for now this code has not been used and
can be safely gotten rid of.
2019-07-02 15:47:05 -05:00
Denis Kenzior 6414be86db wiphy: Remove protocol features query
We run on newer kernels which are guaranteed to have split wiphy dump
support.  So no point in actually querying this.
2019-07-02 15:47:05 -05:00
James Prestwood 8c0e1f62fc network: allow connections to hotspot networks 2019-06-26 23:16:38 -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
James Prestwood 99ce41b405 netdev: remove anqp_request functionality 2019-06-26 23:09:49 -05:00
James Prestwood 3979785703 main: add anqp_init/exit 2019-06-26 23:09:47 -05:00
James Prestwood 0bde59ca13 anqp: move request functionality into anqp.c
The actual ANQP request was handled by netdev, but in the case of P2P
their may be no netdev. For this reason all functionality needed for
an ANQP request has been moved into anqp.c. There are still a few netdev
references, which need to be removed when P2P is introduced. Leaving them
in for now as its still going to work as a first pass implementation
2019-06-26 23:09:23 -05:00
James Prestwood be9e926c6a nl80211util: move CMD_FRAME builder into nl80211util
This will be needed outside of netdev
2019-06-26 22:52:56 -05:00
James Prestwood 3d1f1eb21c main: create .hotspot directory if it does not exist 2019-06-26 14:29:48 -05:00
James Prestwood 537fcd12ca anqp: rework NAI Realm parsing
The initial ANQP parser design did not work well with how the hotspot
implementation was turning out. For one, much care was taken into parsing
the EAP credentials which are not really required. The assumption is
that any hotspot network will already be provisioned, so checking that
the EAP parameters match is a bit overkill. Instead only the NAI Realms
will be checked. This greatly simplifies the NAI realm parser, as now it
can just return a string list of realms instead of the full EAP
credential info.
2019-06-26 14:28:07 -05:00
James Prestwood a5f2710d05 hotspot: add hotspot module
This module will be in charge of managing Hotspot provisioning files
stored under the .hotspot/ directory. This includes a dir watch to
handle file changes/removal as well as an API to match a network
object to a hotspot provisioning file.
2019-06-26 14:25:11 -05:00
James Prestwood 701a5cc41e network: store HESSID and NAI Realms in network object
Hotspot networks are supposed to include an HESSID in the scan
results. This is more or less an identifier for the overall
network. In addition, the NAI Realms can be obtained via ANQP
and should be the same for each BSS. Since both HESSID and NAI
realms should be the same for a given network in range we can
store these values in the network object itself. This also allows
us to easily find hotspot configuration files by looking at
the HESSID/NAI Realms directly in the network object as opposed
to individual scan_bss's.
2019-06-26 13:23:22 -05:00
James Prestwood d63c8290a9 scan: add suspend/resume scan APIs
In order to do ANQP efficiently IWD needs the ability to suspend scanning
temporarily. This is because both scanning and ANQP go offchannel and must
remain off channel for some amount of time. This cannot be done
simultaneously and if e.g. ANQP is requested after a scan is already
pending, the kernel will wait till that scan finishes before sending out
the frame.
2019-06-26 13:09:48 -05:00
James Prestwood 45130ec5ee scan: parse interworking element 2019-06-26 13:07:24 -05:00
Denis Kenzior f0848cc44a rtnlutil: Don't use explicit_bzero
Use memset instead.  explicit_bzero should only be used when we're
wiping a secret just prior to the encopassing storage being freed.  The
compiler would usually optimize away the memset, leaving the secrets
around.

In rtnlutil we're simply zeroing the structure prior to filling it, so
the use of explicit_bzero is not needed and brings confusion to the
reader since no secrets are being wiped.
2019-06-26 10:43:38 -05:00
Tim Kourt 0706a357a4 station: Integrate netconfig into station creation and removal 2019-06-26 10:40:59 -05:00
Tim Kourt 56e4dc549a netconfig: Enable config. with static IPv4 addresses 2019-06-26 10:39:50 -05:00
Tim Kourt d80d1d5f1a netconfig: Implement address installation and removal 2019-06-26 10:38:14 -05:00
Tim Kourt 6aabd80051 rtnlutil: Utils to Add/Remove IPv4 addresses 2019-06-26 10:36:59 -05:00
Tim Kourt b70ff5d091 netconfig: Add station state watch
netconfig is interested in three station states: connected,
disconnected and connected after it has roamed. On connected
it tries to obtain a new DHCP lease, on disconnected it stops
the DHCP client and discards all addresses from interface, on
connected after roaming it will try to request a previously
issued address.
2019-06-26 10:34:35 -05:00
Tim Kourt 3d40f3a38b netconfig: Introduce IPv4 DHCP client
The client is used to obtain and configure the dynamic IPv4
addresses for the network.
2019-06-26 10:28:18 -05:00
Tim Kourt 1368851611 netconfig: Obtain all currently assigned IPv4 addresses 2019-06-26 10:27:27 -05:00
Tim Kourt 9b0838d07c netconfig: Subscribe for IPv4 link address notifications
iwd keeps track of the addresses assigned to the managed
interfaces. The list of assigned IPv4/IPv6 addresses is stored
in ifaddr_list inside of netconfig. The tracking of the IP
addresses will help to remove them from an interface once they
are no longer valid.
2019-06-26 10:27:00 -05:00
Tim Kourt f3f343c04b rtnlutil: Add parser for ifaddrmsg struct
Its purpose is to extract interface label, ip, and
broadcast addresses out of ifaddrmsg rntl message.
2019-06-26 10:26:26 -05:00
Tim Kourt 4e3e1fbf60 netconfig: Introduce netconfig module
netconfig module will be responsible for the orchestration
of the network configuration with the IP addresses.

iwd creates one netconfig structure per interface index.
The purpose of this struct is to hold all of the interface
related addressing states such as: assigned dhcp
clients, known addresses, routes, etc.
2019-06-26 10:25:57 -05:00
Denis Kenzior 397699c9c5 manager: Fix memory leak 2019-06-21 12:22:48 -05:00
James Prestwood 2fd58141a4 scan: fix formatting in scan.h
Replaced two 8-spaced indentation to tabs.
2019-06-18 13:29:27 -05:00
James Prestwood baf6b3ee4d netdev: optimize GAS request timeout
A not-yet-merged kernel patch will enable the FRAME_WAIT_CANCEL
event to be emitted when a CMD_FRAME duration expires. This can
shortcut the ridiculously long timeout that is required making
GAS requests with no response drastically quicker to handle.
2019-06-14 17:42:13 -05:00
James Prestwood 1e33eaa072 scan: free osen IE 2019-06-14 17:41:57 -05:00
James Prestwood 3a8b9a5d0c netdev: support basic ANQP requests
This adds a new API netdev_anqp_request which will send out a GAS
request, parses the GAS portion of the response and forwards the
ANQP response to the callers callback.
2019-06-14 17:40:39 -05:00
James Prestwood bed116e319 scan: add new hs20_capable member to scan_bss
If the BSS is Hotspot 2.0 capable this will get set
2019-06-14 16:24:38 -05:00
James Prestwood cb8d592b13 scan: parse Advertisement Protocol Element
This IE tells us what Advertisement Protocols the AP supports. This
is only here to look for ANQP support, so all this does is iterate
through all other Advertisement Protocol tuples looking for ANQP.
If found, anqp_capable is set in the scan_bss
2019-06-14 16:22:36 -05:00
Denis Kenzior b8d60bb848 anqp: Fix l_strlcpy usage 2019-06-14 16:22:22 -05:00
James Prestwood 2ce5277f6d anqp: added utility for parsing ANQP responses
Currently these are geared to support the WiFi Alliance Hotspot 2.0
ANQP elements, which all fall under the vendor specific ANQP element.

anqp_iter_next behaves similar to the genl parsers, where the id, length
and data will be returned as out parameters. Currently there is only
vendor support for Hotspot 2.0. anqp_iter_is_hs20 can be used to setup
the subtype, length, and data pointer to parse any Hotspot 2.0 ANQP
elements. From here the subtype can be checked and a vendor specific
parser for that subtype can be used to parse the data, e.g.
hs20_parse_osu_provider_nai.
2019-06-14 16:09:29 -05:00
James Prestwood 77a6b49803 wiphy: parse OFFCHANNEL_TX_OK attribute
The wiphy can indicate if it supports sending offchannel frames. This
allows us to bail out of a Hotspot connection early if this is not
supported.
2019-06-14 13:33:35 -05:00
James Prestwood e38cbcd31b station: support OSEN IE setting in handshake
The check for MFP is now skipped for OSEN as it should not be set for
this AKM.
2019-06-10 18:25:01 -05:00
James Prestwood c62ca4e185 scan: update vendor specific IE parsing to handle WFA
The vendor specific IE was being parsed only to check if the AP supported
WPA, which used a Microsoft OUI. Hotspot/OSEN uses neither WPA or RSN
(although its nearly identical to RSN) so the we also need to check for
this Wifi-Alliance OUI and set bss->osen (new) if found.
2019-06-10 18:23:21 -05:00
James Prestwood d3baec4eee eapol: add eapol_find_osen
The OSEN AKM uses the vendor specific IE, so when finding the RSNE
element we need to handle it specially to ensure that its both
a vendor specific element and it matches the WFA OUI since other
vendor specific elements may be included.
2019-06-10 18:22:44 -05:00
James Prestwood 058d65c686 handshake: handle OSEN AKM when setting IEs 2019-06-10 18:21:57 -05:00
James Prestwood b09dbcd5ac ie: add parser/builder to handle OSEN
The OSEN AKM is nearly identical to the RSN IE, but differs slightly.
For one, OSEN is encapsulated into the vendor specific IE, and includes
the WFA OUI before the 'normal' RSN elements. OSEN also does not include
a WPA version, since its not technically WPA/WPA2.

Some of the RSN parsing was made common so both RSN/OSEN parsing could
use it.
2019-06-10 18:03:10 -05:00
James Prestwood 08a3775821 station: fix compiler error after bss_free change 2019-06-10 15:19:11 -05:00
James Prestwood 0ec9618b5f station: remove print in bss_free
In environments with many APs, the debug log is spammed with this print,
which isn't particularly useful to the average user.
2019-06-10 14:15:02 -05:00
James Prestwood 039ae3659b eapol: handshake: add OSEN AKM
The handshake procedure for OSEN is part of the 'AKM_DEFINED' group
of AKMs.
2019-06-07 17:10:49 -05:00
James Prestwood 5d3b37e2e4 ie: add is_ie_wfa_ie
This checks if an IE tagged as vendor specific is a WiFi-Alliance
OUI. This is similar to how is_ie_wpa_ie works.
2019-06-07 16:15:09 -05:00
James Prestwood 2e0fed3d77 ie: add IE_RSN_AKM_SUITE_OSEN 2019-06-07 16:15:07 -05:00
James Prestwood 75e6ee98f3 handshake: simplify IE setters
The handshake object had 4 setters for authenticator/supplicant IE.
Since the IE ultimately gets put into the same buffer, there really
only needs to be a single setter for authenticator/supplicant. The
handshake object can deal with parsing to decide what kind of IE it
is (WPA or RSN).
2019-06-07 14:22:36 -05:00
James Prestwood f6df93d358 crypto: add OSEN AKM
OSEN (OSU Server-Only authenticated layer 2 Encryption Network) is
required for the WiFi Alliance Hotspot Specification.
2019-06-07 14:22:33 -05:00
James Prestwood 6ee479f022 eap-tls: add new EAP method for Anonymous TLS
This adds the WiFi Alliance 'Anonymous TLS' EAP type.
2019-06-06 13:29:11 -05:00
James Prestwood 233804d7fc eap-tls-common: allow for EAP_TYPE_EXPANDED in TLS
The Hotspot 2.0 spec introduces 'Anonymous EAP-TLS' as a new EAP method
to be used with OSEN/Hotspot. The protocol details of this aren't
relevant to this patch, but one major difference is that it uses the
expanded EAP type rather than the TLS type. Since the common TLS code
was written with only EAP_TYPE_TLS in mind the vendor ID/type cause the
EAP packet to be malformed when using the expanded EAP type.

To handle this the common TLS code now checks the EAP type, and if its
expanded we shift the payload 7 bytes further to account for the extra
header data.
2019-06-06 13:29:11 -05:00
James Prestwood f3ad319e59 ie: add advertisement protocol definitions
802.11 defines GAS (generic advertisement service) which can be used
to query supported advertisement protocols from an AP before
authentication/association. Hotspot/OSEN only care about the ANQP
protocol, but the way the IE is structured potentially requires
iterating through several tuples before you reach the ANQP protocol
identifier. Because of this we define all protocol identifiers.
2019-06-05 16:53:11 -05:00
Denis Kenzior c80d32a162 ap: Convert to IWD_MODULE 2019-05-28 14:43:42 -05:00
Denis Kenzior eeac3e8f40 adhoc: Convert to IWD_MODULE 2019-05-28 14:24:37 -05:00
Denis Kenzior a9e3b3e906 scan: Convert to IWD_MODULE 2019-05-28 14:12:25 -05:00
Denis Kenzior d74fcfd25c storage: Use L_TFR instead of TFR 2019-05-28 14:06:22 -05:00
Denis Kenzior 57748347b0 treewide: Use L_TFR macro 2019-05-24 11:52:40 -05:00
Denis Kenzior 865492df8c ft: Fix endianness issues
The use of mmpdu_association_response members marked as __le requires
the relevant endianness conversion.
2019-05-23 16:59:34 -05:00
Denis Kenzior 360ec1488d fils: Fix endianness issues
Using mmpdu_associate_response and mmpdu_authenticate structure
members marked __le requires the relevant endianness conversion.
2019-05-23 16:59:14 -05:00
Denis Kenzior e53bd17992 owe: Fix endianness issues
Using mmpdu_associate_response structure members marked __le requires
the relevant endianness conversion.
2019-05-23 16:58:59 -05:00
Denis Kenzior 85bd019c85 sae: Fix endianness issues
The use of mmpdu_authentication and mmpdu_association_response members
marked as __le requires the relevant endianness conversion.
2019-05-23 16:56:45 -05:00
James Prestwood 628c079e55 station: netdev: allow FILS-FT AKMs
This adds some checks for the FT_OVER_FILS AKMs in station and netdev
allowing the FILS-FT AKMs to be selected during a connection.

Inside netdev_connect_event we actually have to skip parsing the IEs
because FILS itself takes care of this (needs to handle them specially)
2019-05-23 15:27:29 -05:00
James Prestwood e583b1d243 fils: update to handle FILS-FT
FILS unfortunately is a special case when it comes to fast transition.
We have to process the FT IEs internally since we cannot trigger the
same initial mobility association code path (via netdev).
2019-05-23 15:26:34 -05:00
James Prestwood 5ca4fa9b9e wiphy: allow both FILS-FT AKMs to be chosen 2019-05-23 15:23:46 -05:00
James Prestwood 7f7a5c861d ft: update for larger MIC/FILS-FT 2019-05-23 15:23:46 -05:00
James Prestwood 1accf534dc ie: allow 24 byte FTE MIC
FT over FILS-SHA384 uses a 24 byte FT MIC rather than the 16 byte MIC
used for all other AKMs. This change allows both the FT builder/parser
to handle both lengths of MIC. The mic length is now passed directly
into ie_parse_fast_bss_transition and ie_build_fast_bss_transition
2019-05-23 15:23:08 -05:00
James Prestwood 4097a49669 eapol: add FILS-FT AKMs to eapol_start
This will prevent FILS-FT from starting the 4-way handshake as it
does for regular FILS
2019-05-22 16:29:23 -05:00
James Prestwood 5d2b995175 handshake: update FT derivation functions for FILS-FT
FILS-FT could derive a longer PMKR0/R1 key, as well as uses a special
xxkey that it derives during FILS.
2019-05-22 16:15:23 -05:00
James Prestwood 0e9ed03e60 handshake: update key getters for FILS-FT
FILS-FT is a special case with respect to the PTK keys. The KCK getter
was updated to handle both FT-FILS AKMs, by returning the offset in
the PTK to the special KCK generated during FILS. A getter for the KCK
length was added, which handles the SHA384 variant. The PTK size was
also updated since FILS-FT can generate an additional 56 bytes of PTK
2019-05-22 16:14:51 -05:00
James Prestwood bc381bd8c3 crypto: update FT derivation functions to use sha384
FILS-FT requires the SHA384 KDF to derive the FT keys
2019-05-22 16:14:14 -05:00
James Prestwood aafb3fa7ed handshake: add key for FILS-FT in handshake_state
FILS derives its own FT key, for use as xxkey during fast transition.
2019-05-22 16:14:01 -05:00
James Prestwood e109e1b1cf crypto: pass xxkey length for crypto_derive_pmk_r0
FILS-FT has a special derivation for xxkey, and depending on AKM
the key may be 32 or 48 bytes long.
2019-05-22 16:13:57 -05:00
James Prestwood 4c32dd09f6 fils: add forgotten break 2019-05-22 16:13:08 -05:00
Denis Kenzior 03ff5ef7d0 device: Convert to using IWD_MODULE 2019-05-22 10:20:10 -05:00
Denis Kenzior 978e538f81 station: Convert to use IWD_MODULE 2019-05-22 10:20:10 -05:00
Denis Kenzior 23b278ef52 wsc: Convert to use IWD_MODULE 2019-05-22 10:20:10 -05:00
Denis Kenzior 4cfcb9c88d network: Convert to use IWD_MODULE 2019-05-22 10:20:10 -05:00
Denis Kenzior 800d57d095 knownnetworks: Convert to IWD_MODULE 2019-05-22 10:20:10 -05:00
Denis Kenzior 546c3c26d3 simauth: Convert to use IWD_MODULE 2019-05-22 10:20:08 -05:00
Denis Kenzior b8f6899f40 blacklist: Convert to use IWD_MODULE 2019-05-22 09:58:04 -05:00
Denis Kenzior a1d9c07f2f erp: Convert to using IWD_MODULE 2019-05-19 13:07:13 -05:00
Denis Kenzior 2386fa7938 main: Add IWD_MODULE macro 2019-05-19 13:05:06 -05:00
Denis Kenzior 8dced8b7f7 main: Update to the new genl api 2019-05-17 17:10:18 -05:00
Andrew Zaborowski 08ec88671a manager: Also delete interfaces without an ifindex, cleanup 2019-05-13 14:10:49 -05:00
Andrew Zaborowski 0b109c52b7 netdev: Add missing initialization
ifaddr is not guaranteed to be initialized, I'm not sure why there was
no compiler warning.  Also replace a | with a || for boolean conditions
and merge the wiphy check with that line.
2019-05-13 14:10:49 -05:00
Andrew Zaborowski b86af171f0 netdev: Don't warn on genl messages not matching a netdev
This is going to be a normal situation when we start using interfaces
without an ifindex.
2019-05-13 14:10:49 -05:00
Andrew Zaborowski 925095f835 netdev: Drop remaining whitelist/blacklist code 2019-05-13 14:10:49 -05:00
Andrew Zaborowski 236dc14a3d station: Cancel the roam scan in station_free
We'd remove the roam timeout but not scancel the roam scan in
station_free, instead call station_roam_state_clear which does both
things.
2019-05-10 19:19:21 -05:00
Andrew Zaborowski b560ca6173 scan: Make sure request is unqueued in scan_cancel
We were forgetting to handle the case of scan requests that are not at the
top of the queue.
2019-05-10 19:19:07 -05:00
Andrew Zaborowski 157d5f9f47 scan: Check if an external scan flushed intermediate results
When handling a scan finished event for a scan we haven't started check
that we were not halfway through a scan request that would have its
results flushed by the external scan.
2019-05-10 19:19:02 -05:00
Marcel Holtmann 51553415bd erp: Include src/missing.h for explicit_bzero 2019-05-10 11:06:52 +02:00
Marcel Holtmann cab0bc29c4 sae: Include src/missing.h for explicit_bzero 2019-05-10 11:01:32 +02:00
James Prestwood c0c8faf32f ft: netdev: station: support FT-over-DS
FT-over-DS is a way to do a Fast BSS Transition using action frames for
the authenticate step. This allows a station to start a fast transition
to a target AP while still being connected to the original AP. This,
in theory, can result in less carrier downtime.

The existing ft_sm_new was removed, and two new constructors were added;
one for over-air, and another for over-ds. The internals of ft.c mostly
remain the same. A flag to distinguish between air/ds was added along
with a new parser to parse the action frames rather than authenticate
frames. The IE parsing is identical.

Netdev now just initializes the auth-proto differently depending on if
its doing over-air or over-ds. A new TX authenticate function was added
and used for over-ds. This will send out the IEs from ft.c with an
FT Request action frame.

The FT Response action frame is then recieved from the AP and fed into
the auth-proto state machine. After this point ft-over-ds behaves the
same as ft-over-air (associate to the target AP).

Some simple code was added in station.c to determine if over-air or
over-ds should be used. FT-over-DS can be beneficial in cases where the
AP is directing us to roam, or if the RSSI falls below a threshold.
It should not be used if we have lost communication to the AP all
(beacon lost) as it only works while we can still talk to the original
AP.
2019-05-09 13:38:34 -05:00
James Prestwood a432ceeee4 netdev: modify netdev_send_action_frame for ft-over-ds
To support FT-over-DS this API needed some slight modifications:

- Instead of setting the DA to netdev->handshake->aa, it is just set to
  the same address as the 'to' parameter. The kernel actually requires
  and checks for these addresses to match. All occurences were passing
  the handshake->aa anyways so this change should have no adverse
  affects; and its actually required by ft-over-ds to pass in the
  previous BSSID, so hard coding handshake->aa will not work.

- The frequency is is also passed in now, as ft-over-ds needs to use
  the frequency of the currently connected AP (netdev->frequency get
  set to the new target in netdev_fast_transition. Previous frequency
  is also saved now).

- A new vector variant (netdev_send_action_framev) was added as well
  to support sending out the FT Request action frame since the FT
  TX authenticate function provides an iovec of the IEs. The existing
  function was already having to prepend the action frame header to
  the body, so its not any more or less copying to do the same thing
  with an iovec instead.
2019-05-09 13:32:45 -05:00
James Prestwood 03807e12e1 ft: netdev: move Authenticate IE building into ft.c
Since FT already handles processing the FT IE's (and building for
associate) it didn't make sense to have all the IE building inside
netdev_build_cmd_ft_authenticate. Instead this logic was moved into
ft.c, and an iovec is now passed from FT into
netdev_ft_tx_authenticate. This leaves the netdev command builder
unburdened by the details of FT, as well as prepares for FT-over-DS.
2019-05-09 12:22:01 -05:00
Andrew Zaborowski 36c08b9508 manager: Disable touching interfaces for some drivers
Blacklist some drivers known to crash when interfaces are deleted or
created so that we don't even attempt that before falling back to using
the default interface.
2019-05-08 11:52:52 -05:00
Andrew Zaborowski ac2eeab570 wiphy: Add wiphy_get_driver api
Read the driver name for each wiphy from sysfs if available.  I didn't
find a better way to obtain the driver name for a phy than by reading
the dir name that the "driver" symlink points at.  For an existing
netdev this can be done using the SIOCETHTOOL ioctl.
2019-05-08 11:52:25 -05:00
Andrew Zaborowski 7ce8d9d8b6 manager: Fix iteration over wiphy setup states
manager_interface_dump_done would use manager_create_interfaces() at the
end of the loop iterating over pending_wiphys.  To prevent it from
crashing make sure manager_create_interfaces never frees the pending
wiphy state and instead make the caller check whether it needs to be
freed so it can be done safely inside loops.
2019-05-08 11:52:14 -05:00
Andrew Zaborowski 8db47ed21d scan: Use scan requests for the periodic scans, refactor
Instead of having two separate types of scans make the periodic scan
logic a layer on top of the one-off scan requests, with minimum code to
account for the lower priority of those scans and the fact that periodic
scans also receive results from external scans.  Also try to simplify
the code for both the periodic and one-off scans.  In the SCAN_RESULTS
and SCAN_ABORT add more complete checks of the current request's state
so we avoid some existing crashes related to external scans.

scan_send_next_cmd and start_next_scan_request are now just one function
since their funcionality was similar and start_next_scan_request is used
everywhere.  Also the state after the trigger command receives an EBUSY
is now the same as when a new scan is on top of the queue so we have
fewer situations to consider.

This code still does not account for fragmented scans where an external
scan between two or our fragments flushes the results and we lose some
of the results, or for fragmented scans that take over 30s and the
kernel expires some results (both situations are unlikely.)
2019-05-08 11:31:02 -05:00
James Prestwood ce7df37132 netdev: remove in_ft checks and set_use_eapol_start
In both netdev_{authenticate,associate}_event there is no need to check
for in_ft at the start since netdev->ap will always be set if in_ft is
set.

There was also no need to set eapol_sm_set_use_eapol_start, as setting
require_handshake implies this and achieves the same result when starting
the SM.
2019-05-07 15:50:05 -05:00
James Prestwood 567f35c32f netdev: ft: refactor FT into an auth-proto
Since FT operates over Authenticate/Associate, it makes the most sense
for it to behave like the other auth-protos.

This change moves all the FT specific processing out of netdev and into
ft.c. The bulk of the changes were strait copy-pastes from netdev into
ft.c with minor API changes (e.g. remove struct netdev).

The 'in_ft' boolean unforunately is still required for a few reasons:

 - netdev_disconnect_event relies on this flag so it can ignore the
   disconnect which comes in when doing a fast transition. We cannot
   simply check netdev->ap because this would cause the other auth-protos
   to not handle a disconnect correctly.
 - netdev_associate_event needs to correctly setup the eapol_sm when
   in FT mode by setting require_handshake and use_eapol_start to false.
   This cannot be handled inside eapol by checking the AKM because an AP
   may only advertise a FT AKM, and the initial mobility association
   does require the 4-way handshake.
2019-05-07 14:19:26 -05:00
James Prestwood 87346212c9 ft: rename ftutil to ft (prep for auth-proto)
Now the 'ft' module, previously ftutil, will be used to drive FT via
the auth-proto virtual class. This renaming is in preparation as
ftutil will become obsolete since all the IE building/processing is
going to be moved out of netdev. The new ft.c module will utilize
the existing ftutil functionality, but since this is now a full blown
auth protocol naming it 'ft' is better suited.
2019-05-07 14:09:08 -05:00
James Prestwood d1286200e9 netdev: move connect completion into netdev_connect_event
The duplicate/similar code in netdev_associate_event and
netdev_connect_event leads to very hard to follow code, especially
when you throw OWE/SAE/FILS or full mac cards into the mix.
Currently these protocols finish the connection inside
netdev_associate_event, and set ignore_connect_event. But for full
mac cards we must finish the connection in netdev_connect_event.

In attempt to simplify this, all connections will be completed
and/or the 4-way started in netdev_connect_event. This satisfies
both soft/full mac cards as well as simplifies the FT processing
in netdev_associate_event. Since the FT IEs can be processed in
netdev_connect_event (as they already are to support full mac)
we can assume that any FT processing inside netdev_associate_event
is for a fast transition, not initial mobility association. This
simplifies netdev_ft_process_associate by removing all the blocks
that would get hit if transition == false.

Handling FT this way also fixes FT-SAE which was broken after the
auth-proto changes since the initial mobility association was
never processed if there was an auth-proto running.
2019-05-07 12:12:17 -05:00
Tim Kourt e282d1fedf netdev: use rtnlutil for linkmode/operstate 2019-05-06 13:21:36 -05:00