diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index 90c09bb..d6f3143 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
return service->attributes[0]->handle + service->num_handles - 1;
}
+
+uint32_t gatt_db_get_attribute_permissions(struct gatt_db *db, uint16_t handle)
+{
+ struct gatt_db_attribute *attribute;
+ struct gatt_db_service *service;
+ uint16_t service_handle;
+
+ service = queue_find(db->services, find_service_for_handle,
+ INT_TO_PTR(handle));
+ if (!service)
+ return 0;
+
+ service_handle = service->attributes[0]->handle;
+
+ /*
+ * We can safely get attribute from attributes array with offset,
+ * because find_service_for_handle() check if given handle is
+ * in service range.
+ */
+ attribute = service->attributes[handle - service_handle];
+ if (!attribute)
+ return 0;
+
+ return attribute->permissions;
+}
diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h
index 350e34e..f2f2f4d 100644
--- a/src/shared/gatt-db.h
+++ b/src/shared/gatt-db.h
uint16_t handle);
uint16_t gatt_db_get_end_handle(struct gatt_db *db, uint16_t handle);
+
+uint32_t gatt_db_get_attribute_permissions(struct gatt_db *db, uint16_t handle);