uuid.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. *
  3. * Embedded Linux library
  4. *
  5. * Copyright (C) 2011-2015 Intel Corporation. All rights reserved.
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. */
  22. #ifndef __ELL_UUID_H
  23. #define __ELL_UUID_H
  24. #include <stdbool.h>
  25. #include <inttypes.h>
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. enum l_uuid_version {
  30. L_UUID_VERSION_1_TIME = 1,
  31. L_UUID_VERSION_2_DCE = 2,
  32. L_UUID_VERSION_3_MD5 = 3,
  33. L_UUID_VERSION_4_RANDOM = 4,
  34. L_UUID_VERSION_5_SHA1 = 5,
  35. };
  36. extern const uint8_t L_UUID_NAMESPACE_DNS[];
  37. extern const uint8_t L_UUID_NAMESPACE_URL[];
  38. extern const uint8_t L_UUID_NAMESPACE_OID[];
  39. extern const uint8_t L_UUID_NAMESPACE_X500[];
  40. bool l_uuid_v3(const uint8_t nsid[16], const void *name, size_t name_size,
  41. uint8_t out_uuid[16]);
  42. bool l_uuid_v4(uint8_t out_uuid[16]);
  43. bool l_uuid_v5(const uint8_t nsid[16], const void *name, size_t name_size,
  44. uint8_t out_uuid[16]);
  45. bool l_uuid_is_valid(const uint8_t uuid[16]);
  46. enum l_uuid_version l_uuid_get_version(const uint8_t uuid[16]);
  47. bool l_uuid_to_string(const uint8_t uuid[16], char *dest, size_t dest_size);
  48. bool l_uuid_from_string(const char *src, uint8_t uuid[16]);
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #endif /* __ELL_UTIL_H */