Loading system/stack/include/l2cdefs.h +19 −9 Original line number Diff line number Diff line Loading @@ -16,8 +16,7 @@ * ******************************************************************************/ #ifndef L2CDEFS_H #define L2CDEFS_H #pragma once #include <bluetooth/log.h> Loading Loading @@ -237,11 +236,24 @@ inline tL2CAP_CONN to_l2cap_result_code(uint16_t result) { } /* Credit based reconfig results code */ #define L2CAP_RECONFIG_SUCCEED 0 #define L2CAP_RECONFIG_REDUCTION_MTU_NO_ALLOWED 1 #define L2CAP_RECONFIG_REDUCTION_MPS_NO_ALLOWED 2 #define L2CAP_RECONFIG_INVALID_DCID 3 #define L2CAP_RECONFIG_UNACCAPTED_PARAM 4 enum class tL2CAP_RECONFIG_RESULT : uint16_t { L2CAP_RECONFIG_SUCCEED = 0, L2CAP_RECONFIG_REDUCTION_MTU_NO_ALLOWED = 1, L2CAP_RECONFIG_REDUCTION_MPS_NO_ALLOWED = 2, L2CAP_RECONFIG_INVALID_DCID = 3, L2CAP_RECONFIG_UNACCAPTED_PARAM = 4, }; inline std::string l2cap_reconfig_result_text(const tL2CAP_RECONFIG_RESULT& result) { switch (result) { CASE_RETURN_TEXT(tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_SUCCEED); CASE_RETURN_TEXT(tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_REDUCTION_MTU_NO_ALLOWED); CASE_RETURN_TEXT(tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_REDUCTION_MPS_NO_ALLOWED); CASE_RETURN_TEXT(tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_INVALID_DCID); CASE_RETURN_TEXT(tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_UNACCAPTED_PARAM); } RETURN_UNKNOWN_TYPE_STRING(tL2CAP_RECONFIG_RESULT, result); } /* Define the L2CAP command reject reason codes */ Loading Loading @@ -497,5 +509,3 @@ struct formatter<tL2CAP_CID_FIXED> : enum_formatter<tL2CAP_CID_FIXED> {}; template <> struct formatter<tL2CAP_LE_RESULT_CODE> : enum_formatter<tL2CAP_LE_RESULT_CODE> {}; } // namespace fmt #endif system/stack/l2cap/l2c_ble.cc +11 −6 Original line number Diff line number Diff line Loading @@ -585,7 +585,8 @@ void l2cble_process_sig_cmd(tL2C_LCB* p_lcb, uint8_t* p, uint16_t pkt_len) { } break; case L2CAP_CMD_CREDIT_BASED_RECONFIG_REQ: { if (p + 6 > p_pkt_end) { l2cu_send_ble_reconfig_rsp(p_lcb, id, L2CAP_RECONFIG_UNACCAPTED_PARAM); l2cu_send_ble_reconfig_rsp(p_lcb, id, tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_UNACCAPTED_PARAM); return; } Loading @@ -596,7 +597,8 @@ void l2cble_process_sig_cmd(tL2C_LCB* p_lcb, uint8_t* p, uint16_t pkt_len) { if (mtu < L2CAP_CREDIT_BASED_MIN_MTU || mps < L2CAP_CREDIT_BASED_MIN_MPS || mps > L2CAP_LE_MAX_MPS) { log::error("L2CAP - invalid params"); l2cu_send_ble_reconfig_rsp(p_lcb, id, L2CAP_RECONFIG_UNACCAPTED_PARAM); l2cu_send_ble_reconfig_rsp(p_lcb, id, tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_UNACCAPTED_PARAM); return; } Loading @@ -614,21 +616,24 @@ void l2cble_process_sig_cmd(tL2C_LCB* p_lcb, uint8_t* p, uint16_t pkt_len) { p_ccb = l2cu_find_ccb_by_remote_cid(p_lcb, rcid); if (!p_ccb) { log::warn("L2CAP - rcvd config req for non existing cid: 0x{:04x}", rcid); l2cu_send_ble_reconfig_rsp(p_lcb, id, L2CAP_RECONFIG_INVALID_DCID); l2cu_send_ble_reconfig_rsp(p_lcb, id, tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_INVALID_DCID); return; } if (p_ccb->peer_conn_cfg.mtu > mtu) { log::warn("L2CAP - rcvd config req mtu reduction new mtu < mtu ({} < {})", mtu, p_ccb->peer_conn_cfg.mtu); l2cu_send_ble_reconfig_rsp(p_lcb, id, L2CAP_RECONFIG_REDUCTION_MTU_NO_ALLOWED); l2cu_send_ble_reconfig_rsp( p_lcb, id, tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_REDUCTION_MTU_NO_ALLOWED); return; } if (p_ccb->peer_conn_cfg.mps > mps && num_of_channels > 1) { log::warn("L2CAP - rcvd config req mps reduction new mps < mps ({} < {})", mtu, p_ccb->peer_conn_cfg.mtu); l2cu_send_ble_reconfig_rsp(p_lcb, id, L2CAP_RECONFIG_REDUCTION_MPS_NO_ALLOWED); l2cu_send_ble_reconfig_rsp( p_lcb, id, tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_REDUCTION_MPS_NO_ALLOWED); return; } } Loading @@ -649,7 +654,7 @@ void l2cble_process_sig_cmd(tL2C_LCB* p_lcb, uint8_t* p, uint16_t pkt_len) { l2c_csm_execute(p_ccb, L2CEVT_L2CAP_CREDIT_BASED_RECONFIG_REQ, &le_cfg); } l2cu_send_ble_reconfig_rsp(p_lcb, id, L2CAP_RECONFIG_SUCCEED); l2cu_send_ble_reconfig_rsp(p_lcb, id, tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_SUCCEED); break; } Loading system/stack/l2cap/l2c_int.h +1 −1 Original line number Diff line number Diff line Loading @@ -739,7 +739,7 @@ void l2cu_send_peer_credit_based_conn_res(tL2C_CCB* p_ccb, std::vector<uint16_t> void l2cu_send_peer_ble_credit_based_conn_req(tL2C_CCB* p_ccb); void l2cu_send_peer_credit_based_conn_req(tL2C_CCB* p_ccb); void l2cu_send_ble_reconfig_rsp(tL2C_LCB* p_lcb, uint8_t rem_id, uint16_t result); void l2cu_send_ble_reconfig_rsp(tL2C_LCB* p_lcb, uint8_t rem_id, tL2CAP_RECONFIG_RESULT result); void l2cu_send_credit_based_reconfig_req(tL2C_CCB* p_ccb, tL2CAP_LE_CFG_INFO* p_data); void l2cu_send_peer_ble_flow_control_credit(tL2C_CCB* p_ccb, uint16_t credit_value); Loading system/stack/l2cap/l2c_utils.cc +3 −3 Original line number Diff line number Diff line Loading @@ -3262,11 +3262,11 @@ void l2cu_reject_ble_connection(tL2C_CCB* p_ccb, uint8_t rem_id, uint16_t result * ******************************************************************************/ void l2cu_send_ble_reconfig_rsp(tL2C_LCB* p_lcb, uint8_t rem_id, uint16_t result) { void l2cu_send_ble_reconfig_rsp(tL2C_LCB* p_lcb, uint8_t rem_id, tL2CAP_RECONFIG_RESULT result) { BT_HDR* p_buf; uint8_t* p; log::verbose("l2cu_send_ble_reconfig_rsp result 0x04{:x}", result); log::verbose("l2cu_send_ble_reconfig_rsp result:{}", l2cap_reconfig_result_text(result)); p_buf = l2cu_build_header(p_lcb, L2CAP_CMD_CREDIT_BASED_RECONFIG_RES_LEN, L2CAP_CMD_CREDIT_BASED_RECONFIG_RES, rem_id); Loading @@ -3279,7 +3279,7 @@ void l2cu_send_ble_reconfig_rsp(tL2C_LCB* p_lcb, uint8_t rem_id, uint16_t result L2CAP_CMD_OVERHEAD; memset(p, 0, L2CAP_CMD_CREDIT_BASED_RECONFIG_RES_LEN); UINT16_TO_STREAM(p, result); UINT16_TO_STREAM(p, static_cast<uint16_t>(result)); l2c_link_check_send_pkts(p_lcb, 0, p_buf); } Loading system/test/mock/mock_stack_l2cap_utils.cc +1 −1 Original line number Diff line number Diff line Loading @@ -164,7 +164,7 @@ void l2cu_release_lcb(tL2C_LCB* /* p_lcb */) { inc_func_call_count(__func__); } void l2cu_release_rcb(tL2C_RCB* /* p_rcb */) { inc_func_call_count(__func__); } void l2cu_resubmit_pending_sec_req(const RawAddress* /* p_bda */) { inc_func_call_count(__func__); } void l2cu_send_ble_reconfig_rsp(tL2C_LCB* /* p_lcb */, uint8_t /* rem_id */, uint16_t /* result */) { tL2CAP_RECONFIG_RESULT /* result */) { inc_func_call_count(__func__); } void l2cu_send_credit_based_reconfig_req(tL2C_CCB* /* p_ccb */, tL2CAP_LE_CFG_INFO* /* p_cfg */) { Loading Loading
system/stack/include/l2cdefs.h +19 −9 Original line number Diff line number Diff line Loading @@ -16,8 +16,7 @@ * ******************************************************************************/ #ifndef L2CDEFS_H #define L2CDEFS_H #pragma once #include <bluetooth/log.h> Loading Loading @@ -237,11 +236,24 @@ inline tL2CAP_CONN to_l2cap_result_code(uint16_t result) { } /* Credit based reconfig results code */ #define L2CAP_RECONFIG_SUCCEED 0 #define L2CAP_RECONFIG_REDUCTION_MTU_NO_ALLOWED 1 #define L2CAP_RECONFIG_REDUCTION_MPS_NO_ALLOWED 2 #define L2CAP_RECONFIG_INVALID_DCID 3 #define L2CAP_RECONFIG_UNACCAPTED_PARAM 4 enum class tL2CAP_RECONFIG_RESULT : uint16_t { L2CAP_RECONFIG_SUCCEED = 0, L2CAP_RECONFIG_REDUCTION_MTU_NO_ALLOWED = 1, L2CAP_RECONFIG_REDUCTION_MPS_NO_ALLOWED = 2, L2CAP_RECONFIG_INVALID_DCID = 3, L2CAP_RECONFIG_UNACCAPTED_PARAM = 4, }; inline std::string l2cap_reconfig_result_text(const tL2CAP_RECONFIG_RESULT& result) { switch (result) { CASE_RETURN_TEXT(tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_SUCCEED); CASE_RETURN_TEXT(tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_REDUCTION_MTU_NO_ALLOWED); CASE_RETURN_TEXT(tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_REDUCTION_MPS_NO_ALLOWED); CASE_RETURN_TEXT(tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_INVALID_DCID); CASE_RETURN_TEXT(tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_UNACCAPTED_PARAM); } RETURN_UNKNOWN_TYPE_STRING(tL2CAP_RECONFIG_RESULT, result); } /* Define the L2CAP command reject reason codes */ Loading Loading @@ -497,5 +509,3 @@ struct formatter<tL2CAP_CID_FIXED> : enum_formatter<tL2CAP_CID_FIXED> {}; template <> struct formatter<tL2CAP_LE_RESULT_CODE> : enum_formatter<tL2CAP_LE_RESULT_CODE> {}; } // namespace fmt #endif
system/stack/l2cap/l2c_ble.cc +11 −6 Original line number Diff line number Diff line Loading @@ -585,7 +585,8 @@ void l2cble_process_sig_cmd(tL2C_LCB* p_lcb, uint8_t* p, uint16_t pkt_len) { } break; case L2CAP_CMD_CREDIT_BASED_RECONFIG_REQ: { if (p + 6 > p_pkt_end) { l2cu_send_ble_reconfig_rsp(p_lcb, id, L2CAP_RECONFIG_UNACCAPTED_PARAM); l2cu_send_ble_reconfig_rsp(p_lcb, id, tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_UNACCAPTED_PARAM); return; } Loading @@ -596,7 +597,8 @@ void l2cble_process_sig_cmd(tL2C_LCB* p_lcb, uint8_t* p, uint16_t pkt_len) { if (mtu < L2CAP_CREDIT_BASED_MIN_MTU || mps < L2CAP_CREDIT_BASED_MIN_MPS || mps > L2CAP_LE_MAX_MPS) { log::error("L2CAP - invalid params"); l2cu_send_ble_reconfig_rsp(p_lcb, id, L2CAP_RECONFIG_UNACCAPTED_PARAM); l2cu_send_ble_reconfig_rsp(p_lcb, id, tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_UNACCAPTED_PARAM); return; } Loading @@ -614,21 +616,24 @@ void l2cble_process_sig_cmd(tL2C_LCB* p_lcb, uint8_t* p, uint16_t pkt_len) { p_ccb = l2cu_find_ccb_by_remote_cid(p_lcb, rcid); if (!p_ccb) { log::warn("L2CAP - rcvd config req for non existing cid: 0x{:04x}", rcid); l2cu_send_ble_reconfig_rsp(p_lcb, id, L2CAP_RECONFIG_INVALID_DCID); l2cu_send_ble_reconfig_rsp(p_lcb, id, tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_INVALID_DCID); return; } if (p_ccb->peer_conn_cfg.mtu > mtu) { log::warn("L2CAP - rcvd config req mtu reduction new mtu < mtu ({} < {})", mtu, p_ccb->peer_conn_cfg.mtu); l2cu_send_ble_reconfig_rsp(p_lcb, id, L2CAP_RECONFIG_REDUCTION_MTU_NO_ALLOWED); l2cu_send_ble_reconfig_rsp( p_lcb, id, tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_REDUCTION_MTU_NO_ALLOWED); return; } if (p_ccb->peer_conn_cfg.mps > mps && num_of_channels > 1) { log::warn("L2CAP - rcvd config req mps reduction new mps < mps ({} < {})", mtu, p_ccb->peer_conn_cfg.mtu); l2cu_send_ble_reconfig_rsp(p_lcb, id, L2CAP_RECONFIG_REDUCTION_MPS_NO_ALLOWED); l2cu_send_ble_reconfig_rsp( p_lcb, id, tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_REDUCTION_MPS_NO_ALLOWED); return; } } Loading @@ -649,7 +654,7 @@ void l2cble_process_sig_cmd(tL2C_LCB* p_lcb, uint8_t* p, uint16_t pkt_len) { l2c_csm_execute(p_ccb, L2CEVT_L2CAP_CREDIT_BASED_RECONFIG_REQ, &le_cfg); } l2cu_send_ble_reconfig_rsp(p_lcb, id, L2CAP_RECONFIG_SUCCEED); l2cu_send_ble_reconfig_rsp(p_lcb, id, tL2CAP_RECONFIG_RESULT::L2CAP_RECONFIG_SUCCEED); break; } Loading
system/stack/l2cap/l2c_int.h +1 −1 Original line number Diff line number Diff line Loading @@ -739,7 +739,7 @@ void l2cu_send_peer_credit_based_conn_res(tL2C_CCB* p_ccb, std::vector<uint16_t> void l2cu_send_peer_ble_credit_based_conn_req(tL2C_CCB* p_ccb); void l2cu_send_peer_credit_based_conn_req(tL2C_CCB* p_ccb); void l2cu_send_ble_reconfig_rsp(tL2C_LCB* p_lcb, uint8_t rem_id, uint16_t result); void l2cu_send_ble_reconfig_rsp(tL2C_LCB* p_lcb, uint8_t rem_id, tL2CAP_RECONFIG_RESULT result); void l2cu_send_credit_based_reconfig_req(tL2C_CCB* p_ccb, tL2CAP_LE_CFG_INFO* p_data); void l2cu_send_peer_ble_flow_control_credit(tL2C_CCB* p_ccb, uint16_t credit_value); Loading
system/stack/l2cap/l2c_utils.cc +3 −3 Original line number Diff line number Diff line Loading @@ -3262,11 +3262,11 @@ void l2cu_reject_ble_connection(tL2C_CCB* p_ccb, uint8_t rem_id, uint16_t result * ******************************************************************************/ void l2cu_send_ble_reconfig_rsp(tL2C_LCB* p_lcb, uint8_t rem_id, uint16_t result) { void l2cu_send_ble_reconfig_rsp(tL2C_LCB* p_lcb, uint8_t rem_id, tL2CAP_RECONFIG_RESULT result) { BT_HDR* p_buf; uint8_t* p; log::verbose("l2cu_send_ble_reconfig_rsp result 0x04{:x}", result); log::verbose("l2cu_send_ble_reconfig_rsp result:{}", l2cap_reconfig_result_text(result)); p_buf = l2cu_build_header(p_lcb, L2CAP_CMD_CREDIT_BASED_RECONFIG_RES_LEN, L2CAP_CMD_CREDIT_BASED_RECONFIG_RES, rem_id); Loading @@ -3279,7 +3279,7 @@ void l2cu_send_ble_reconfig_rsp(tL2C_LCB* p_lcb, uint8_t rem_id, uint16_t result L2CAP_CMD_OVERHEAD; memset(p, 0, L2CAP_CMD_CREDIT_BASED_RECONFIG_RES_LEN); UINT16_TO_STREAM(p, result); UINT16_TO_STREAM(p, static_cast<uint16_t>(result)); l2c_link_check_send_pkts(p_lcb, 0, p_buf); } Loading
system/test/mock/mock_stack_l2cap_utils.cc +1 −1 Original line number Diff line number Diff line Loading @@ -164,7 +164,7 @@ void l2cu_release_lcb(tL2C_LCB* /* p_lcb */) { inc_func_call_count(__func__); } void l2cu_release_rcb(tL2C_RCB* /* p_rcb */) { inc_func_call_count(__func__); } void l2cu_resubmit_pending_sec_req(const RawAddress* /* p_bda */) { inc_func_call_count(__func__); } void l2cu_send_ble_reconfig_rsp(tL2C_LCB* /* p_lcb */, uint8_t /* rem_id */, uint16_t /* result */) { tL2CAP_RECONFIG_RESULT /* result */) { inc_func_call_count(__func__); } void l2cu_send_credit_based_reconfig_req(tL2C_CCB* /* p_ccb */, tL2CAP_LE_CFG_INFO* /* p_cfg */) { Loading