p_ccb->local_cid <= L2CAP_LAST_FIXED_CHNL) {
if (p_ccb->local_cid < L2CAP_BASE_APPL_CID) {
if (l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL]
- .pL2CA_FixedData_Cb)
+ .pL2CA_FixedData_Cb != nullptr) {
+ p_ccb->metrics.rx(static_cast<BT_HDR*>(p_data)->len);
(*l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL]
.pL2CA_FixedData_Cb)(p_ccb->local_cid,
p_ccb->p_lcb->remote_bd_addr,
(BT_HDR*)p_data);
- else
- osi_free(p_data);
+ } else {
+ if (p_data != nullptr) osi_free_and_reset(&p_data);
+ }
break;
}
}
+ if (p_data) p_ccb->metrics.rx(static_cast<BT_HDR*>(p_data)->len);
(*p_ccb->p_rcb->api.pL2CA_DataInd_Cb)(p_ccb->local_cid, (BT_HDR*)p_data);
break;
break;
case L2CEVT_L2CAP_DATA: /* Peer data packet rcvd */
- if ((p_ccb->p_rcb) && (p_ccb->p_rcb->api.pL2CA_DataInd_Cb))
+ if ((p_ccb->p_rcb) && (p_ccb->p_rcb->api.pL2CA_DataInd_Cb)) {
+ p_ccb->metrics.rx(static_cast<BT_HDR*>(p_data)->len);
(*p_ccb->p_rcb->api.pL2CA_DataInd_Cb)(p_ccb->local_cid,
(BT_HDR*)p_data);
+ }
break;
case L2CEVT_L2CA_DISCONNECT_REQ: /* Upper wants to disconnect */
*
******************************************************************************/
void l2c_enqueue_peer_data(tL2C_CCB* p_ccb, BT_HDR* p_buf) {
+ CHECK(p_ccb != nullptr);
+
+ p_ccb->metrics.tx(p_buf->len);
+
uint8_t* p;
if (p_ccb->peer_cfg.fcr.mode != L2CAP_FCR_BASIC_MODE) {
/* used to indicate that ECOC is used */
bool ecoc{false};
bool reconfig_started;
+
+ struct {
+ struct {
+ unsigned bytes{0};
+ unsigned packets{0};
+ void operator()(unsigned bytes) {
+ this->bytes += bytes;
+ this->packets++;
+ }
+ } rx, tx;
+ struct {
+ struct {
+ unsigned bytes{0};
+ unsigned packets{0};
+ void operator()(unsigned bytes) {
+ this->bytes += bytes;
+ this->packets++;
+ }
+ } rx, tx;
+ } dropped;
+ } metrics;
+
} tL2C_CCB;
/***********************************************************************
/* If no CCB for this channel, allocate one */
p_ccb = p_lcb->p_fixed_ccbs[rcv_cid - L2CAP_FIRST_FIXED_CHNL];
+ p_ccb->metrics.rx(p_msg->len);
if (p_ccb->peer_cfg.fcr.mode != L2CAP_FCR_BASIC_MODE)
l2c_fcr_proc_pdu(p_ccb, p_msg);