--- /dev/null
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef LTTNG_UUID_H
+#define LTTNG_UUID_H
+
+/*
+ * Includes final \0.
+ */
+#define LTTNG_UUID_STR_LEN 37
+#define LTTNG_UUID_LEN 16
+#define LTTNG_UUID_VER 4
+
+#define LTTNG_UUID_FMT \
+ "%02hhx%02hhx%02hhx%02hhx-%02hhx" \
+ "%02hhx-%02hhx%02hhx-%02hhx%02hhx" \
+ "-%02hhx%02hhx%02hhx%02hhx%02hhx" \
+ "%02hhx"
+
+#define LTTNG_UUID_FMT_VALUES(uuid) \
+ (uuid)[0], (uuid)[1], (uuid)[2], (uuid)[3], (uuid)[4], (uuid)[5], \
+ (uuid)[6], (uuid)[7], (uuid)[8], (uuid)[9], (uuid)[10], (uuid)[11], \
+ (uuid)[12], (uuid)[13], (uuid)[14], (uuid)[15]
+
+#define LTTNG_UUID_SCAN_VALUES(uuid) \
+ &(uuid)[0], &(uuid)[1], &(uuid)[2], &(uuid)[3], &(uuid)[4], &(uuid)[5], \
+ &(uuid)[6], &(uuid)[7], &(uuid)[8], &(uuid)[9], &(uuid)[10], &(uuid)[11], \
+ &(uuid)[12], &(uuid)[13], &(uuid)[14], &(uuid)[15]
+
+typedef unsigned char lttng_uuid[LTTNG_UUID_LEN];
+
+int lttng_uuid_from_str(const char *str_in, lttng_uuid uuid_out);
+
+#endif /* LTTNG_UUID_H */
lttng-context-need-reschedule.o \
lttng-calibrate.o \
lttng-context-hostname.o \
- lttng-context-callstack.o \
+ lttng-context-callstack.o \
probes/lttng.o \
lttng-tracker-id.o \
lttng-bytecode.o lttng-bytecode-interpreter.o \
lttng-bytecode-validator.o \
probes/lttng-probe-user.o \
lttng-tp-mempool.o \
- lttng-event-notifier-notification.o
+ lttng-event-notifier-notification.o \
+ lttng-uuid.o
lttng-wrapper-objs := wrapper/page_alloc.o \
wrapper/random.o \
--- /dev/null
+/*
+ * Copyright (C) 2018 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include <linux/module.h>
+#include <lttng/uuid.h>
+
+int lttng_uuid_from_str(const char *str_in, lttng_uuid uuid_out)
+{
+ int ret = 0;
+ lttng_uuid uuid_scan;
+
+ if ((str_in == NULL) || (uuid_out == NULL)) {
+ ret = -1;
+ goto end;
+ }
+
+ if (strnlen(str_in, LTTNG_UUID_STR_LEN) != LTTNG_UUID_STR_LEN - 1) {
+ ret = -1;
+ goto end;
+ }
+
+ /* Scan to a temporary location in case of a partial match. */
+ if (sscanf(str_in, LTTNG_UUID_FMT, LTTNG_UUID_SCAN_VALUES(uuid_scan)) !=
+ LTTNG_UUID_LEN) {
+ ret = -1;
+ }
+
+ memcpy(uuid_out, uuid_scan, LTTNG_UUID_LEN);
+end:
+ return ret;
+}