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

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

 



This function will return the particular uuid type

Signed-off-by: Syam Sidhardhan <s.syam@xxxxxxxxxxx>
Tested-by: Chan-yeol Park <chanyeol.park@xxxxxxxxxxx>
---
 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

--
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