AVCT_TRACE_DEBUG("%s peer_mtu:%d use:%d", __func__, p_lcb->peer_mtu, max_mtu);
- if (p_lcb->peer_mtu >= AVCT_MIN_BROWSE_MTU)
- p_cfg->result = L2CAP_CFG_OK;
- else {
- p_cfg->result = L2CAP_CFG_UNACCEPTABLE_PARAMS;
- p_cfg->mtu_present = true;
- p_cfg->mtu = AVCT_MIN_BROWSE_MTU;
- }
+ p_cfg->result = L2CAP_CFG_OK;
/* send L2CAP configure response */
L2CA_ConfigRsp(lcid, p_cfg);
- if (p_cfg->result != L2CAP_CFG_OK) {
- return;
- }
-
/* if first config ind */
if ((p_lcb->ch_flags & AVCT_L2C_CFG_IND_DONE) == 0) {
/* update flags */
******************************************************************************/
static void bnep_config_ind(uint16_t l2cap_cid, tL2CAP_CFG_INFO* p_cfg) {
tBNEP_CONN* p_bcb;
- uint16_t result, mtu = 0;
/* Find CCB based on CID */
p_bcb = bnepu_find_bcb_by_cid(l2cap_cid);
BNEP_TRACE_EVENT("BNEP - Rcvd cfg ind, CID: 0x%x", l2cap_cid);
- /* Remember the remote MTU size */
- if ((!p_cfg->mtu_present) || (p_cfg->mtu < BNEP_MTU_SIZE)) {
- mtu = p_cfg->mtu;
- p_cfg->flush_to_present = false;
- p_cfg->mtu_present = true;
- p_cfg->mtu = BNEP_MTU_SIZE;
- p_cfg->result = result = L2CAP_CFG_UNACCEPTABLE_PARAMS;
- } else {
-
- /* For now, always accept configuration from the other side */
- p_cfg->flush_to_present = false;
- p_cfg->mtu_present = false;
- p_cfg->result = result = L2CAP_CFG_OK;
- }
+ /* For now, always accept configuration from the other side */
+ p_cfg->flush_to_present = false;
+ p_cfg->mtu_present = false;
+ p_cfg->result = L2CAP_CFG_OK;
L2CA_ConfigRsp(l2cap_cid, p_cfg);
- if (result != L2CAP_CFG_OK) {
- BNEP_TRACE_EVENT("BNEP - Rcvd cfg ind with bad MTU %d, CID: 0x%x", mtu,
- l2cap_cid);
- return;
- }
-
p_bcb->con_flags |= BNEP_FLAGS_HIS_CFG_DONE;
if (p_bcb->con_flags & BNEP_FLAGS_MY_CFG_DONE) {
bool flush_to_ok = true;
bool fcr_ok = true;
uint8_t fcr_status;
+ uint16_t required_remote_mtu =
+ std::max<uint16_t>(L2CAP_MIN_MTU, p_ccb->p_rcb->required_remote_mtu);
/* Ignore FCR parameters for basic mode */
if (!p_cfg->fcr_present) p_cfg->fcr.mode = L2CAP_FCR_BASIC_MODE;
- /* Save the MTU that our peer can receive */
- if (p_cfg->mtu_present) {
+ if (!p_cfg->mtu_present && required_remote_mtu > L2CAP_DEFAULT_MTU) {
+ // We reject if we have a MTU requirement higher than default MTU
+ p_cfg->mtu = required_remote_mtu;
+ mtu_ok = false;
+ } else if (p_cfg->mtu_present) {
/* Make sure MTU is at least the minimum */
- if (p_cfg->mtu >= L2CAP_MIN_MTU) {
+ if (p_cfg->mtu >= required_remote_mtu) {
/* In basic mode, limit the MTU to our buffer size */
if ((!p_cfg->fcr_present) && (p_cfg->mtu > L2CAP_MTU_SIZE))
p_cfg->mtu = L2CAP_MTU_SIZE;
p_ccb->peer_cfg.mtu_present = true;
} else /* Illegal MTU value */
{
- p_cfg->mtu = L2CAP_MIN_MTU;
+ p_cfg->mtu = required_remote_mtu;
mtu_ok = false;
}
}