]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: Indicate PBC session overlap in wps_pbc return value
authorChao-Wen Yang <Chao-Wen.Yang@Atheros.com>
Thu, 10 Mar 2011 16:59:51 +0000 (18:59 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 10 Mar 2011 16:59:51 +0000 (18:59 +0200)
Use a specific return value, WPS-PBC-OVERLAP, to indicate a reason
for rejecting a wps_pbc command in wpa_supplicant AP mode if the
PBC mode cannot be started due to PBC session overlap having been
detected during monitor time.

src/wps/wps_registrar.c
wpa_supplicant/ctrl_iface.c

index c585fb926f1714d1382b264c07544bbbfab991d6..ff4cc59ae49bea5bde56b86d84d4ce18d6654e0a 100644 (file)
@@ -873,11 +873,14 @@ static void wps_registrar_pbc_timeout(void *eloop_ctx, void *timeout_ctx)
  * @reg: Registrar data from wps_registrar_init()
  * @p2p_dev_addr: Limit allowed PBC devices to the specified P2P device, %NULL
  *     indicates no such filtering
- * Returns: 0 on success, -1 on failure
+ * Returns: 0 on success, -1 on failure, -2 on session overlap
  *
  * This function is called on an AP when a push button is pushed to activate
  * PBC mode. The PBC mode will be stopped after walk time (2 minutes) timeout
- * or when a PBC registration is completed.
+ * or when a PBC registration is completed. If more than one Enrollee in active
+ * PBC mode has been detected during the monitor time (previous 2 minutes), the
+ * PBC mode is not actived and -2 is returned to indicate session overlap. This
+ * is skipped if a specific Enrollee is selected.
  */
 int wps_registrar_button_pushed(struct wps_registrar *reg,
                                const u8 *p2p_dev_addr)
@@ -887,7 +890,7 @@ int wps_registrar_button_pushed(struct wps_registrar *reg,
                wpa_printf(MSG_DEBUG, "WPS: PBC overlap - do not start PBC "
                           "mode");
                wps_pbc_overlap_event(reg->wps);
-               return -1;
+               return -2;
        }
        wpa_printf(MSG_DEBUG, "WPS: Button pushed - PBC mode started");
        reg->force_pbc_overlap = 0;
index ed9a7666a990e54b1828dc89eb5f8c95716dec34..9f06115803771f8e50edbb6cf02d3bdd35beaaa4 100644 (file)
@@ -2929,10 +2929,18 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
 #endif /* CONFIG_IEEE80211R */
 #ifdef CONFIG_WPS
        } else if (os_strcmp(buf, "WPS_PBC") == 0) {
-               if (wpa_supplicant_ctrl_iface_wps_pbc(wpa_s, NULL))
+               int res = wpa_supplicant_ctrl_iface_wps_pbc(wpa_s, NULL);
+               if (res == -2) {
+                       os_memcpy(reply, "FAIL-PBC-OVERLAP\n", 17);
+                       reply_len = 17;
+               } else if (res)
                        reply_len = -1;
        } else if (os_strncmp(buf, "WPS_PBC ", 8) == 0) {
-               if (wpa_supplicant_ctrl_iface_wps_pbc(wpa_s, buf + 8))
+               int res = wpa_supplicant_ctrl_iface_wps_pbc(wpa_s, buf + 8);
+               if (res == -2) {
+                       os_memcpy(reply, "FAIL-PBC-OVERLAP\n", 17);
+                       reply_len = 17;
+               } else if (res)
                        reply_len = -1;
        } else if (os_strncmp(buf, "WPS_PIN ", 8) == 0) {
                reply_len = wpa_supplicant_ctrl_iface_wps_pin(wpa_s, buf + 8,