From 064f48ad6dd0eb4becb94f5492b6c78218065f19 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 2 Mar 2016 16:04:18 +0200 Subject: shared/gatt-client: Fix not detecting BT_ATT_SECURITY_AUTO Using bt_gatt_security cannot detect if BT_ATT_SECURITY_AUTO is enabled since it actually checks the current level when operating over L2CAP, so instead use io_sec_level internal field to detect the security level in which ATT is supposed to be operating. --- src/shared/att.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/shared/att.c b/src/shared/att.c index 3a84783b6..7b2075733 100644 --- a/src/shared/att.c +++ b/src/shared/att.c @@ -573,10 +573,11 @@ static bool change_security(struct bt_att *att, uint8_t ecode) { int security; - security = bt_att_get_security(att); - if (security != BT_ATT_SECURITY_AUTO) + if (att->io_sec_level != BT_ATT_SECURITY_AUTO) return false; + security = bt_att_get_security(att); + if (ecode == BT_ATT_ERROR_INSUFFICIENT_ENCRYPTION && security < BT_ATT_SECURITY_MEDIUM) security = BT_ATT_SECURITY_MEDIUM; @@ -979,7 +980,7 @@ struct bt_att *bt_att_new(int fd, bool ext_signed) att->io_on_l2cap = is_io_l2cap_based(att->fd); if (!att->io_on_l2cap) - att->io_sec_level = BT_SECURITY_LOW; + att->io_sec_level = BT_ATT_SECURITY_LOW; return bt_att_ref(att); -- cgit v1.2.1