Skip to content

Commit

Permalink
Bluetooth: ATT: Respond with not support error for unknown PDUs
Browse files Browse the repository at this point in the history
This ensures that an unknown request won't cause ATT to timeout since
no response is currently generated.

Signed-off-by: Luiz Augusto von Dentz <[email protected]>
  • Loading branch information
Vudentz authored and Anas Nashif committed May 2, 2017
1 parent b7f6aaa commit 024de97
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions subsys/bluetooth/host/att.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
BT_GATT_PERM_WRITE_ENCRYPT)
#define BT_GATT_PERM_AUTHEN_MASK (BT_GATT_PERM_READ_AUTHEN | \
BT_GATT_PERM_WRITE_AUTHEN)
#define ATT_CMD_MASK 0x40

#define ATT_TIMEOUT K_SECONDS(30)

Expand Down Expand Up @@ -1825,6 +1826,10 @@ static att_type_t att_op_get_type(u8_t op)
}
}

if (op & ATT_CMD_MASK) {
return ATT_COMMAND;
}

return ATT_UNKNOWN;
}

Expand Down Expand Up @@ -1854,6 +1859,10 @@ static void bt_att_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)

if (!handler) {
BT_WARN("Unknown ATT code 0x%02x", hdr->code);
if (att_op_get_type(hdr->code) != ATT_COMMAND) {
send_err_rsp(chan->conn, hdr->code, 0,
BT_ATT_ERR_NOT_SUPPORTED);
}
return;
}

Expand Down

0 comments on commit 024de97

Please sign in to comment.