summaryrefslogtreecommitdiffstats
path: root/stack
diff options
context:
space:
mode:
authorKausik Sinnaswamy <kausik@broadcom.com>2012-04-24 22:42:52 +0530
committerMatthew Xie <mattx@google.com>2012-07-14 11:19:18 -0700
commit4ccd6261b39fef1854761442b10deac3490be623 (patch)
tree874cbd1400d6691939e8654d08dbaa72e2e435fe /stack
parentc6be83856892327f88002191b0c067e1e26d0d9e (diff)
downloadexternal_bluetooth_bluedroid-4ccd6261b39fef1854761442b10deac3490be623.zip
external_bluetooth_bluedroid-4ccd6261b39fef1854761442b10deac3490be623.tar.gz
external_bluetooth_bluedroid-4ccd6261b39fef1854761442b10deac3490be623.tar.bz2
Support added to report custom 128-bit UUIDs as part of the BT_PROPERTY_UUIDS of the remote device
Change-Id: I1facd9238cf847915df4c01b33c77b2fdaa168cb
Diffstat (limited to 'stack')
-rw-r--r--stack/include/sdp_api.h29
-rw-r--r--stack/sdp/sdp_api.c122
-rw-r--r--stack/sdp/sdp_utils.c22
-rw-r--r--stack/sdp/sdpint.h2
4 files changed, 174 insertions, 1 deletions
diff --git a/stack/include/sdp_api.h b/stack/include/sdp_api.h
index e4774c3..121afd4 100644
--- a/stack/include/sdp_api.h
+++ b/stack/include/sdp_api.h
@@ -330,6 +330,35 @@ SDP_API extern tSDP_DISC_REC *SDP_FindServiceUUIDInDb (tSDP_DISCOVERY_DB *p_db,
tBT_UUID *p_uuid,
tSDP_DISC_REC *p_start_rec);
+/*******************************************************************************
+**
+** Function SDP_FindServiceUUIDInRec_128bit
+**
+** Description This function is called to read the 128-bit service UUID within a record
+** if there is any.
+**
+** Parameters: p_rec - pointer to a SDP record.
+** p_uuid - output parameter to save the UUID found.
+**
+** Returns TRUE if found, otherwise FALSE.
+**
+*******************************************************************************/
+SDP_API extern BOOLEAN SDP_FindServiceUUIDInRec_128bit(tSDP_DISC_REC *p_rec, tBT_UUID * p_uuid);
+
+/*******************************************************************************
+**
+** Function SDP_FindServiceInDb_128bit
+**
+** Description This function queries an SDP database for a specific service.
+** If the p_start_rec pointer is NULL, it looks from the beginning
+** of the database, else it continues from the next record after
+** p_start_rec.
+**
+** Returns Pointer to record containing service class, or NULL
+**
+*******************************************************************************/
+SDP_API extern tSDP_DISC_REC *SDP_FindServiceInDb_128bit(tSDP_DISCOVERY_DB *p_db,
+ tSDP_DISC_REC *p_start_rec);
/*******************************************************************************
**
diff --git a/stack/sdp/sdp_api.c b/stack/sdp/sdp_api.c
index ef13f15..fc2324a 100644
--- a/stack/sdp/sdp_api.c
+++ b/stack/sdp/sdp_api.c
@@ -392,6 +392,63 @@ BOOLEAN SDP_FindServiceUUIDInRec(tSDP_DISC_REC *p_rec, tBT_UUID * p_uuid)
/*******************************************************************************
**
+** Function SDP_FindServiceUUIDInRec_128bit
+**
+** Description This function is called to read the 128-bit service UUID within a record
+** if there is any.
+**
+** Parameters: p_rec - pointer to a SDP record.
+** p_uuid - output parameter to save the UUID found.
+**
+** Returns TRUE if found, otherwise FALSE.
+**
+*******************************************************************************/
+BOOLEAN SDP_FindServiceUUIDInRec_128bit(tSDP_DISC_REC *p_rec, tBT_UUID * p_uuid)
+{
+#if SDP_CLIENT_ENABLED == TRUE
+ tSDP_DISC_ATTR *p_attr, *p_sattr, *p_extra_sattr;
+
+ p_attr = p_rec->p_first_attr;
+
+ while (p_attr)
+ {
+ if ((p_attr->attr_id == ATTR_ID_SERVICE_CLASS_ID_LIST)
+ && (SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) == DATA_ELE_SEQ_DESC_TYPE))
+ {
+ for (p_sattr = p_attr->attr_value.v.p_sub_attr; p_sattr; p_sattr = p_sattr->p_next_attr)
+ {
+ if (SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UUID_DESC_TYPE)
+ {
+ /* only support 128 bits UUID for now */
+ if (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == 16)
+ {
+ p_uuid->len = 16;
+ memcpy(p_uuid->uu.uuid128, p_sattr->attr_value.v.array, MAX_UUID_SIZE);
+ }
+ return (TRUE);
+ }
+ }
+ break;
+ }
+ else if (p_attr->attr_id == ATTR_ID_SERVICE_ID)
+ {
+ if ((SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) == UUID_DESC_TYPE)
+ /* only support 128 bits UUID for now */
+ && (SDP_DISC_ATTR_LEN(p_attr->attr_len_type) == 16))
+ {
+ p_uuid->len = 16;
+ memcpy(p_uuid->uu.uuid128, p_sattr->attr_value.v.array, MAX_UUID_SIZE);
+ return (TRUE);
+ }
+ }
+ p_attr = p_attr->p_next_attr;
+ }
+ return FALSE;
+#endif
+}
+
+/*******************************************************************************
+**
** Function SDP_FindServiceInDb
**
** Description This function queries an SDP database for a specific service.
@@ -479,6 +536,71 @@ tSDP_DISC_REC *SDP_FindServiceInDb (tSDP_DISCOVERY_DB *p_db, UINT16 service_uuid
return (NULL);
}
+/*******************************************************************************
+**
+** Function SDP_FindServiceInDb_128bit
+**
+** Description This function queries an SDP database for a specific service.
+** If the p_start_rec pointer is NULL, it looks from the beginning
+** of the database, else it continues from the next record after
+** p_start_rec.
+**
+** This function is kept separate from SDP_FindServiceInDb since
+** that API is expected to return only 16-bit UUIDs
+**
+** Returns Pointer to record containing service class, or NULL
+**
+*******************************************************************************/
+tSDP_DISC_REC *SDP_FindServiceInDb_128bit(tSDP_DISCOVERY_DB *p_db, tSDP_DISC_REC *p_start_rec)
+{
+#if SDP_CLIENT_ENABLED == TRUE
+ tSDP_DISC_REC *p_rec;
+ tSDP_DISC_ATTR *p_attr, *p_sattr, *p_extra_sattr;
+
+ /* Must have a valid database */
+ if (p_db == NULL)
+ return (NULL);
+
+ if (!p_start_rec)
+ p_rec = p_db->p_first_rec;
+ else
+ p_rec = p_start_rec->p_next_rec;
+
+ while (p_rec)
+ {
+ p_attr = p_rec->p_first_attr;
+ while (p_attr)
+ {
+ if ((p_attr->attr_id == ATTR_ID_SERVICE_CLASS_ID_LIST)
+ && (SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) == DATA_ELE_SEQ_DESC_TYPE))
+ {
+ for (p_sattr = p_attr->attr_value.v.p_sub_attr; p_sattr; p_sattr = p_sattr->p_next_attr)
+ {
+ if ((SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UUID_DESC_TYPE)
+ && (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == 16))
+ {
+ return (p_rec);
+ }
+ }
+ break;
+ }
+ else if (p_attr->attr_id == ATTR_ID_SERVICE_ID)
+ {
+ if ((SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) == UUID_DESC_TYPE)
+ && (SDP_DISC_ATTR_LEN(p_attr->attr_len_type) == 16))
+ return (p_rec);
+ }
+
+ p_attr = p_attr->p_next_attr;
+ }
+
+ p_rec = p_rec->p_next_rec;
+ }
+#endif
+ /* If here, no matching UUID found */
+ return (NULL);
+}
+
/*******************************************************************************
**
diff --git a/stack/sdp/sdp_utils.c b/stack/sdp/sdp_utils.c
index 2e0fdd8..d98a30c 100644
--- a/stack/sdp/sdp_utils.c
+++ b/stack/sdp/sdp_utils.c
@@ -10,6 +10,7 @@
#include <stdlib.h>
#include <string.h>
+#include <netinet/in.h>
#include <stdio.h>
#include "gki.h"
@@ -1002,3 +1003,24 @@ UINT8 *sdpu_build_partial_attrib_entry (UINT8 *p_out, tSDP_ATTRIBUTE *p_attr, UI
return p_out;
}
+/*******************************************************************************
+**
+** Function sdpu_uuid16_to_uuid128
+**
+** Description This function converts UUID-16 to UUID-128 by including the base UUID
+**
+** uuid16: 2-byte UUID
+** p_uuid128: Expanded 128-bit UUID
+**
+** Returns None
+**
+*******************************************************************************/
+void sdpu_uuid16_to_uuid128(UINT16 uuid16, UINT8* p_uuid128)
+{
+ UINT16 uuid16_bo;
+ memset(p_uuid128, 0, 16);
+
+ memcpy(p_uuid128, sdp_base_uuid, MAX_UUID_SIZE);
+ uuid16_bo = ntohs(uuid16);
+ memcpy(p_uuid128+ 2, &uuid16_bo, sizeof(uint16_t));
+}
diff --git a/stack/sdp/sdpint.h b/stack/sdp/sdpint.h
index f4416d0..60b9f4e 100644
--- a/stack/sdp/sdpint.h
+++ b/stack/sdp/sdpint.h
@@ -283,7 +283,7 @@ extern UINT16 sdpu_get_list_len( tSDP_UUID_SEQ *uid_seq, tSDP_ATTR_SEQ *attr
extern UINT16 sdpu_get_attrib_seq_len(tSDP_RECORD *p_rec, tSDP_ATTR_SEQ *attr_seq);
extern UINT16 sdpu_get_attrib_entry_len(tSDP_ATTRIBUTE *p_attr);
extern UINT8 *sdpu_build_partial_attrib_entry (UINT8 *p_out, tSDP_ATTRIBUTE *p_attr, UINT16 len, UINT16 *offset);
-
+extern void sdpu_uuid16_to_uuid128(UINT16 uuid16, UINT8* p_uuid128);
/* Functions provided by sdp_db.c
*/