Add wps_cancel for hostapd_cli
Implement wps_cancel for hostapd similarly to how it was already supported in wpa_supplicant AP mode. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
parent
21d996f775
commit
4c374cde2f
7 changed files with 57 additions and 16 deletions
|
@ -755,6 +755,9 @@ static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
|
|||
} else if (os_strcmp(buf, "WPS_PBC") == 0) {
|
||||
if (hostapd_wps_button_pushed(hapd, NULL))
|
||||
reply_len = -1;
|
||||
} else if (os_strcmp(buf, "WPS_CANCEL") == 0) {
|
||||
if (hostapd_wps_cancel(hapd))
|
||||
reply_len = -1;
|
||||
#ifdef CONFIG_WPS_OOB
|
||||
} else if (os_strncmp(buf, "WPS_OOB ", 8) == 0) {
|
||||
if (hostapd_ctrl_iface_wps_oob(hapd, buf + 8))
|
||||
|
|
|
@ -392,6 +392,13 @@ static int hostapd_cli_cmd_wps_pbc(struct wpa_ctrl *ctrl, int argc,
|
|||
}
|
||||
|
||||
|
||||
static int hostapd_cli_cmd_wps_cancel(struct wpa_ctrl *ctrl, int argc,
|
||||
char *argv[])
|
||||
{
|
||||
return wpa_ctrl_command(ctrl, "WPS_CANCEL");
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_WPS_OOB
|
||||
static int hostapd_cli_cmd_wps_oob(struct wpa_ctrl *ctrl, int argc,
|
||||
char *argv[])
|
||||
|
@ -719,6 +726,7 @@ static struct hostapd_cli_cmd hostapd_cli_commands[] = {
|
|||
{ "wps_pin", hostapd_cli_cmd_wps_pin },
|
||||
{ "wps_check_pin", hostapd_cli_cmd_wps_check_pin },
|
||||
{ "wps_pbc", hostapd_cli_cmd_wps_pbc },
|
||||
{ "wps_cancel", hostapd_cli_cmd_wps_cancel },
|
||||
#ifdef CONFIG_WPS_OOB
|
||||
{ "wps_oob", hostapd_cli_cmd_wps_oob },
|
||||
#endif /* CONFIG_WPS_OOB */
|
||||
|
|
|
@ -592,6 +592,23 @@ void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta,
|
|||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_WPS
|
||||
int ap_sta_wps_cancel(struct hostapd_data *hapd,
|
||||
struct sta_info *sta, void *ctx)
|
||||
{
|
||||
if (sta && (sta->flags & WLAN_STA_WPS)) {
|
||||
ap_sta_deauthenticate(hapd, sta,
|
||||
WLAN_REASON_PREV_AUTH_NOT_VALID);
|
||||
wpa_printf(MSG_DEBUG, "WPS: %s: Deauth sta=" MACSTR,
|
||||
__func__, MAC2STR(sta->addr));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_WPS */
|
||||
|
||||
|
||||
int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
int old_vlanid)
|
||||
{
|
||||
|
|
|
@ -156,6 +156,10 @@ void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta,
|
|||
u16 reason);
|
||||
void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
u16 reason);
|
||||
#ifdef CONFIG_WPS
|
||||
int ap_sta_wps_cancel(struct hostapd_data *hapd,
|
||||
struct sta_info *sta, void *ctx);
|
||||
#endif /* CONFIG_WPS */
|
||||
int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
int old_vlanid);
|
||||
void ap_sta_start_sa_query(struct hostapd_data *hapd, struct sta_info *sta);
|
||||
|
|
|
@ -1104,6 +1104,24 @@ int hostapd_wps_button_pushed(struct hostapd_data *hapd,
|
|||
}
|
||||
|
||||
|
||||
static int wps_cancel(struct hostapd_data *hapd, void *ctx)
|
||||
{
|
||||
if (hapd->wps == NULL)
|
||||
return 0;
|
||||
|
||||
wps_registrar_wps_cancel(hapd->wps->registrar);
|
||||
ap_for_each_sta(hapd, ap_sta_wps_cancel, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int hostapd_wps_cancel(struct hostapd_data *hapd)
|
||||
{
|
||||
return hostapd_wps_for_each(hapd, wps_cancel, NULL);
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_WPS_OOB
|
||||
int hostapd_wps_start_oob(struct hostapd_data *hapd, char *device_type,
|
||||
char *path, char *method, char *name)
|
||||
|
|
|
@ -20,6 +20,7 @@ int hostapd_wps_add_pin(struct hostapd_data *hapd, const u8 *addr,
|
|||
const char *uuid, const char *pin, int timeout);
|
||||
int hostapd_wps_button_pushed(struct hostapd_data *hapd,
|
||||
const u8 *p2p_dev_addr);
|
||||
int hostapd_wps_cancel(struct hostapd_data *hapd);
|
||||
int hostapd_wps_start_oob(struct hostapd_data *hapd, char *device_type,
|
||||
char *path, char *method, char *name);
|
||||
int hostapd_wps_get_mib_sta(struct hostapd_data *hapd, const u8 *addr,
|
||||
|
@ -67,6 +68,11 @@ static inline int hostapd_wps_button_pushed(struct hostapd_data *hapd,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline int hostapd_wps_cancel(struct hostapd_data *hapd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_WPS */
|
||||
|
||||
#endif /* WPS_HOSTAPD_H */
|
||||
|
|
|
@ -659,21 +659,6 @@ int wpa_supplicant_ap_wps_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid,
|
|||
}
|
||||
|
||||
|
||||
static int wpa_supplicant_ap_wps_sta_cancel(struct hostapd_data *hapd,
|
||||
struct sta_info *sta, void *ctx)
|
||||
{
|
||||
if (sta && (sta->flags & WLAN_STA_WPS)) {
|
||||
ap_sta_deauthenticate(hapd, sta,
|
||||
WLAN_REASON_PREV_AUTH_NOT_VALID);
|
||||
wpa_printf(MSG_DEBUG, "WPS: %s: Deauth sta=" MACSTR,
|
||||
__func__, MAC2STR(sta->addr));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int wpa_supplicant_ap_wps_cancel(struct wpa_supplicant *wpa_s)
|
||||
{
|
||||
struct wps_registrar *reg;
|
||||
|
@ -685,7 +670,7 @@ int wpa_supplicant_ap_wps_cancel(struct wpa_supplicant *wpa_s)
|
|||
reg = wpa_s->ap_iface->bss[0]->wps->registrar;
|
||||
reg_sel = wps_registrar_wps_cancel(reg);
|
||||
wps_sta = ap_for_each_sta(wpa_s->ap_iface->bss[0],
|
||||
wpa_supplicant_ap_wps_sta_cancel, NULL);
|
||||
ap_sta_wps_cancel, NULL);
|
||||
|
||||
if (!reg_sel && !wps_sta) {
|
||||
wpa_printf(MSG_DEBUG, "No WPS operation in progress at this "
|
||||
|
|
Loading…
Reference in a new issue