aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndre Dieb Martins <andre.dieb@signove.com>2011-02-23 12:14:19 -0300
committerJohan Hedberg <johan.hedberg@nokia.com>2011-02-24 15:43:32 -0300
commit4ae6cfca554d704053dc3a4c02f0bc3eca9f77ab (patch)
tree36dce00f3ca02ae6e598d6743ee269d43b881955 /src
parent34d6f0e397265e41bbce687bdee68f9c27ac950e (diff)
downloadbluez-4ae6cfca554d704053dc3a4c02f0bc3eca9f77ab.tar.gz
Check properties before setting client configs
Only enable notification/indication if the descriptor allows it.
Diffstat (limited to 'src')
-rw-r--r--src/attrib-server.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 47ca5d9d..21da17e3 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -199,13 +199,14 @@ static uint8_t client_set_notifications(struct attribute *attr,
struct gatt_channel *channel = user_data;
struct attribute *last_chr_val = NULL;
uint16_t cfg_val;
+ uint8_t props;
uuid_t uuid;
GSList *l;
cfg_val = att_get_u16(attr->data);
sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
- for (l = database; l != NULL; l = l->next) {
+ for (l = database, props = 0; l != NULL; l = l->next) {
struct attribute *a = l->data;
static uint16_t handle = 0;
@@ -213,6 +214,7 @@ static uint8_t client_set_notifications(struct attribute *attr,
break;
if (sdp_uuid_cmp(&a->uuid, &uuid) == 0) {
+ props = att_get_u8(&a->data[0]);
handle = att_get_u16(&a->data[1]);
continue;
}
@@ -224,8 +226,11 @@ static uint8_t client_set_notifications(struct attribute *attr,
if (last_chr_val == NULL)
return 0;
- /* FIXME: Characteristic properties shall be checked for
- * Notification/Indication permissions. */
+ if ((cfg_val & 0x0001) && !(props & ATT_CHAR_PROPER_NOTIFY))
+ return ATT_ECODE_WRITE_NOT_PERM;
+
+ if ((cfg_val & 0x0002) && !(props & ATT_CHAR_PROPER_INDICATE))
+ return ATT_ECODE_WRITE_NOT_PERM;
if (cfg_val & 0x0001)
channel->notify = g_slist_append(channel->notify, last_chr_val);