bthost: Add callback to accept ISO connections
Luiz Augusto von Dentz
maintainerPATCH 1/2 bthost: Add callback to accept ISO connections
From: Luiz Augusto von Dentz <[email protected]>
This enables setting an accept callback which can return reject reason if the connection shall not be accepted.
--- emulator/bthost.c | 21 ++++++++++++++++++--- emulator/bthost.h | 5 +++-- tools/iso-tester.c | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-)
emulator/bthost.c +18 -3
@@ -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; }
emulator/bthost.h +3 -2
@@ -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);
tools/iso-tester.c +1 -1
@@ -752,7 +752,7 @@ static void setup_powered_callback(uint8_t status, uint16_t length,continue ;if (isodata->send || isodata->recv || isodata->disconnect) -bthost_set_iso_cb (host, iso_new_conn, data); +bthost_set_iso_cb (host,NULL , iso_new_conn, data);if (isodata->bcast) {bthost_set_pa_params (host);
Signature · 1 line
2.37.3
Luiz Augusto von Dentz
maintainerPATCH 2/2 iso-tester: Add test when peer rejects CIS
From: Luiz Augusto von Dentz <[email protected]>
This adds the following test for testing when remote stack rejects the CIS:
--- tools/iso-tester.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-)
tools/iso-tester.c +31 -6
@@ -130,6 +130,7 @@ struct test_data {uint16_t mgmt_index;struct hciemu *hciemu;enum hciemu_type hciemu_type; +uint8_t accept_reason;uint16_t handle;uint16_t acl_handle;GIOChannel *io;
@@ -342,7 +343,7 @@ static void test_data_free(void *test_data)free (data); } -#define test_iso_full (name, data, setup, func, num) \ +#define test_iso_full (name, data, setup, func, num, reason) \ do { \ struct test_data *user; \ user = new0(struct test_data, 1); \
@@ -351,16 +352,20 @@ static void test_data_free(void *test_data) user->hciemu_type =HCIEMU_TYPE_BREDRLE ; \ user->test_data = data; \ user->client_num = num; \ + user->accept_reason = reason; \tester_add_full (name, data, \ test_pre_setup, setup, func,NULL , \ test_post_teardown,2 , user, test_data_free); \ } while (0)#define test_iso (name, data, setup, func) \ - test_iso_full(name, data, setup, func, 1) + test_iso_full(name, data, setup, func, 1, 0x00)#define test_iso2 (name, data, setup, func) \ - test_iso_full(name, data, setup, func, 2) + test_iso_full(name, data, setup, func, 2, 0x00) + +#define test_iso_rej (name, data, setup, func, reason) \ + test_iso_full(name, data, setup, func, 1, reason)static const struct iso_client_data connect_8_1_1 = { .qos =QOS_8_1_1 ,
@@ -537,6 +542,11 @@ static const struct iso_client_data connect_invalid = { .expect_err = -EINVAL }; +static const struct iso_client_data connect_reject = { + .qos =QOS_16_1_2 , + .expect_err = -ENOSYS +}; +static const uint8_t data_16_2_1[40 ] = { [0 ...39 ] =0xff };static const struct iovec send_16_2_1 = { .iov_base = (void *)data_16_2_1,
@@ -714,6 +724,16 @@ static void iso_new_conn(uint16_t handle, void *user_data) bthost_iso_disconnected); } +static uint8_t iso_accept_conn (uint16_t handle,void *user_data) +{ +struct test_data *data = user_data; + +tester_print ("Accept client connection with handle 0x%04x: 0x%02x" , + handle, data->accept_reason); + +return data->accept_reason; +} +static void acl_new_conn (uint16_t handle,void *user_data) {struct test_data *data = user_data;
@@ -751,8 +771,10 @@ static void setup_powered_callback(uint8_t status, uint16_t length,if (!isodata)continue ; -if (isodata->send || isodata->recv || isodata->disconnect) -bthost_set_iso_cb (host,NULL , iso_new_conn, data); +if (isodata->send || isodata->recv || isodata->disconnect || + data->accept_reason) +bthost_set_iso_cb (host, iso_accept_conn, iso_new_conn, + data);if (isodata->bcast) {bthost_set_pa_params (host);
@@ -1249,7 +1271,7 @@ static gboolean iso_connect(GIOChannel *io, GIOCondition cond,else tester_print ("Successfully connected" ); -if (-err != isodata->expect_err) { +if (err != isodata->expect_err) {tester_warn ("Expect error: %s (%d) != %s (%d)" ,strerror (-isodata->expect_err), -isodata->expect_err,strerror (-err), -err);
@@ -1773,6 +1795,9 @@ int main(int argc, char *argv[])test_iso ("ISO QoS - Invalid" , &connect_invalid, setup_powered, test_connect); +test_iso_rej ("ISO Connect - Reject" , &connect_reject, setup_powered, + test_connect,BT_HCI_ERR_CONN_FAILED_TO_ESTABLISH ); +test_iso2 ("ISO Connect2 CIG 0x01 - Success" , &connect_1_16_2_1, setup_powered, test_connect2);
Signature · 1 line
2.37.3
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=702365
---Test result---
Test Summary:
CheckPatch FAIL 1.18 seconds GitLint PASS 0.58 seconds BuildEll PASS 26.21 seconds BluezMake PASS 754.78 seconds MakeCheck PASS 11.29 seconds MakeDistcheck PASS 145.20 seconds CheckValgrind PASS 238.68 seconds bluezmakeextell PASS 93.16 seconds IncrementalBuild PASS 1219.62 seconds ScanBuild PASS 967.01 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,2/2] iso-tester: Add test when peer rejects CIS WARNING:ENOSYS: ENOSYS means 'invalid syscall nr' and nothing else #141: FILE: tools/iso-tester.c:547:
+ .expect_err = -ENOSYS
/github/workspace/src/src/13066515.patch total: 0 errors, 1 warnings, 93 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/src/13066515.patch has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
---
Regards,
Linux Bluetooth
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 9 lines · On Tue, 6 Dec 2022 17:35:45 -0800 you wrote:
From: Luiz Augusto von Dentz <[email protected]>
This enables setting an accept callback which can return reject reason if the connection shall not be accepted.
--- emulator/bthost.c | 21 ++++++++++++++++++--- emulator/bthost.h | 5 +++-- tools/iso-tester.c | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-)
Here is the summary with links:
- [BlueZ,1/2] bthost: Add callback to accept ISO connections (no matching commit)
- [BlueZ,2/2] iso-tester: Add test when peer rejects CIS
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=758161c422e6
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html