diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2022-12-06 13:31:58 -0800 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2022-12-06 13:31:58 -0800 |
commit | 33b84917ee9645a1fbef9173ee6e1df47cc8ff2c (patch) | |
tree | e79d3a2a70c32f2546108f8f4fd5cdf15b1b3f23 /emulator | |
parent | 9a550d43b84ed808ff2a678b0117a8e14355d80c (diff) | |
download | bluez-33b84917ee9645a1fbef9173ee6e1df47cc8ff2c.tar.gz |
bthost: Add callback to accept ISO connections
This enables setting an accept callback which can return reject
reason if the connection shall not be accepted.
Diffstat (limited to 'emulator')
-rw-r--r-- | emulator/bthost.c | 21 | ||||
-rw-r--r-- | emulator/bthost.h | 5 |
2 files changed, 21 insertions, 5 deletions
diff --git a/emulator/bthost.c b/emulator/bthost.c index b05198953..3cce4666c 100644 --- a/emulator/bthost.c +++ b/emulator/bthost.c @@ -224,6 +224,7 @@ struct bthost { void *cmd_complete_data; bthost_new_conn_cb new_conn_cb; void *new_conn_data; + bthost_accept_conn_cb accept_iso_cb; bthost_new_conn_cb new_iso_cb; void *new_iso_data; struct rfcomm_connection_data *rfcomm_conn_data; @@ -1465,12 +1466,25 @@ static void evt_le_cis_req(struct bthost *bthost, const void *data, uint8_t len) { const struct bt_hci_evt_le_cis_req *ev = data; struct bt_hci_cmd_le_accept_cis cmd; + struct bt_hci_cmd_le_reject_cis rej; if (len < sizeof(*ev)) return; - memset(&cmd, 0, sizeof(cmd)); + if (bthost->accept_iso_cb) { + memset(&rej, 0, sizeof(rej)); + + rej.reason = bthost->accept_iso_cb(le16_to_cpu(ev->cis_handle), + bthost->new_iso_data); + if (rej.reason) { + rej.handle = ev->cis_handle; + send_command(bthost, BT_HCI_CMD_LE_REJECT_CIS, + &rej, sizeof(rej)); + return; + } + } + memset(&cmd, 0, sizeof(cmd)); cmd.handle = ev->cis_handle; send_command(bthost, BT_HCI_CMD_LE_ACCEPT_CIS, &cmd, sizeof(cmd)); @@ -2893,9 +2907,10 @@ void bthost_set_connect_cb(struct bthost *bthost, bthost_new_conn_cb cb, bthost->new_conn_data = user_data; } -void bthost_set_iso_cb(struct bthost *bthost, bthost_new_conn_cb cb, - void *user_data) +void bthost_set_iso_cb(struct bthost *bthost, bthost_accept_conn_cb accept, + bthost_new_conn_cb cb, void *user_data) { + bthost->accept_iso_cb = accept; bthost->new_iso_cb = cb; bthost->new_iso_data = user_data; } diff --git a/emulator/bthost.h b/emulator/bthost.h index 2cfdef766..c42444476 100644 --- a/emulator/bthost.h +++ b/emulator/bthost.h @@ -44,13 +44,14 @@ typedef void (*bthost_cmd_complete_cb) (uint16_t opcode, uint8_t status, void bthost_set_cmd_complete_cb(struct bthost *bthost, bthost_cmd_complete_cb cb, void *user_data); +typedef uint8_t (*bthost_accept_conn_cb) (uint16_t handle, void *user_data); typedef void (*bthost_new_conn_cb) (uint16_t handle, void *user_data); void bthost_set_connect_cb(struct bthost *bthost, bthost_new_conn_cb cb, void *user_data); -void bthost_set_iso_cb(struct bthost *bthost, bthost_new_conn_cb cb, - void *user_data); +void bthost_set_iso_cb(struct bthost *bthost, bthost_accept_conn_cb accept, + bthost_new_conn_cb cb, void *user_data); void bthost_hci_connect(struct bthost *bthost, const uint8_t *bdaddr, uint8_t addr_type); |