[PATCH BlueZ v2 01/17] shared: Add put_uuid()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add helper to put 16/32/128-bit UUID values to the given buffer using
little-endian representation.
---
 src/shared/util.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/shared/util.h b/src/shared/util.h
index d7d4a94..f614c99 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -26,6 +26,8 @@
 #include <alloca.h>
 #include <byteswap.h>
 
+#include "lib/uuid.h"
+
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define le16_to_cpu(val) (val)
 #define le32_to_cpu(val) (val)
@@ -90,3 +92,13 @@ void util_debug(util_debug_func_t function, void *user_data,
 
 void util_hexdump(const char dir, const unsigned char *buf, size_t len,
 				util_debug_func_t function, void *user_data);
+
+static inline void put_uuid(const bt_uuid_t *src, void *dst)
+{
+	if (src->type == BT_UUID16)
+		put_unaligned(cpu_to_le16(src->value.u16), (uint16_t *) dst);
+	else if (src->type == BT_UUID32)
+		put_unaligned(cpu_to_le32(src->value.u32), (uint32_t *) dst);
+	else
+		htob128(&(src->value.u128), (uint128_t *) dst);
+}
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux