Commit Graph

2575 Commits

Author SHA1 Message Date
Denis Kenzior 681172a999 storage: Add ability to preserve times
We use the mtime on the network profile as the 'Last Connected Time'.
When we update any property and sync the file to disk, the mtime was not
preserved (since we were creating a new temporary file instead of
modifying the old one).  This led to LastConnectedTime property change
being emitted / updated incorrectly when a writable property on the
KnownNetwork interface was updated.
2020-01-22 11:15:19 -06:00
Torstein Husebø 759dbdd37f treewide: fix typos 2020-01-21 16:03:28 -06:00
Denis Kenzior b00d4f4ce6 wsc: Use macros to simplify reply code a bit 2020-01-17 12:50:23 -06:00
Denis Kenzior 30ec06edcc wsc: Remove stale comment
Known networks are now automatically updated through inotify mechanisms,
so this comment is no longer needed.
2020-01-17 12:50:23 -06:00
Denis Kenzior ec15838215 wsc: Rework wsc_enrollee_destroy
Our design preference is to not call any callbacks in the _free/_destroy
method of a class (with the exception of explicit destroy callbacks
provided, if any).

Invoking the callback in this case was unnecessary: wsc_dbus_free was
already replying to pending connect / cancel messages.  The only other
thing the callback would attempt to do is to set station back into
autoconnect mode.  This was unnecessary as well since the netdev is
already down.

This change removes the callback invocation.  Since wsc_enrollee_destroy
is now just calling wsc_enrollee_free, remove this from the API and
expose wsc_enrollee_free instead.
2020-01-17 12:50:23 -06:00
Andrew Zaborowski 1f14941011 wsc: Accept extra IEs in wsc_enrollee_new 2020-01-17 12:50:23 -06:00
Andrew Zaborowski ce16ba3bf8 wsc: Refactor WSC D-Bus interface logic
Split the WSC D-Bus interface class (struct wsc) into a base class
common to station mode and P2P mode (struct wsc_dbus) and station-
specific logic like scanning, saving the credentials as a known network
and triggering the station-mode connection (struct wsc_station_dbus).

Make the base class and its utilities public in wsc.h for P2P use.
2020-01-17 12:50:23 -06:00
Andrew Zaborowski b10264dcc7 wsc: Split out enrollee state machine to own object
Create struct wsc_enrollee which is allocated with wsc_enrollee_new,
taking a done callback as a parameter.  The callback is always
called so there's no need for a separate destroy callback.  The object
only lives until the done callback happens so wsc_enrollee_cancel/destroy
can only be used before this.

Looks like the rest of the file is simplified thanks to this.
2020-01-17 12:50:23 -06:00
Andrew Zaborowski 02f7d425b3 netdev: Drop the netdev_frame_watch API 2020-01-16 11:38:01 -06:00
Andrew Zaborowski baad7e5fd8 netdev: Switch to new frame watch API 2020-01-16 11:37:59 -06:00
Andrew Zaborowski b234a8e614 rrm: Switch to new frame watch API 2020-01-16 11:37:57 -06:00
Andrew Zaborowski b31a23785a device: Switch to new frame watch API 2020-01-16 11:37:55 -06:00
Andrew Zaborowski 4a61620a9b ap: Switch to new frame watch API 2020-01-13 11:49:08 -06:00
Andrew Zaborowski 6484b7dbb6 Add a new frame watch API
This new API is independent of netdev.c and allows actually
unregistering from receiving notifications of frames, although with some
quirks.  The current API only allowed the callback for a registration to
be forgotten but our process and/or the kernel would still be woken up
when matching frames were received because the kernel had no frame
unregister call.  In the new API you can supply a group-id paramter when
registering frames.  If it is non-zero the frame_watch_group_remove() call
can be used to remove all frame registrations that had a given group-id
by closing the netlink socket on which the notifications would be
received.  This means though that it's a slightly costly operation.

The file is named frame-xchg.c because I'm thinking of also adding
utilities for sending frames and waiting for one of a number of replies
and handling the acked/un-acked information.
2020-01-13 11:49:08 -06:00
Andrew Zaborowski c6c45e0569 wscutil: Add wsc_build_m8_encrypted_settings 2020-01-09 14:03:45 -06:00
Andrew Zaborowski c67219a292 wscutil: Add wsc_build_credential 2020-01-09 13:57:11 -06:00
Andrew Zaborowski 0f8a49501e wsc: Refactor store_credentials / try_credentials
Instead of taking the credentials from wsc object directly, have the
caller pass these in.  This makes it more consistent with how the
done_cb was done.
2020-01-06 15:23:55 -06:00
Andrew Zaborowski 25708fbb5c wsc: Refactor to separate station-specific code
Split the interface-specific logic from the core WSC logic.  The core
WSC code is the part that we can re-use between P2P and station and
doesn't include the D-Bus code, scanning for the target BSS or the
attempt to make a station mode connection.
2020-01-06 11:50:12 -06:00
Andrew Zaborowski a716f46573 netdev: Replace bool randomize_mac with specific address
Allow netdev_create_from_genl callers to draw a random or non-random MAC
and pass it in the parameter instead of a bool to tell us to generating
the MAC locally.  In P2P we are generating the MAC some time before
creating the netdev in order to pass it to the peer during negotiation.
2020-01-06 11:27:38 -06:00
Tim Kourt d9efacfbba peap: Ignore Crypto-Binding TLVs with invalid compound MACs
Some server implementation don't seem to provide the valid compound MACs.
In the meantime, iwd will ignore the invalid Crypto-Binding TLVs as their
usage is optional.
2019-12-18 23:46:49 -06:00
Denis Kenzior 83e535b643 netdev: Use nl80211_parse_attrs 2019-12-17 16:58:04 -06:00
Denis Kenzior 9ee2b4ea4a nl80211util: Support ATTR_MAC 2019-12-17 16:58:04 -06:00
Denis Kenzior ab14515715 resolve: Fix invalid method name check
The intent was to check for the presence of the add_domain_name
operation, not add_dns operation.

Fixes: 930528e35e ("resolve: Add systemd-resolved domain name installer")
2019-12-17 16:58:04 -06:00
Denis Kenzior 0e49561bb7 treewide: Use l_debug with at least one argument
By convention we should be passing at least an empty string to make it
clearer that no additional debug info is being printed
2019-12-17 16:15:05 -06:00
Denis Kenzior 3607ee0c7e netdev: Allow both -EOPNOTSUPP and -ENOTSUPP
It seems that the kernel uses -EOPNOTSUPP if the change_station
operation is not implemented by the driver.  However, some drivers do
implement change_station and choose to report -ENOTSUPP instead of
-EOPNOTSUPP.

To add to the confusion, EOPNOTSUPP and -ENOTSUPP are the same on some
systems (e.g. Gentoo).  Be paranoid and allow both errors to be ignored
when sending CMD_SET_STATION.

Fixes: 0238ffb8d9 ("netdev: Use -EOPNOTSUPP instead of -ENOTSUPP")
2019-12-17 16:10:46 -06:00
Tim Kourt 1f84c3b19a manpage: Add section about IPv4 static network configuration 2019-12-17 11:30:54 -06:00
Tim Kourt f21d1aa78b peap: Add debug statements 2019-12-17 11:07:32 -06:00
Denis Kenzior 295e42f87a resolve: Don't try to set routing domains
The intent was to treat all domains as search domains, not routing
domains.

Fixes: 930528e35e ("resolve: Add systemd-resolved domain name installer")
2019-12-17 11:01:38 -06:00
James Prestwood 18c2c98ad5 rrm: fix bad sign for calculating RCPI
The first if case should be -10950, not 10950. Without the negative
this first case would get hit every time since signal strength values
are always negative.
2019-12-13 08:34:14 +01:00
Tim Kourt 8884fd8bbd peap: Add support for Crypto-Binding in PEAPv0
The Crypto Binding TLV is used to ensure that the EAP peer and the
EAP server participated in both the inner and the outer EAP
authentications of a PEAP authentication by cryptographically associating
the phase 1 and phase 2 authentications.

The usage of Crypto-Binding in PEAPv0 is optional and is triggered by
the reception of the Crypto-Binding TLV from the server.
2019-12-12 15:13:32 -06:00
Tim Kourt 8e5f838219 peap: Extend EAP Extensions to handle multiple TLVs
The handler for EAP Extensions has been modified to support multiple
TLV types instead of the single Result TLV. This will allow to handle
the other TLVs such as Crypto-Binding TLV.
2019-12-12 15:13:32 -06:00
Tim Kourt fb338154a2 netconfig: Add IPv4 domain name helper and installer
The provided domain name helper allows to override the DHCP lease
option value with the static one from network configuration file.
2019-12-12 10:35:12 -06:00
Pinghao Wu d510f332b6 eap-gtc: Try to auth even if request not Password
There are some server implementations that send requests that are
not "Password" but still want us send password. This commit modify
the behavior to send a warning and still try to auth with password.

This makes me able to auth with server in my school which sends
"Enter Aruba Login".

wpa_supplicant does not check if it is "Password".
2019-12-12 10:22:58 -06:00
Denis Kenzior 0238ffb8d9 netdev: Use -EOPNOTSUPP instead of -ENOTSUPP
The kernel uses -EOPNOTSUPP in the case of change_station operation not
being provided.  On most systems -EOPNOTSUPP is defined to be the same
as -ENOTSUPP, but seemingly not all systems.
2019-12-12 10:19:24 -06:00
Tim Kourt 930528e35e resolve: Add systemd-resolved domain name installer
The exposed DBus API is used to install doamin name into
sytemd-resolved.
2019-12-11 00:57:35 -06:00
Tim Kourt 1fd794a444 netconfig: Use CamelCase for IPv6 DNS setting 2019-12-11 00:57:29 -06:00
Tim Kourt ac9c87d012 netconfig: Use CamelCase for IPv6 gateway setting 2019-12-11 00:57:29 -06:00
Tim Kourt 2414a3ae51 netconfig: Use CamelCase for IPv6 address settings 2019-12-11 00:57:29 -06:00
Tim Kourt e7db478f97 netconfig: Use CamelCase for IPv4 DNS setting 2019-12-11 00:57:29 -06:00
Tim Kourt 994c1a4b5a netconfig: Use CamelCase for IPv4 gateway setting 2019-12-11 00:57:29 -06:00
Tim Kourt 0d9487d4ec netconfig: Use CamelCase for IPv4 address settings 2019-12-11 00:57:29 -06:00
Tim Kourt 1b483c3963 crypto: Add support for PRF+ SHA1
The PRF+ algorithm is based Internet Key Exchange (IKEv2) Protocol:
	https://www.ietf.org/rfc/rfc4306.txt
2019-12-09 01:47:11 -06:00
Tim Kourt 24b6a95366 peap: Rename AVPs to TLVs
Most of the literature seems to refer to AVPs as TLVs. Rename the
variables to follow the common nomenclature.
2019-12-09 01:39:41 -06:00
Tim Kourt 9bf0b756c8 peap: Delay key installation until success of Phase 2
Previously, the key was installed once the tunnel was created
despite the outcome of the second authentication phase. Now, the
key installation is delayed until the successful completion of
the second authentication phase. This excludes the unnecessary
operations in the case of a failure and key reinstallation with
cypro-binding in use.
2019-12-09 01:39:27 -06:00
Tim Kourt 5273a3b581 peap: Introduce PEAP state
Introduction of the state struct will allow to hold the additional
state variables related to the implementation of PEAP.
2019-12-09 01:38:59 -06:00
Andrew Zaborowski cbbc247aa2 wsc: Declare the credentials structure in wsc.h 2019-12-08 21:48:33 -06:00
Denis Kenzior 738184d491 device/netdev: init scan in netdev instead of device
Commit 1057d8aa74 changed the device interface creation logic
from being unconditional inside netdev.c to instead use NETDEV_WATCH_*
events.  However, this broke the assumption that the device interface
was created before all others.  The effect is that the scan_wdev_add
might no longer be called prior to station interface being created.  Fix
this by moving scan_wdev_add/remove calls to netdev.c instead.

Fixes: 1057d8aa74 ("device: Move device creation from netdev.c to event watch")
2019-12-06 10:12:55 -06:00
Denis Kenzior d2556a48b7 scan: Fix crash when scan is triggered outside iwd
#0  0x000055555558ee5d in scan_notify (msg=0x55555560b640, user_data=0x0) at src/scan.c:1706
 #1  0x00007ffff7f2c78c in ?? () from /usr/lib/libell.so.0
 #2  0x00007ffff7f299ec in ?? () from /usr/lib/libell.so.0
 #3  0x00007ffff7f28e4a in l_main_iterate () from /usr/lib/libell.so.0
 #4  0x00007ffff7f28efc in l_main_run () from /usr/lib/libell.so.0
 #5  0x00007ffff7f290b9 in l_main_run_with_signal () from /usr/lib/libell.so.0
 #6  0x00005555555639c4 in main (argc=1, argv=0x7fffffffec18) at src/main.c:497
2019-12-02 11:02:05 -06:00
Marcel Holtmann 9d8e74c1bc module: Declare functions as foo(void) instead of just foo() 2019-11-24 19:44:06 +01:00
Andrew Zaborowski becba0dd09 scan: Add scan_bss_new_from_probe_req 2019-11-21 20:51:21 -06:00