qemu/include/qemu/uuid.h
<<
>>
Prefs
   1/*
   2 *  QEMU UUID functions
   3 *
   4 *  Copyright 2016 Red Hat, Inc.
   5 *
   6 *  Authors:
   7 *   Fam Zheng <famz@redhat.com>
   8 *
   9 * This program is free software; you can redistribute it and/or modify it
  10 * under the terms of the GNU General Public License as published by the Free
  11 * Software Foundation; either version 2 of the License, or (at your option)
  12 * any later version.
  13 *
  14 */
  15
  16#ifndef QEMU_UUID_H
  17#define QEMU_UUID_H
  18
  19
  20/* Version 4 UUID (pseudo random numbers), RFC4122 4.4. */
  21
  22typedef struct {
  23    union {
  24        unsigned char data[16];
  25        struct {
  26            /* Generated in BE endian, can be swapped with qemu_uuid_bswap. */
  27            uint32_t time_low;
  28            uint16_t time_mid;
  29            uint16_t time_high_and_version;
  30            uint8_t  clock_seq_and_reserved;
  31            uint8_t  clock_seq_low;
  32            uint8_t  node[6];
  33        } fields;
  34    };
  35} QemuUUID;
  36
  37#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-" \
  38                 "%02hhx%02hhx-%02hhx%02hhx-" \
  39                 "%02hhx%02hhx-" \
  40                 "%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
  41
  42#define UUID_FMT_LEN 36
  43
  44#define UUID_NONE "00000000-0000-0000-0000-000000000000"
  45
  46void qemu_uuid_generate(QemuUUID *out);
  47
  48int qemu_uuid_is_null(const QemuUUID *uu);
  49
  50int qemu_uuid_is_equal(const QemuUUID *lhv, const QemuUUID *rhv);
  51
  52void qemu_uuid_unparse(const QemuUUID *uuid, char *out);
  53
  54char *qemu_uuid_unparse_strdup(const QemuUUID *uuid);
  55
  56int qemu_uuid_parse(const char *str, QemuUUID *uuid);
  57
  58QemuUUID qemu_uuid_bswap(QemuUUID uuid);
  59
  60#endif
  61