1 /* 2 * Copyright (C) 2014 Samsung Electronics 3 * Przemyslaw Marczak <p.marczak@samsung.com> 4 * 5 * SPDX-License-Identifier: GPL-2.0+ 6 */ 7 #ifndef __UUID_H__ 8 #define __UUID_H__ 9 10 /* This is structure is in big-endian */ 11 struct uuid { 12 unsigned int time_low; 13 unsigned short time_mid; 14 unsigned short time_hi_and_version; 15 unsigned char clock_seq_hi_and_reserved; 16 unsigned char clock_seq_low; 17 unsigned char node[6]; 18 } __packed; 19 20 enum { 21 UUID_STR_FORMAT_STD, 22 UUID_STR_FORMAT_GUID 23 }; 24 25 #define UUID_STR_LEN 36 26 #define UUID_BIN_LEN sizeof(struct uuid) 27 28 #define UUID_VERSION_MASK 0xf000 29 #define UUID_VERSION_SHIFT 12 30 #define UUID_VERSION 0x4 31 32 #define UUID_VARIANT_MASK 0xc0 33 #define UUID_VARIANT_SHIFT 7 34 #define UUID_VARIANT 0x1 35 36 int uuid_str_valid(const char *uuid); 37 int uuid_str_to_bin(char *uuid_str, unsigned char *uuid_bin, int str_format); 38 void uuid_bin_to_str(unsigned char *uuid_bin, char *uuid_str, int str_format); 39 #ifdef CONFIG_PARTITION_TYPE_GUID 40 int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin); 41 int uuid_guid_get_str(unsigned char *guid_bin, char *guid_str); 42 #endif 43 void gen_rand_uuid(unsigned char *uuid_bin); 44 void gen_rand_uuid_str(char *uuid_str, int str_format); 45 #endif 46