Bluetooth: controller: Implement Read/Write Auth Payload timeout
Added implementation to support HCI Read Authenticated Payload Timeout Command and HCI Write Authenticated Payload Timeout Command. This fixes: TP/SEC/SLA/BV-08-C [No response to LL_PING_REQ] TP/SEC/SLA/BV-09-C [Modified Authentication Payload Timeout] TP/SEC/MAS/BV-08-C [No response to LL_PING_REQ] TP/SEC/MAS/BV-09-C [Modified Authentication Payload Timeout] conformance tests in LL.TS.5.0.0. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
4732452a42
commit
255e5cc344
4 changed files with 130 additions and 5 deletions
|
@ -555,6 +555,28 @@ struct bt_hci_cp_write_sc_host_supp {
|
|||
u8_t sc_support;
|
||||
} __packed;
|
||||
|
||||
#define BT_HCI_OP_READ_AUTH_PAYLOAD_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x007b)
|
||||
struct bt_hci_cp_read_auth_payload_timeout {
|
||||
u16_t handle;
|
||||
} __packed;
|
||||
|
||||
struct bt_hci_rp_read_auth_payload_timeout {
|
||||
u8_t status;
|
||||
u16_t handle;
|
||||
u16_t auth_payload_timeout;
|
||||
} __packed;
|
||||
|
||||
#define BT_HCI_OP_WRITE_AUTH_PAYLOAD_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x007c)
|
||||
struct bt_hci_cp_write_auth_payload_timeout {
|
||||
u16_t handle;
|
||||
u16_t auth_payload_timeout;
|
||||
} __packed;
|
||||
|
||||
struct bt_hci_rp_write_auth_payload_timeout {
|
||||
u8_t status;
|
||||
u16_t handle;
|
||||
} __packed;
|
||||
|
||||
/* HCI version from Assigned Numbers */
|
||||
#define BT_HCI_VERSION_1_0B 0
|
||||
#define BT_HCI_VERSION_1_1 1
|
||||
|
|
|
@ -314,6 +314,45 @@ static void host_num_completed_packets(struct net_buf *buf,
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_LE_PING)
|
||||
static void read_auth_payload_timeout(struct net_buf *buf, struct net_buf **evt)
|
||||
{
|
||||
struct bt_hci_cp_read_auth_payload_timeout *cmd = (void *)buf->data;
|
||||
struct bt_hci_rp_read_auth_payload_timeout *rp;
|
||||
u32_t status;
|
||||
u16_t handle;
|
||||
u16_t auth_payload_timeout;
|
||||
|
||||
handle = sys_le16_to_cpu(cmd->handle);
|
||||
|
||||
status = ll_apto_get(handle, &auth_payload_timeout);
|
||||
|
||||
rp = cmd_complete(evt, sizeof(*rp));
|
||||
rp->status = (!status) ? 0x00 : BT_HCI_ERR_CMD_DISALLOWED;
|
||||
rp->handle = sys_cpu_to_le16(handle);
|
||||
rp->auth_payload_timeout = sys_cpu_to_le16(auth_payload_timeout);
|
||||
}
|
||||
|
||||
static void write_auth_payload_timeout(struct net_buf *buf,
|
||||
struct net_buf **evt)
|
||||
{
|
||||
struct bt_hci_cp_write_auth_payload_timeout *cmd = (void *)buf->data;
|
||||
struct bt_hci_rp_write_auth_payload_timeout *rp;
|
||||
u32_t status;
|
||||
u16_t handle;
|
||||
u16_t auth_payload_timeout;
|
||||
|
||||
handle = sys_le16_to_cpu(cmd->handle);
|
||||
auth_payload_timeout = sys_le16_to_cpu(cmd->auth_payload_timeout);
|
||||
|
||||
status = ll_apto_set(handle, auth_payload_timeout);
|
||||
|
||||
rp = cmd_complete(evt, sizeof(*rp));
|
||||
rp->status = (!status) ? 0x00 : BT_HCI_ERR_CMD_DISALLOWED;
|
||||
rp->handle = sys_cpu_to_le16(handle);
|
||||
}
|
||||
#endif /* CONFIG_BLUETOOTH_CONTROLLER_LE_PING */
|
||||
|
||||
static int ctrl_bb_cmd_handle(u16_t ocf, struct net_buf *cmd,
|
||||
struct net_buf **evt)
|
||||
{
|
||||
|
@ -343,6 +382,17 @@ static int ctrl_bb_cmd_handle(u16_t ocf, struct net_buf *cmd,
|
|||
host_num_completed_packets(cmd, evt);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_LE_PING)
|
||||
case BT_OCF(BT_HCI_OP_READ_AUTH_PAYLOAD_TIMEOUT):
|
||||
read_auth_payload_timeout(cmd, evt);
|
||||
break;
|
||||
|
||||
case BT_OCF(BT_HCI_OP_WRITE_AUTH_PAYLOAD_TIMEOUT):
|
||||
write_auth_payload_timeout(cmd, evt);
|
||||
break;
|
||||
#endif /* CONFIG_BLUETOOTH_CONTROLLER_LE_PING */
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -379,6 +429,7 @@ static void read_supported_commands(struct net_buf *buf, struct net_buf **evt)
|
|||
/* Set FC, Host Buffer Size and Host Num Completed */
|
||||
rp->commands[10] |= BIT(5) | BIT(6) | BIT(7);
|
||||
#endif
|
||||
|
||||
/* Read Local Version Info, Read Local Supported Features. */
|
||||
rp->commands[14] |= BIT(3) | BIT(5);
|
||||
/* Read BD ADDR. */
|
||||
|
@ -430,6 +481,10 @@ static void read_supported_commands(struct net_buf *buf, struct net_buf **evt)
|
|||
rp->commands[27] |= BIT(2) | BIT(5);
|
||||
/* LE Remote Conn Param Req and Neg Reply */
|
||||
rp->commands[33] |= BIT(4) | BIT(5);
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_LE_PING)
|
||||
/* Read and Write authenticated payload timeout */
|
||||
rp->commands[32] |= BIT(4) | BIT(5);
|
||||
#endif
|
||||
#endif /* CONFIG_BLUETOOTH_CONN */
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_PRIVACY)
|
||||
/* LE resolving list commands, LE Read Peer RPA */
|
||||
|
|
|
@ -71,6 +71,11 @@ u32_t ll_version_ind_send(u16_t handle);
|
|||
u32_t ll_terminate_ind_send(u16_t handle, u8_t reason);
|
||||
void ll_timeslice_ticker_id_get(u8_t * const instance_index, u8_t * const user_id);
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_LE_PING)
|
||||
u32_t ll_apto_get(u16_t handle, u16_t *apto);
|
||||
u32_t ll_apto_set(u16_t handle, u16_t apto);
|
||||
#endif /* CONFIG_BLUETOOTH_CONTROLLER_LE_PING */
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH)
|
||||
u32_t ll_length_req_send(u16_t handle, u16_t tx_octets);
|
||||
void ll_length_default_get(u16_t *max_tx_octets, u16_t *max_tx_time);
|
||||
|
|
|
@ -2579,12 +2579,24 @@ isr_rx_conn_pkt(struct radio_pdu_node_rx *radio_pdu_node_rx,
|
|||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_LE_PING)
|
||||
} else if ((_radio.conn_curr->enc_rx) ||
|
||||
(_radio.conn_curr->pause_rx)) {
|
||||
struct connection *conn = _radio.conn_curr;
|
||||
u16_t appto_reload_new;
|
||||
|
||||
/* check for change in apto */
|
||||
appto_reload_new = (conn->apto_reload >
|
||||
(conn->latency + 6)) ?
|
||||
(conn->apto_reload -
|
||||
(conn->latency + 6)) :
|
||||
conn->apto_reload;
|
||||
if (conn->appto_reload != appto_reload_new) {
|
||||
conn->appto_reload = appto_reload_new;
|
||||
conn->apto_expire = 0;
|
||||
}
|
||||
|
||||
/* start authenticated payload (pre) timeout */
|
||||
if (_radio.conn_curr->apto_expire == 0) {
|
||||
_radio.conn_curr->appto_expire =
|
||||
_radio.conn_curr->appto_reload;
|
||||
_radio.conn_curr->apto_expire =
|
||||
_radio.conn_curr->apto_reload;
|
||||
if (conn->apto_expire == 0) {
|
||||
conn->appto_expire = conn->appto_reload;
|
||||
conn->apto_expire = conn->apto_reload;
|
||||
}
|
||||
#endif /* CONFIG_BLUETOOTH_CONTROLLER_LE_PING */
|
||||
|
||||
|
@ -9097,6 +9109,37 @@ u32_t ll_terminate_ind_send(u16_t handle, u8_t reason)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_LE_PING)
|
||||
u32_t ll_apto_get(u16_t handle, u16_t *apto)
|
||||
{
|
||||
struct connection *conn;
|
||||
|
||||
conn = connection_get(handle);
|
||||
if (!conn) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
*apto = conn->apto_reload * conn->conn_interval * 125 / 1000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32_t ll_apto_set(u16_t handle, u16_t apto)
|
||||
{
|
||||
struct connection *conn;
|
||||
|
||||
conn = connection_get(handle);
|
||||
if (!conn) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
conn->apto_reload = RADIO_CONN_EVENTS(apto * 10 * 1000,
|
||||
conn->conn_interval * 1250);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_BLUETOOTH_CONTROLLER_LE_PING */
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_DATA_LENGTH)
|
||||
u32_t ll_length_req_send(u16_t handle, u16_t tx_octets)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue