All of lore.kernel.org
 help / color / mirror / Atom feed
From: Inga Stotland <ingas@codeaurora.org>
To: linux-bluetooth@vger.kernel.org
Cc: rshaffer@codeaurora.org, johan.hedberg@gmail.com,
	marcel@holtmann.org, Inga Stotland <ingas@codeaurora.org>
Subject: [PATCH 4/7] Support for adding UUID128 to extended inquiry response
Date: Tue,  3 Aug 2010 17:03:54 -0700	[thread overview]
Message-ID: <1280880237-2296-5-git-send-email-ingas@codeaurora.org> (raw)
In-Reply-To: <1280880237-2296-1-git-send-email-ingas@codeaurora.org>

---
 src/sdpd-service.c |   65 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 64 insertions(+), 1 deletions(-)

diff --git a/src/sdpd-service.c b/src/sdpd-service.c
index 50c0a97..651e24c 100644
--- a/src/sdpd-service.c
+++ b/src/sdpd-service.c
@@ -49,6 +49,8 @@
 #include "manager.h"
 #include "adapter.h"
 
+#define SIZEOF_UUID128 16
+
 static sdp_record_t *server = NULL;
 
 static uint16_t did_vendor = 0x0000;
@@ -174,6 +176,63 @@ static void update_svclass_list(const bdaddr_t *src)
 
 }
 
+static void eir_generate_uuid128(sdp_list_t *list,
+					uint8_t *ptr, uint16_t *eir_len)
+{
+	int i, k, index = 0;
+	uint16_t len = *eir_len;
+	uint8_t *uuid128;
+	gboolean truncated = FALSE;
+
+	/* Store UUID128 in place, skip 2 bytes to insert type and length later */
+	uuid128 = ptr + 2;
+
+	for (; list; list = list->next) {
+		sdp_record_t *rec = (sdp_record_t *) list->data;
+		uint8_t *uuid128_data = rec->svclass.value.uuid128.data;
+
+		if (rec->svclass.type != SDP_UUID128)
+			continue;
+
+		/* Stop if not enough space to put next UUID128 */
+		if ((len + 2 + SIZEOF_UUID128) > EIR_DATA_LENGTH) {
+			truncated = TRUE;
+			break;
+		}
+
+		/* Check for duplicates, EIR data is Little Endian */
+		for (i = 0; i < index; i++) {
+			for (k = 0; k < SIZEOF_UUID128; k++) {
+				if (uuid128[i * SIZEOF_UUID128 + k] !=
+					uuid128_data[SIZEOF_UUID128 - k])
+					break;
+			}
+			if (k == SIZEOF_UUID128)
+				break;
+		}
+
+		if (i < index)
+			continue;
+
+		/* EIR data is Little Endian */
+		for (k = 0; k < SIZEOF_UUID128; k++)
+			uuid128[index * SIZEOF_UUID128 + k] =
+				uuid128_data[SIZEOF_UUID128 - 1 - k];
+
+		len += SIZEOF_UUID128;
+		index++;
+	}
+
+	if (index > 0 || truncated) {
+		/* EIR Data length */
+		ptr[0] = (index * SIZEOF_UUID128) + 1;
+		/* EIR Data type */
+		ptr[1] = truncated ? EIR_UUID128_SOME : EIR_UUID128_ALL;
+		len += 2;
+		*eir_len = len;
+	}
+}
+
 void create_ext_inquiry_response(const char *name,
 					int8_t tx_power, sdp_list_t *services,
 					uint8_t *data)
@@ -261,7 +320,7 @@ void create_ext_inquiry_response(const char *name,
 		/* EIR Data length */
 		ptr[0] = (index * sizeof(uint16_t)) + 1;
 		/* EIR Data type */
-		ptr[1] = (truncated) ? EIR_UUID16_SOME : EIR_UUID16_ALL;
+		ptr[1] = truncated ? EIR_UUID16_SOME : EIR_UUID16_ALL;
 
 		ptr += 2;
 		eir_len += 2;
@@ -271,6 +330,10 @@ void create_ext_inquiry_response(const char *name,
 			*ptr++ = (uuid16[i] & 0xff00) >> 8;
 		}
 	}
+
+	/* Group all UUID128 types */
+	if (eir_len <= EIR_DATA_LENGTH - 2)
+		eir_generate_uuid128(services, ptr, &eir_len);
 }
 
 void register_public_browse_group(void)
-- 
1.7.2

-- 
Inga Stotland
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

  parent reply	other threads:[~2010-08-04  0:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-04  0:03 [PATCH v6 0/7] Enhanced support for extended inquiry response Inga Stotland
2010-08-04  0:03 ` [PATCH 1/7] Spec constants for Extended Inquiry Response field types Inga Stotland
2010-08-04  0:03 ` [PATCH 2/7] Minor fix when skipping duplicate UUID16 from EIR Inga Stotland
2010-08-04  0:03 ` [PATCH 3/7] Clean up code that generates extended inquiry response Inga Stotland
2010-08-04 14:07   ` Johan Hedberg
2010-08-04  0:03 ` Inga Stotland [this message]
2010-08-04 14:08   ` [PATCH 4/7] Support for adding UUID128 to " Johan Hedberg
2010-08-04  0:03 ` [PATCH 5/7] Fix in logic to write EIR when SDP records are changed Inga Stotland
2010-08-04 14:09   ` Johan Hedberg
2010-08-04  0:03 ` [PATCH 6/7] Handle arrays in device properties dictionary Inga Stotland
2010-08-04  0:03 ` [PATCH 7/7] Add service UUIDs from EIR to device properties in "Device Found" signal Inga Stotland
  -- strict thread matches above, loose matches on Subject: below --
2010-08-04 17:07 [PATCH v7 0/7] Enhanced support for extended inquiry response Inga Stotland
2010-08-04 17:07 ` [PATCH 4/7] Support for adding UUID128 to " Inga Stotland
2010-08-04 17:07 ` Inga Stotland
2010-08-04 23:00 [PATCH v8 0/7] Enhanced support for " Inga Stotland
2010-08-04 23:00 ` [PATCH 4/7] Support for adding UUID128 to " Inga Stotland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1280880237-2296-5-git-send-email-ingas@codeaurora.org \
    --to=ingas@codeaurora.org \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=rshaffer@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.