1ceabc9638bd7d619f87e78e5f24410c82bc0647
[libeap.git] / wpa_supplicant / wps_supplicant.c
1 /*
2  * wpa_supplicant / WPS integration
3  * Copyright (c) 2008, Jouni Malinen <j@w1.fi>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  *
9  * Alternatively, this software may be distributed under the terms of BSD
10  * license.
11  *
12  * See README and COPYING for more details.
13  */
14
15 #include "includes.h"
16
17 #include "common.h"
18 #include "ieee802_11_defs.h"
19 #include "wpa_common.h"
20 #include "config.h"
21 #include "eap_peer/eap.h"
22 #include "wpa_supplicant_i.h"
23 #include "eloop.h"
24 #include "wpa_ctrl.h"
25 #include "eap_common/eap_wsc_common.h"
26 #include "wps/wps.h"
27 #include "wps/wps_defs.h"
28 #include "wps_supplicant.h"
29
30
31 static void wpas_wps_timeout(void *eloop_ctx, void *timeout_ctx);
32 static void wpas_clear_wps(struct wpa_supplicant *wpa_s);
33
34
35 int wpas_wps_eapol_cb(struct wpa_supplicant *wpa_s)
36 {
37         eloop_cancel_timeout(wpas_wps_timeout, wpa_s, NULL);
38
39         if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPS && wpa_s->current_ssid &&
40             !(wpa_s->current_ssid->key_mgmt & WPA_KEY_MGMT_WPS)) {
41                 wpa_printf(MSG_DEBUG, "WPS: Network configuration replaced - "
42                            "try to associate with the received credential");
43                 wpa_supplicant_deauthenticate(wpa_s,
44                                               WLAN_REASON_DEAUTH_LEAVING);
45                 wpa_s->reassociate = 1;
46                 wpa_supplicant_req_scan(wpa_s, 0, 0);
47                 return 1;
48         }
49
50         return 0;
51 }
52
53
54 static int wpa_supplicant_wps_cred(void *ctx,
55                                    const struct wps_credential *cred)
56 {
57         struct wpa_supplicant *wpa_s = ctx;
58         struct wpa_ssid *ssid = wpa_s->current_ssid;
59
60         wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_CRED_RECEIVED);
61
62         if (ssid && (ssid->key_mgmt & WPA_KEY_MGMT_WPS)) {
63                 wpa_printf(MSG_DEBUG, "WPS: Replace WPS network block based "
64                            "on the received credential");
65                 os_free(ssid->eap.identity);
66                 ssid->eap.identity = NULL;
67                 ssid->eap.identity_len = 0;
68                 os_free(ssid->eap.phase1);
69                 ssid->eap.phase1 = NULL;
70                 os_free(ssid->eap.eap_methods);
71                 ssid->eap.eap_methods = NULL;
72         } else {
73                 wpa_printf(MSG_DEBUG, "WPS: Create a new network based on the "
74                            "received credential");
75                 ssid = wpa_config_add_network(wpa_s->conf);
76                 if (ssid == NULL)
77                         return -1;
78         }
79
80         wpa_config_set_network_defaults(ssid);
81
82         os_free(ssid->ssid);
83         ssid->ssid = os_malloc(cred->ssid_len);
84         if (ssid->ssid) {
85                 os_memcpy(ssid->ssid, cred->ssid, cred->ssid_len);
86                 ssid->ssid_len = cred->ssid_len;
87         }
88
89         switch (cred->encr_type) {
90         case WPS_ENCR_NONE:
91                 ssid->pairwise_cipher = ssid->group_cipher = WPA_CIPHER_NONE;
92                 break;
93         case WPS_ENCR_WEP:
94                 ssid->pairwise_cipher = ssid->group_cipher =
95                         WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104;
96                 if (cred->key_len > 0 && cred->key_len <= MAX_WEP_KEY_LEN &&
97                     cred->key_idx < NUM_WEP_KEYS) {
98                         os_memcpy(ssid->wep_key[cred->key_idx], cred->key,
99                                   cred->key_len);
100                         ssid->wep_key_len[cred->key_idx] = cred->key_len;
101                         ssid->wep_tx_keyidx = cred->key_idx;
102                 }
103                 break;
104         case WPS_ENCR_TKIP:
105                 ssid->pairwise_cipher = WPA_CIPHER_TKIP;
106                 ssid->group_cipher = WPA_CIPHER_TKIP;
107                 break;
108         case WPS_ENCR_AES:
109                 ssid->pairwise_cipher = WPA_CIPHER_CCMP;
110                 ssid->group_cipher = WPA_CIPHER_CCMP | WPA_CIPHER_TKIP;
111                 break;
112         }
113
114         switch (cred->auth_type) {
115         case WPS_AUTH_OPEN:
116                 ssid->auth_alg = WPA_AUTH_ALG_OPEN;
117                 ssid->key_mgmt = WPA_KEY_MGMT_NONE;
118                 ssid->proto = 0;
119                 break;
120         case WPS_AUTH_SHARED:
121                 ssid->auth_alg = WPA_AUTH_ALG_SHARED;
122                 ssid->key_mgmt = WPA_KEY_MGMT_NONE;
123                 ssid->proto = 0;
124                 break;
125         case WPS_AUTH_WPAPSK:
126                 ssid->auth_alg = WPA_AUTH_ALG_OPEN;
127                 ssid->key_mgmt = WPA_KEY_MGMT_PSK;
128                 ssid->proto = WPA_PROTO_WPA;
129                 break;
130         case WPS_AUTH_WPA:
131                 ssid->auth_alg = WPA_AUTH_ALG_OPEN;
132                 ssid->key_mgmt = WPA_KEY_MGMT_IEEE8021X;
133                 ssid->proto = WPA_PROTO_WPA;
134                 break;
135         case WPS_AUTH_WPA2:
136                 ssid->auth_alg = WPA_AUTH_ALG_OPEN;
137                 ssid->key_mgmt = WPA_KEY_MGMT_IEEE8021X;
138                 ssid->proto = WPA_PROTO_RSN;
139                 break;
140         case WPS_AUTH_WPA2PSK:
141                 ssid->auth_alg = WPA_AUTH_ALG_OPEN;
142                 ssid->key_mgmt = WPA_KEY_MGMT_PSK;
143                 ssid->proto = WPA_PROTO_RSN;
144                 break;
145         }
146
147         if (ssid->key_mgmt == WPA_KEY_MGMT_PSK) {
148                 if (cred->key_len == 2 * PMK_LEN) {
149                         if (hexstr2bin((const char *) cred->key, ssid->psk,
150                                        PMK_LEN)) {
151                                 wpa_printf(MSG_ERROR, "WPS: Invalid Network "
152                                            "Key");
153                                 return -1;
154                         }
155                         ssid->psk_set = 1;
156                 } else if (cred->key_len >= 8 && cred->key_len < 2 * PMK_LEN) {
157                         os_free(ssid->passphrase);
158                         ssid->passphrase = os_malloc(cred->key_len + 1);
159                         if (ssid->passphrase == NULL)
160                                 return -1;
161                         os_memcpy(ssid->passphrase, cred->key, cred->key_len);
162                         ssid->passphrase[cred->key_len] = '\0';
163                         wpa_config_update_psk(ssid);
164                 } else {
165                         wpa_printf(MSG_ERROR, "WPS: Invalid Network Key "
166                                    "length %lu",
167                                    (unsigned long) cred->key_len);
168                         return -1;
169                 }
170         }
171
172 #ifndef CONFIG_NO_CONFIG_WRITE
173         if (wpa_s->conf->update_config &&
174             wpa_config_write(wpa_s->confname, wpa_s->conf)) {
175                 wpa_printf(MSG_DEBUG, "WPS: Failed to update configuration");
176                 return -1;
177         }
178 #endif /* CONFIG_NO_CONFIG_WRITE */
179
180         return 0;
181 }
182
183
184 static void wpa_supplicant_wps_event_m2d(struct wpa_supplicant *wpa_s,
185                                          struct wps_event_m2d *m2d)
186 {
187         wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_M2D
188                 "dev_password_id=%d config_error=%d",
189                 m2d->dev_password_id, m2d->config_error);
190 }
191
192
193 static void wpa_supplicant_wps_event_fail(struct wpa_supplicant *wpa_s,
194                                           struct wps_event_fail *fail)
195 {
196         wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_FAIL "msg=%d", fail->msg);
197         wpas_clear_wps(wpa_s);
198 }
199
200
201 static void wpa_supplicant_wps_event_success(struct wpa_supplicant *wpa_s)
202 {
203         wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_SUCCESS);
204 }
205
206
207 static void wpa_supplicant_wps_event(void *ctx, enum wps_event event,
208                                      union wps_event_data *data)
209 {
210         struct wpa_supplicant *wpa_s = ctx;
211         switch (event) {
212         case WPS_EV_M2D:
213                 wpa_supplicant_wps_event_m2d(wpa_s, &data->m2d);
214                 break;
215         case WPS_EV_FAIL:
216                 wpa_supplicant_wps_event_fail(wpa_s, &data->fail);
217                 break;
218         case WPS_EV_SUCCESS:
219                 wpa_supplicant_wps_event_success(wpa_s);
220                 break;
221         }
222 }
223
224
225 u8 wpas_wps_get_req_type(struct wpa_ssid *ssid)
226 {
227         if (eap_is_wps_pbc_enrollee(&ssid->eap) ||
228             eap_is_wps_pin_enrollee(&ssid->eap))
229                 return WPS_REQ_ENROLLEE;
230         else
231                 return WPS_REQ_REGISTRAR;
232 }
233
234
235 static void wpas_clear_wps(struct wpa_supplicant *wpa_s)
236 {
237         int id;
238         struct wpa_ssid *ssid;
239
240         eloop_cancel_timeout(wpas_wps_timeout, wpa_s, NULL);
241
242         /* Remove any existing WPS network from configuration */
243         ssid = wpa_s->conf->ssid;
244         while (ssid) {
245                 if (ssid->key_mgmt & WPA_KEY_MGMT_WPS) {
246                         if (ssid == wpa_s->current_ssid)
247                                 wpa_s->current_ssid = NULL;
248                         id = ssid->id;
249                 } else
250                         id = -1;
251                 ssid = ssid->next;
252                 if (id >= 0)
253                         wpa_config_remove_network(wpa_s->conf, id);
254         }
255 }
256
257
258 static void wpas_wps_timeout(void *eloop_ctx, void *timeout_ctx)
259 {
260         struct wpa_supplicant *wpa_s = eloop_ctx;
261         wpa_printf(MSG_DEBUG, "WPS: Requested operation timed out");
262         wpas_clear_wps(wpa_s);
263 }
264
265
266 static struct wpa_ssid * wpas_wps_add_network(struct wpa_supplicant *wpa_s,
267                                               int registrar, const u8 *bssid)
268 {
269         struct wpa_ssid *ssid;
270
271         ssid = wpa_config_add_network(wpa_s->conf);
272         if (ssid == NULL)
273                 return NULL;
274         wpa_config_set_network_defaults(ssid);
275         if (wpa_config_set(ssid, "key_mgmt", "WPS", 0) < 0 ||
276             wpa_config_set(ssid, "eap", "WSC", 0) < 0 ||
277             wpa_config_set(ssid, "identity", registrar ?
278                            "\"" WSC_ID_REGISTRAR "\"" :
279                            "\"" WSC_ID_ENROLLEE "\"", 0) < 0) {
280                 wpa_config_remove_network(wpa_s->conf, ssid->id);
281                 return NULL;
282         }
283
284         if (bssid) {
285                 size_t i;
286                 struct wpa_scan_res *res;
287
288                 os_memcpy(ssid->bssid, bssid, ETH_ALEN);
289
290                 /* Try to get SSID from scan results */
291                 if (wpa_s->scan_res == NULL &&
292                     wpa_supplicant_get_scan_results(wpa_s) < 0)
293                         return ssid; /* Could not find any scan results */
294
295                 for (i = 0; i < wpa_s->scan_res->num; i++) {
296                         const u8 *ie;
297
298                         res = wpa_s->scan_res->res[i];
299                         if (os_memcmp(bssid, res->bssid, ETH_ALEN) != 0)
300                                 continue;
301
302                         ie = wpa_scan_get_ie(res, WLAN_EID_SSID);
303                         if (ie == NULL)
304                                 break;
305                         os_free(ssid->ssid);
306                         ssid->ssid = os_malloc(ie[1]);
307                         if (ssid->ssid == NULL)
308                                 break;
309                         os_memcpy(ssid->ssid, ie + 2, ie[1]);
310                         ssid->ssid_len = ie[1];
311                         break;
312                 }
313         }
314
315         return ssid;
316 }
317
318
319 static void wpas_wps_reassoc(struct wpa_supplicant *wpa_s,
320                              struct wpa_ssid *selected)
321 {
322         struct wpa_ssid *ssid;
323
324         /* Mark all other networks disabled and trigger reassociation */
325         ssid = wpa_s->conf->ssid;
326         while (ssid) {
327                 ssid->disabled = ssid != selected;
328                 ssid = ssid->next;
329         }
330         wpa_s->disconnected = 0;
331         wpa_s->reassociate = 1;
332         wpa_supplicant_req_scan(wpa_s, 0, 0);
333 }
334
335
336 int wpas_wps_start_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid)
337 {
338         struct wpa_ssid *ssid;
339         wpas_clear_wps(wpa_s);
340         ssid = wpas_wps_add_network(wpa_s, 0, bssid);
341         if (ssid == NULL)
342                 return -1;
343         wpa_config_set(ssid, "phase1", "\"pbc=1\"", 0);
344         eloop_register_timeout(WPS_PBC_WALK_TIME, 0, wpas_wps_timeout,
345                                wpa_s, NULL);
346         wpas_wps_reassoc(wpa_s, ssid);
347         return 0;
348 }
349
350
351 int wpas_wps_start_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
352                        const char *pin)
353 {
354         struct wpa_ssid *ssid;
355         char val[30];
356         unsigned int rpin = 0;
357
358         wpas_clear_wps(wpa_s);
359         ssid = wpas_wps_add_network(wpa_s, 0, bssid);
360         if (ssid == NULL)
361                 return -1;
362         if (pin)
363                 os_snprintf(val, sizeof(val), "\"pin=%s\"", pin);
364         else {
365                 rpin = wps_generate_pin();
366                 os_snprintf(val, sizeof(val), "\"pin=%08d\"", rpin);
367         }
368         wpa_config_set(ssid, "phase1", val, 0);
369         eloop_register_timeout(WPS_PBC_WALK_TIME, 0, wpas_wps_timeout,
370                                wpa_s, NULL);
371         wpas_wps_reassoc(wpa_s, ssid);
372         return rpin;
373 }
374
375
376 int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid,
377                        const char *pin)
378 {
379         struct wpa_ssid *ssid;
380         char val[30];
381
382         if (!pin)
383                 return -1;
384         wpas_clear_wps(wpa_s);
385         ssid = wpas_wps_add_network(wpa_s, 1, bssid);
386         if (ssid == NULL)
387                 return -1;
388         os_snprintf(val, sizeof(val), "\"pin=%s\"", pin);
389         wpa_config_set(ssid, "phase1", val, 0);
390         eloop_register_timeout(WPS_PBC_WALK_TIME, 0, wpas_wps_timeout,
391                                wpa_s, NULL);
392         wpas_wps_reassoc(wpa_s, ssid);
393         return 0;
394 }
395
396
397 int wpas_wps_init(struct wpa_supplicant *wpa_s)
398 {
399         struct wps_context *wps;
400
401         wps = os_zalloc(sizeof(*wps));
402         if (wps == NULL)
403                 return -1;
404
405         wps->cred_cb = wpa_supplicant_wps_cred;
406         wps->event_cb = wpa_supplicant_wps_event;
407         wps->cb_ctx = wpa_s;
408
409         wps->dev.device_name = wpa_s->conf->device_name;
410         wps->dev.manufacturer = wpa_s->conf->manufacturer;
411         wps->dev.model_name = wpa_s->conf->model_name;
412         wps->dev.model_number = wpa_s->conf->model_number;
413         wps->dev.serial_number = wpa_s->conf->serial_number;
414         if (wpa_s->conf->device_type) {
415                 char *pos;
416                 u8 oui[4];
417                 /* <categ>-<OUI>-<subcateg> */
418                 wps->dev.categ = atoi(wpa_s->conf->device_type);
419                 pos = os_strchr(wpa_s->conf->device_type, '-');
420                 if (pos == NULL) {
421                         wpa_printf(MSG_ERROR, "WPS: Invalid device_type");
422                         os_free(wps);
423                         return -1;
424                 }
425                 pos++;
426                 if (hexstr2bin(pos, oui, 4)) {
427                         wpa_printf(MSG_ERROR, "WPS: Invalid device_type OUI");
428                         os_free(wps);
429                         return -1;
430                 }
431                 wps->dev.oui = WPA_GET_BE32(oui);
432                 pos = os_strchr(pos, '-');
433                 if (pos == NULL) {
434                         wpa_printf(MSG_ERROR, "WPS: Invalid device_type");
435                         os_free(wps);
436                         return -1;
437                 }
438                 pos++;
439                 wps->dev.sub_categ = atoi(pos);
440         }
441         wps->dev.os_version = WPA_GET_BE32(wpa_s->conf->os_version);
442         wps->dev.rf_bands = WPS_RF_24GHZ | WPS_RF_50GHZ; /* TODO: config */
443         os_memcpy(wps->dev.mac_addr, wpa_s->own_addr, ETH_ALEN);
444         os_memcpy(wps->uuid, wpa_s->conf->uuid, 16);
445
446         wpa_s->wps = wps;
447
448         return 0;
449 }
450
451
452 void wpas_wps_deinit(struct wpa_supplicant *wpa_s)
453 {
454         eloop_cancel_timeout(wpas_wps_timeout, wpa_s, NULL);
455
456         if (wpa_s->wps == NULL)
457                 return;
458
459         os_free(wpa_s->wps->network_key);
460         os_free(wpa_s->wps);
461         wpa_s->wps = NULL;
462 }
463
464
465 int wpas_wps_ssid_bss_match(struct wpa_ssid *ssid, struct wpa_scan_res *bss)
466 {
467         struct wpabuf *wps_ie;
468
469         if (!(ssid->key_mgmt & WPA_KEY_MGMT_WPS))
470                 return -1;
471
472         wps_ie = wpa_scan_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
473         if (eap_is_wps_pbc_enrollee(&ssid->eap)) {
474                 if (!wps_ie) {
475                         wpa_printf(MSG_DEBUG, "   skip - non-WPS AP");
476                         return 0;
477                 }
478
479                 if (!wps_is_selected_pbc_registrar(wps_ie)) {
480                         wpa_printf(MSG_DEBUG, "   skip - WPS AP "
481                                    "without active PBC Registrar");
482                         wpabuf_free(wps_ie);
483                         return 0;
484                 }
485
486                 /* TODO: overlap detection */
487                 wpa_printf(MSG_DEBUG, "   selected based on WPS IE "
488                            "(Active PBC)");
489                 wpabuf_free(wps_ie);
490                 return 1;
491         }
492
493         if (eap_is_wps_pin_enrollee(&ssid->eap)) {
494                 if (!wps_ie) {
495                         wpa_printf(MSG_DEBUG, "   skip - non-WPS AP");
496                         return 0;
497                 }
498
499                 if (!wps_is_selected_pin_registrar(wps_ie)) {
500                         wpa_printf(MSG_DEBUG, "   skip - WPS AP "
501                                    "without active PIN Registrar");
502                         wpabuf_free(wps_ie);
503                         return 0;
504                 }
505                 wpa_printf(MSG_DEBUG, "   selected based on WPS IE "
506                            "(Active PIN)");
507                 wpabuf_free(wps_ie);
508                 return 1;
509         }
510
511         if (wps_ie) {
512                 wpa_printf(MSG_DEBUG, "   selected based on WPS IE");
513                 wpabuf_free(wps_ie);
514                 return 1;
515         }
516
517         return -1;
518 }
519
520
521 int wpas_wps_ssid_wildcard_ok(struct wpa_ssid *ssid,
522                               struct wpa_scan_res *bss)
523 {
524         struct wpabuf *wps_ie = NULL;
525         int ret = 0;
526
527         if (eap_is_wps_pbc_enrollee(&ssid->eap)) {
528                 wps_ie = wpa_scan_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
529                 if (wps_ie && wps_is_selected_pbc_registrar(wps_ie)) {
530                         /* allow wildcard SSID for WPS PBC */
531                         ret = 1;
532                 }
533         } else if (eap_is_wps_pin_enrollee(&ssid->eap)) {
534                 wps_ie = wpa_scan_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
535                 if (wps_ie && wps_is_selected_pin_registrar(wps_ie)) {
536                         /* allow wildcard SSID for WPS PIN */
537                         ret = 1;
538                 }
539         }
540
541         wpabuf_free(wps_ie);
542
543         return ret;
544 }
545
546
547 int wpas_wps_scan_pbc_overlap(struct wpa_supplicant *wpa_s,
548                               struct wpa_scan_res *selected,
549                               struct wpa_ssid *ssid)
550 {
551         const u8 *sel_uuid, *uuid;
552         size_t i;
553         struct wpabuf *wps_ie;
554         int ret = 0;
555
556         if (!eap_is_wps_pbc_enrollee(&ssid->eap))
557                 return 0;
558
559         /* Make sure that only one AP is in active PBC mode */
560         wps_ie = wpa_scan_get_vendor_ie_multi(selected, WPS_IE_VENDOR_TYPE);
561         if (wps_ie)
562                 sel_uuid = wps_get_uuid_e(wps_ie);
563         else
564                 sel_uuid = NULL;
565         if (!sel_uuid) {
566                 wpa_printf(MSG_DEBUG, "WPS: UUID-E not available for PBC "
567                            "overlap detection");
568                 wpabuf_free(wps_ie);
569                 return 1;
570         }
571
572         for (i = 0; i < wpa_s->scan_res->num; i++) {
573                 struct wpa_scan_res *bss = wpa_s->scan_res->res[i];
574                 struct wpabuf *ie;
575                 if (bss == selected)
576                         continue;
577                 ie = wpa_scan_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
578                 if (!ie)
579                         continue;
580                 if (!wps_is_selected_pbc_registrar(ie)) {
581                         wpabuf_free(ie);
582                         continue;
583                 }
584                 uuid = wps_get_uuid_e(ie);
585                 if (uuid == NULL) {
586                         wpa_printf(MSG_DEBUG, "WPS: UUID-E not available for "
587                                    "PBC overlap detection (other BSS)");
588                         ret = 1;
589                         wpabuf_free(ie);
590                         break;
591                 }
592                 if (os_memcmp(sel_uuid, uuid, 16) != 0) {
593                         ret = 1; /* PBC overlap */
594                         wpabuf_free(ie);
595                         break;
596                 }
597
598                 /* TODO: verify that this is reasonable dual-band situation */
599
600                 wpabuf_free(ie);
601         }
602
603         wpabuf_free(wps_ie);
604
605         return ret;
606 }
607
608
609 void wpas_wps_notify_scan_results(struct wpa_supplicant *wpa_s)
610 {
611         size_t i;
612
613         if (wpa_s->disconnected || wpa_s->wpa_state >= WPA_ASSOCIATED)
614                 return;
615
616         for (i = 0; i < wpa_s->scan_res->num; i++) {
617                 struct wpa_scan_res *bss = wpa_s->scan_res->res[i];
618                 struct wpabuf *ie;
619                 ie = wpa_scan_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
620                 if (!ie)
621                         continue;
622                 if (wps_is_selected_pbc_registrar(ie))
623                         wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_AP_AVAILABLE_PBC);
624                 else if (wps_is_selected_pin_registrar(ie))
625                         wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_AP_AVAILABLE_PIN);
626                 else
627                         wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_AP_AVAILABLE);
628                 wpabuf_free(ie);
629                 break;
630         }
631 }