Skip to content

Commit 2cddfce

Browse files
cvinayakhenrikbrixandersen
authored andcommitted
Bluetooth: Controller: Add explicit LLCP error code check
Add unit tests to cover explicit LLCP error code check and cover the same in the Controller implementation. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]> (cherry picked from commit d6f2bc9) Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 9022588 commit 2cddfce

File tree

2 files changed

+433
-4
lines changed

2 files changed

+433
-4
lines changed

subsys/bluetooth/controller/ll_sw/ull_llcp_enc.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,19 +382,29 @@ static void lp_enc_store_s(struct ll_conn *conn, struct proc_ctx *ctx, struct pd
382382

383383
static inline uint8_t reject_error_code(struct pdu_data *pdu)
384384
{
385+
uint8_t error;
386+
385387
if (pdu->llctrl.opcode == PDU_DATA_LLCTRL_TYPE_REJECT_IND) {
386-
return pdu->llctrl.reject_ind.error_code;
388+
error = pdu->llctrl.reject_ind.error_code;
387389
#if defined(CONFIG_BT_CTLR_EXT_REJ_IND)
388390
} else if (pdu->llctrl.opcode == PDU_DATA_LLCTRL_TYPE_REJECT_EXT_IND) {
389-
return pdu->llctrl.reject_ext_ind.error_code;
391+
error = pdu->llctrl.reject_ext_ind.error_code;
390392
#endif /* CONFIG_BT_CTLR_EXT_REJ_IND */
391393
} else {
392394
/* Called with an invalid PDU */
393395
LL_ASSERT(0);
394396

395397
/* Keep compiler happy */
396-
return BT_HCI_ERR_UNSPECIFIED;
398+
error = BT_HCI_ERR_UNSPECIFIED;
399+
}
400+
401+
/* Check expected error code from the peer */
402+
if (error != BT_HCI_ERR_PIN_OR_KEY_MISSING &&
403+
error != BT_HCI_ERR_UNSUPP_REMOTE_FEATURE) {
404+
error = BT_HCI_ERR_UNSPECIFIED;
397405
}
406+
407+
return error;
398408
}
399409

400410
static void lp_enc_st_wait_rx_enc_rsp(struct ll_conn *conn, struct proc_ctx *ctx, uint8_t evt,

0 commit comments

Comments
 (0)