You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by na...@apache.org on 2021/05/26 08:55:14 UTC
[mynewt-nimble] branch master updated: bttester: handle special
PSMs in l2cap
This is an automated email from the ASF dual-hosted git repository.
naraj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
The following commit(s) were added to refs/heads/master by this push:
new aeb1adb bttester: handle special PSMs in l2cap
aeb1adb is described below
commit aeb1adb59bf0b64956eb28596b6fff4b26aed0e9
Author: Krzysztof Kopyściński <kr...@codecoup.pl>
AuthorDate: Tue May 25 12:11:09 2021 +0200
bttester: handle special PSMs in l2cap
Added special PSM that identify channels requireing security. These
PSMs correspond to TSPX_psm_authentication_required,
TSPX_psm_authorization_required, TSPX_psm_encryption_key_size_required.
When connection is accepted on these PSMs, link security is checked
and appropriate error is returned when condition is not met.
This affects tests L2CAP/LE/CFC/BV-{11, 13, 15}-C
---
apps/bttester/src/l2cap.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/apps/bttester/src/l2cap.c b/apps/bttester/src/l2cap.c
index 5c4fc71..b9b97ec 100644
--- a/apps/bttester/src/l2cap.c
+++ b/apps/bttester/src/l2cap.c
@@ -249,6 +249,7 @@ tester_l2cap_event(struct ble_l2cap_event *event, void *arg)
{
struct ble_l2cap_chan_info chan_info;
int accept_response;
+ struct ble_gap_conn_desc conn;
switch (event->type) {
case BLE_L2CAP_EVENT_COC_CONNECTED:
@@ -288,6 +289,28 @@ tester_l2cap_event(struct ble_l2cap_event *event, void *arg)
event->disconnect.chan, &chan_info, arg);
return 0;
case BLE_L2CAP_EVENT_COC_ACCEPT:
+ ble_l2cap_get_chan_info(event->accept.chan, &chan_info);
+ if (chan_info.psm == 0x00F2) {
+ /* TSPX_psm_authentication_required */
+ ble_gap_conn_find(event->accept.conn_handle, &conn);
+ if (!conn.sec_state.authenticated) {
+ return BLE_HS_EAUTHEN;
+ }
+ } else if (chan_info.psm == 0x00F3) {
+ /* TSPX_psm_authorization_required */
+ ble_gap_conn_find(event->accept.conn_handle, &conn);
+ if (!conn.sec_state.encrypted) {
+ return BLE_HS_EAUTHOR;
+ }
+ return BLE_HS_EAUTHOR;
+ } else if (chan_info.psm == 0x00F4) {
+ /* TSPX_psm_encryption_key_size_required */
+ ble_gap_conn_find(event->accept.conn_handle, &conn);
+ if (conn.sec_state.key_size < 16) {
+ return BLE_HS_EENCRYPT_KEY_SZ;
+ }
+ }
+
accept_response = POINTER_TO_INT(arg);
if (accept_response) {
return accept_response;