]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: Make UUID-from-MAC Address easily available
authorJouni Malinen <jouni@qca.qualcomm.com>
Wed, 18 Dec 2013 00:00:21 +0000 (16:00 -0800)
committerJouni Malinen <j@w1.fi>
Tue, 11 Feb 2014 13:44:13 +0000 (15:44 +0200)
"hostapd -u<MAC Address>" can now be used to display the UUID that will
be generated based on a MAC Address (i.e., when hostapd configuration
does not set a specific UUID).

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

hostapd/main.c

index 5a1b0a9e9295460b75ea54427345974f48d10c20..db2a455824555b078eb49434fb1f1603b81c05a7 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "utils/common.h"
 #include "utils/eloop.h"
+#include "utils/uuid.h"
 #include "crypto/random.h"
 #include "crypto/tls.h"
 #include "common/version.h"
@@ -501,6 +502,27 @@ static int hostapd_get_ctrl_iface_group(struct hapd_interfaces *interfaces,
 }
 
 
+#ifdef CONFIG_WPS
+static int gen_uuid(const char *txt_addr)
+{
+       u8 addr[ETH_ALEN];
+       u8 uuid[UUID_LEN];
+       char buf[100];
+
+       if (hwaddr_aton(txt_addr, addr) < 0)
+               return -1;
+
+       uuid_gen_mac_addr(addr, uuid);
+       if (uuid_bin2str(uuid, buf, sizeof(buf)) < 0)
+               return -1;
+
+       printf("%s\n", buf);
+
+       return 0;
+}
+#endif /* CONFIG_WPS */
+
+
 int main(int argc, char *argv[])
 {
        struct hapd_interfaces interfaces;
@@ -531,7 +553,7 @@ int main(int argc, char *argv[])
        interfaces.global_ctrl_sock = -1;
 
        for (;;) {
-               c = getopt(argc, argv, "b:Bde:f:hKP:Ttvg:G:");
+               c = getopt(argc, argv, "b:Bde:f:hKP:Ttu:vg:G:");
                if (c < 0)
                        break;
                switch (c) {
@@ -588,6 +610,10 @@ int main(int argc, char *argv[])
                        bss_config = tmp_bss;
                        bss_config[num_bss_configs++] = optarg;
                        break;
+#ifdef CONFIG_WPS
+               case 'u':
+                       return gen_uuid(optarg);
+#endif /* CONFIG_WPS */
                default:
                        usage();
                        break;