blob: c3f423fab47848e74445af2cdead0419daebbf67 [file] [log] [blame]
Przemyslaw Marczak0c813362014-04-02 10:20:03 +02001/*
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
Przemyslaw Marczakb4285142014-04-02 10:20:04 +020010/* This is structure is in big-endian */
11struct 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
Przemyslaw Marczak0c813362014-04-02 10:20:03 +020020enum {
21 UUID_STR_FORMAT_STD,
22 UUID_STR_FORMAT_GUID
23};
24
25#define UUID_STR_LEN 36
Przemyslaw Marczakb4285142014-04-02 10:20:04 +020026#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
Przemyslaw Marczak0c813362014-04-02 10:20:03 +020035
36int uuid_str_valid(const char *uuid);
37int uuid_str_to_bin(char *uuid_str, unsigned char *uuid_bin, int str_format);
38void uuid_bin_to_str(unsigned char *uuid_bin, char *uuid_str, int str_format);
Patrick Delaunay65f94ed2015-10-27 11:00:28 +010039#ifdef CONFIG_PARTITION_TYPE_GUID
40int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin);
41int uuid_guid_get_str(unsigned char *guid_bin, char *guid_str);
42#endif
Przemyslaw Marczakb4285142014-04-02 10:20:04 +020043void gen_rand_uuid(unsigned char *uuid_bin);
44void gen_rand_uuid_str(char *uuid_str, int str_format);
Przemyslaw Marczak0c813362014-04-02 10:20:03 +020045#endif