diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2013-11-06 12:01:34 +0100 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2013-11-06 12:01:34 +0100 |
commit | 5f5442b6db684a8233bafc96fcd62ec3c2ca0d66 (patch) | |
tree | b30d312ad980047178ef478cb8decf44b3a8ac6b | |
parent | 487dbfcf2ddbbbcf2a929289f60313683eb65dec (diff) |
owfd: p2pd: acknowledge p2p-prov-disc-show-pin in dummy
As a workaround for the dummy client, acknowledge all P2P provision
discovery requests to show PINs with the related connect command.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
-rw-r--r-- | src/p2pd.h | 5 | ||||
-rw-r--r-- | src/p2pd_dummy.c | 18 | ||||
-rw-r--r-- | src/p2pd_interface.c | 23 |
3 files changed, 46 insertions, 0 deletions
@@ -94,6 +94,11 @@ void owfd_p2pd_interface_unregister_event_fn(struct owfd_p2pd_interface *iface, owfd_p2pd_interface_event_fn event_fn, void *data); +int owfd_p2pd_interface_connect(struct owfd_p2pd_interface *iface, + const char *peer_mac, + const char *pin, + const char *pin_mode); + /* dummy */ struct owfd_p2pd_dummy; diff --git a/src/p2pd_dummy.c b/src/p2pd_dummy.c index c862342..7e1bf5d 100644 --- a/src/p2pd_dummy.c +++ b/src/p2pd_dummy.c @@ -51,6 +51,24 @@ static void dummy_event_fn(struct owfd_p2pd_interface *iface, void *data) { struct owfd_p2pd_dummy *dummy = data; + int r; + + switch (ev->type) { + case OWFD_WPA_EVENT_P2P_PROV_DISC_SHOW_PIN: + r = owfd_p2pd_interface_connect(dummy->iface, + ev->p.p2p_prov_disc_show_pin.peer_mac, + ev->p.p2p_prov_disc_show_pin.pin, + "display"); + if (r < 0) { + log_error("cannot acknowledge SHOW-PIN with connect: %d", + r); + return; + } + + log_info("P2P SHOW-PIN acknowledged with connect"); + + break; + } } int owfd_p2pd_dummy_new(struct owfd_p2pd_dummy **out, diff --git a/src/p2pd_interface.c b/src/p2pd_interface.c index c1f1db1..6f1e56f 100644 --- a/src/p2pd_interface.c +++ b/src/p2pd_interface.c @@ -495,6 +495,29 @@ static int wpa_request(struct owfd_p2pd_interface *iface, const char *req, buf, len, -1); } +int owfd_p2pd_interface_connect(struct owfd_p2pd_interface *iface, + const char *peer_mac, + const char *pin, + const char *pin_mode) +{ + char *req; + int r; + + if (pin_mode) + r = asprintf(&req, "P2P_CONNECT %s %s %s", + peer_mac, pin, pin_mode); + else + r = asprintf(&req, "P2P_CONNECT %s %s", + peer_mac, pin); + + if (r < 0) + return -ENOMEM; + + r = wpa_request_ok(iface, req); + free(req); + return r; +} + static int wpa_setup(struct owfd_p2pd_interface *iface) { int r; |