Thread (7 messages) 7 messages, 1 author, 2013-01-24
STALE4932d REVIEWED: 1 (0M)

[RFC PATCH v0 2/6] Bluetooth: Add helper function to get the uuid type

From: Syam Sidhardhan <hidden>
Date: 2013-01-24 05:57:55
Subsystem: bluetooth subsystem, the rest · Maintainers: Marcel Holtmann, Luiz Augusto von Dentz, Linus Torvalds

This function will return the particular uuid type

Signed-off-by: Syam Sidhardhan <redacted>
Tested-by: Chan-yeol Park <redacted>
---
 net/bluetooth/mgmt.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 4fd45a3..0f32986 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -37,6 +37,10 @@ bool enable_hs;
 #define MGMT_VERSION	1
 #define MGMT_REVISION	2
 
+#define EIR_TYPE_UUID16 1
+#define EIR_TYPE_UUID32 2
+#define EIR_TYPE_UUID128 3
+
 static const u16 mgmt_commands[] = {
 	MGMT_OP_READ_INDEX_LIST,
 	MGMT_OP_READ_INFO,
@@ -440,6 +444,23 @@ static u8 bluetooth_base_uuid[] = {
 			0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 };
 
+static int get_uuid_type(u8 *uuid128)
+{
+	u32 val;
+	int i;
+
+	for (i = 0; i < 12; i++) {
+		if (bluetooth_base_uuid[i] != uuid128[i])
+			return EIR_TYPE_UUID128;
+	}
+
+	val = get_unaligned_le32(&uuid128[12]);
+	if (val > 0xffff)
+		return EIR_TYPE_UUID32;
+	else
+		return EIR_TYPE_UUID16;
+}
+
 static u16 get_uuid16(u8 *uuid128)
 {
 	u32 val;
-- 
1.7.9.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help