Commit Graph

2255 Commits

Author SHA1 Message Date
Tim Kourt 18c339beab resolve: Add resolvconf as DNS manager
Enable the systems that use resolvconf as DNS manager to be
configurable by iwd.
2019-08-02 06:24:00 -05:00
James Prestwood 8053152730 wsc: fix station lookup by ifindex
The station was being lookup up using the wdev ID rather than the
interface index.
2019-08-02 02:23:05 -05:00
Matthias Schoepfer 4ae5c38be8 iwd.service.in: remove PrivateDevices=true
Previously, the option PrivateDevices=true disabled access to
/dev/rfkill, which lead to:
  'iwctl adapter phy0 set-property Powered {off|on}'
to fail.

This patch explicitly allows access to /dev/rfkill
2019-08-01 01:55:12 -05:00
James Prestwood 236211af60 rtnlutil: fix compiler error
src/rtnlutil.c: In function ‘rtnl_route_add’:
./ell/util.h:248:2: error: ‘rtmmsg’ may be used uninitialized in
	this function [-Werror=maybe-uninitialized]
2019-07-31 12:39:41 -05:00
Denis Kenzior 66b5541970 netconfig: make ROUTE_PRIORITY_OFFSET a uint32_t
Also move it up into the static variable block
2019-07-31 12:38:40 -05:00
Denis Kenzior 1fd0dbb74b netconfig: Store rtm_protocol value directly
Instead of using a flag ipv4_static, just store the value of the rtm
protocol directly inside netconfig object.  This allows us to simplify
the logic quite significantly and avoid repeating the conditional
expression needlessly
2019-07-31 04:38:54 -05:00
Tim Kourt 2eded67c62 netconfig: Install connected and gateway routes
The routes are installed as a result of a successful installation
of the IP addresses. The gateway is fetched with netconfig_ipv4_get_gateway
helper function according to the origin of the installed IP address.

The route priority offset can be set in main.conf. The default value
of 300 is used if the offset isn’t set.
2019-07-31 03:53:32 -05:00
Denis Kenzior be5219883c rtnlutil: Simplify error handling 2019-07-31 03:53:01 -05:00
Tim Kourt cce59ad7f1 rtnlutil: Add connected and gateway route API
The API allows to add connected and gateway routes to the main
routing table.

rtnl_route_ipv4_add_gateway() is equivalent to the following
example 'ip route' command:
ip route add default via 10.0.0.1 dev wlan0 proto dhcp src 10.0.0.2 metric 339

rtnl_route_ipv4_add_connected()  is equivalent to the following
example 'ip route' command:
sudo ip route add 10.0.0.0/24 dev wlan0 proto dhcp src 10.0.0.2 scope link

The 'ip route' output from the above commands looks as follows:

rtnl_route_ipv4_add_connected():
10.0.0.0/24 dev wlan0 proto dhcp scope link src 10.0.0.2

rtnl_route_ipv4_add_gateway():
default via 10.0.0.1 dev wlan0 proto dhcp src 10.0.0.2 metric 339
2019-07-31 03:49:35 -05:00
Tim Kourt a91136d4b9 netconfig: Install\uninstall DNS addresses
The DNS addresses are installed as a result of a successful
installation of the IP addresses. The DNS lists are fetched
with netconfig_ipv4_get_dns helper function according to the
origin of the installed IP address.
2019-07-31 03:42:53 -05:00
Tim Kourt 372240fe8c netconfig: Refactor Install/Uninstall for IPv4 addresses 2019-07-31 03:42:01 -05:00
Tim Kourt 72e6598c6e netconfig: Switch IPv4 DHCP event handler to use ifaddr helper 2019-07-31 03:41:47 -05:00
Tim Kourt 10791d02aa netconfig: Remove no longer used static address loader
Note: there will be provided the separate helper functions for
fetching gateway and dns
2019-07-31 03:39:47 -05:00
Tim Kourt a4a7f88ace netconfig: Refactor station state changed event logic
iwd reconfigures the wireless interfaces with respective
connection events. Each supported network protocol is
reconfigured. The address for each protocol is
selected as static or dynamic based on availability.
2019-07-31 03:38:19 -05:00
Tim Kourt dd188bf97a netconfig: Add helper for IPv4 addresses
netconfig_ipv4_get_ifaddr helper function allows to fetch IPv4
addresses from static or dynamic sources. The origin of the addresses
is noted in 'ipv4_is_static' flag.
2019-07-31 03:35:51 -05:00
Tim Kourt c13b0971bb netconfig: Add 'ipv4' to ipv4-specific function names 2019-07-31 03:27:38 -05:00
James Prestwood 30fc736b62 network: update several APIs to be const 2019-07-30 14:47:37 -05:00
James Prestwood e2bed192f6 util: knownnetworks: move timespec_compare into util 2019-07-30 14:44:38 -05:00
James Prestwood 3f794a1f20 iwd: netdev: deprecate ControlPortOverNL80211
control_port_over_nl80211 should now be used instead.
2019-07-30 14:41:49 -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
James Prestwood 6088c06507 ie: add parser/builder for hotspot indication element
The parser fully parses the IE and returns the version, Domain ID,
and PPS MO ID. This is meant to be used with an IE in scan results.

The builder only takes the version number, and assumes DGAF disabled,
and no Domain ID or PPS MO ID.
2019-07-24 00:13:27 -05:00
Tim Kourt 5478034eb7 network: Check for already connected network
Check if the requested network is already connected,
if so return success.
2019-07-23 17:19:12 -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
James Prestwood 55491f5c02 network: add boolean for hs20 support
Since NAI realms, Roaming Consortium and HESSID are defined in 802.11,
they are not a guarentee that the network is Hotspot 2.0. The indication
element in addition to these IE's gives a better idea of Hotspot 2.0
support. Now, when a BSS is added this is_hs20 boolean will get set to
true if the HS20 IE was found in the BSS.

Now, if is_hs20 is set AND one of NAI realms, roaming consortium, or
HESSID is set we know this is a hotspot 2.0 network.
2019-07-21 15:17:05 -05:00
Denis Kenzior 46b85c00c1 netconfig: Use uint32 instead of unsigned int
For consistency, the type used to obtain the new length should be the
same as the passed in len parameter, which is uint32_t
2019-07-21 07:06:17 -05:00
Denis Kenzior d8c058f25f netconfig: Use uint32_t len instead of int 2019-07-21 07:05:51 -05:00
Tim Kourt 18119537f7 netconfig: Unify static and dynamic addressing APIs 2019-07-21 07:05:15 -05:00
Tim Kourt 2d007a25b6 netconfig: Differentiate the origin of the addresses.
The origin of the addresses is later used with the route
installations for the convenience of the user.
2019-07-21 07:05:14 -05:00
Tim Kourt 1c7e803dbb rtnlutil: Add utility to DUMP ipv4 routes 2019-07-21 07:04:32 -05:00
Tim Kourt 83db65e929 rtnlutil: Add utility to extract route attributes 2019-07-20 06:51:46 -05:00
Tim Kourt 56670755c1 netconfig: Refactor rtnl error handling
Keep the rtnl destruction code in one place as it will have a
few more usages in the future.
2019-07-20 05:53:15 -05:00
James Prestwood fd1a267313 scan: free hs20_ie 2019-07-18 23:35:35 -05:00
James Prestwood 0241fe81df sae: check minimum anti-clogging token size
It is possible for a zero-length anti-clogging token payload to cause
IWD to abort. If the length passed into sae_process_anti_clogging was
1, l_memdup would be called with a size of -1. This will cause malloc
to abort.

Fix this by checking for a minimum packet length and dropping the
packet if the length is too small.
2019-07-18 23:34:03 -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 a1699b1587 hotspot: add length check for roaming consortium
The hotspot spec specifically mentions the roaming consortium OI be
3 or 5 bytes long. This requirement also prevents potential buffer
overflows if the user were to configure a long roaming consortium OI.
2019-07-16 12:00:35 -05:00
Denis Kenzior 0f6d1ece78 eapol: Remove eapol_sm_set_protocol_version
Handshake state will now pick reasonable defaults
2019-07-15 21:45:58 -05:00
Denis Kenzior d984c605f7 handshake: Add handshake_state_set_protocol_version 2019-07-15 21:45:12 -05:00
Denis Kenzior f7e23b3512 eapolutil: Add 2010 EAP protocol version 2019-07-15 21:24:05 -05:00
Denis Kenzior 7ba4f53c57 scan: Make sure to reset triggered for aborted scans
If the scan was triggered and later aborted, make sure to reset the
triggered value when the CMD_NEW_SCAN_RESULTS event comes in.

src/station.c:station_enter_state() Old State: disconnected, new state: connecting
src/scan.c:scan_notify() Scan notification 33
src/station.c:station_netdev_event() Associating
src/scan.c:scan_notify() Scan notification 34
Aborting (signal 11) [/home/denkenz/iwd-master/src/iwd]
++++++++ backtrace ++++++++
 #0  0x7efd4d6a2ef0 in /lib64/libc.so.6
 #1  0x42b20d in scan_notify() at src/scan.c:1383
2019-07-15 15:58:03 -05:00
Denis Kenzior 5ff23af29e scan: Add extra scan_cancel debugs 2019-07-15 14:53:47 -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
Tim Kourt 6efc94ff5a resolve: Fix message argument
Previously, the argument was incorrectly passed by reference
instead of by value.
2019-07-15 14:06:26 -05:00
Denis Kenzior f557c7e6cd treewide: Use nl80211cmd_to_string
Using integer ids for event notifications received was hard to debug.
Use the nl80211cmd_to_string function to prettify these.
2019-07-15 14:06:26 -05:00
Denis Kenzior bb61e971e5 nl80211cmd: Introduce new utility 2019-07-15 14:06:26 -05:00
James Prestwood 090ac03100 ie: expose vendor OUIs
In the same fashion as the WSC WFA OUI, ie.[ch] will now expose the
other vendor OUIs to avoid duplication across multiple files in IWD
as well as used in iwmon.
2019-07-15 12:42:22 -05:00
Andrew Zaborowski 213d75b9bb scan: Process P2P IEs from scan results 2019-07-15 12:40:44 -05:00
Andrew Zaborowski cf684fdfa1 scan: Add option to use the NO_CCK scan flag
P2P probe requests are to be sent at min 6.0 Mb/s using OFDM,
specifically the 802.11b rates are prohibited (section 2.4.1 in Wi-Fi
P2p Technical Spec v1.7), some of which use CCK modulation.  This is
already the default for 5G but for 2.4G the drivers generally do this
if we set the NL80211_ATTR_TX_NO_CCK_RATE flags with
NL80211_CMD_TRIGGER_SCAN.
2019-07-15 11:36:34 -05:00
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