]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add wps_cancel for hostapd_cli
authorAnirban Sirkhell <anirban@qca.qualcomm.com>
Mon, 19 Mar 2012 06:23:31 +0000 (20:23 -1000)
committerJouni Malinen <j@w1.fi>
Fri, 30 Mar 2012 08:11:35 +0000 (11:11 +0300)
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>

hostapd/ctrl_iface.c
hostapd/hostapd_cli.c
src/ap/sta_info.c
src/ap/sta_info.h
src/ap/wps_hostapd.c
src/ap/wps_hostapd.h
wpa_supplicant/ap.c

index b1bafc10c82847997819f38510d25345db605de0..63fe557e453528e5b453a13fd94fc51975a140b0 100644 (file)
@@ -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))
index 89125fdf7c6eea9e2a34ef49ef7a6cd68f42cda4..e2d9f9f87c9515e0c39c5652076bef9f5b648fd7 100644 (file)
@@ -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 */
index c1c212bbffa91292f63537c4796496d442766369..d8b5621bc9224aa237cad8924ef53862d1fcd658 100644 (file)
@@ -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)
 {
index d3a0fe1a95fe05db599644dc50de06648c044068..2f3af1b5251cf7229cf22495339395bb451d715b 100644 (file)
@@ -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);
index 94eea255e9a4562633c14c0eb06730da7721d930..01038e9e24137b1e9ba5e52c8d5a3663fd6d33fc 100644 (file)
@@ -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)
index 91942250a4dfbccdc0e745b4ff3bba973458aea1..5f5d2f6d4feb307df0c978cd325ff793a959e4b3 100644 (file)
@@ -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 */
index d18e3f1c28ddef08abbd6117aee3955067063d17..66b0e1f8f9882d2ba5895d01353970bfe717fbbf 100644 (file)
@@ -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 "