2 * Universally Unique IDentifier (UUID)
3 * Copyright (c) 2008, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
14 int uuid_str2bin(const char *str, u8 *bin)
22 if (hexstr2bin(pos, opos, 4))
27 if (*pos++ != '-' || hexstr2bin(pos, opos, 2))
32 if (*pos++ != '-' || hexstr2bin(pos, opos, 2))
37 if (*pos++ != '-' || hexstr2bin(pos, opos, 2))
42 if (*pos++ != '-' || hexstr2bin(pos, opos, 6))
49 int uuid_bin2str(const u8 *bin, char *str, size_t max_len)
52 len = os_snprintf(str, max_len, "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
53 "%02x%02x-%02x%02x%02x%02x%02x%02x",
54 bin[0], bin[1], bin[2], bin[3],
55 bin[4], bin[5], bin[6], bin[7],
56 bin[8], bin[9], bin[10], bin[11],
57 bin[12], bin[13], bin[14], bin[15]);
58 if (os_snprintf_error(max_len, len))
64 int is_nil_uuid(const u8 *uuid)
67 for (i = 0; i < UUID_LEN; i++)