#include <string.h>
#include <stdio.h>
-#include "controller.h"
+#include "device/include/controller.h"
+#include "btcore/include/counter.h"
#include "gki.h"
#include "bt_types.h"
#include "hcimsgs.h"
#include "btm_int.h"
#include "hcidefs.h"
#include "bt_utils.h"
+#include "osi/include/allocator.h"
/*******************************************************************************
**
}
#if (BLE_INCLUDED == TRUE)
- l2cb.is_ble_connecting = FALSE;
+ // Reset BLE connecting flag only if the address matches
+ if (!memcmp(l2cb.ble_connecting_bda, p_lcb->remote_bd_addr, BD_ADDR_LEN))
+ l2cb.is_ble_connecting = FALSE;
#endif
#if (L2CAP_NUM_FIXED_CHNLS > 0)
- {
- int xx;
-
- for (xx = 0; xx < L2CAP_NUM_FIXED_CHNLS; xx++)
- {
- if (p_lcb->p_fixed_ccbs[xx])
- {
- l2cu_release_ccb (p_lcb->p_fixed_ccbs[xx]);
- p_lcb->p_fixed_ccbs[xx] = NULL;
- (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, p_lcb->transport);
- }
- else if ( (p_lcb->peer_chnl_mask[0] & (1 << (xx + L2CAP_FIRST_FIXED_CHNL)))
- && (l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb != NULL) )
- (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, p_lcb->transport);
- }
- }
+ l2cu_process_fixed_disc_cback(p_lcb);
#endif
/* Ensure no CCBs left on this LCB */
#else
btm_acl_removed (p_lcb->remote_bd_addr, BT_TRANSPORT_BR_EDR);
#endif
+
/* Release any held buffers */
- while (!list_is_empty(p_lcb->link_xmit_data_q)) {
- BT_HDR *p_buf = list_front(p_lcb->link_xmit_data_q);
- list_remove(p_lcb->link_xmit_data_q, p_buf);
- GKI_freebuf(p_buf);
+ if (p_lcb->link_xmit_data_q)
+ {
+ while (!list_is_empty(p_lcb->link_xmit_data_q)) {
+ BT_HDR *p_buf = list_front(p_lcb->link_xmit_data_q);
+ list_remove(p_lcb->link_xmit_data_q, p_buf);
+ GKI_freebuf(p_buf);
+ }
+ list_free(p_lcb->link_xmit_data_q);
+ p_lcb->link_xmit_data_q = NULL;
}
- list_free(p_lcb->link_xmit_data_q);
- p_lcb->link_xmit_data_q = NULL;
#if (L2CAP_UCD_INCLUDED == TRUE)
/* clean up any security pending UCD */
#if (BLE_INCLUDED == TRUE)
if (p_lcb->transport == BT_TRANSPORT_LE)
{
+ counter_add("l2cap.ble.tx.bytes", p_buf->len);
+ counter_add("l2cap.ble.tx.pkts", 1);
+
UINT16_TO_STREAM (p, L2CAP_BLE_SIGNALLING_CID);
}
else
#endif
{
+ counter_add("l2cap.sig.tx.bytes", p_buf->len);
+ counter_add("l2cap.sig.tx.pkts", 1);
UINT16_TO_STREAM (p, L2CAP_SIGNALLING_CID);
}
p_ccb->p_lcb = p_lcb;
p_ccb->p_rcb = NULL;
+ p_ccb->should_free_rcb = false;
/* Set priority then insert ccb into LCB queue (if we have an LCB) */
p_ccb->ccb_priority = L2CAP_CHNL_PRIORITY_LOW;
btm_sec_clr_service_by_psm(p_rcb->psm);
}
+ if (p_ccb->should_free_rcb)
+ {
+ osi_free(p_rcb);
+ p_ccb->p_rcb = NULL;
+ p_ccb->should_free_rcb = false;
+ }
+
btm_sec_clr_temp_auth_service (p_lcb->remote_bd_addr);
/* Stop the timer */
return (FALSE);
}
-#if (defined(BTM_BUSY_LEVEL_CHANGE_INCLUDED) && BTM_BUSY_LEVEL_CHANGE_INCLUDED == TRUE)
btm_acl_update_busy_level (BTM_BLI_PAGE_EVT);
-#endif
btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK,
L2CAP_LINK_CONNECT_TOUT);
*******************************************************************************/
void l2cu_process_fixed_chnl_resp (tL2C_LCB *p_lcb)
{
- int xx;
#if (BLE_INCLUDED == TRUE)
/* always exclude LE fixed channel on BR/EDR fix channel capability */
if (p_lcb->transport == BT_TRANSPORT_BR_EDR)
p_lcb->peer_chnl_mask[0] &= ~(L2CAP_FIXED_CHNL_ATT_BIT| \
L2CAP_FIXED_CHNL_BLE_SIG_BIT| \
L2CAP_FIXED_CHNL_SMP_BIT);
+ else
+ p_lcb->peer_chnl_mask[0] = l2cb.l2c_ble_fixed_chnls_mask;
#endif
/* Tell all registered fixed channels about the connection */
- for (xx = 0; xx < L2CAP_NUM_FIXED_CHNLS; xx++)
+ for (int xx = 0; xx < L2CAP_NUM_FIXED_CHNLS; xx++)
{
#if BLE_INCLUDED == TRUE
/* skip sending LE fix channel callbacks on BR/EDR links */
void l2cu_process_fixed_disc_cback (tL2C_LCB *p_lcb)
{
#if (L2CAP_NUM_FIXED_CHNLS > 0)
- int xx;
- for (xx = 0; xx < L2CAP_NUM_FIXED_CHNLS; xx++)
+ /* Select peer channels mask to use depending on transport */
+ UINT8 peer_channel_mask = p_lcb->peer_chnl_mask[0];
+
+ // For LE, reset the stored peer channel mask
+ if (p_lcb->transport == BT_TRANSPORT_LE)
+ p_lcb->peer_chnl_mask[0] = 0;
+
+ for (int xx = 0; xx < L2CAP_NUM_FIXED_CHNLS; xx++)
{
if (p_lcb->p_fixed_ccbs[xx])
{
if (p_lcb->p_fixed_ccbs[xx] != p_lcb->p_pending_ccb)
{
- l2cu_release_ccb (p_lcb->p_fixed_ccbs[xx]);
+ tL2C_CCB *p_l2c_chnl_ctrl_block;
+ p_l2c_chnl_ctrl_block = p_lcb->p_fixed_ccbs[xx];
p_lcb->p_fixed_ccbs[xx] = NULL;
+ l2cu_release_ccb(p_l2c_chnl_ctrl_block);
#if BLE_INCLUDED == TRUE
(*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, p_lcb->transport);
#else
#endif
}
}
- else if ( (p_lcb->peer_chnl_mask[0] & (1 << (xx + L2CAP_FIRST_FIXED_CHNL)))
+ else if ( (peer_channel_mask & (1 << (xx + L2CAP_FIRST_FIXED_CHNL)))
&& (l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb != NULL) )
#if BLE_INCLUDED == TRUE
(*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, p_lcb->transport);