Lines Matching full:p_ccb
41 static void l2c_csm_closed(tL2C_CCB* p_ccb, uint16_t event, void* p_data);
42 static void l2c_csm_orig_w4_sec_comp(tL2C_CCB* p_ccb, uint16_t event,
44 static void l2c_csm_term_w4_sec_comp(tL2C_CCB* p_ccb, uint16_t event,
46 static void l2c_csm_w4_l2cap_connect_rsp(tL2C_CCB* p_ccb, uint16_t event,
48 static void l2c_csm_w4_l2ca_connect_rsp(tL2C_CCB* p_ccb, uint16_t event,
50 static void l2c_csm_config(tL2C_CCB* p_ccb, uint16_t event, void* p_data);
51 static void l2c_csm_open(tL2C_CCB* p_ccb, uint16_t event, void* p_data);
52 static void l2c_csm_w4_l2cap_disconnect_rsp(tL2C_CCB* p_ccb, uint16_t event,
54 static void l2c_csm_w4_l2ca_disconnect_rsp(tL2C_CCB* p_ccb, uint16_t event,
68 void l2c_csm_execute(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {
69 if (!l2cu_is_ccb_active(p_ccb)) {
75 switch (p_ccb->chnl_state) {
77 l2c_csm_closed(p_ccb, event, p_data);
81 l2c_csm_orig_w4_sec_comp(p_ccb, event, p_data);
85 l2c_csm_term_w4_sec_comp(p_ccb, event, p_data);
89 l2c_csm_w4_l2cap_connect_rsp(p_ccb, event, p_data);
93 l2c_csm_w4_l2ca_connect_rsp(p_ccb, event, p_data);
97 l2c_csm_config(p_ccb, event, p_data);
101 l2c_csm_open(p_ccb, event, p_data);
105 l2c_csm_w4_l2cap_disconnect_rsp(p_ccb, event, p_data);
109 l2c_csm_w4_l2ca_disconnect_rsp(p_ccb, event, p_data);
129 static void l2c_csm_closed(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {
131 uint16_t local_cid = p_ccb->local_cid;
135 if (p_ccb->p_rcb == NULL) {
137 p_ccb->local_cid, l2c_csm_get_event_name(event));
141 disconnect_ind = p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb;
142 connect_cfm = p_ccb->p_rcb->api.pL2CA_ConnectCfm_Cb;
145 p_ccb->local_cid, l2c_csm_get_event_name(event));
151 p_ccb->local_cid);
152 l2cu_release_ccb(p_ccb);
157 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) {
158 p_ccb->chnl_state = CST_ORIG_W4_SEC_COMP;
159 l2ble_sec_access_req(p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm,
160 true, &l2c_link_sec_comp2, p_ccb);
162 p_ccb->chnl_state = CST_ORIG_W4_SEC_COMP;
163 btm_sec_l2cap_access_req(p_ccb->p_lcb->remote_bd_addr,
164 p_ccb->p_rcb->psm, p_ccb->p_lcb->handle, true,
165 &l2c_link_sec_comp, p_ccb);
172 !btm_acl_notif_conn_collision(p_ccb->p_lcb->remote_bd_addr)) {
175 p_ccb->local_cid, p_ci->status);
176 l2cu_release_ccb(p_ccb);
182 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) {
183 p_ccb->chnl_state = CST_ORIG_W4_SEC_COMP;
184 l2ble_sec_access_req(p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm,
185 true, &l2c_link_sec_comp2, p_ccb);
192 BTM_SetPowerMode(BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr,
197 if (btm_sec_l2cap_access_req(p_ccb->p_lcb->remote_bd_addr,
198 p_ccb->p_rcb->psm, p_ccb->p_lcb->handle,
200 p_ccb) == BTM_CMD_STARTED) {
201 p_ccb->chnl_state = CST_ORIG_W4_SEC_COMP;
207 p_ccb->chnl_state = CST_W4_L2CAP_CONNECT_RSP;
211 if (!p_ccb->p_lcb->w4_info_rsp) {
213 if (!l2c_fcr_chk_chan_modes(p_ccb)) {
214 l2cu_release_ccb(p_ccb);
215 (*p_ccb->p_rcb->api.pL2CA_ConnectCfm_Cb)(local_cid,
218 l2cu_send_peer_connect_req(p_ccb);
219 alarm_set_on_mloop(p_ccb->l2c_ccb_timer,
221 l2c_ccb_timer_timeout, p_ccb);
229 p_ccb->local_cid, L2CAP_CONN_TIMEOUT);
230 l2cu_release_ccb(p_ccb);
237 alarm_cancel(p_ccb->p_lcb->l2c_lcb_timer);
239 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) {
240 p_ccb->chnl_state = CST_TERM_W4_SEC_COMP;
241 l2ble_sec_access_req(p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm,
242 false, &l2c_link_sec_comp2, p_ccb);
250 BTM_SetPowerMode(BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr,
254 p_ccb->chnl_state = CST_TERM_W4_SEC_COMP;
255 if (btm_sec_l2cap_access_req(p_ccb->p_lcb->remote_bd_addr,
256 p_ccb->p_rcb->psm, p_ccb->p_lcb->handle,
258 p_ccb) == BTM_CMD_STARTED) {
261 l2cu_send_peer_connect_rsp(p_ccb, L2CAP_CONN_PENDING, 0);
269 p_ccb->local_cid, L2CAP_CONN_TIMEOUT);
270 l2cu_release_ccb(p_ccb);
280 l2cu_release_ccb(p_ccb);
295 static void l2c_csm_orig_w4_sec_comp(tL2C_CCB* p_ccb, uint16_t event,
298 p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb;
299 tL2CA_CONNECT_CFM_CB* connect_cfm = p_ccb->p_rcb->api.pL2CA_ConnectCfm_Cb;
300 uint16_t local_cid = p_ccb->local_cid;
304 ((p_ccb->p_lcb) && (p_ccb->p_lcb->transport == BT_TRANSPORT_LE)) ? "LE "
306 p_ccb->local_cid, l2c_csm_get_event_name(event));
312 p_ccb->local_cid);
313 l2cu_release_ccb(p_ccb);
319 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) {
320 l2ble_sec_access_req(p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm,
321 false, &l2c_link_sec_comp2, p_ccb);
323 btm_sec_l2cap_access_req(p_ccb->p_lcb->remote_bd_addr,
324 p_ccb->p_rcb->psm, p_ccb->p_lcb->handle, true,
325 &l2c_link_sec_comp, p_ccb);
332 p_ccb->chnl_state = CST_W4_L2CAP_CONNECT_RSP;
333 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) {
334 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS,
335 l2c_ccb_timer_timeout, p_ccb);
336 l2cble_credit_based_conn_req(p_ccb); /* Start Connection */
338 if (!p_ccb->p_lcb->w4_info_rsp) {
340 if (!l2c_fcr_chk_chan_modes(p_ccb)) {
341 l2cu_release_ccb(p_ccb);
344 alarm_set_on_mloop(p_ccb->l2c_ccb_timer,
346 l2c_ccb_timer_timeout, p_ccb);
347 l2cu_send_peer_connect_req(p_ccb); /* Start Connection */
356 p_ccb->local_cid, HCI_ERR_AUTH_FAILURE);
360 if ((p_ccb == p_ccb->p_lcb->ccb_queue.p_first_ccb) &&
361 (p_ccb == p_ccb->p_lcb->ccb_queue.p_last_ccb)) {
362 p_ccb->p_lcb->idle_timeout = 0;
365 l2cu_release_ccb(p_ccb);
376 btm_sec_abort_access_req(p_ccb->p_lcb->remote_bd_addr);
378 l2cu_release_ccb(p_ccb);
393 static void l2c_csm_term_w4_sec_comp(tL2C_CCB* p_ccb, uint16_t event,
396 p_ccb->local_cid, l2c_csm_get_event_name(event));
401 btm_sec_abort_access_req(p_ccb->p_lcb->remote_bd_addr);
403 l2cu_release_ccb(p_ccb);
407 p_ccb->chnl_state = CST_W4_L2CA_CONNECT_RSP;
411 if (!p_ccb->p_lcb->w4_info_rsp) {
413 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS,
414 l2c_ccb_timer_timeout, p_ccb);
416 p_ccb->local_cid);
418 (*p_ccb->p_rcb->api.pL2CA_ConnectInd_Cb)(
419 p_ccb->p_lcb->remote_bd_addr, p_ccb->local_cid, p_ccb->p_rcb->psm,
420 p_ccb->remote_id);
432 l2cu_send_peer_connect_rsp(p_ccb, L2CAP_CONN_PENDING, 0);
440 alarm_set_on_mloop(p_ccb->l2c_ccb_timer,
442 l2c_ccb_timer_timeout, p_ccb);
444 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE)
445 l2cu_reject_ble_connection(p_ccb->p_lcb, p_ccb->remote_id,
448 l2cu_send_peer_connect_rsp(p_ccb, L2CAP_CONN_SECURITY_BLOCK, 0);
449 l2cu_release_ccb(p_ccb);
459 l2cu_release_ccb(p_ccb);
463 l2cu_send_peer_disc_rsp(p_ccb->p_lcb, p_ccb->remote_id, p_ccb->local_cid,
464 p_ccb->remote_cid);
467 btm_sec_abort_access_req(p_ccb->p_lcb->remote_bd_addr);
469 l2cu_release_ccb(p_ccb);
474 btsnd_hcic_disconnect(p_ccb->p_lcb->handle, HCI_ERR_AUTH_FAILURE);
478 btm_sec_l2cap_access_req(p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm,
479 p_ccb->p_lcb->handle, false, &l2c_link_sec_comp,
480 p_ccb);
495 static void l2c_csm_w4_l2cap_connect_rsp(tL2C_CCB* p_ccb, uint16_t event,
499 p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb;
500 tL2CA_CONNECT_CFM_CB* connect_cfm = p_ccb->p_rcb->api.pL2CA_ConnectCfm_Cb;
501 uint16_t local_cid = p_ccb->local_cid;
504 p_ccb->local_cid, l2c_csm_get_event_name(event));
512 p_ccb->chnl_state = CST_CLOSED;
513 if ((p_ccb->flags & CCB_FLAG_NO_RETRY) || !p_data ||
517 p_ccb->local_cid);
518 l2cu_release_ccb(p_ccb);
521 p_ccb->flags |= CCB_FLAG_NO_RETRY;
525 p_ccb->remote_cid = p_ci->remote_cid;
526 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) {
528 alarm_cancel(p_ccb->l2c_ccb_timer);
529 p_ccb->chnl_state = CST_OPEN;
531 p_ccb->chnl_state = CST_CONFIG;
532 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
533 l2c_ccb_timer_timeout, p_ccb);
536 p_ccb->local_cid);
538 (*p_ccb->p_rcb->api.pL2CA_ConnectCfm_Cb)(local_cid, L2CAP_CONN_OK);
542 p_ccb->remote_cid = p_ci->remote_cid;
543 alarm_set_on_mloop(p_ccb->l2c_ccb_timer,
545 l2c_ccb_timer_timeout, p_ccb);
546 if (p_ccb->p_rcb->api.pL2CA_ConnectPnd_Cb) {
548 p_ccb->local_cid);
549 (*p_ccb->p_rcb->api.pL2CA_ConnectPnd_Cb)(p_ccb->local_cid);
555 << loghex(p_ccb->local_cid)
557 l2cu_release_ccb(p_ccb);
563 << loghex(p_ccb->local_cid);
564 l2cu_release_ccb(p_ccb);
570 if (p_ccb->remote_cid != 0) {
571 l2cu_send_peer_disc_req(p_ccb);
572 p_ccb->chnl_state = CST_W4_L2CAP_DISCONNECT_RSP;
573 alarm_set_on_mloop(p_ccb->l2c_ccb_timer,
575 l2c_ccb_timer_timeout, p_ccb);
578 p_ccb->p_rcb->api.pL2CA_DisconnectCfm_Cb;
579 l2cu_release_ccb(p_ccb);
595 if (!l2c_fcr_chk_chan_modes(p_ccb)) {
596 l2cu_release_ccb(p_ccb);
600 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS,
601 l2c_ccb_timer_timeout, p_ccb);
602 l2cu_send_peer_connect_req(p_ccb); /* Start Connection */
618 static void l2c_csm_w4_l2ca_connect_rsp(tL2C_CCB* p_ccb, uint16_t event,
622 p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb;
623 uint16_t local_cid = p_ccb->local_cid;
626 p_ccb->local_cid, l2c_csm_get_event_name(event));
632 p_ccb->local_cid);
633 l2cu_release_ccb(p_ccb);
639 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) {
642 l2cble_credit_based_conn_res(p_ccb, L2CAP_CONN_OK);
643 p_ccb->chnl_state = CST_OPEN;
644 alarm_cancel(p_ccb->l2c_ccb_timer);
646 l2cble_credit_based_conn_res(p_ccb, p_ci->l2cap_result);
647 l2cu_release_ccb(p_ccb);
652 l2cu_send_peer_connect_rsp(p_ccb, L2CAP_CONN_OK, 0);
653 p_ccb->chnl_state = CST_CONFIG;
654 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
655 l2c_ccb_timer_timeout, p_ccb);
658 l2cu_send_peer_connect_rsp(p_ccb, p_ci->l2cap_result,
660 alarm_set_on_mloop(p_ccb->l2c_ccb_timer,
662 l2c_ccb_timer_timeout, p_ccb);
669 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE)
670 l2cble_credit_based_conn_res(p_ccb, p_ci->l2cap_result);
672 l2cu_send_peer_connect_rsp(p_ccb, p_ci->l2cap_result,
674 l2cu_release_ccb(p_ccb);
678 l2cu_send_peer_connect_rsp(p_ccb, L2CAP_CONN_NO_PSM, 0);
681 p_ccb->local_cid);
682 l2cu_release_ccb(p_ccb);
692 l2cu_send_peer_disc_req(p_ccb);
693 p_ccb->chnl_state = CST_W4_L2CAP_DISCONNECT_RSP;
694 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS,
695 l2c_ccb_timer_timeout, p_ccb);
700 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS,
701 l2c_ccb_timer_timeout, p_ccb);
703 p_ccb->local_cid);
705 (*p_ccb->p_rcb->api.pL2CA_ConnectInd_Cb)(
706 p_ccb->p_lcb->remote_bd_addr, p_ccb->local_cid, p_ccb->p_rcb->psm,
707 p_ccb->remote_id);
722 static void l2c_csm_config(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {
725 p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb;
726 uint16_t local_cid = p_ccb->local_cid;
730 p_ccb->local_cid, l2c_csm_get_event_name(event));
736 p_ccb->local_cid);
737 l2cu_release_ccb(p_ccb);
743 cfg_result = l2cu_process_peer_cfg_req(p_ccb, p_cfg);
747 p_ccb->local_cid, (p_cfg->flags & L2CAP_CFG_FLAGS_MASK_CONT));
748 (*p_ccb->p_rcb->api.pL2CA_ConfigInd_Cb)(p_ccb->local_cid, p_cfg);
752 l2cu_disconnect_chnl(p_ccb);
757 l2cu_send_peer_config_rsp(p_ccb, p_cfg);
762 l2cu_process_peer_cfg_rsp(p_ccb, p_cfg);
771 p_ccb->config_done |= OB_CFG_DONE;
773 if (p_ccb->config_done & IB_CFG_DONE) {
775 if (p_ccb->our_cfg.fcr.mode != p_ccb->peer_cfg.fcr.mode) {
776 l2cu_send_peer_disc_req(p_ccb);
780 p_ccb->local_cid);
781 l2cu_release_ccb(p_ccb);
786 p_ccb->config_done |= RECONFIG_FLAG;
787 p_ccb->chnl_state = CST_OPEN;
789 alarm_cancel(p_ccb->l2c_ccb_timer);
792 if (p_ccb->fcrb.wait_ack) l2c_fcr_start_timer(p_ccb);
795 ** check p_ccb->our_cfg.fcr.mon_tout and
796 *p_ccb->our_cfg.fcr.rtrans_tout
800 if ((p_ccb->our_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) &&
801 ((p_ccb->our_cfg.fcr.mon_tout == 0) ||
802 (p_ccb->our_cfg.fcr.rtrans_tout))) {
803 l2c_fcr_adj_monitor_retran_timeout(p_ccb);
807 p_ccb->fcrb.connect_tick_count = time_get_os_boottime_ms();
810 if (!fixed_queue_is_empty(p_ccb->xmit_hold_q)) {
811 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL);
817 p_ccb->local_cid);
818 (*p_ccb->p_rcb->api.pL2CA_ConfigCfm_Cb)(p_ccb->local_cid, p_cfg);
823 alarm_cancel(p_ccb->l2c_ccb_timer);
826 if (!l2c_fcr_renegotiate_chan(p_ccb, p_cfg)) {
829 p_ccb->local_cid, p_cfg->result);
830 (*p_ccb->p_rcb->api.pL2CA_ConfigCfm_Cb)(p_ccb->local_cid, p_cfg);
835 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS,
836 l2c_ccb_timer_timeout, p_ccb);
837 p_ccb->chnl_state = CST_W4_L2CA_DISCONNECT_RSP;
840 p_ccb->local_cid);
841 (*p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb)(p_ccb->local_cid, true);
845 l2cu_process_our_cfg_req(p_ccb, p_cfg);
846 l2cu_send_peer_config_req(p_ccb, p_cfg);
847 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
848 l2c_ccb_timer_timeout, p_ccb);
852 l2cu_process_our_cfg_rsp(p_ccb, p_cfg);
858 l2cu_send_peer_config_rsp(p_ccb, p_cfg);
864 p_ccb->peer_cfg.mtu_present = false;
865 p_ccb->peer_cfg.flush_to_present = false;
866 p_ccb->peer_cfg.qos_present = false;
868 p_ccb->config_done |= IB_CFG_DONE;
870 if (p_ccb->config_done & OB_CFG_DONE) {
872 if (p_ccb->our_cfg.fcr.mode != p_ccb->peer_cfg.fcr.mode) {
873 l2cu_send_peer_disc_req(p_ccb);
877 p_ccb->local_cid);
878 l2cu_release_ccb(p_ccb);
883 p_ccb->config_done |= RECONFIG_FLAG;
884 p_ccb->chnl_state = CST_OPEN;
886 alarm_cancel(p_ccb->l2c_ccb_timer);
889 l2cu_send_peer_config_rsp(p_ccb, p_cfg);
892 if (p_ccb->fcrb.wait_ack) l2c_fcr_start_timer(p_ccb);
895 p_ccb->fcrb.connect_tick_count = time_get_os_boottime_ms();
899 if ((p_ccb->chnl_state == CST_OPEN) &&
900 (!fixed_queue_is_empty(p_ccb->xmit_hold_q))) {
901 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL);
906 l2cu_send_peer_config_rsp(p_ccb, p_cfg);
907 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
908 l2c_ccb_timer_timeout, p_ccb);
912 l2cu_send_peer_disc_req(p_ccb);
913 p_ccb->chnl_state = CST_W4_L2CAP_DISCONNECT_RSP;
914 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS,
915 l2c_ccb_timer_timeout, p_ccb);
920 p_ccb->local_cid);
922 if (p_ccb->local_cid >= L2CAP_FIRST_FIXED_CHNL &&
923 p_ccb->local_cid <= L2CAP_LAST_FIXED_CHNL) {
924 if (p_ccb->local_cid < L2CAP_BASE_APPL_CID) {
925 if (l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL]
927 (*l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL]
928 .pL2CA_FixedData_Cb)(p_ccb->local_cid,
929 p_ccb->p_lcb->remote_bd_addr,
937 (*p_ccb->p_rcb->api.pL2CA_DataInd_Cb)(p_ccb->local_cid, (BT_HDR*)p_data);
941 if (p_ccb->config_done & OB_CFG_DONE)
942 l2c_enqueue_peer_data(p_ccb, (BT_HDR*)p_data);
948 l2cu_send_peer_disc_req(p_ccb);
951 p_ccb->local_cid);
952 l2cu_release_ccb(p_ccb);
968 static void l2c_csm_open(tL2C_CCB* p_ccb, uint16_t event, void* p_data) {
969 uint16_t local_cid = p_ccb->local_cid;
976 L2CAP_TRACE_EVENT("L2CAP - LCID: 0x%04x st: OPEN evt: %s", p_ccb->local_cid,
983 p_ccb->local_cid);
984 l2cu_release_ccb(p_ccb);
985 if (p_ccb->p_rcb)
986 (*p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb)(local_cid, false);
991 if (p_ccb->p_rcb->api.pL2CA_QoSViolationInd_Cb)
992 (*p_ccb->p_rcb->api.pL2CA_QoSViolationInd_Cb)(
993 p_ccb->p_lcb->remote_bd_addr);
999 tempstate = p_ccb->chnl_state;
1000 tempcfgdone = p_ccb->config_done;
1001 p_ccb->chnl_state = CST_CONFIG;
1002 p_ccb->config_done &= ~IB_CFG_DONE;
1004 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
1005 l2c_ccb_timer_timeout, p_ccb);
1007 cfg_result = l2cu_process_peer_cfg_req(p_ccb, p_cfg);
1009 (*p_ccb->p_rcb->api.pL2CA_ConfigInd_Cb)(p_ccb->local_cid, p_cfg);
1014 alarm_cancel(p_ccb->l2c_ccb_timer);
1015 p_ccb->chnl_state = tempstate;
1016 p_ccb->config_done = tempcfgdone;
1017 l2cu_send_peer_config_rsp(p_ccb, p_cfg);
1024 l2cu_disconnect_chnl(p_ccb);
1029 if (p_ccb->p_lcb->transport != BT_TRANSPORT_LE) {
1035 BTM_SetPowerMode(BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr,
1040 p_ccb->chnl_state = CST_W4_L2CA_DISCONNECT_RSP;
1041 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS,
1042 l2c_ccb_timer_timeout, p_ccb);
1045 p_ccb->local_cid);
1046 (*p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb)(p_ccb->local_cid, true);
1050 if ((p_ccb->p_rcb) && (p_ccb->p_rcb->api.pL2CA_DataInd_Cb))
1051 (*p_ccb->p_rcb->api.pL2CA_DataInd_Cb)(p_ccb->local_cid,
1056 if (p_ccb->p_lcb->transport != BT_TRANSPORT_LE) {
1062 BTM_SetPowerMode(BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr,
1067 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE)
1068 l2cble_send_peer_disc_req(p_ccb);
1070 l2cu_send_peer_disc_req(p_ccb);
1072 p_ccb->chnl_state = CST_W4_L2CAP_DISCONNECT_RSP;
1073 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS,
1074 l2c_ccb_timer_timeout, p_ccb);
1078 l2c_enqueue_peer_data(p_ccb, (BT_HDR*)p_data);
1079 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL);
1083 p_ccb->chnl_state = CST_CONFIG;
1084 p_ccb->config_done &= ~CFG_DONE_MASK;
1085 l2cu_process_our_cfg_req(p_ccb, (tL2CAP_CFG_INFO*)p_data);
1086 l2cu_send_peer_config_req(p_ccb, (tL2CAP_CFG_INFO*)p_data);
1087 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS,
1088 l2c_ccb_timer_timeout, p_ccb);
1094 if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE)
1095 l2c_fcr_proc_tout(p_ccb);
1099 l2c_fcr_proc_ack_tout(p_ccb);
1105 l2cble_send_flow_control_credit(p_ccb, *credit);
1111 if ((p_ccb->peer_conn_cfg.credits + *credit) > L2CAP_LE_CREDIT_MAX) {
1115 l2cble_send_peer_disc_req(p_ccb);
1117 p_ccb->peer_conn_cfg.credits += *credit;
1120 p_ccb->p_rcb->api.pL2CA_CreditsReceived_Cb;
1121 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE && (cr_cb)) {
1122 (*cr_cb)(p_ccb->local_cid, *credit, p_ccb->peer_conn_cfg.credits);
1124 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL);
1140 static void l2c_csm_w4_l2cap_disconnect_rsp(tL2C_CCB* p_ccb, uint16_t event,
1143 p_ccb->p_rcb->api.pL2CA_DisconnectCfm_Cb;
1144 uint16_t local_cid = p_ccb->local_cid;
1147 p_ccb->local_cid, l2c_csm_get_event_name(event));
1151 l2cu_release_ccb(p_ccb);
1160 l2cu_send_peer_disc_rsp(p_ccb->p_lcb, p_ccb->remote_id, p_ccb->local_cid,
1161 p_ccb->remote_cid);
1162 l2cu_release_ccb(p_ccb);
1172 l2cu_release_ccb(p_ccb);
1197 static void l2c_csm_w4_l2ca_disconnect_rsp(tL2C_CCB* p_ccb, uint16_t event,
1200 p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb;
1201 uint16_t local_cid = p_ccb->local_cid;
1204 p_ccb->local_cid, l2c_csm_get_event_name(event));
1210 p_ccb->local_cid);
1211 l2cu_release_ccb(p_ccb);
1216 l2cu_send_peer_disc_rsp(p_ccb->p_lcb, p_ccb->remote_id, p_ccb->local_cid,
1217 p_ccb->remote_cid);
1220 p_ccb->local_cid);
1221 l2cu_release_ccb(p_ccb);
1227 l2cu_send_peer_disc_rsp(p_ccb->p_lcb, p_ccb->remote_id, p_ccb->local_cid,
1228 p_ccb->remote_cid);
1229 l2cu_release_ccb(p_ccb);
1342 void l2c_enqueue_peer_data(tL2C_CCB* p_ccb, BT_HDR* p_buf) {
1345 if (p_ccb->peer_cfg.fcr.mode != L2CAP_FCR_BASIC_MODE) {
1349 p_buf->event = p_ccb->local_cid;
1360 UINT16_TO_STREAM(p, p_ccb->remote_cid);
1363 if (p_ccb->xmit_hold_q == NULL) {
1365 "%s: empty queue: p_ccb = %p p_ccb->in_use = %d p_ccb->chnl_state = %d "
1366 "p_ccb->local_cid = %u p_ccb->remote_cid = %u",
1367 __func__, p_ccb, p_ccb->in_use, p_ccb->chnl_state, p_ccb->local_cid,
1368 p_ccb->remote_cid);
1370 fixed_queue_enqueue(p_ccb->xmit_hold_q, p_buf);
1372 l2cu_check_channel_congestion(p_ccb);
1376 if ((p_ccb->p_lcb->rr_pri > p_ccb->ccb_priority) &&
1377 (p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].quota > 0)) {
1379 p_ccb->p_lcb->rr_pri = p_ccb->ccb_priority;
1384 if (p_ccb->p_lcb->link_xmit_quota == 0) l2cb.check_round_robin = true;