Lines Matching refs:p_ccb
41 static void l2c_csm_closed(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data);
42 static void l2c_csm_orig_w4_sec_comp(tL2C_CCB* p_ccb, tL2CEVT event,
44 static void l2c_csm_term_w4_sec_comp(tL2C_CCB* p_ccb, tL2CEVT event,
46 static void l2c_csm_w4_l2cap_connect_rsp(tL2C_CCB* p_ccb, tL2CEVT event,
48 static void l2c_csm_w4_l2ca_connect_rsp(tL2C_CCB* p_ccb, tL2CEVT event,
50 static void l2c_csm_config(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data);
51 static void l2c_csm_open(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data);
52 static void l2c_csm_w4_l2cap_disconnect_rsp(tL2C_CCB* p_ccb, tL2CEVT event,
54 static void l2c_csm_w4_l2ca_disconnect_rsp(tL2C_CCB* p_ccb, tL2CEVT event,
60 static void l2c_csm_send_connect_rsp(tL2C_CCB* p_ccb) { in l2c_csm_send_connect_rsp() argument
61 l2c_csm_execute(p_ccb, L2CEVT_L2CA_CONNECT_RSP, NULL); in l2c_csm_send_connect_rsp()
65 static void l2c_csm_send_config_req(tL2C_CCB* p_ccb) { in l2c_csm_send_config_req() argument
68 config.mtu = p_ccb->p_rcb->my_mtu; in l2c_csm_send_config_req()
69 p_ccb->max_rx_mtu = config.mtu; in l2c_csm_send_config_req()
70 if (p_ccb->p_rcb->ertm_info.preferred_mode != L2CAP_FCR_BASIC_MODE) { in l2c_csm_send_config_req()
74 p_ccb->our_cfg = config; in l2c_csm_send_config_req()
75 l2c_csm_execute(p_ccb, L2CEVT_L2CA_CONFIG_REQ, &config); in l2c_csm_send_config_req()
79 static void l2c_csm_send_config_rsp_ok(tL2C_CCB* p_ccb) { in l2c_csm_send_config_rsp_ok() argument
82 l2c_csm_execute(p_ccb, L2CEVT_L2CA_CONFIG_RSP, &config); in l2c_csm_send_config_rsp_ok()
85 static void l2c_csm_send_disconnect_rsp(tL2C_CCB* p_ccb) { in l2c_csm_send_disconnect_rsp() argument
86 l2c_csm_execute(p_ccb, L2CEVT_L2CA_DISCONNECT_RSP, NULL); in l2c_csm_send_disconnect_rsp()
89 static void l2c_csm_indicate_connection_open(tL2C_CCB* p_ccb) { in l2c_csm_indicate_connection_open() argument
90 if (p_ccb->connection_initiator == L2CAP_INITIATOR_LOCAL) { in l2c_csm_indicate_connection_open()
91 (*p_ccb->p_rcb->api.pL2CA_ConnectCfm_Cb)(p_ccb->local_cid, L2CAP_CONN_OK); in l2c_csm_indicate_connection_open()
93 (*p_ccb->p_rcb->api.pL2CA_ConnectInd_Cb)( in l2c_csm_indicate_connection_open()
94 p_ccb->p_lcb->remote_bd_addr, p_ccb->local_cid, p_ccb->p_rcb->psm, in l2c_csm_indicate_connection_open()
95 p_ccb->remote_id); in l2c_csm_indicate_connection_open()
97 if (p_ccb->chnl_state == CST_OPEN && !p_ccb->p_lcb->is_transport_ble()) { in l2c_csm_indicate_connection_open()
98 (*p_ccb->p_rcb->api.pL2CA_ConfigCfm_Cb)( in l2c_csm_indicate_connection_open()
99 p_ccb->local_cid, p_ccb->connection_initiator, &p_ccb->peer_cfg); in l2c_csm_indicate_connection_open()
112 void l2c_csm_execute(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data) { in l2c_csm_execute() argument
113 if (!l2cu_is_ccb_active(p_ccb)) { in l2c_csm_execute()
119 channel_state_text(p_ccb->chnl_state).c_str(), p_ccb->chnl_state, in l2c_csm_execute()
122 switch (p_ccb->chnl_state) { in l2c_csm_execute()
124 l2c_csm_closed(p_ccb, event, p_data); in l2c_csm_execute()
128 l2c_csm_orig_w4_sec_comp(p_ccb, event, p_data); in l2c_csm_execute()
132 l2c_csm_term_w4_sec_comp(p_ccb, event, p_data); in l2c_csm_execute()
136 l2c_csm_w4_l2cap_connect_rsp(p_ccb, event, p_data); in l2c_csm_execute()
140 l2c_csm_w4_l2ca_connect_rsp(p_ccb, event, p_data); in l2c_csm_execute()
144 l2c_csm_config(p_ccb, event, p_data); in l2c_csm_execute()
148 l2c_csm_open(p_ccb, event, p_data); in l2c_csm_execute()
152 l2c_csm_w4_l2cap_disconnect_rsp(p_ccb, event, p_data); in l2c_csm_execute()
156 l2c_csm_w4_l2ca_disconnect_rsp(p_ccb, event, p_data); in l2c_csm_execute()
160 LOG_ERROR("Unhandled state %d, event %d", p_ccb->chnl_state, event); in l2c_csm_execute()
176 static void l2c_csm_closed(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data) { in l2c_csm_closed() argument
178 uint16_t local_cid = p_ccb->local_cid; in l2c_csm_closed()
181 if (p_ccb->p_rcb == NULL) { in l2c_csm_closed()
183 p_ccb->local_cid, l2c_csm_get_event_name(event)); in l2c_csm_closed()
187 disconnect_ind = p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb; in l2c_csm_closed()
189 LOG_DEBUG("LCID: 0x%04x st: CLOSED evt: %s", p_ccb->local_cid, in l2c_csm_closed()
195 p_ccb->local_cid); in l2c_csm_closed()
196 l2cu_release_ccb(p_ccb); in l2c_csm_closed()
201 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2c_csm_closed()
202 p_ccb->chnl_state = CST_ORIG_W4_SEC_COMP; in l2c_csm_closed()
203 l2ble_sec_access_req(p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm, in l2c_csm_closed()
204 true, &l2c_link_sec_comp2, p_ccb); in l2c_csm_closed()
206 p_ccb->chnl_state = CST_ORIG_W4_SEC_COMP; in l2c_csm_closed()
207 btm_sec_l2cap_access_req(p_ccb->p_lcb->remote_bd_addr, in l2c_csm_closed()
208 p_ccb->p_rcb->psm, true, &l2c_link_sec_comp, in l2c_csm_closed()
209 p_ccb); in l2c_csm_closed()
215 btm_acl_notif_conn_collision(p_ccb->p_lcb->remote_bd_addr); in l2c_csm_closed()
217 l2cu_release_ccb(p_ccb); in l2c_csm_closed()
218 (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); in l2c_csm_closed()
224 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2c_csm_closed()
225 p_ccb->chnl_state = CST_ORIG_W4_SEC_COMP; in l2c_csm_closed()
226 l2ble_sec_access_req(p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm, in l2c_csm_closed()
227 true, &l2c_link_sec_comp2, p_ccb); in l2c_csm_closed()
229 if (!BTM_SetLinkPolicyActiveMode(p_ccb->p_lcb->remote_bd_addr)) { in l2c_csm_closed()
235 p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm, true, in l2c_csm_closed()
236 &l2c_link_sec_comp, p_ccb) == BTM_CMD_STARTED) { in l2c_csm_closed()
237 p_ccb->chnl_state = CST_ORIG_W4_SEC_COMP; in l2c_csm_closed()
243 p_ccb->chnl_state = CST_W4_L2CAP_CONNECT_RSP; in l2c_csm_closed()
247 if (!p_ccb->p_lcb->w4_info_rsp) { in l2c_csm_closed()
249 if (!l2c_fcr_chk_chan_modes(p_ccb)) { in l2c_csm_closed()
250 l2cu_release_ccb(p_ccb); in l2c_csm_closed()
251 (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, in l2c_csm_closed()
254 l2cu_send_peer_connect_req(p_ccb); in l2c_csm_closed()
255 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, in l2c_csm_closed()
257 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_closed()
263 l2cu_release_ccb(p_ccb); in l2c_csm_closed()
264 (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); in l2c_csm_closed()
271 alarm_cancel(p_ccb->p_lcb->l2c_lcb_timer); in l2c_csm_closed()
273 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2c_csm_closed()
274 p_ccb->chnl_state = CST_TERM_W4_SEC_COMP; in l2c_csm_closed()
276 p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm, false, in l2c_csm_closed()
277 &l2c_link_sec_comp2, p_ccb); in l2c_csm_closed()
286 l2cu_reject_ble_connection(p_ccb, p_ccb->remote_id, result); in l2c_csm_closed()
287 l2cu_release_ccb(p_ccb); in l2c_csm_closed()
297 if (!BTM_SetLinkPolicyActiveMode(p_ccb->p_lcb->remote_bd_addr)) { in l2c_csm_closed()
300 p_ccb->chnl_state = CST_TERM_W4_SEC_COMP; in l2c_csm_closed()
301 auto status = btm_sec_l2cap_access_req(p_ccb->p_lcb->remote_bd_addr, in l2c_csm_closed()
302 p_ccb->p_rcb->psm, false, in l2c_csm_closed()
303 &l2c_link_sec_comp, p_ccb); in l2c_csm_closed()
306 l2cu_send_peer_connect_rsp(p_ccb, L2CAP_CONN_PENDING, 0); in l2c_csm_closed()
309 p_ccb->p_rcb->psm, status); in l2c_csm_closed()
315 l2cu_release_ccb(p_ccb); in l2c_csm_closed()
316 (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); in l2c_csm_closed()
325 l2cu_release_ccb(p_ccb); in l2c_csm_closed()
332 channel_state_text(p_ccb->chnl_state).c_str(), p_ccb->chnl_state, in l2c_csm_closed()
346 static void l2c_csm_orig_w4_sec_comp(tL2C_CCB* p_ccb, tL2CEVT event, in l2c_csm_orig_w4_sec_comp() argument
349 p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb; in l2c_csm_orig_w4_sec_comp()
350 uint16_t local_cid = p_ccb->local_cid; in l2c_csm_orig_w4_sec_comp()
353 ((p_ccb->p_lcb) && (p_ccb->p_lcb->transport == BT_TRANSPORT_LE)) in l2c_csm_orig_w4_sec_comp()
356 p_ccb->local_cid, l2c_csm_get_event_name(event)); in l2c_csm_orig_w4_sec_comp()
361 p_ccb->local_cid); in l2c_csm_orig_w4_sec_comp()
362 l2cu_release_ccb(p_ccb); in l2c_csm_orig_w4_sec_comp()
368 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2c_csm_orig_w4_sec_comp()
369 l2ble_sec_access_req(p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm, in l2c_csm_orig_w4_sec_comp()
370 false, &l2c_link_sec_comp2, p_ccb); in l2c_csm_orig_w4_sec_comp()
372 btm_sec_l2cap_access_req(p_ccb->p_lcb->remote_bd_addr, in l2c_csm_orig_w4_sec_comp()
373 p_ccb->p_rcb->psm, true, &l2c_link_sec_comp, in l2c_csm_orig_w4_sec_comp()
374 p_ccb); in l2c_csm_orig_w4_sec_comp()
381 p_ccb->chnl_state = CST_W4_L2CAP_CONNECT_RSP; in l2c_csm_orig_w4_sec_comp()
382 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2c_csm_orig_w4_sec_comp()
383 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS, in l2c_csm_orig_w4_sec_comp()
384 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_orig_w4_sec_comp()
385 l2cble_credit_based_conn_req(p_ccb); /* Start Connection */ in l2c_csm_orig_w4_sec_comp()
387 if (!p_ccb->p_lcb->w4_info_rsp) { in l2c_csm_orig_w4_sec_comp()
389 if (!l2c_fcr_chk_chan_modes(p_ccb)) { in l2c_csm_orig_w4_sec_comp()
390 l2cu_release_ccb(p_ccb); in l2c_csm_orig_w4_sec_comp()
391 (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, in l2c_csm_orig_w4_sec_comp()
394 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, in l2c_csm_orig_w4_sec_comp()
396 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_orig_w4_sec_comp()
397 l2cu_send_peer_connect_req(p_ccb); /* Start Connection */ in l2c_csm_orig_w4_sec_comp()
406 if ((p_ccb == p_ccb->p_lcb->ccb_queue.p_first_ccb) && in l2c_csm_orig_w4_sec_comp()
407 (p_ccb == p_ccb->p_lcb->ccb_queue.p_last_ccb)) { in l2c_csm_orig_w4_sec_comp()
408 p_ccb->p_lcb->idle_timeout = 0; in l2c_csm_orig_w4_sec_comp()
411 l2cu_release_ccb(p_ccb); in l2c_csm_orig_w4_sec_comp()
412 (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); in l2c_csm_orig_w4_sec_comp()
422 btm_sec_abort_access_req(p_ccb->p_lcb->remote_bd_addr); in l2c_csm_orig_w4_sec_comp()
424 l2cu_release_ccb(p_ccb); in l2c_csm_orig_w4_sec_comp()
431 channel_state_text(p_ccb->chnl_state).c_str(), p_ccb->chnl_state, in l2c_csm_orig_w4_sec_comp()
445 static void l2c_csm_term_w4_sec_comp(tL2C_CCB* p_ccb, tL2CEVT event, in l2c_csm_term_w4_sec_comp() argument
447 LOG_DEBUG("LCID: 0x%04x st: TERM_W4_SEC_COMP evt: %s", p_ccb->local_cid, in l2c_csm_term_w4_sec_comp()
453 btm_sec_abort_access_req(p_ccb->p_lcb->remote_bd_addr); in l2c_csm_term_w4_sec_comp()
455 l2cu_release_ccb(p_ccb); in l2c_csm_term_w4_sec_comp()
459 p_ccb->chnl_state = CST_W4_L2CA_CONNECT_RSP; in l2c_csm_term_w4_sec_comp()
463 if (!p_ccb->p_lcb->w4_info_rsp) { in l2c_csm_term_w4_sec_comp()
466 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS, in l2c_csm_term_w4_sec_comp()
467 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_term_w4_sec_comp()
469 if (p_ccb->p_lcb->transport != BT_TRANSPORT_LE) { in l2c_csm_term_w4_sec_comp()
471 l2c_csm_send_connect_rsp(p_ccb); in l2c_csm_term_w4_sec_comp()
472 l2c_csm_send_config_req(p_ccb); in l2c_csm_term_w4_sec_comp()
474 if (p_ccb->ecoc) { in l2c_csm_term_w4_sec_comp()
477 p_ccb->p_lcb->pending_ecoc_conn_cnt); in l2c_csm_term_w4_sec_comp()
480 for (int i = 0; i < p_ccb->p_lcb->pending_ecoc_conn_cnt; i++) { in l2c_csm_term_w4_sec_comp()
481 uint16_t cid = p_ccb->p_lcb->pending_ecoc_connection_cids[i]; in l2c_csm_term_w4_sec_comp()
485 (*p_ccb->p_rcb->api.pL2CA_CreditBasedConnectInd_Cb)( in l2c_csm_term_w4_sec_comp()
486 p_ccb->p_lcb->remote_bd_addr, pending_cids, p_ccb->p_rcb->psm, in l2c_csm_term_w4_sec_comp()
487 p_ccb->peer_cfg.mtu, p_ccb->remote_id); in l2c_csm_term_w4_sec_comp()
491 p_ccb->local_cid); in l2c_csm_term_w4_sec_comp()
492 l2c_csm_send_connect_rsp(p_ccb); in l2c_csm_term_w4_sec_comp()
493 l2c_csm_indicate_connection_open(p_ccb); in l2c_csm_term_w4_sec_comp()
508 l2cu_send_peer_connect_rsp(p_ccb, L2CAP_CONN_PENDING, 0); in l2c_csm_term_w4_sec_comp()
516 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, in l2c_csm_term_w4_sec_comp()
518 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_term_w4_sec_comp()
520 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) in l2c_csm_term_w4_sec_comp()
522 p_ccb, p_ccb->remote_id, in l2c_csm_term_w4_sec_comp()
525 l2cu_send_peer_connect_rsp(p_ccb, L2CAP_CONN_SECURITY_BLOCK, 0); in l2c_csm_term_w4_sec_comp()
526 l2cu_release_ccb(p_ccb); in l2c_csm_term_w4_sec_comp()
536 l2cu_release_ccb(p_ccb); in l2c_csm_term_w4_sec_comp()
540 l2cu_send_peer_disc_rsp(p_ccb->p_lcb, p_ccb->remote_id, p_ccb->local_cid, in l2c_csm_term_w4_sec_comp()
541 p_ccb->remote_cid); in l2c_csm_term_w4_sec_comp()
544 btm_sec_abort_access_req(p_ccb->p_lcb->remote_bd_addr); in l2c_csm_term_w4_sec_comp()
546 l2cu_release_ccb(p_ccb); in l2c_csm_term_w4_sec_comp()
551 acl_disconnect_from_handle(p_ccb->p_lcb->Handle(), HCI_ERR_AUTH_FAILURE); in l2c_csm_term_w4_sec_comp()
555 btm_sec_l2cap_access_req(p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm, in l2c_csm_term_w4_sec_comp()
556 false, &l2c_link_sec_comp, p_ccb); in l2c_csm_term_w4_sec_comp()
563 channel_state_text(p_ccb->chnl_state).c_str(), p_ccb->chnl_state, in l2c_csm_term_w4_sec_comp()
577 static void l2c_csm_w4_l2cap_connect_rsp(tL2C_CCB* p_ccb, tL2CEVT event, in l2c_csm_w4_l2cap_connect_rsp() argument
581 p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb; in l2c_csm_w4_l2cap_connect_rsp()
583 p_ccb->p_rcb->api.pL2CA_CreditBasedConnectCfm_Cb; in l2c_csm_w4_l2cap_connect_rsp()
584 uint16_t local_cid = p_ccb->local_cid; in l2c_csm_w4_l2cap_connect_rsp()
585 tL2C_LCB* p_lcb = p_ccb->p_lcb; in l2c_csm_w4_l2cap_connect_rsp()
587 LOG_DEBUG("LCID: 0x%04x st: W4_L2CAP_CON_RSP evt: %s", p_ccb->local_cid, in l2c_csm_w4_l2cap_connect_rsp()
596 p_ccb->chnl_state = CST_CLOSED; in l2c_csm_w4_l2cap_connect_rsp()
597 if ((p_ccb->flags & CCB_FLAG_NO_RETRY) || !p_data || in l2c_csm_w4_l2cap_connect_rsp()
600 p_ccb->local_cid); in l2c_csm_w4_l2cap_connect_rsp()
601 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
604 p_ccb->flags |= CCB_FLAG_NO_RETRY; in l2c_csm_w4_l2cap_connect_rsp()
608 p_ccb->remote_cid = p_ci->remote_cid; in l2c_csm_w4_l2cap_connect_rsp()
609 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2c_csm_w4_l2cap_connect_rsp()
611 alarm_cancel(p_ccb->l2c_ccb_timer); in l2c_csm_w4_l2cap_connect_rsp()
612 p_ccb->chnl_state = CST_OPEN; in l2c_csm_w4_l2cap_connect_rsp()
613 l2c_csm_indicate_connection_open(p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
614 p_ccb->local_conn_cfg = p_ccb->p_rcb->coc_cfg; in l2c_csm_w4_l2cap_connect_rsp()
615 p_ccb->remote_credit_count = p_ccb->p_rcb->coc_cfg.credits; in l2c_csm_w4_l2cap_connect_rsp()
616 l2c_csm_execute(p_ccb, L2CEVT_L2CA_CONNECT_RSP, NULL); in l2c_csm_w4_l2cap_connect_rsp()
618 p_ccb->chnl_state = CST_CONFIG; in l2c_csm_w4_l2cap_connect_rsp()
619 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS, in l2c_csm_w4_l2cap_connect_rsp()
620 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
623 p_ccb->local_cid); in l2c_csm_w4_l2cap_connect_rsp()
625 l2c_csm_send_config_req(p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
629 p_ccb->remote_cid = p_ci->remote_cid; in l2c_csm_w4_l2cap_connect_rsp()
630 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, in l2c_csm_w4_l2cap_connect_rsp()
632 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
636 alarm_cancel(p_ccb->l2c_ccb_timer); in l2c_csm_w4_l2cap_connect_rsp()
637 p_ccb->chnl_state = CST_OPEN; in l2c_csm_w4_l2cap_connect_rsp()
641 p_ccb->local_cid, L2CAP_CONN_OK); in l2c_csm_w4_l2cap_connect_rsp()
643 (*credit_based_connect_cfm)(p_lcb->remote_bd_addr, p_ccb->local_cid, in l2c_csm_w4_l2cap_connect_rsp()
652 (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, p_ci->l2cap_result); in l2c_csm_w4_l2cap_connect_rsp()
654 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
659 << loghex(p_ccb->local_cid) in l2c_csm_w4_l2cap_connect_rsp()
661 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
662 (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); in l2c_csm_w4_l2cap_connect_rsp()
668 if (p_ccb->ecoc) { in l2c_csm_w4_l2cap_connect_rsp()
673 (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(p_ccb->local_cid, in l2c_csm_w4_l2cap_connect_rsp()
682 LOG(WARNING) << __func__ << ": lcid= " << loghex(p_ccb->local_cid); in l2c_csm_w4_l2cap_connect_rsp()
683 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
684 (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); in l2c_csm_w4_l2cap_connect_rsp()
690 if (p_ccb->remote_cid != 0) { in l2c_csm_w4_l2cap_connect_rsp()
691 l2cu_send_peer_disc_req(p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
692 p_ccb->chnl_state = CST_W4_L2CAP_DISCONNECT_RSP; in l2c_csm_w4_l2cap_connect_rsp()
693 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, in l2c_csm_w4_l2cap_connect_rsp()
695 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
697 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
708 if (!l2c_fcr_chk_chan_modes(p_ccb)) { in l2c_csm_w4_l2cap_connect_rsp()
709 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
710 (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); in l2c_csm_w4_l2cap_connect_rsp()
713 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS, in l2c_csm_w4_l2cap_connect_rsp()
714 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
715 l2cu_send_peer_connect_req(p_ccb); /* Start Connection */ in l2c_csm_w4_l2cap_connect_rsp()
723 channel_state_text(p_ccb->chnl_state).c_str(), p_ccb->chnl_state, in l2c_csm_w4_l2cap_connect_rsp()
737 static void l2c_csm_w4_l2ca_connect_rsp(tL2C_CCB* p_ccb, tL2CEVT event, in l2c_csm_w4_l2ca_connect_rsp() argument
741 p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb; in l2c_csm_w4_l2ca_connect_rsp()
742 uint16_t local_cid = p_ccb->local_cid; in l2c_csm_w4_l2ca_connect_rsp()
744 LOG_DEBUG("LCID: 0x%04x st: W4_L2CA_CON_RSP evt: %s", p_ccb->local_cid, in l2c_csm_w4_l2ca_connect_rsp()
750 p_ccb->local_cid); in l2c_csm_w4_l2ca_connect_rsp()
751 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
757 if (p_ccb->p_lcb && p_ccb->p_lcb->transport != BT_TRANSPORT_LE) { in l2c_csm_w4_l2ca_connect_rsp()
761 l2cu_send_peer_credit_based_conn_res(p_ccb, p_ci->lcids, in l2c_csm_w4_l2ca_connect_rsp()
763 alarm_cancel(p_ccb->l2c_ccb_timer); in l2c_csm_w4_l2ca_connect_rsp()
765 for (int i = 0; i < p_ccb->p_lcb->pending_ecoc_conn_cnt; i++) { in l2c_csm_w4_l2ca_connect_rsp()
766 uint16_t cid = p_ccb->p_lcb->pending_ecoc_connection_cids[i]; in l2c_csm_w4_l2ca_connect_rsp()
767 tL2C_CCB* temp_p_ccb = l2cu_find_ccb_by_cid(p_ccb->p_lcb, cid); in l2c_csm_w4_l2ca_connect_rsp()
775 p_ccb->p_lcb->pending_ecoc_conn_cnt = 0; in l2c_csm_w4_l2ca_connect_rsp()
776 memset(p_ccb->p_lcb->pending_ecoc_connection_cids, 0, in l2c_csm_w4_l2ca_connect_rsp()
782 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2c_csm_w4_l2ca_connect_rsp()
785 l2cble_credit_based_conn_res(p_ccb, L2CAP_CONN_OK); in l2c_csm_w4_l2ca_connect_rsp()
786 p_ccb->chnl_state = CST_OPEN; in l2c_csm_w4_l2ca_connect_rsp()
787 alarm_cancel(p_ccb->l2c_ccb_timer); in l2c_csm_w4_l2ca_connect_rsp()
789 l2cble_credit_based_conn_res(p_ccb, p_ci->l2cap_result); in l2c_csm_w4_l2ca_connect_rsp()
790 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
796 l2cu_send_peer_connect_rsp(p_ccb, L2CAP_CONN_OK, 0); in l2c_csm_w4_l2ca_connect_rsp()
797 p_ccb->chnl_state = CST_CONFIG; in l2c_csm_w4_l2ca_connect_rsp()
798 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS, in l2c_csm_w4_l2ca_connect_rsp()
799 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
804 l2cu_send_peer_connect_rsp(p_ccb, p_ci->l2cap_result, in l2c_csm_w4_l2ca_connect_rsp()
806 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, in l2c_csm_w4_l2ca_connect_rsp()
808 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
815 if (p_ccb->p_lcb && p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2c_csm_w4_l2ca_connect_rsp()
816 l2cu_send_peer_credit_based_conn_res(p_ccb, p_ci->lcids, in l2c_csm_w4_l2ca_connect_rsp()
819 alarm_cancel(p_ccb->l2c_ccb_timer); in l2c_csm_w4_l2ca_connect_rsp()
820 for (int i = 0; i < p_ccb->p_lcb->pending_ecoc_conn_cnt; i++) { in l2c_csm_w4_l2ca_connect_rsp()
821 uint16_t cid = p_ccb->p_lcb->pending_ecoc_connection_cids[i]; in l2c_csm_w4_l2ca_connect_rsp()
822 tL2C_CCB* temp_p_ccb = l2cu_find_ccb_by_cid(p_ccb->p_lcb, cid); in l2c_csm_w4_l2ca_connect_rsp()
826 p_ccb->p_lcb->pending_ecoc_conn_cnt = 0; in l2c_csm_w4_l2ca_connect_rsp()
827 memset(p_ccb->p_lcb->pending_ecoc_connection_cids, 0, in l2c_csm_w4_l2ca_connect_rsp()
833 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) in l2c_csm_w4_l2ca_connect_rsp()
834 l2cble_credit_based_conn_res(p_ccb, p_ci->l2cap_result); in l2c_csm_w4_l2ca_connect_rsp()
836 l2cu_send_peer_connect_rsp(p_ccb, p_ci->l2cap_result, in l2c_csm_w4_l2ca_connect_rsp()
838 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
842 l2cu_send_peer_connect_rsp(p_ccb, L2CAP_CONN_NO_PSM, 0); in l2c_csm_w4_l2ca_connect_rsp()
844 p_ccb->local_cid); in l2c_csm_w4_l2ca_connect_rsp()
845 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
855 l2cu_send_peer_disc_req(p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
856 p_ccb->chnl_state = CST_W4_L2CAP_DISCONNECT_RSP; in l2c_csm_w4_l2ca_connect_rsp()
857 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS, in l2c_csm_w4_l2ca_connect_rsp()
858 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
863 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS, in l2c_csm_w4_l2ca_connect_rsp()
864 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
865 LOG_DEBUG("Calling Connect_Ind_Cb(), CID: 0x%04x", p_ccb->local_cid); in l2c_csm_w4_l2ca_connect_rsp()
867 l2c_csm_send_connect_rsp(p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
868 l2c_csm_send_config_req(p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
874 channel_state_text(p_ccb->chnl_state).c_str(), p_ccb->chnl_state, in l2c_csm_w4_l2ca_connect_rsp()
888 static void l2c_csm_config(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data) { in l2c_csm_config() argument
891 p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb; in l2c_csm_config()
892 uint16_t local_cid = p_ccb->local_cid; in l2c_csm_config()
894 tL2C_LCB* p_lcb = p_ccb->p_lcb; in l2c_csm_config()
898 LOG_DEBUG("LCID: 0x%04x st: CONFIG evt: %s", p_ccb->local_cid, in l2c_csm_config()
904 p_ccb->local_cid); in l2c_csm_config()
905 l2cu_release_ccb(p_ccb); in l2c_csm_config()
914 p_ccb->local_cid); in l2c_csm_config()
916 (*p_ccb->p_rcb->api.pL2CA_CreditBasedReconfigCompleted_Cb)( in l2c_csm_config()
917 p_lcb->remote_bd_addr, p_ccb->local_cid, false, p_le_cfg); in l2c_csm_config()
920 cfg_result = l2cu_process_peer_cfg_req(p_ccb, p_cfg); in l2c_csm_config()
923 p_ccb->local_cid, (p_cfg->flags & L2CAP_CFG_FLAGS_MASK_CONT)); in l2c_csm_config()
924 l2c_csm_send_config_rsp_ok(p_ccb); in l2c_csm_config()
925 if (p_ccb->config_done & OB_CFG_DONE) { in l2c_csm_config()
926 if (p_ccb->remote_config_rsp_result == L2CAP_CFG_OK) { in l2c_csm_config()
927 l2c_csm_indicate_connection_open(p_ccb); in l2c_csm_config()
929 if (p_ccb->connection_initiator == L2CAP_INITIATOR_LOCAL) { in l2c_csm_config()
930 (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(p_ccb->local_cid, in l2c_csm_config()
938 l2cu_disconnect_chnl(p_ccb); in l2c_csm_config()
942 l2cu_send_peer_config_rsp(p_ccb, p_cfg); in l2c_csm_config()
947 p_ccb->config_done |= OB_CFG_DONE; in l2c_csm_config()
948 p_ccb->config_done |= RECONFIG_FLAG; in l2c_csm_config()
949 p_ccb->chnl_state = CST_OPEN; in l2c_csm_config()
950 alarm_cancel(p_ccb->l2c_ccb_timer); in l2c_csm_config()
952 LOG_DEBUG("Calling Config_Rsp_Cb(), CID: 0x%04x", p_ccb->local_cid); in l2c_csm_config()
954 p_ccb->p_rcb->api.pL2CA_CreditBasedReconfigCompleted_Cb( in l2c_csm_config()
955 p_lcb->remote_bd_addr, p_ccb->local_cid, true, p_le_cfg); in l2c_csm_config()
959 l2cu_process_peer_cfg_rsp(p_ccb, p_cfg); in l2c_csm_config()
967 p_ccb->config_done |= OB_CFG_DONE; in l2c_csm_config()
969 if (p_ccb->config_done & IB_CFG_DONE) { in l2c_csm_config()
971 if (p_ccb->our_cfg.fcr.mode != p_ccb->peer_cfg.fcr.mode) { in l2c_csm_config()
972 l2cu_send_peer_disc_req(p_ccb); in l2c_csm_config()
976 p_ccb->local_cid); in l2c_csm_config()
977 l2cu_release_ccb(p_ccb); in l2c_csm_config()
982 p_ccb->config_done |= RECONFIG_FLAG; in l2c_csm_config()
983 p_ccb->chnl_state = CST_OPEN; in l2c_csm_config()
985 alarm_cancel(p_ccb->l2c_ccb_timer); in l2c_csm_config()
988 if (p_ccb->fcrb.wait_ack) l2c_fcr_start_timer(p_ccb); in l2c_csm_config()
996 if ((p_ccb->our_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) && in l2c_csm_config()
997 ((p_ccb->our_cfg.fcr.mon_tout == 0) || in l2c_csm_config()
998 (p_ccb->our_cfg.fcr.rtrans_tout))) { in l2c_csm_config()
999 l2c_fcr_adj_monitor_retran_timeout(p_ccb); in l2c_csm_config()
1003 if (!fixed_queue_is_empty(p_ccb->xmit_hold_q)) { in l2c_csm_config()
1004 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, NULL); in l2c_csm_config()
1008 LOG_DEBUG("Calling Config_Rsp_Cb(), CID: 0x%04x", p_ccb->local_cid); in l2c_csm_config()
1009 p_ccb->remote_config_rsp_result = p_cfg->result; in l2c_csm_config()
1010 if (p_ccb->config_done & IB_CFG_DONE) { in l2c_csm_config()
1011 l2c_csm_indicate_connection_open(p_ccb); in l2c_csm_config()
1017 alarm_cancel(p_ccb->l2c_ccb_timer); in l2c_csm_config()
1020 if (!l2c_fcr_renegotiate_chan(p_ccb, p_cfg)) { in l2c_csm_config()
1022 p_ccb->local_cid, p_cfg->result); in l2c_csm_config()
1023 if (p_ccb->connection_initiator == L2CAP_INITIATOR_LOCAL) { in l2c_csm_config()
1024 (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(p_ccb->local_cid, in l2c_csm_config()
1031 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS, in l2c_csm_config()
1032 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_config()
1033 p_ccb->chnl_state = CST_W4_L2CA_DISCONNECT_RSP; in l2c_csm_config()
1035 p_ccb->local_cid); in l2c_csm_config()
1036 (*p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb)(p_ccb->local_cid, true); in l2c_csm_config()
1037 l2c_csm_send_disconnect_rsp(p_ccb); in l2c_csm_config()
1041 l2cu_send_credit_based_reconfig_req(p_ccb, (tL2CAP_LE_CFG_INFO*)p_data); in l2c_csm_config()
1042 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS, in l2c_csm_config()
1043 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_config()
1046 l2cu_process_our_cfg_req(p_ccb, p_cfg); in l2c_csm_config()
1047 l2cu_send_peer_config_req(p_ccb, p_cfg); in l2c_csm_config()
1048 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS, in l2c_csm_config()
1049 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_config()
1053 l2cu_process_our_cfg_rsp(p_ccb, p_cfg); in l2c_csm_config()
1055 p_ccb->config_done |= IB_CFG_DONE; in l2c_csm_config()
1057 if (p_ccb->config_done & OB_CFG_DONE) { in l2c_csm_config()
1059 if (p_ccb->our_cfg.fcr.mode != p_ccb->peer_cfg.fcr.mode) { in l2c_csm_config()
1060 l2cu_send_peer_disc_req(p_ccb); in l2c_csm_config()
1064 p_ccb->local_cid); in l2c_csm_config()
1065 l2cu_release_ccb(p_ccb); in l2c_csm_config()
1070 p_ccb->config_done |= RECONFIG_FLAG; in l2c_csm_config()
1071 p_ccb->chnl_state = CST_OPEN; in l2c_csm_config()
1073 alarm_cancel(p_ccb->l2c_ccb_timer); in l2c_csm_config()
1076 l2cu_send_peer_config_rsp(p_ccb, p_cfg); in l2c_csm_config()
1079 if (p_ccb->fcrb.wait_ack) l2c_fcr_start_timer(p_ccb); in l2c_csm_config()
1082 if ((p_ccb->chnl_state == CST_OPEN) && in l2c_csm_config()
1083 (!fixed_queue_is_empty(p_ccb->xmit_hold_q))) { in l2c_csm_config()
1084 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, NULL); in l2c_csm_config()
1089 l2cu_send_peer_disc_req(p_ccb); in l2c_csm_config()
1090 p_ccb->chnl_state = CST_W4_L2CAP_DISCONNECT_RSP; in l2c_csm_config()
1091 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS, in l2c_csm_config()
1092 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_config()
1096 LOG_DEBUG("Calling DataInd_Cb(), CID: 0x%04x", p_ccb->local_cid); in l2c_csm_config()
1097 if (p_ccb->local_cid >= L2CAP_FIRST_FIXED_CHNL && in l2c_csm_config()
1098 p_ccb->local_cid <= L2CAP_LAST_FIXED_CHNL) { in l2c_csm_config()
1099 if (p_ccb->local_cid < L2CAP_BASE_APPL_CID) { in l2c_csm_config()
1100 if (l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL] in l2c_csm_config()
1102 p_ccb->metrics.rx(static_cast<BT_HDR*>(p_data)->len); in l2c_csm_config()
1103 (*l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL] in l2c_csm_config()
1104 .pL2CA_FixedData_Cb)(p_ccb->local_cid, in l2c_csm_config()
1105 p_ccb->p_lcb->remote_bd_addr, in l2c_csm_config()
1113 if (p_data) p_ccb->metrics.rx(static_cast<BT_HDR*>(p_data)->len); in l2c_csm_config()
1114 (*p_ccb->p_rcb->api.pL2CA_DataInd_Cb)(p_ccb->local_cid, (BT_HDR*)p_data); in l2c_csm_config()
1118 if (p_ccb->config_done & OB_CFG_DONE) in l2c_csm_config()
1119 l2c_enqueue_peer_data(p_ccb, (BT_HDR*)p_data); in l2c_csm_config()
1125 if (p_ccb->ecoc) { in l2c_csm_config()
1135 acl_disconnect_from_handle(p_ccb->p_lcb->Handle(), in l2c_csm_config()
1140 l2cu_send_peer_disc_req(p_ccb); in l2c_csm_config()
1142 p_ccb->local_cid); in l2c_csm_config()
1143 l2cu_release_ccb(p_ccb); in l2c_csm_config()
1150 channel_state_text(p_ccb->chnl_state).c_str(), p_ccb->chnl_state, in l2c_csm_config()
1164 static void l2c_csm_open(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data) { in l2c_csm_open() argument
1165 uint16_t local_cid = p_ccb->local_cid; in l2c_csm_open()
1173 LOG_DEBUG("LCID: 0x%04x st: OPEN evt: %s", p_ccb->local_cid, in l2c_csm_open()
1179 p_ccb->local_cid); in l2c_csm_open()
1180 l2cu_release_ccb(p_ccb); in l2c_csm_open()
1181 if (p_ccb->p_rcb) in l2c_csm_open()
1182 (*p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb)(local_cid, false); in l2c_csm_open()
1190 p_ccb->local_cid); in l2c_csm_open()
1192 (*p_ccb->p_rcb->api.pL2CA_CreditBasedReconfigCompleted_Cb)( in l2c_csm_open()
1193 p_ccb->p_lcb->remote_bd_addr, p_ccb->local_cid, false, p_le_cfg); in l2c_csm_open()
1199 tempstate = p_ccb->chnl_state; in l2c_csm_open()
1200 tempcfgdone = p_ccb->config_done; in l2c_csm_open()
1201 p_ccb->chnl_state = CST_CONFIG; in l2c_csm_open()
1203 p_ccb->peer_cfg.mtu_present = false; in l2c_csm_open()
1204 p_ccb->peer_cfg.flush_to_present = false; in l2c_csm_open()
1205 p_ccb->peer_cfg.qos_present = false; in l2c_csm_open()
1206 p_ccb->config_done &= ~IB_CFG_DONE; in l2c_csm_open()
1208 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS, in l2c_csm_open()
1209 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_open()
1211 cfg_result = l2cu_process_peer_cfg_req(p_ccb, p_cfg); in l2c_csm_open()
1213 (*p_ccb->p_rcb->api.pL2CA_ConfigInd_Cb)(p_ccb->local_cid, p_cfg); in l2c_csm_open()
1214 l2c_csm_send_config_rsp_ok(p_ccb); in l2c_csm_open()
1219 alarm_cancel(p_ccb->l2c_ccb_timer); in l2c_csm_open()
1220 p_ccb->chnl_state = tempstate; in l2c_csm_open()
1221 p_ccb->config_done = tempcfgdone; in l2c_csm_open()
1222 l2cu_send_peer_config_rsp(p_ccb, p_cfg); in l2c_csm_open()
1229 l2cu_disconnect_chnl(p_ccb); in l2c_csm_open()
1234 if (p_ccb->p_lcb->transport != BT_TRANSPORT_LE) { in l2c_csm_open()
1235 if (!BTM_SetLinkPolicyActiveMode(p_ccb->p_lcb->remote_bd_addr)) { in l2c_csm_open()
1240 p_ccb->chnl_state = CST_W4_L2CA_DISCONNECT_RSP; in l2c_csm_open()
1241 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS, in l2c_csm_open()
1242 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_open()
1244 p_ccb->local_cid); in l2c_csm_open()
1245 (*p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb)(p_ccb->local_cid, true); in l2c_csm_open()
1246 l2c_csm_send_disconnect_rsp(p_ccb); in l2c_csm_open()
1250 if ((p_ccb->p_rcb) && (p_ccb->p_rcb->api.pL2CA_DataInd_Cb)) { in l2c_csm_open()
1251 p_ccb->metrics.rx(static_cast<BT_HDR*>(p_data)->len); in l2c_csm_open()
1252 (*p_ccb->p_rcb->api.pL2CA_DataInd_Cb)(p_ccb->local_cid, in l2c_csm_open()
1258 if (p_ccb->p_lcb->transport != BT_TRANSPORT_LE) { in l2c_csm_open()
1260 if (!BTM_SetLinkPolicyActiveMode(p_ccb->p_lcb->remote_bd_addr)) { in l2c_csm_open()
1265 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) in l2c_csm_open()
1266 l2cble_send_peer_disc_req(p_ccb); in l2c_csm_open()
1268 l2cu_send_peer_disc_req(p_ccb); in l2c_csm_open()
1270 p_ccb->chnl_state = CST_W4_L2CAP_DISCONNECT_RSP; in l2c_csm_open()
1271 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS, in l2c_csm_open()
1272 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_open()
1276 l2c_enqueue_peer_data(p_ccb, (BT_HDR*)p_data); in l2c_csm_open()
1277 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, NULL); in l2c_csm_open()
1281 p_ccb->chnl_state = CST_CONFIG; in l2c_csm_open()
1282 p_ccb->config_done &= ~OB_CFG_DONE; in l2c_csm_open()
1284 l2cu_send_credit_based_reconfig_req(p_ccb, (tL2CAP_LE_CFG_INFO*)p_data); in l2c_csm_open()
1286 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS, in l2c_csm_open()
1287 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_open()
1299 if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) in l2c_csm_open()
1300 l2c_fcr_proc_tout(p_ccb); in l2c_csm_open()
1304 l2c_fcr_proc_ack_tout(p_ccb); in l2c_csm_open()
1310 l2cble_send_flow_control_credit(p_ccb, credit); in l2c_csm_open()
1316 if ((p_ccb->peer_conn_cfg.credits + credit) > L2CAP_LE_CREDIT_MAX) { in l2c_csm_open()
1320 l2cble_send_peer_disc_req(p_ccb); in l2c_csm_open()
1322 p_ccb->peer_conn_cfg.credits += credit; in l2c_csm_open()
1323 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, NULL); in l2c_csm_open()
1330 channel_state_text(p_ccb->chnl_state).c_str(), p_ccb->chnl_state, in l2c_csm_open()
1344 static void l2c_csm_w4_l2cap_disconnect_rsp(tL2C_CCB* p_ccb, tL2CEVT event, in l2c_csm_w4_l2cap_disconnect_rsp() argument
1346 LOG_DEBUG("LCID: 0x%04x st: W4_L2CAP_DISC_RSP evt: %s", p_ccb->local_cid, in l2c_csm_w4_l2cap_disconnect_rsp()
1351 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2cap_disconnect_rsp()
1355 l2cu_send_peer_disc_rsp(p_ccb->p_lcb, p_ccb->remote_id, p_ccb->local_cid, in l2c_csm_w4_l2cap_disconnect_rsp()
1356 p_ccb->remote_cid); in l2c_csm_w4_l2cap_disconnect_rsp()
1357 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2cap_disconnect_rsp()
1362 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2cap_disconnect_rsp()
1373 channel_state_text(p_ccb->chnl_state).c_str(), p_ccb->chnl_state, in l2c_csm_w4_l2cap_disconnect_rsp()
1387 static void l2c_csm_w4_l2ca_disconnect_rsp(tL2C_CCB* p_ccb, tL2CEVT event, in l2c_csm_w4_l2ca_disconnect_rsp() argument
1390 p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb; in l2c_csm_w4_l2ca_disconnect_rsp()
1391 uint16_t local_cid = p_ccb->local_cid; in l2c_csm_w4_l2ca_disconnect_rsp()
1393 LOG_DEBUG("LCID: 0x%04x st: W4_L2CA_DISC_RSP evt: %s", p_ccb->local_cid, in l2c_csm_w4_l2ca_disconnect_rsp()
1399 p_ccb->local_cid); in l2c_csm_w4_l2ca_disconnect_rsp()
1400 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2ca_disconnect_rsp()
1405 l2cu_send_peer_disc_rsp(p_ccb->p_lcb, p_ccb->remote_id, p_ccb->local_cid, in l2c_csm_w4_l2ca_disconnect_rsp()
1406 p_ccb->remote_cid); in l2c_csm_w4_l2ca_disconnect_rsp()
1408 p_ccb->local_cid); in l2c_csm_w4_l2ca_disconnect_rsp()
1409 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2ca_disconnect_rsp()
1415 l2cu_send_peer_disc_rsp(p_ccb->p_lcb, p_ccb->remote_id, p_ccb->local_cid, in l2c_csm_w4_l2ca_disconnect_rsp()
1416 p_ccb->remote_cid); in l2c_csm_w4_l2ca_disconnect_rsp()
1417 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2ca_disconnect_rsp()
1428 channel_state_text(p_ccb->chnl_state).c_str(), p_ccb->chnl_state, in l2c_csm_w4_l2ca_disconnect_rsp()
1550 void l2c_enqueue_peer_data(tL2C_CCB* p_ccb, BT_HDR* p_buf) { in l2c_enqueue_peer_data() argument
1551 CHECK(p_ccb != nullptr); in l2c_enqueue_peer_data()
1553 p_ccb->metrics.tx(p_buf->len); in l2c_enqueue_peer_data()
1557 if (p_ccb->peer_cfg.fcr.mode != L2CAP_FCR_BASIC_MODE) { in l2c_enqueue_peer_data()
1561 p_buf->event = p_ccb->local_cid; in l2c_enqueue_peer_data()
1572 UINT16_TO_STREAM(p, p_ccb->remote_cid); in l2c_enqueue_peer_data()
1575 if (p_ccb->xmit_hold_q == NULL) { in l2c_enqueue_peer_data()
1579 p_ccb, p_ccb->in_use, p_ccb->chnl_state, p_ccb->local_cid, in l2c_enqueue_peer_data()
1580 p_ccb->remote_cid); in l2c_enqueue_peer_data()
1582 fixed_queue_enqueue(p_ccb->xmit_hold_q, p_buf); in l2c_enqueue_peer_data()
1584 l2cu_check_channel_congestion(p_ccb); in l2c_enqueue_peer_data()
1587 if ((p_ccb->p_lcb->rr_pri > p_ccb->ccb_priority) && in l2c_enqueue_peer_data()
1588 (p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].quota > 0)) { in l2c_enqueue_peer_data()
1590 p_ccb->p_lcb->rr_pri = p_ccb->ccb_priority; in l2c_enqueue_peer_data()
1594 if (p_ccb->p_lcb->link_xmit_quota == 0) l2cb.check_round_robin = true; in l2c_enqueue_peer_data()