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 <michal.narajowski@codecoup.pl>
This commit is contained in:
parent
f77c7dc2c8
commit
a614fc02ad
2 changed files with 8 additions and 10 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue