Commit Graph

85 Commits

Author SHA1 Message Date
Andrew Zaborowski 19ab25f1d6 p2p: Send the right UUID-E in probe request WSC IEs
When building the scan IEs for our provisioning scans, use the UUID-E
based on the Interface Address, not the Device Address, as that is what
wsc.c will be using to in the registration protocol.

Eventually we may have to base the UUID-E on the Device Address or
something else that is persistent, and pass the actual UUID-E to wsc.c,
as the Interface Address is randomly generated on every connect attempt.
IIRC the UUID-E is supposed to be persistent.
2020-08-25 16:51:51 -05:00
Andrew Zaborowski 3910b9d9c3 p2p: Use a longer DHCP timeout
With some devices the 10 seconds are not enough for the P2P Group Owner
to give us an address but I think we still want to use a timeout as
short as possible so that the user doesn't wait too long if the
connection isn't working.
2020-07-31 10:38:59 -05:00
Andrew Zaborowski 2dea8bcc69 p2p: Set p2p_own_wfd->available by default
We need to set this flag true when the WFD service is first registered
as there's no WFD session and we're available for a new session.
2020-07-31 10:38:59 -05:00
Andrew Zaborowski c42de40a3b p2p: Add a null-check before use
p2p_connection_reset may be called as a result of a WFD service
unregistering and p2p_own_wfd is going to be NULL, don't update
p2p_own_wfd->available in this case.
2020-07-31 10:38:59 -05:00
Andrew Zaborowski 650e7715b1 p2p: Retry connect on "Previous authentication not valid"
With some WFD devices we occasionally get a Disconnect before or during
the DHCP setup on the first connection attempt to a newly formeg group,
with the reason code MMPDU_REASON_CODE_PREV_AUTH_NOT_VALID.  Retrying a
a few times makes the connections consistently successful.  Some
conditions are simplified/update in this patch because
conn_dhcp_timeout now implies conn_wsc_bss, and both imply
conn_retry_count.
2020-07-31 10:38:59 -05:00
Andrew Zaborowski 8faa0c1f0d frame-xchg: Re-add frame_xchg_stop
In 98cf2bf3ec frame_xchg_stop was removed
and its use in p2p.c was changed to frame_xchg_cancel with the slight
complication that the ID returned by frame_xchg_start had do be stored.
Re-add frame_xchg_stop, (renamed as frame_xchg_stop_wdev) to simplify
this bit in p2p.c.
2020-07-31 10:38:59 -05:00
Andrew Zaborowski 1f4b32ff53 p2p: Update call after frame-xchg changes 2020-07-21 08:59:24 -05:00
Andrew Zaborowski 07915485ed p2p: Add WFD IEs in GO Negotiation and association
This patch lets us establish WFD connections by parsing, validating and
acting on WFD IEs in received frames, and adding our own WFD IEs in the
GO Negotiation and Association frames.  Applications should assume that
any connection to a WFD-capable peer when we ourselves have a WFD
service registered, are WFD connections and should handle RTSP and
other IP-based protocols on those connections.

When connecting to a WFD-capable peer and when we have a WFD service
registered, the connection will fail if there are any conflicting or
invalid WFD parameters during GO Negotiation.
2020-07-16 10:48:43 -05:00
Andrew Zaborowski edf6b1b644 p2p: Add the p2p.Display interface on WFD-capable peers
If anyone's registered as implementing the WFD service, add the
net.connman.iwd.p2p.Display DBus interface on peer objects that are
WFD-capable and are available for a WFD Session.
2020-07-16 10:47:03 -05:00
Andrew Zaborowski 4cf5f5c4b6 p2p: Implement the p2p.ServiceManager interface
The net.connman.iwd.p2p.ServiceManager interface on the /net/connman/iwd
object lets user applications register/unregister the Wi-Fi Display
service.  In this commit all it does is it adds local WFD information
as given by the app, to the frames we send out during discovery.

Instead of accepting raw WFD IE contents from the app and exposing
peers' raw WFD IEs to the app, we build the WFD IEs in our code based on
the few meaningful DBus properties that we support and using default
values for the rest.  If an app ever needs any of the other WFD
capabilities more properties can be added.
2020-07-16 10:42:38 -05:00
Andrew Zaborowski 344fb528ab p2p: Add ConnectedInterface and ConnectedIP Peer properties
The are useful for P2P service implementations to know unambiguously
which network interface a new P2P connection is on and the peer's IPv4
address if they need to initiate an IP connection or validate an
incoming connection's address from the peer.
2020-07-13 14:53:38 -05:00
Andrew Zaborowski c8f4b9d98f p2p: Implement the Peer.Device property
Add the net.connman.iwd.p2p.Peer.Device property as listed in
doc/p2p-peer-api.txt
2020-07-13 14:12:44 -05:00
Andrew Zaborowski a09d7628dd p2p: Use nl80211_parse_attrs
Simplify p2p_device_update_from_genl by making use of nl80211_parse_attrs.
2020-07-13 14:11:07 -05:00
Andrew Zaborowski 09c9482045 p2p: Initialize dev->discovery_users in p2p_device_request_discovery
Make sure dev->discovery_users points at a queue before we try adding
user records to it.
2020-07-13 14:10:44 -05:00
Andrew Zaborowski 7d3092e1ca p2p: Update peer->device_addr when updating peer->bss
peer->device_addr is a pointer to the Device Address contained in
one of two possible places in peer->bss.  If during discovery we've
received a new beacon/probe response for an existing peer and we're
going to replace peer->bss, we also have to update peer->device_addr.
2020-07-13 14:09:42 -05:00
Andrew Zaborowski 122ea7a8aa p2p: Stop discovery after GO Negotiation Req error
If we were in discovery only to be able to receive the target peer's
GO Negotiation Request (i.e. we have no users requesting discovery)
and we've received the frame and decided that the connection has
failed, exit discovery.
2020-07-13 14:08:51 -05:00
James Prestwood 98cf2bf3ec frame-xchg: refactor to use wiphy work queue
In order to first integrate frame-xchg some refactoring needed to
be done. First it is useful to allow queueing frames up rather than
requiring the module (p2p, anqp etc) to wait for the last frame to
finish. This can be aided by radio management but frame-xchg needed
some refactoring as well.

First was getting rid of this fx pointer re-use. It looks like this
was done to save a bit of memory but things get pretty complex
needed to check if the pointer is stale or has been reset. Instead
of this we now just allocate a new pointer each frame-xchg. This
allows for the module to queue multiple requests as well as removes
the complexity of needed to check if the fx pointer is stale.

Next was adding the ability to track frame-xchgs by ID. If a module
can queue up multiple requests it also needs to be able to cancel
them individually vs per-wdev. This comes free with the wiphy work
queue since it returns an ID which can be given directly to the
caller.

Then radio management was simply piped in by adding the
insert/done APIs.
2020-07-09 09:58:16 -05:00
James Prestwood 05ad0120a8 frame-xchg: add destroy function to start() APIs
This makes things more consistent with other IWD APIs as well as
prepares for unifying frame-xchg and scanning.
2020-06-23 10:45:31 -05:00
Fabrice Fontaine 6bf5c3ddbd p2p: fix build with uclibc
explicit_bzero is used in src/p2p.c since commit
1675c765a3 but src/missing.h is not
included, as a result build with uclibc fails on:

/home/naourr/work/instance-0/output-1/per-package/iwd/host/opt/ext-toolchain/bin/../lib/gcc/mips64el-buildroot-linux-uclibc/5.5.0/../../../../mips64el-buildroot-linux-uclibc/bin/ld: src/p2p.o: in function `p2p_connection_reset':
p2p.c:(.text+0x2cf4): undefined reference to `explicit_bzero'
/home/naourr/work/instance-0/output-1/per-package/iwd/host/opt/ext-toolchain/bin/../lib/gcc/mips64el-buildroot-linux-uclibc/5.5.0/../../../../mips64el-buildroot-linux-uclibc/bin/ld: p2p.c:(.text+0x2cfc): undefined reference to `explicit_bzero'
2020-06-22 10:27:19 -05:00
Andrew Zaborowski c49b724a2e p2p: Do DHCP as part of connection setup
Use netconfig.c functions to unconditionally run DHCP negotiation,
fail the connection setup if DHCP fails.  Only report connection success
after netconfig returns.
2020-05-01 11:38:43 -05:00
Andrew Zaborowski 7a38085bf8 p2p: WSC client provisioning and connection
Add the final two steps of the connection setup, and corresponding
disconnect logic:

* the WSC connection to the GO to do the client provisioning,
* the netdev_connect call to use the provisioned credentials for the
  final WPA2 connection.
2020-04-27 13:53:15 -05:00
Andrew Zaborowski 85f09d9318 p2p: Create the P2P-Client interface
Once we've found the provisioning BSS create the P2P-Client interface
that we're going to use for the actual provisioning and the final P2P
connection.
2020-04-27 13:51:08 -05:00
Andrew Zaborowski d77fdd087b p2p: Scan for the provision BSS
Add the next step after Provision Discovery or GO Negotiation that is
scanning for the WSC BSS that the GO has set up for client provisioning.
2020-04-27 13:49:35 -05:00
Andrew Zaborowski ce4b1e1fcb p2p: Add the Provision Discovery frame sequence
When connecting to an existing group, use the Provision Discovery
Request/Response frame exchange before calling
p2p_start_client_provision().
2020-04-27 13:49:03 -05:00
Andrew Zaborowski fdf2b8a94c p2p: Respond to Probe Reqs when waiting for GO negotiation
Some devices (a Wi-Fi Display dongle in my case) will send us Probe
Requests and wait for a response before they send us the GO
Negotiation Request that we're waiting for after the peer initially
replied with "Fail: Information Not Available" to our GO Negotiation
attempt.  Curiously this specific device I tested would even accept
a Probe Response with a mangled body such that the IE sequence couldn't
be parsed.
2020-04-27 13:47:42 -05:00
Andrew Zaborowski bb4a3e8f84 p2p: Handle the Information Not Available response code
Handle the scenario where the peer's P2P state machine doesn't know
whether a connection has been authorized by the user and needs some time
to ask the user or a higher software layer whether to accept a
connection.  In that case their GO Negotiation Response to our GO
Negotiation Request will have the status code "Fail: Information Not
Available" and we need to give the peer 120s to start a new GO
Negotiation with us.  In this patch we handle the GO Negotiation
responder side where we parse the Request frame, build and send the
Response and finally parse the Confirmation.  The existing code so far
only did the initiator side.
2020-04-27 13:44:40 -05:00
Andrew Zaborowski bff4147d52 p2p: Handle GO Negotiation Response, send Confirmation
Parse the GO Negotiation Response frame and if no errors found send the
GO Negotiation Confirmation.  If that gets ACKed wait for the GO to set
up the group.
2020-04-27 13:43:21 -05:00
Andrew Zaborowski 3ef8688df5 p2p: Build and send the GO Negotiation Request 2020-04-27 13:43:12 -05:00
Andrew Zaborowski 1675c765a3 p2p: Add the WSC interface on peer DBus objects
Add net.connman.iwd.SimpleConfiguration interfaces to peer objects on
DBus and handle method calls.  Building and transmitting the actual
action frames to start the connection sequence is done in the following
commits.
2020-04-24 22:18:52 -05:00
Andrew Zaborowski 3d4725870d p2p: Add the Listen State
Start a remain-on-channel cmd implementing the Listen State, after each
the Scan Phase implemented as an active scan.
2020-04-24 22:16:43 -05:00
Andrew Zaborowski 6e98d8a888 p2p: Add the Scan Phase
Add some of the Device Discovery logic and the DBus API.  Device
Discovery is documented as having three states: the Scan Phase, the Find
Phase and the Listen State.

This patch adds the Scan Phase and the next patch adds the Listen State,
which will happen sequentially in a loop until discovery is stopped.

The Find Phase, which is documented as happening at the beginning of the
Discovery Phase, is incorporated into the Scan Phases.  The difference
between the two is that Find Phase scans all of the supported channels
while the Scan Phase only scans the three "social" channels.  In
practical terms the Find Phase would discover existing groups, which may
operate on any channel, while the Scan Phase will only discover P2P
Devices -- peers that are not in a group yet.  To cover existing groups,
we add a few "non-social" channels to each of our active scans
implementing the Scan Phases.
2020-04-24 11:42:46 -05:00
Andrew Zaborowski 59cc1e27c2 p2p: Add device enable/disable logic
Implement the Enabled property on device interface.  The P2P device is
currently disabled on startup but automatically enabling the P2P device
can be considered.
2020-04-24 11:36:54 -05:00
Andrew Zaborowski ff65e1fd9a p2p: Add main device settings
Read WSC configuration methods and the Primary Device Type from the
config file and expose device name as a property.
2020-04-24 11:35:30 -05:00
Andrew Zaborowski 945abadc8a p2p: Add peer WSC device type properties 2020-04-23 14:49:24 -05:00
Andrew Zaborowski 326a8cd6ee Add minimal p2p.c and p2p.h
Add the functions to be called by manager.c and a minimal DBus API.
2020-04-10 06:31:19 -05:00