diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2013-10-29 16:12:10 +0100 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2013-10-29 16:12:10 +0100 |
commit | bce0f12ba793c8505dfe31bcd40d2dea22bba335 (patch) | |
tree | c4fb97cd7245d4e96cfc0886a545293371e3a387 | |
parent | 361cfe0d536dd6b12b8a3c911fee62f10d8ecbeb (diff) |
owfd: p2pd: setup wpa_supplicant
Set basic parameters so we can perform p2p and wifi-display operations.
Fail is the stack doesn't support either.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
-rw-r--r-- | src/p2pd_interface.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/p2pd_interface.c b/src/p2pd_interface.c index fd26f12..8a17864 100644 --- a/src/p2pd_interface.c +++ b/src/p2pd_interface.c @@ -48,6 +48,7 @@ struct owfd_p2pd_interface { pid_t pid; }; +static int wpa_setup(struct owfd_p2pd_interface *iface); static void wpa_event(struct owfd_wpa_ctrl *wpa, void *buf, size_t len, void *data); @@ -304,6 +305,11 @@ static int fork_wpa(struct owfd_p2pd_interface *iface) } free(ctrl); + + r = wpa_setup(iface); + if (r < 0) + return r; + return 0; } @@ -421,6 +427,52 @@ int owfd_p2pd_interface_dispatch_chld(struct owfd_p2pd_interface *iface, return OWFD_P2PD_EP_QUIT; } +static int wpa_request_ok(struct owfd_p2pd_interface *iface, const char *req) +{ + return owfd_wpa_ctrl_request_ok(iface->wpa, req, strlen(req), -1); +} + +static int wpa_request(struct owfd_p2pd_interface *iface, const char *req, + char *buf, size_t *len) +{ + return owfd_wpa_ctrl_request(iface->wpa, req, strlen(req), + buf, len, -1); +} + +static int wpa_setup(struct owfd_p2pd_interface *iface) +{ + int r; + char buf[128]; + size_t len; + + len = sizeof(buf); + r = wpa_request(iface, "GET wifi_display", buf, &len); + if (r < 0 || len != 1 || *buf != '1') + goto err_notsupp; + + r = wpa_request_ok(iface, "SET ap_scan 1"); + if (r < 0) + goto err_notsupp; + + r = wpa_request_ok(iface, "SET device_name some-random-name"); + if (r < 0) + goto err_notsupp; + + r = wpa_request_ok(iface, "SET device_type 1-0050F204-1"); + if (r < 0) + goto err_notsupp; + + r = wpa_request_ok(iface, "SET wifi_display 1"); + if (r < 0) + goto err_notsupp; + + return 0; + +err_notsupp: + log_error("wpa-setup failed; wifi-display probably not supported by adapter or wpa_supplicant"); + return -ENODEV; +} + static void wpa_event(struct owfd_wpa_ctrl *wpa, void *buf, size_t len, void *data) { |