Bluetooth: ATT: Check mask instead of specific permission

This enables simpler permissions as it is not longer needed to include
BT_GATT_PERM_READ or BT_GATT_PERM_WRITE.

Change-Id: I0c749b75bedb125bda8ea451474c82eec13d3c38
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2016-01-25 10:41:53 +02:00 committed by Anas Nashif
commit 7834061d12

View file

@ -532,11 +532,13 @@ static bool uuid_create(struct bt_uuid *uuid, struct net_buf *buf)
static uint8_t check_perm(struct bt_conn *conn, const struct bt_gatt_attr *attr,
uint8_t mask)
{
if ((mask & BT_GATT_PERM_READ) && !(attr->perm & BT_GATT_PERM_READ)) {
if ((mask & BT_GATT_PERM_READ) &&
!(attr->perm & BT_GATT_PERM_READ_MASK)) {
return BT_ATT_ERR_READ_NOT_PERMITTED;
}
if ((mask & BT_GATT_PERM_WRITE) && !(attr->perm & BT_GATT_PERM_WRITE)) {
if ((mask & BT_GATT_PERM_WRITE) &&
!(attr->perm & BT_GATT_PERM_WRITE_MASK)) {
return BT_ATT_ERR_WRITE_NOT_PERMITTED;
}