Bluetooth: controller: Validate disconnect reason in disconnect command
Validate the disconnect reason in the disconnect command, according to the the core specification. 7.1.6 Disconnect command: Authentication Failure error code (0x05), Other End Terminated Connec- tion error codes (0x13 to 0x15), Unsupported Remote Feature error code (0x1A), Pairing with Unit Key Not Supported error code (0x29) and Unac- ceptable Connection Parameters error code (0x3B). Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
9205fe0a3a
commit
39e14580e9
1 changed files with 20 additions and 0 deletions
|
@ -410,10 +410,30 @@ uint8_t ll_chm_get(uint16_t handle, uint8_t *chm)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static bool is_valid_disconnect_reason(uint8_t reason)
|
||||
{
|
||||
switch (reason) {
|
||||
case BT_HCI_ERR_AUTH_FAIL:
|
||||
case BT_HCI_ERR_REMOTE_USER_TERM_CONN:
|
||||
case BT_HCI_ERR_REMOTE_LOW_RESOURCES:
|
||||
case BT_HCI_ERR_REMOTE_POWER_OFF:
|
||||
case BT_HCI_ERR_UNSUPP_REMOTE_FEATURE:
|
||||
case BT_HCI_ERR_PAIRING_NOT_SUPPORTED:
|
||||
case BT_HCI_ERR_UNACCEPT_CONN_PARAM:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ll_terminate_ind_send(uint16_t handle, uint8_t reason)
|
||||
{
|
||||
struct ll_conn *conn;
|
||||
|
||||
if (!is_valid_disconnect_reason(reason)) {
|
||||
return BT_HCI_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
conn = ll_connected_get(handle);
|
||||
if (!conn) {
|
||||
return BT_HCI_ERR_UNKNOWN_CONN_ID;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue