Split hostapd/driver.h into two files
[wpasupplicant] / hostapd / wps_hostapd.c
index 76258ee..74c2d88 100644 (file)
@@ -15,7 +15,7 @@
 #include "includes.h"
 
 #include "hostapd.h"
-#include "driver.h"
+#include "driver_i.h"
 #include "eloop.h"
 #include "uuid.h"
 #include "wpa_ctrl.h"
@@ -383,7 +383,12 @@ int hostapd_init_wps(struct hostapd_data *hapd,
        os_memset(&cfg, 0, sizeof(cfg));
        wps->wps_state = hapd->conf->wps_state;
        wps->ap_setup_locked = hapd->conf->ap_setup_locked;
-       os_memcpy(wps->uuid, hapd->conf->uuid, UUID_LEN);
+       if (is_nil_uuid(hapd->conf->uuid)) {
+               uuid_gen_mac_addr(hapd->own_addr, wps->uuid);
+               wpa_hexdump(MSG_DEBUG, "WPS: UUID based on MAC address",
+                           wps->uuid, UUID_LEN);
+       } else
+               os_memcpy(wps->uuid, hapd->conf->uuid, UUID_LEN);
        wps->ssid_len = hapd->conf->ssid.ssid_len;
        os_memcpy(wps->ssid, hapd->conf->ssid.ssid, wps->ssid_len);
        wps->ap = 1;
@@ -543,9 +548,15 @@ int hostapd_wps_add_pin(struct hostapd_data *hapd, const char *uuid,
                        const char *pin)
 {
        u8 u[UUID_LEN];
-       if (hapd->wps == NULL || uuid_str2bin(uuid, u))
+       int any = 0;
+
+       if (hapd->wps == NULL)
+               return -1;
+       if (os_strcmp(uuid, "any") == 0)
+               any = 1;
+       else if (uuid_str2bin(uuid, u))
                return -1;
-       return wps_registrar_add_pin(hapd->wps->registrar, u,
+       return wps_registrar_add_pin(hapd->wps->registrar, any ? NULL : u,
                                     (const u8 *) pin, os_strlen(pin));
 }