feat(bt/bluedroid): Add flags for BQB auto test of L2CAP

1: add sdp_bqb_disable_flag to avoid running sdpu_build_n_send_error.
2: add sdp_bqb_inact_timeout_flag to set the SDP inactivity timeout to 90 seconds.
3: add l2cap_bqb_bad_cmd_len_rej_flag to reject the C-Frame with invalid PDU length
4: add l2cap_bqb_ertm_mode_included_flag to set L2CAP_FCR_ERTM_MODE for most L2CAP cases
This commit is contained in:
wanglai@espressif.com
2023-08-28 20:08:47 +08:00
committed by gongyantao
parent 10c7026053
commit afc7cf445e
5 changed files with 158 additions and 10 deletions
@@ -2137,6 +2137,33 @@ UINT8 L2CA_DataWrite (UINT16 cid, BT_HDR *p_data)
}
#endif ///CLASSIC_BT_INCLUDED == TRUE
/*******************************************************************************
**
** Function l2cap_bqb_write_data
**
** Description Call L2CA_DataWrite and write I-Frame data for BQB test.
**
** Returns None
**
*******************************************************************************/
#if (BT_CLASSIC_BQB_INCLUDED == TRUE)
void l2cap_bqb_write_data(UINT16 cid)
{
BT_HDR *p_buf;
uint8_t *p;
if ((p_buf = (BT_HDR *)osi_malloc(SDP_DATA_BUF_SIZE)) != NULL) {
p_buf->len = 30;
p_buf->offset = L2CAP_MIN_OFFSET;
p = (UINT8 *)(p_buf + 1) + p_buf->offset;
for(int i = 0 ; i < 10; i++) {
UINT8_TO_BE_STREAM(p, 0)
}
L2CA_DataWrite(cid, p_buf);
}
}
#endif /* BT_CLASSIC_BQB_INCLUDED */
/*******************************************************************************
**
** Function L2CA_SetChnlFlushability
@@ -52,6 +52,10 @@ tL2C_CB l2cb;
tL2C_CB *l2c_cb_ptr;
#endif
#if BT_CLASSIC_BQB_INCLUDED
static BOOLEAN s_l2cap_bqb_bad_cmd_len_rej_flag = FALSE;
#endif /* BT_CLASSIC_BQB_INCLUDED */
#if 0 //Unused
/*******************************************************************************
**
@@ -107,6 +111,24 @@ void l2c_bcst_msg( BT_HDR *p_buf, UINT16 psm )
}
#endif
/*******************************************************************************
**
** Function l2cap_bqb_bad_cmd_len_rej_ctrl
**
** Description Control rejecting L2CAP signaling PDUs with incorrect length
** for BQB test.
**
** Returns void
**
*******************************************************************************/
#if BT_CLASSIC_BQB_INCLUDED
void l2cap_bqb_bad_cmd_len_rej_ctrl(BOOLEAN enable)
{
s_l2cap_bqb_bad_cmd_len_rej_flag = enable;
}
#endif /* BT_CLASSIC_BQB_INCLUDED */
/*******************************************************************************
**
** Function l2c_rcv_acl_data
@@ -461,6 +483,12 @@ static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
p_ccb->remote_cid = rcid;
l2c_csm_execute(p_ccb, L2CEVT_L2CAP_CONNECT_REQ, &con_info);
#if BT_CLASSIC_BQB_INCLUDED
// L2CAP/COS/CED/BI-02-C
if (s_l2cap_bqb_bad_cmd_len_rej_flag) {
l2cu_send_peer_cmd_reject (p_lcb, L2CAP_CMD_REJ_NOT_UNDERSTOOD, id, 0, 0);
}
#endif /* BT_CLASSIC_BQB_INCLUDED */
break;
case L2CAP_CMD_CONN_RSP:
@@ -39,6 +39,10 @@
#include "osi/allocator.h"
#include "osi/list.h"
#if BT_SDP_BQB_INCLUDED
extern BOOLEAN l2cap_bqb_ertm_mode_included_flag;
#endif /* BT_SDP_BQB_INCLUDED */
/*******************************************************************************
**
** Function l2cu_allocate_lcb
@@ -1558,8 +1562,17 @@ tL2C_CCB *l2cu_allocate_ccb (tL2C_LCB *p_lcb, UINT16 cid)
#if (CLASSIC_BT_INCLUDED == TRUE)
l2c_fcr_free_timer (p_ccb);
#endif ///CLASSIC_BT_INCLUDED == TRUE
p_ccb->ertm_info.preferred_mode = L2CAP_FCR_BASIC_MODE; /* Default mode for channel is basic mode */
p_ccb->ertm_info.allowed_modes = L2CAP_FCR_CHAN_OPT_BASIC|L2CAP_FCR_CHAN_OPT_ERTM;
#if BT_CLASSIC_BQB_INCLUDED
if (l2cap_bqb_ertm_mode_included_flag) {
p_ccb->ertm_info.preferred_mode = L2CAP_FCR_ERTM_MODE;
p_ccb->ertm_info.allowed_modes = L2CAP_FCR_CHAN_OPT_ERTM;
} else
#endif /* BT_CLASSIC_BQB_INCLUDED */
{
p_ccb->ertm_info.preferred_mode = L2CAP_FCR_BASIC_MODE; /* Default mode for channel is basic mode */
p_ccb->ertm_info.allowed_modes = L2CAP_FCR_CHAN_OPT_BASIC|L2CAP_FCR_CHAN_OPT_ERTM;
}
p_ccb->ertm_info.fcr_rx_buf_size = L2CAP_FCR_RX_BUF_SIZE;
p_ccb->ertm_info.fcr_tx_buf_size = L2CAP_FCR_TX_BUF_SIZE;
p_ccb->ertm_info.user_rx_buf_size = L2CAP_USER_RX_BUF_SIZE;