summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinjun.yang <injun.yang@samsung.com>2020-04-13 12:07:23 +0900
committerWootak Jung <wootak.jung@samsung.com>2020-04-14 13:00:20 +0900
commit9a0566e791b76b74dae640d434430c36811a601b (patch)
treebef51d00d78f697c2ce564c68564dc47e6785991
parent152d19ff37e598b9592b14c3fbec317506573ab0 (diff)
downloadbluez-9a0566e791b76b74dae640d434430c36811a601b.tar.gz
bluez-9a0566e791b76b74dae640d434430c36811a601b.tar.bz2
bluez-9a0566e791b76b74dae640d434430c36811a601b.zip
Set the permission of CCC descriptior properly
[Model] All [BinType] AP [Customer] OPEN [Issue#] N/A [Request] Internal [Occurrence Version] N/A [Problem] Non bonded device can access to CCCD which have encrypted_authenticated permission [Cause & Measure] Even though application set encrypted_authenticated permission to CCCD, bluez set it as read & write permission [Checking Method] Register gatt server app which have encrypted_authenticated permiion on descriptor [Team] Convergence BT [Developer] Injun Yang [Solution company] Samsung [Change Type] Specification change Change-Id: If6e718946a1e14297f6bd8c7af232d7425947746
-rw-r--r--src/gatt-database.c65
1 files changed, 64 insertions, 1 deletions
diff --git a/src/gatt-database.c b/src/gatt-database.c
index 3eeebb39..ec834200 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -1239,6 +1239,42 @@ service_add_ccc(struct gatt_db_attribute *service,
return ccc;
}
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+static struct gatt_db_attribute *
+service_add_ccc_extra(struct gatt_db_attribute *service,
+ struct btd_gatt_database *database,
+ btd_gatt_database_ccc_write_t write_callback,
+ uint32_t perm,
+ void *user_data,
+ btd_gatt_database_destroy_t destroy)
+{
+ struct gatt_db_attribute *ccc;
+ struct ccc_cb_data *ccc_cb;
+ bt_uuid_t uuid;
+
+ ccc_cb = new0(struct ccc_cb_data, 1);
+
+ bt_uuid16_create(&uuid, GATT_CLIENT_CHARAC_CFG_UUID);
+ ccc = gatt_db_service_add_descriptor(service, &uuid,
+ perm,
+ gatt_ccc_read_cb, gatt_ccc_write_cb, database);
+ if (!ccc) {
+ error("Failed to create CCC entry in database");
+ free(ccc_cb);
+ return NULL;
+ }
+
+ ccc_cb->handle = gatt_db_attribute_get_handle(ccc);
+ ccc_cb->callback = write_callback;
+ ccc_cb->destroy = destroy;
+ ccc_cb->user_data = user_data;
+
+ queue_push_tail(database->ccc_callbacks, ccc_cb);
+
+ return ccc;
+}
+#endif
+
static void cli_feat_read_cb(struct gatt_db_attribute *attrib,
unsigned int id, uint16_t offset,
uint8_t opcode, struct bt_att *att,
@@ -3153,6 +3189,32 @@ static void property_changed_cb(GDBusProxy *proxy, const char *name,
#endif
}
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+static bool database_add_ccc_extra(struct external_service *service,
+ struct external_chrc *chrc, struct external_desc *desc)
+{
+ if (!(chrc->props & BT_GATT_CHRC_PROP_NOTIFY) &&
+ !(chrc->props & BT_GATT_CHRC_PROP_INDICATE))
+ return true;
+
+ chrc->ccc = service_add_ccc_extra(service->attrib, service->app->database,
+ ccc_write_cb, desc->perm, chrc, NULL);
+ if (!chrc->ccc) {
+ error("Failed to create CCC entry for characteristic");
+ return false;
+ }
+
+ if (g_dbus_proxy_set_property_watch(chrc->proxy, property_changed_cb,
+ chrc) == FALSE) {
+ error("Failed to set up property watch for characteristic");
+ return false;
+ }
+
+ DBG("Created CCC entry for characteristic");
+
+ return true;
+}
+#else
static bool database_add_ccc(struct external_service *service,
struct external_chrc *chrc)
{
@@ -3177,6 +3239,7 @@ static bool database_add_ccc(struct external_service *service,
return true;
}
+#endif
static void cep_write_cb(struct gatt_db_attribute *attrib, int err,
void *user_data)
@@ -3565,7 +3628,7 @@ static bool database_add_chrc(struct external_service *service,
/* Check if Application wants to add CCC and use existing
* implemenation to add CCC descriptors */
if (database_check_ccc_desc(desc)) {
- if (!database_add_ccc(service, chrc)) {
+ if (!database_add_ccc_extra(service, chrc, desc)) {
chrc->attrib = NULL;
return false;
}