From a614fc02ad58706fbb9f4d74b9e55a0bbb6c8855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Narajowski?= Date: Fri, 27 Aug 2021 15:34:34 +0200 Subject: [PATCH] Bluetooth: tester: Configure L2CAP Connection Response MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/bluetooth/tester/src/bttester.h | 5 +++++ tests/bluetooth/tester/src/l2cap.c | 13 +++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/bluetooth/tester/src/bttester.h b/tests/bluetooth/tester/src/bttester.h index c49309fb2d3..826c4749234 100644 --- a/tests/bluetooth/tester/src/bttester.h +++ b/tests/bluetooth/tester/src/bttester.h @@ -767,6 +767,11 @@ struct l2cap_send_data_cmd { #define L2CAP_TRANSPORT_BREDR 0x00 #define L2CAP_TRANSPORT_LE 0x01 +#define L2CAP_CONNECTION_RESPONSE_SUCCESS 0x00 +#define L2CAP_CONNECTION_RESPONSE_INSUFF_AUTHEN 0x01 +#define L2CAP_CONNECTION_RESPONSE_INSUFF_AUTHOR 0x02 +#define L2CAP_CONNECTION_RESPONSE_INSUFF_ENC_KEY 0x03 + #define L2CAP_LISTEN 0x05 struct l2cap_listen_cmd { uint16_t psm; diff --git a/tests/bluetooth/tester/src/l2cap.c b/tests/bluetooth/tester/src/l2cap.c index 470fad9bfc6..80ac7b96bc2 100644 --- a/tests/bluetooth/tester/src/l2cap.c +++ b/tests/bluetooth/tester/src/l2cap.c @@ -313,14 +313,9 @@ static int accept(struct bt_conn *conn, struct bt_l2cap_chan **l2cap_chan) } if (bt_conn_enc_key_size(conn) < req_keysize) { - /* TSPX_psm_encryption_key_size_required */ req_keysize = 0; return -EPERM; } else if (authorize_flag) { - /* TSPX_psm_authorization_required - * we never authorize this connection, so return error - * everytime this psm is used - */ authorize_flag = false; return -EACCES; } @@ -352,14 +347,12 @@ static void listen(uint8_t *data, uint16_t len) server->accept = accept; server->psm = cmd->psm; - if (server->psm == 0x00F4) { + if (cmd->response == L2CAP_CONNECTION_RESPONSE_INSUFF_ENC_KEY) { /* TSPX_psm_encryption_key_size_required */ req_keysize = 16; - } else if (server->psm == 0x00F3) { - /* TSPX_psm_authentication_required */ + } else if (cmd->response == L2CAP_CONNECTION_RESPONSE_INSUFF_AUTHOR) { authorize_flag = true; - } else if (server->psm == 0x00F2) { - /* TSPX_psm_authentication_required */ + } else if (cmd->response == L2CAP_CONNECTION_RESPONSE_INSUFF_AUTHEN) { server->sec_level = BT_SECURITY_L3; }