]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: Move from WLAN_STA_MAYBE_WPS to WLAN_STA_WPS based on EAP messages
authorJouni Malinen <jouni.malinen@atheros.com>
Tue, 6 Jul 2010 22:29:33 +0000 (15:29 -0700)
committerJouni Malinen <j@w1.fi>
Sun, 18 Jul 2010 23:10:08 +0000 (16:10 -0700)
If the station does not include WSC IE in Association Request, it
is marked with WLAN_STA_MAYBE_WPS flag. We can update that to
WLAN_STA_WPS if the station uses either of the WPS identity strings.
This enables some workarounds for WPS stations.

src/ap/ieee802_1x.c

index 4ab100150c456bf22e979e7a8f655a46e51a2298..eb160f8e015c0855bf153d14099276109f12ee49 100644 (file)
@@ -23,6 +23,7 @@
 #include "radius/radius.h"
 #include "radius/radius_client.h"
 #include "eap_server/eap.h"
+#include "eap_common/eap_wsc_common.h"
 #include "eapol_auth/eapol_auth_sm.h"
 #include "eapol_auth/eapol_auth_sm_i.h"
 #include "hostapd.h"
@@ -1455,6 +1456,30 @@ static void ieee802_1x_rekey(void *eloop_ctx, void *timeout_ctx)
 static void ieee802_1x_eapol_send(void *ctx, void *sta_ctx, u8 type,
                                  const u8 *data, size_t datalen)
 {
+#ifdef CONFIG_WPS
+       struct sta_info *sta = sta_ctx;
+
+       if ((sta->flags & (WLAN_STA_WPS | WLAN_STA_MAYBE_WPS)) ==
+           WLAN_STA_MAYBE_WPS) {
+               const u8 *identity;
+               size_t identity_len;
+               struct eapol_state_machine *sm = sta->eapol_sm;
+
+               identity = eap_get_identity(sm->eap, &identity_len);
+               if (identity &&
+                   ((identity_len == WSC_ID_ENROLLEE_LEN &&
+                     os_memcmp(identity, WSC_ID_ENROLLEE,
+                               WSC_ID_ENROLLEE_LEN) == 0) ||
+                    (identity_len == WSC_ID_REGISTRAR_LEN &&
+                     os_memcmp(identity, WSC_ID_REGISTRAR,
+                               WSC_ID_REGISTRAR_LEN) == 0))) {
+                       wpa_printf(MSG_DEBUG, "WPS: WLAN_STA_MAYBE_WPS -> "
+                                  "WLAN_STA_WPS");
+                       sta->flags |= WLAN_STA_WPS;
+               }
+       }
+#endif /* CONFIG_WPS */
+
        ieee802_1x_send(ctx, sta_ctx, type, data, datalen);
 }