]> git.ipfire.org Git - thirdparty/hostap.git/blobdiff - src/eap_peer/eap.c
Added preliminary Wi-Fi Protected Setup (WPS) implementation
[thirdparty/hostap.git] / src / eap_peer / eap.c
index e518ec3a7d7bad3d377a015c2a8ef94b295e2dd1..2627faa26a13f72f5796fa3f79abe9d2a28b9309 100644 (file)
@@ -31,6 +31,7 @@
 #include "pcsc_funcs.h"
 #include "wpa_ctrl.h"
 #include "state_machine.h"
+#include "eap_common/eap_wsc_common.h"
 
 #define STATE_MACHINE_DATA struct eap_sm
 #define STATE_MACHINE_DEBUG_PREFIX "EAP"
@@ -2043,3 +2044,29 @@ void eap_invalidate_cached_session(struct eap_sm *sm)
        if (sm)
                eap_deinit_prev_method(sm, "invalidate");
 }
+
+
+int eap_is_wps_pbc_enrollee(struct eap_peer_config *conf)
+{
+       if (conf->identity_len != WSC_ID_ENROLLEE_LEN ||
+           os_memcmp(conf->identity, WSC_ID_ENROLLEE, WSC_ID_ENROLLEE_LEN))
+               return 0; /* Not a WPS Enrollee */
+
+       if (conf->phase1 == NULL || os_strstr(conf->phase1, "pbc=1") == NULL)
+               return 0; /* Not using PBC */
+
+       return 1;
+}
+
+
+int eap_is_wps_pin_enrollee(struct eap_peer_config *conf)
+{
+       if (conf->identity_len != WSC_ID_ENROLLEE_LEN ||
+           os_memcmp(conf->identity, WSC_ID_ENROLLEE, WSC_ID_ENROLLEE_LEN))
+               return 0; /* Not a WPS Enrollee */
+
+       if (conf->phase1 == NULL || os_strstr(conf->phase1, "pin=") == NULL)
+               return 0; /* Not using PIN */
+
+       return 1;
+}