P2P: Allow WPS_PBC command on GO to select on P2P Device Address
[mech_eap.git] / src / eap_server / eap_server_wsc.c
index 28d4f67..e944a4d 100644 (file)
@@ -18,6 +18,7 @@
 #include "eloop.h"
 #include "eap_i.h"
 #include "eap_common/eap_wsc_common.h"
+#include "p2p/p2p.h"
 #include "wps/wps.h"
 
 
@@ -128,14 +129,21 @@ static void * eap_wsc_init(struct eap_sm *sm)
                        wpa_printf(MSG_DEBUG, "EAP-WSC: No AP PIN (password) "
                                   "configured for Enrollee functionality - "
                                   "allow for probing capabilities (M1)");
+               } else {
+                       cfg.pin = sm->user->password;
+                       cfg.pin_len = sm->user->password_len;
                }
-               cfg.pin = sm->user->password;
-               cfg.pin_len = sm->user->password_len;
        }
        cfg.assoc_wps_ie = sm->assoc_wps_ie;
        cfg.peer_addr = sm->peer_addr;
-       if (0 /* TODO: could provide option for forcing PSK format */)
-                cfg.use_psk_key = 1;
+#ifdef CONFIG_P2P
+       if (sm->assoc_p2p_ie) {
+               wpa_printf(MSG_DEBUG, "EAP-WSC: Prefer PSK format for P2P "
+                          "client");
+               cfg.use_psk_key = 1;
+               cfg.p2p_dev_addr = p2p_get_go_dev_addr(sm->assoc_p2p_ie);
+       }
+#endif /* CONFIG_P2P */
        data->wps = wps_init(&cfg);
        if (data->wps == NULL) {
                os_free(data);