aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hostapd/ctrl_iface.c3
-rw-r--r--hostapd/hostapd_cli.c9
-rw-r--r--hostapd/wps_hostapd.c6
-rw-r--r--hostapd/wps_hostapd.h1
-rw-r--r--src/wps/wps.h1
-rw-r--r--src/wps/wps_defs.h3
-rw-r--r--src/wps/wps_registrar.c41
7 files changed, 64 insertions, 0 deletions
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 6452952..e7f448a 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -318,6 +318,9 @@ static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
} else if (os_strncmp(buf, "WPS_PIN ", 8) == 0) {
if (hostapd_ctrl_iface_wps_pin(hapd, buf + 8))
reply_len = -1;
+ } else if (os_strcmp(buf, "WPS_PBC") == 0) {
+ if (hostapd_wps_button_pushed(hapd))
+ reply_len = -1;
#endif /* CONFIG_WPS */
} else {
os_memcpy(reply, "UNKNOWN COMMAND\n", 16);
diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c
index bd85513..e5285ae 100644
--- a/hostapd/hostapd_cli.c
+++ b/hostapd/hostapd_cli.c
@@ -85,6 +85,7 @@ static const char *commands_help =
" new_sta <addr> add a new station\n"
#ifdef CONFIG_WPS
" wps_pin <uuid> <pin> add WPS Enrollee PIN (Device Password)\n"
+" wps_pbc indicate button pushed to initiate PBC\n"
#endif /* CONFIG_WPS */
" help show this usage help\n"
" interface [ifname] show interfaces/select interface\n"
@@ -246,6 +247,13 @@ static int hostapd_cli_cmd_wps_pin(struct wpa_ctrl *ctrl, int argc,
snprintf(buf, sizeof(buf), "WPS_PIN %s %s", argv[0], argv[1]);
return wpa_ctrl_command(ctrl, buf);
}
+
+
+static int hostapd_cli_cmd_wps_pbc(struct wpa_ctrl *ctrl, int argc,
+ char *argv[])
+{
+ return wpa_ctrl_command(ctrl, "WPS_PBC");
+}
#endif /* CONFIG_WPS */
@@ -399,6 +407,7 @@ static struct hostapd_cli_cmd hostapd_cli_commands[] = {
{ "new_sta", hostapd_cli_cmd_new_sta },
#ifdef CONFIG_WPS
{ "wps_pin", hostapd_cli_cmd_wps_pin },
+ { "wps_pbc", hostapd_cli_cmd_wps_pbc },
#endif /* CONFIG_WPS */
{ "help", hostapd_cli_cmd_help },
{ "interface", hostapd_cli_cmd_interface },
diff --git a/hostapd/wps_hostapd.c b/hostapd/wps_hostapd.c
index f61aba4..adb1a37 100644
--- a/hostapd/wps_hostapd.c
+++ b/hostapd/wps_hostapd.c
@@ -254,3 +254,9 @@ int hostapd_wps_add_pin(struct hostapd_data *hapd, const char *uuid,
return wps_registrar_add_pin(hapd->wps_registrar, u,
(const u8 *) pin, os_strlen(pin));
}
+
+
+int hostapd_wps_button_pushed(struct hostapd_data *hapd)
+{
+ return wps_registrar_button_pushed(hapd->wps_registrar);
+}
diff --git a/hostapd/wps_hostapd.h b/hostapd/wps_hostapd.h
index 6497c75..621cc82 100644
--- a/hostapd/wps_hostapd.h
+++ b/hostapd/wps_hostapd.h
@@ -22,6 +22,7 @@ int hostapd_init_wps(struct hostapd_data *hapd,
void hostapd_deinit_wps(struct hostapd_data *hapd);
int hostapd_wps_add_pin(struct hostapd_data *hapd, const char *uuid,
const char *pin);
+int hostapd_wps_button_pushed(struct hostapd_data *hapd);
#else /* CONFIG_WPS */
diff --git a/src/wps/wps.h b/src/wps/wps.h
index 0e94861..3a53716 100644
--- a/src/wps/wps.h
+++ b/src/wps/wps.h
@@ -89,6 +89,7 @@ int wps_registrar_add_pin(struct wps_registrar *reg, const u8 *uuid,
const u8 *pin, size_t pin_len);
int wps_registrar_invalidate_pin(struct wps_registrar *reg, const u8 *uuid);
int wps_registrar_unlock_pin(struct wps_registrar *reg, const u8 *uuid);
+int wps_registrar_button_pushed(struct wps_registrar *reg);
struct wpabuf * wps_enrollee_build_assoc_req_ie(void);
diff --git a/src/wps/wps_defs.h b/src/wps/wps_defs.h
index ade752d..c5d4860 100644
--- a/src/wps/wps_defs.h
+++ b/src/wps/wps_defs.h
@@ -288,4 +288,7 @@ enum wps_response_type {
WPS_RESP_AP = 3
};
+/* Walk Time for push button configuration (in seconds) */
+#define WPS_PBC_WALK_TIME 120
+
#endif /* WPS_DEFS_H */
diff --git a/src/wps/wps_registrar.c b/src/wps/wps_registrar.c
index c6c8cb3..f67c1eb 100644
--- a/src/wps/wps_registrar.c
+++ b/src/wps/wps_registrar.c
@@ -17,6 +17,7 @@
#include "common.h"
#include "sha256.h"
#include "ieee802_11_defs.h"
+#include "eloop.h"
#include "wps_i.h"
@@ -75,6 +76,7 @@ struct wps_registrar {
static int wps_set_ie(struct wps_registrar *reg);
static int wps_build_version(struct wpabuf *msg);
+static void wps_registrar_pbc_timeout(void *eloop_ctx, void *timeout_ctx);
static int wps_build_wps_state(struct wps_registrar *reg, struct wpabuf *msg)
@@ -306,6 +308,7 @@ void wps_registrar_deinit(struct wps_registrar *reg)
{
if (reg == NULL)
return;
+ eloop_cancel_timeout(wps_registrar_pbc_timeout, reg, NULL);
os_free(reg->network_key);
wps_free_pins(reg->pins);
os_free(reg);
@@ -412,6 +415,41 @@ int wps_registrar_unlock_pin(struct wps_registrar *reg, const u8 *uuid)
}
+static void wps_registrar_pbc_timeout(void *eloop_ctx, void *timeout_ctx)
+{
+ struct wps_registrar *reg = eloop_ctx;
+
+ wpa_printf(MSG_DEBUG, "WPS: PBC timed out - disable PBC mode");
+ reg->selected_registrar = 0;
+ reg->pbc = 0;
+ wps_set_ie(reg);
+}
+
+
+int wps_registrar_button_pushed(struct wps_registrar *reg)
+{
+ wpa_printf(MSG_DEBUG, "WPS: Button pushed - PBC mode started");
+ reg->selected_registrar = 1;
+ reg->pbc = 1;
+ wps_set_ie(reg);
+
+ eloop_cancel_timeout(wps_registrar_pbc_timeout, reg, NULL);
+ eloop_register_timeout(WPS_PBC_WALK_TIME, 0, wps_registrar_pbc_timeout,
+ reg, NULL);
+ return 0;
+}
+
+
+static void wps_registrar_pbc_completed(struct wps_registrar *reg)
+{
+ wpa_printf(MSG_DEBUG, "WPS: PBC completed - stopping PBC mode");
+ eloop_cancel_timeout(wps_registrar_pbc_timeout, reg, NULL);
+ reg->selected_registrar = 0;
+ reg->pbc = 0;
+ wps_set_ie(reg);
+}
+
+
static int wps_cb_new_psk(struct wps_registrar *reg, const u8 *mac_addr,
const u8 *psk, size_t psk_len)
{
@@ -1737,6 +1775,9 @@ static enum wps_process_res wps_process_wsc_done(struct wps_data *wps,
wps->new_psk = NULL;
}
+ if (wps->pbc)
+ wps_registrar_pbc_completed(wps->registrar);
+
return WPS_DONE;
}