blob: 93027c1b286952650fc3e25e3fa90c504f2fcebd [file] [log] [blame]
Przemyslaw Marczakd718ded2014-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 Marczak4e4815f2014-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 Marczakd718ded2014-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 Marczak4e4815f2014-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 Marczakd718ded2014-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);
Przemyslaw Marczak4e4815f2014-04-02 10:20:04 +020039void gen_rand_uuid(unsigned char *uuid_bin);
40void gen_rand_uuid_str(char *uuid_str, int str_format);
Przemyslaw Marczakd718ded2014-04-02 10:20:03 +020041#endif