1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (C) 2014 Samsung Electronics
4 * Przemyslaw Marczak <p.marczak@samsung.com>
5 * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
8 * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
13 #include <linux/bitops.h>
15 /* This is structure is in big-endian */
17 unsigned int time_low;
18 unsigned short time_mid;
19 unsigned short time_hi_and_version;
20 unsigned char clock_seq_hi_and_reserved;
21 unsigned char clock_seq_low;
22 unsigned char node[6];
25 /* Bits of a bitmask specifying the output format for GUIDs */
26 #define UUID_STR_FORMAT_STD 0
27 #define UUID_STR_FORMAT_GUID BIT(0)
28 #define UUID_STR_UPPER_CASE BIT(1)
30 /* Use UUID_STR_LEN + 1 for string space */
31 #define UUID_STR_LEN 36
32 #define UUID_BIN_LEN sizeof(struct uuid)
34 #define UUID_VERSION_MASK 0xf000
35 #define UUID_VERSION_SHIFT 12
36 #define UUID_VERSION 0x4
38 #define UUID_VARIANT_MASK 0xc0
39 #define UUID_VARIANT_SHIFT 7
40 #define UUID_VARIANT 0x1
42 int uuid_str_valid(const char *uuid);
43 int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin,
45 void uuid_bin_to_str(const unsigned char *uuid_bin, char *uuid_str,
47 int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin);
48 const char *uuid_guid_get_str(const unsigned char *guid_bin);
49 void gen_rand_uuid(unsigned char *uuid_bin);
50 void gen_rand_uuid_str(char *uuid_str, int str_format);
53 * uuid_str_to_le_bin() - Convert string UUID to little endian binary data.
54 * @uuid_str: pointer to UUID string
55 * @uuid_bin: pointer to allocated array for little endian output [16B]
57 * uuid_bin filled with little endian UUID data
58 * On success 0 is returned. Otherwise, failure code.
60 int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin);