From: Jouni Malinen Date: Wed, 18 Dec 2013 00:00:21 +0000 (-0800) Subject: WPS: Make UUID-from-MAC Address easily available X-Git-Tag: hostap_2_2~882 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b0d18bc2a1bd20cb81a2fbb51126a3a7f2ab417a;p=thirdparty%2Fhostap.git WPS: Make UUID-from-MAC Address easily available "hostapd -u" 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 --- diff --git a/hostapd/main.c b/hostapd/main.c index 5a1b0a9e9..db2a45582 100644 --- a/hostapd/main.c +++ b/hostapd/main.c @@ -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;