Skip to content

Commit a614fc0

Browse files
Michał Narajowskicarlescufi
authored andcommitted
Bluetooth: tester: Configure L2CAP Connection Response
Some test cases require the IUT to respond with a certain error. To get the stack to return this error to PTS the application needs to be configured specifically for this test case. Signed-off-by: Michał Narajowski <[email protected]>
1 parent f77c7dc commit a614fc0

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

tests/bluetooth/tester/src/bttester.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,11 @@ struct l2cap_send_data_cmd {
767767
#define L2CAP_TRANSPORT_BREDR 0x00
768768
#define L2CAP_TRANSPORT_LE 0x01
769769

770+
#define L2CAP_CONNECTION_RESPONSE_SUCCESS 0x00
771+
#define L2CAP_CONNECTION_RESPONSE_INSUFF_AUTHEN 0x01
772+
#define L2CAP_CONNECTION_RESPONSE_INSUFF_AUTHOR 0x02
773+
#define L2CAP_CONNECTION_RESPONSE_INSUFF_ENC_KEY 0x03
774+
770775
#define L2CAP_LISTEN 0x05
771776
struct l2cap_listen_cmd {
772777
uint16_t psm;

tests/bluetooth/tester/src/l2cap.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,9 @@ static int accept(struct bt_conn *conn, struct bt_l2cap_chan **l2cap_chan)
313313
}
314314

315315
if (bt_conn_enc_key_size(conn) < req_keysize) {
316-
/* TSPX_psm_encryption_key_size_required */
317316
req_keysize = 0;
318317
return -EPERM;
319318
} else if (authorize_flag) {
320-
/* TSPX_psm_authorization_required
321-
* we never authorize this connection, so return error
322-
* everytime this psm is used
323-
*/
324319
authorize_flag = false;
325320
return -EACCES;
326321
}
@@ -352,14 +347,12 @@ static void listen(uint8_t *data, uint16_t len)
352347
server->accept = accept;
353348
server->psm = cmd->psm;
354349

355-
if (server->psm == 0x00F4) {
350+
if (cmd->response == L2CAP_CONNECTION_RESPONSE_INSUFF_ENC_KEY) {
356351
/* TSPX_psm_encryption_key_size_required */
357352
req_keysize = 16;
358-
} else if (server->psm == 0x00F3) {
359-
/* TSPX_psm_authentication_required */
353+
} else if (cmd->response == L2CAP_CONNECTION_RESPONSE_INSUFF_AUTHOR) {
360354
authorize_flag = true;
361-
} else if (server->psm == 0x00F2) {
362-
/* TSPX_psm_authentication_required */
355+
} else if (cmd->response == L2CAP_CONNECTION_RESPONSE_INSUFF_AUTHEN) {
363356
server->sec_level = BT_SECURITY_L3;
364357
}
365358

0 commit comments

Comments
 (0)