]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: SelectedRegistrar expiration for internal PIN registrar
authorAndriy Tkachuk <andriy.v.tkachuk@globallogic.com>
Sun, 1 Nov 2009 20:19:02 +0000 (22:19 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 1 Nov 2009 20:19:02 +0000 (22:19 +0200)
Though we have such a timeout when handling SetSelectedRegistrar UPnP
message from an external registrar, it looks like we don't have one when
the internal registrar is activated for PIN connection. Thus we set the
SelectedRegistrar flag when AP is activated for PIN connection but we
never reset it - not by some timeout, nor when registration succeeds.
This lead to situations where AP everlastingly declare that it is
activated for WPS PIN connection when in reality it is not.

Use the same timeout (and also success with PIN) to clear the selected
registrar flag when using internal registrar, too.

src/wps/wps_registrar.c

index 9b66d9361e06d25aa5c84280c640cf6ea5bf7d01..6bd9dc135910c860259340d9cc13e01535f74520 100644 (file)
@@ -536,6 +536,10 @@ int wps_registrar_add_pin(struct wps_registrar *reg, const u8 *uuid,
        reg->selected_registrar = 1;
        reg->pbc = 0;
        wps_set_ie(reg);
+       eloop_cancel_timeout(wps_registrar_set_selected_timeout, reg, NULL);
+       eloop_register_timeout(WPS_PBC_WALK_TIME, 0,
+                              wps_registrar_set_selected_timeout,
+                              reg, NULL);
 
        return 0;
 }
@@ -736,6 +740,14 @@ static void wps_registrar_pbc_completed(struct wps_registrar *reg)
        wps_registrar_stop_pbc(reg);
 }
 
+static void wps_registrar_pin_completed(struct wps_registrar *reg)
+{
+       wpa_printf(MSG_DEBUG, "WPS: PIN completed using internal Registrar");
+       eloop_cancel_timeout(wps_registrar_set_selected_timeout, reg, NULL);
+       reg->selected_registrar = 0;
+       wps_set_ie(reg);
+}
+
 
 /**
  * wps_registrar_probe_req_rx - Notify Registrar of Probe Request
@@ -2587,6 +2599,8 @@ static enum wps_process_res wps_process_wsc_done(struct wps_data *wps,
                wps_registrar_remove_pbc_session(wps->wps->registrar,
                                                 wps->mac_addr_e, wps->uuid_e);
                wps_registrar_pbc_completed(wps->wps->registrar);
+       } else {
+               wps_registrar_pin_completed(wps->wps->registrar);
        }
 
        wps_success_event(wps->wps);