• Home
  • Raw
  • Download

Lines Matching refs:p_ccb

42 static void l2c_csm_closed(tL2C_CCB* p_ccb, uint16_t event, void* p_data);
43 static void l2c_csm_orig_w4_sec_comp(tL2C_CCB* p_ccb, uint16_t event,
45 static void l2c_csm_term_w4_sec_comp(tL2C_CCB* p_ccb, uint16_t event,
47 static void l2c_csm_w4_l2cap_connect_rsp(tL2C_CCB* p_ccb, uint16_t event,
49 static void l2c_csm_w4_l2ca_connect_rsp(tL2C_CCB* p_ccb, uint16_t event,
51 static void l2c_csm_config(tL2C_CCB* p_ccb, uint16_t event, void* p_data);
52 static void l2c_csm_open(tL2C_CCB* p_ccb, uint16_t event, void* p_data);
53 static void l2c_csm_w4_l2cap_disconnect_rsp(tL2C_CCB* p_ccb, uint16_t event,
55 static void l2c_csm_w4_l2ca_disconnect_rsp(tL2C_CCB* p_ccb, uint16_t event,
69 void l2c_csm_execute(tL2C_CCB* p_ccb, uint16_t event, void* p_data) { in l2c_csm_execute() argument
70 if (!l2cu_is_ccb_active(p_ccb)) { in l2c_csm_execute()
76 switch (p_ccb->chnl_state) { in l2c_csm_execute()
78 l2c_csm_closed(p_ccb, event, p_data); in l2c_csm_execute()
82 l2c_csm_orig_w4_sec_comp(p_ccb, event, p_data); in l2c_csm_execute()
86 l2c_csm_term_w4_sec_comp(p_ccb, event, p_data); in l2c_csm_execute()
90 l2c_csm_w4_l2cap_connect_rsp(p_ccb, event, p_data); in l2c_csm_execute()
94 l2c_csm_w4_l2ca_connect_rsp(p_ccb, event, p_data); in l2c_csm_execute()
98 l2c_csm_config(p_ccb, event, p_data); in l2c_csm_execute()
102 l2c_csm_open(p_ccb, event, p_data); in l2c_csm_execute()
106 l2c_csm_w4_l2cap_disconnect_rsp(p_ccb, event, p_data); in l2c_csm_execute()
110 l2c_csm_w4_l2ca_disconnect_rsp(p_ccb, event, p_data); in l2c_csm_execute()
130 static void l2c_csm_closed(tL2C_CCB* p_ccb, uint16_t event, void* p_data) { in l2c_csm_closed() argument
132 uint16_t local_cid = p_ccb->local_cid; in l2c_csm_closed()
136 if (p_ccb->p_rcb == NULL) { in l2c_csm_closed()
138 p_ccb->local_cid, l2c_csm_get_event_name(event)); in l2c_csm_closed()
142 disconnect_ind = p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb; in l2c_csm_closed()
143 connect_cfm = p_ccb->p_rcb->api.pL2CA_ConnectCfm_Cb; in l2c_csm_closed()
146 p_ccb->local_cid, l2c_csm_get_event_name(event)); in l2c_csm_closed()
152 p_ccb->local_cid); in l2c_csm_closed()
153 l2cu_release_ccb(p_ccb); in l2c_csm_closed()
158 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2c_csm_closed()
159 p_ccb->chnl_state = CST_ORIG_W4_SEC_COMP; in l2c_csm_closed()
160 l2ble_sec_access_req(p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm, in l2c_csm_closed()
161 true, &l2c_link_sec_comp2, p_ccb); in l2c_csm_closed()
163 p_ccb->chnl_state = CST_ORIG_W4_SEC_COMP; in l2c_csm_closed()
164 btm_sec_l2cap_access_req(p_ccb->p_lcb->remote_bd_addr, in l2c_csm_closed()
165 p_ccb->p_rcb->psm, p_ccb->p_lcb->handle, true, in l2c_csm_closed()
166 &l2c_link_sec_comp, p_ccb); in l2c_csm_closed()
173 !btm_acl_notif_conn_collision(p_ccb->p_lcb->remote_bd_addr)) { in l2c_csm_closed()
176 p_ccb->local_cid, p_ci->status); in l2c_csm_closed()
177 l2cu_release_ccb(p_ccb); in l2c_csm_closed()
183 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2c_csm_closed()
184 p_ccb->chnl_state = CST_ORIG_W4_SEC_COMP; in l2c_csm_closed()
185 l2ble_sec_access_req(p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm, in l2c_csm_closed()
186 true, &l2c_link_sec_comp2, p_ccb); in l2c_csm_closed()
193 BTM_SetPowerMode(BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr, in l2c_csm_closed()
198 if (btm_sec_l2cap_access_req(p_ccb->p_lcb->remote_bd_addr, in l2c_csm_closed()
199 p_ccb->p_rcb->psm, p_ccb->p_lcb->handle, in l2c_csm_closed()
201 p_ccb) == BTM_CMD_STARTED) { in l2c_csm_closed()
202 p_ccb->chnl_state = CST_ORIG_W4_SEC_COMP; in l2c_csm_closed()
208 p_ccb->chnl_state = CST_W4_L2CAP_CONNECT_RSP; in l2c_csm_closed()
212 if (!p_ccb->p_lcb->w4_info_rsp) { in l2c_csm_closed()
214 if (!l2c_fcr_chk_chan_modes(p_ccb)) { in l2c_csm_closed()
215 l2cu_release_ccb(p_ccb); in l2c_csm_closed()
216 (*p_ccb->p_rcb->api.pL2CA_ConnectCfm_Cb)(local_cid, in l2c_csm_closed()
219 l2cu_send_peer_connect_req(p_ccb); in l2c_csm_closed()
220 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, in l2c_csm_closed()
222 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_closed()
230 p_ccb->local_cid, L2CAP_CONN_TIMEOUT); in l2c_csm_closed()
231 l2cu_release_ccb(p_ccb); in l2c_csm_closed()
238 alarm_cancel(p_ccb->p_lcb->l2c_lcb_timer); in l2c_csm_closed()
240 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2c_csm_closed()
241 p_ccb->chnl_state = CST_TERM_W4_SEC_COMP; in l2c_csm_closed()
243 p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm, false, in l2c_csm_closed()
244 &l2c_link_sec_comp2, p_ccb); in l2c_csm_closed()
250 l2cu_reject_ble_connection(p_ccb->p_lcb, p_ccb->remote_id, result); in l2c_csm_closed()
251 l2cu_release_ccb(p_ccb); in l2c_csm_closed()
262 BTM_SetPowerMode(BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr, in l2c_csm_closed()
266 p_ccb->chnl_state = CST_TERM_W4_SEC_COMP; in l2c_csm_closed()
267 if (btm_sec_l2cap_access_req(p_ccb->p_lcb->remote_bd_addr, in l2c_csm_closed()
268 p_ccb->p_rcb->psm, p_ccb->p_lcb->handle, in l2c_csm_closed()
270 p_ccb) == BTM_CMD_STARTED) { in l2c_csm_closed()
273 l2cu_send_peer_connect_rsp(p_ccb, L2CAP_CONN_PENDING, 0); in l2c_csm_closed()
281 p_ccb->local_cid, L2CAP_CONN_TIMEOUT); in l2c_csm_closed()
282 l2cu_release_ccb(p_ccb); in l2c_csm_closed()
292 l2cu_release_ccb(p_ccb); in l2c_csm_closed()
307 static void l2c_csm_orig_w4_sec_comp(tL2C_CCB* p_ccb, uint16_t event, in l2c_csm_orig_w4_sec_comp() argument
310 p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb; in l2c_csm_orig_w4_sec_comp()
311 tL2CA_CONNECT_CFM_CB* connect_cfm = p_ccb->p_rcb->api.pL2CA_ConnectCfm_Cb; in l2c_csm_orig_w4_sec_comp()
312 uint16_t local_cid = p_ccb->local_cid; in l2c_csm_orig_w4_sec_comp()
316 ((p_ccb->p_lcb) && (p_ccb->p_lcb->transport == BT_TRANSPORT_LE)) ? "LE " in l2c_csm_orig_w4_sec_comp()
318 p_ccb->local_cid, l2c_csm_get_event_name(event)); in l2c_csm_orig_w4_sec_comp()
324 p_ccb->local_cid); in l2c_csm_orig_w4_sec_comp()
325 l2cu_release_ccb(p_ccb); in l2c_csm_orig_w4_sec_comp()
331 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2c_csm_orig_w4_sec_comp()
332 l2ble_sec_access_req(p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm, in l2c_csm_orig_w4_sec_comp()
333 false, &l2c_link_sec_comp2, p_ccb); in l2c_csm_orig_w4_sec_comp()
335 btm_sec_l2cap_access_req(p_ccb->p_lcb->remote_bd_addr, in l2c_csm_orig_w4_sec_comp()
336 p_ccb->p_rcb->psm, p_ccb->p_lcb->handle, true, in l2c_csm_orig_w4_sec_comp()
337 &l2c_link_sec_comp, p_ccb); in l2c_csm_orig_w4_sec_comp()
344 p_ccb->chnl_state = CST_W4_L2CAP_CONNECT_RSP; in l2c_csm_orig_w4_sec_comp()
345 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2c_csm_orig_w4_sec_comp()
346 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS, in l2c_csm_orig_w4_sec_comp()
347 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_orig_w4_sec_comp()
348 l2cble_credit_based_conn_req(p_ccb); /* Start Connection */ in l2c_csm_orig_w4_sec_comp()
350 if (!p_ccb->p_lcb->w4_info_rsp) { in l2c_csm_orig_w4_sec_comp()
352 if (!l2c_fcr_chk_chan_modes(p_ccb)) { in l2c_csm_orig_w4_sec_comp()
353 l2cu_release_ccb(p_ccb); in l2c_csm_orig_w4_sec_comp()
356 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, in l2c_csm_orig_w4_sec_comp()
358 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_orig_w4_sec_comp()
359 l2cu_send_peer_connect_req(p_ccb); /* Start Connection */ in l2c_csm_orig_w4_sec_comp()
368 p_ccb->local_cid, HCI_ERR_AUTH_FAILURE); in l2c_csm_orig_w4_sec_comp()
372 if ((p_ccb == p_ccb->p_lcb->ccb_queue.p_first_ccb) && in l2c_csm_orig_w4_sec_comp()
373 (p_ccb == p_ccb->p_lcb->ccb_queue.p_last_ccb)) { in l2c_csm_orig_w4_sec_comp()
374 p_ccb->p_lcb->idle_timeout = 0; in l2c_csm_orig_w4_sec_comp()
377 l2cu_release_ccb(p_ccb); in l2c_csm_orig_w4_sec_comp()
388 btm_sec_abort_access_req(p_ccb->p_lcb->remote_bd_addr); in l2c_csm_orig_w4_sec_comp()
390 l2cu_release_ccb(p_ccb); in l2c_csm_orig_w4_sec_comp()
405 static void l2c_csm_term_w4_sec_comp(tL2C_CCB* p_ccb, uint16_t event, in l2c_csm_term_w4_sec_comp() argument
408 p_ccb->local_cid, l2c_csm_get_event_name(event)); in l2c_csm_term_w4_sec_comp()
413 btm_sec_abort_access_req(p_ccb->p_lcb->remote_bd_addr); in l2c_csm_term_w4_sec_comp()
415 l2cu_release_ccb(p_ccb); in l2c_csm_term_w4_sec_comp()
419 p_ccb->chnl_state = CST_W4_L2CA_CONNECT_RSP; in l2c_csm_term_w4_sec_comp()
423 if (!p_ccb->p_lcb->w4_info_rsp) { in l2c_csm_term_w4_sec_comp()
425 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS, in l2c_csm_term_w4_sec_comp()
426 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_term_w4_sec_comp()
428 p_ccb->local_cid); in l2c_csm_term_w4_sec_comp()
430 (*p_ccb->p_rcb->api.pL2CA_ConnectInd_Cb)( in l2c_csm_term_w4_sec_comp()
431 p_ccb->p_lcb->remote_bd_addr, p_ccb->local_cid, p_ccb->p_rcb->psm, in l2c_csm_term_w4_sec_comp()
432 p_ccb->remote_id); in l2c_csm_term_w4_sec_comp()
444 l2cu_send_peer_connect_rsp(p_ccb, L2CAP_CONN_PENDING, 0); in l2c_csm_term_w4_sec_comp()
452 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, in l2c_csm_term_w4_sec_comp()
454 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_term_w4_sec_comp()
456 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) in l2c_csm_term_w4_sec_comp()
458 p_ccb->p_lcb, p_ccb->remote_id, in l2c_csm_term_w4_sec_comp()
461 l2cu_send_peer_connect_rsp(p_ccb, L2CAP_CONN_SECURITY_BLOCK, 0); in l2c_csm_term_w4_sec_comp()
462 l2cu_release_ccb(p_ccb); in l2c_csm_term_w4_sec_comp()
472 l2cu_release_ccb(p_ccb); in l2c_csm_term_w4_sec_comp()
476 l2cu_send_peer_disc_rsp(p_ccb->p_lcb, p_ccb->remote_id, p_ccb->local_cid, in l2c_csm_term_w4_sec_comp()
477 p_ccb->remote_cid); in l2c_csm_term_w4_sec_comp()
480 btm_sec_abort_access_req(p_ccb->p_lcb->remote_bd_addr); in l2c_csm_term_w4_sec_comp()
482 l2cu_release_ccb(p_ccb); in l2c_csm_term_w4_sec_comp()
487 btsnd_hcic_disconnect(p_ccb->p_lcb->handle, HCI_ERR_AUTH_FAILURE); in l2c_csm_term_w4_sec_comp()
491 btm_sec_l2cap_access_req(p_ccb->p_lcb->remote_bd_addr, p_ccb->p_rcb->psm, in l2c_csm_term_w4_sec_comp()
492 p_ccb->p_lcb->handle, false, &l2c_link_sec_comp, in l2c_csm_term_w4_sec_comp()
493 p_ccb); in l2c_csm_term_w4_sec_comp()
508 static void l2c_csm_w4_l2cap_connect_rsp(tL2C_CCB* p_ccb, uint16_t event, in l2c_csm_w4_l2cap_connect_rsp() argument
512 p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb; in l2c_csm_w4_l2cap_connect_rsp()
513 tL2CA_CONNECT_CFM_CB* connect_cfm = p_ccb->p_rcb->api.pL2CA_ConnectCfm_Cb; in l2c_csm_w4_l2cap_connect_rsp()
514 uint16_t local_cid = p_ccb->local_cid; in l2c_csm_w4_l2cap_connect_rsp()
517 p_ccb->local_cid, l2c_csm_get_event_name(event)); in l2c_csm_w4_l2cap_connect_rsp()
525 p_ccb->chnl_state = CST_CLOSED; in l2c_csm_w4_l2cap_connect_rsp()
526 if ((p_ccb->flags & CCB_FLAG_NO_RETRY) || !p_data || in l2c_csm_w4_l2cap_connect_rsp()
530 p_ccb->local_cid); in l2c_csm_w4_l2cap_connect_rsp()
531 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
534 p_ccb->flags |= CCB_FLAG_NO_RETRY; in l2c_csm_w4_l2cap_connect_rsp()
538 p_ccb->remote_cid = p_ci->remote_cid; in l2c_csm_w4_l2cap_connect_rsp()
539 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2c_csm_w4_l2cap_connect_rsp()
541 alarm_cancel(p_ccb->l2c_ccb_timer); in l2c_csm_w4_l2cap_connect_rsp()
542 p_ccb->chnl_state = CST_OPEN; in l2c_csm_w4_l2cap_connect_rsp()
544 p_ccb->chnl_state = CST_CONFIG; in l2c_csm_w4_l2cap_connect_rsp()
545 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS, in l2c_csm_w4_l2cap_connect_rsp()
546 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
549 p_ccb->local_cid); in l2c_csm_w4_l2cap_connect_rsp()
551 (*p_ccb->p_rcb->api.pL2CA_ConnectCfm_Cb)(local_cid, L2CAP_CONN_OK); in l2c_csm_w4_l2cap_connect_rsp()
555 p_ccb->remote_cid = p_ci->remote_cid; in l2c_csm_w4_l2cap_connect_rsp()
556 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, in l2c_csm_w4_l2cap_connect_rsp()
558 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
559 if (p_ccb->p_rcb->api.pL2CA_ConnectPnd_Cb) { in l2c_csm_w4_l2cap_connect_rsp()
561 p_ccb->local_cid); in l2c_csm_w4_l2cap_connect_rsp()
562 (*p_ccb->p_rcb->api.pL2CA_ConnectPnd_Cb)(p_ccb->local_cid); in l2c_csm_w4_l2cap_connect_rsp()
568 << loghex(p_ccb->local_cid) in l2c_csm_w4_l2cap_connect_rsp()
570 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
576 << loghex(p_ccb->local_cid); in l2c_csm_w4_l2cap_connect_rsp()
577 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
583 if (p_ccb->remote_cid != 0) { in l2c_csm_w4_l2cap_connect_rsp()
584 l2cu_send_peer_disc_req(p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
585 p_ccb->chnl_state = CST_W4_L2CAP_DISCONNECT_RSP; in l2c_csm_w4_l2cap_connect_rsp()
586 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, in l2c_csm_w4_l2cap_connect_rsp()
588 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
591 p_ccb->p_rcb->api.pL2CA_DisconnectCfm_Cb; in l2c_csm_w4_l2cap_connect_rsp()
592 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
608 if (!l2c_fcr_chk_chan_modes(p_ccb)) { in l2c_csm_w4_l2cap_connect_rsp()
609 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
613 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS, in l2c_csm_w4_l2cap_connect_rsp()
614 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_w4_l2cap_connect_rsp()
615 l2cu_send_peer_connect_req(p_ccb); /* Start Connection */ in l2c_csm_w4_l2cap_connect_rsp()
631 static void l2c_csm_w4_l2ca_connect_rsp(tL2C_CCB* p_ccb, uint16_t event, in l2c_csm_w4_l2ca_connect_rsp() argument
635 p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb; in l2c_csm_w4_l2ca_connect_rsp()
636 uint16_t local_cid = p_ccb->local_cid; in l2c_csm_w4_l2ca_connect_rsp()
639 p_ccb->local_cid, l2c_csm_get_event_name(event)); in l2c_csm_w4_l2ca_connect_rsp()
645 p_ccb->local_cid); in l2c_csm_w4_l2ca_connect_rsp()
646 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
652 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2c_csm_w4_l2ca_connect_rsp()
655 l2cble_credit_based_conn_res(p_ccb, L2CAP_CONN_OK); in l2c_csm_w4_l2ca_connect_rsp()
656 p_ccb->chnl_state = CST_OPEN; in l2c_csm_w4_l2ca_connect_rsp()
657 alarm_cancel(p_ccb->l2c_ccb_timer); in l2c_csm_w4_l2ca_connect_rsp()
659 l2cble_credit_based_conn_res(p_ccb, p_ci->l2cap_result); in l2c_csm_w4_l2ca_connect_rsp()
660 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
665 l2cu_send_peer_connect_rsp(p_ccb, L2CAP_CONN_OK, 0); in l2c_csm_w4_l2ca_connect_rsp()
666 p_ccb->chnl_state = CST_CONFIG; in l2c_csm_w4_l2ca_connect_rsp()
667 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS, in l2c_csm_w4_l2ca_connect_rsp()
668 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
671 l2cu_send_peer_connect_rsp(p_ccb, p_ci->l2cap_result, in l2c_csm_w4_l2ca_connect_rsp()
673 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, in l2c_csm_w4_l2ca_connect_rsp()
675 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
682 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) in l2c_csm_w4_l2ca_connect_rsp()
683 l2cble_credit_based_conn_res(p_ccb, p_ci->l2cap_result); in l2c_csm_w4_l2ca_connect_rsp()
685 l2cu_send_peer_connect_rsp(p_ccb, p_ci->l2cap_result, in l2c_csm_w4_l2ca_connect_rsp()
687 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
691 l2cu_send_peer_connect_rsp(p_ccb, L2CAP_CONN_NO_PSM, 0); in l2c_csm_w4_l2ca_connect_rsp()
694 p_ccb->local_cid); in l2c_csm_w4_l2ca_connect_rsp()
695 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
705 l2cu_send_peer_disc_req(p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
706 p_ccb->chnl_state = CST_W4_L2CAP_DISCONNECT_RSP; in l2c_csm_w4_l2ca_connect_rsp()
707 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS, in l2c_csm_w4_l2ca_connect_rsp()
708 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
713 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS, in l2c_csm_w4_l2ca_connect_rsp()
714 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_w4_l2ca_connect_rsp()
716 p_ccb->local_cid); in l2c_csm_w4_l2ca_connect_rsp()
718 (*p_ccb->p_rcb->api.pL2CA_ConnectInd_Cb)( in l2c_csm_w4_l2ca_connect_rsp()
719 p_ccb->p_lcb->remote_bd_addr, p_ccb->local_cid, p_ccb->p_rcb->psm, in l2c_csm_w4_l2ca_connect_rsp()
720 p_ccb->remote_id); in l2c_csm_w4_l2ca_connect_rsp()
735 static void l2c_csm_config(tL2C_CCB* p_ccb, uint16_t event, void* p_data) { in l2c_csm_config() argument
738 p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb; in l2c_csm_config()
739 uint16_t local_cid = p_ccb->local_cid; in l2c_csm_config()
743 p_ccb->local_cid, l2c_csm_get_event_name(event)); in l2c_csm_config()
749 p_ccb->local_cid); in l2c_csm_config()
750 l2cu_release_ccb(p_ccb); in l2c_csm_config()
756 cfg_result = l2cu_process_peer_cfg_req(p_ccb, p_cfg); in l2c_csm_config()
760 p_ccb->local_cid, (p_cfg->flags & L2CAP_CFG_FLAGS_MASK_CONT)); in l2c_csm_config()
761 (*p_ccb->p_rcb->api.pL2CA_ConfigInd_Cb)(p_ccb->local_cid, p_cfg); in l2c_csm_config()
765 l2cu_disconnect_chnl(p_ccb); in l2c_csm_config()
770 l2cu_send_peer_config_rsp(p_ccb, p_cfg); in l2c_csm_config()
775 l2cu_process_peer_cfg_rsp(p_ccb, p_cfg); in l2c_csm_config()
784 p_ccb->config_done |= OB_CFG_DONE; in l2c_csm_config()
786 if (p_ccb->config_done & IB_CFG_DONE) { in l2c_csm_config()
788 if (p_ccb->our_cfg.fcr.mode != p_ccb->peer_cfg.fcr.mode) { in l2c_csm_config()
789 l2cu_send_peer_disc_req(p_ccb); in l2c_csm_config()
793 p_ccb->local_cid); in l2c_csm_config()
794 l2cu_release_ccb(p_ccb); in l2c_csm_config()
799 p_ccb->config_done |= RECONFIG_FLAG; in l2c_csm_config()
800 p_ccb->chnl_state = CST_OPEN; in l2c_csm_config()
802 alarm_cancel(p_ccb->l2c_ccb_timer); in l2c_csm_config()
805 if (p_ccb->fcrb.wait_ack) l2c_fcr_start_timer(p_ccb); in l2c_csm_config()
813 if ((p_ccb->our_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) && in l2c_csm_config()
814 ((p_ccb->our_cfg.fcr.mon_tout == 0) || in l2c_csm_config()
815 (p_ccb->our_cfg.fcr.rtrans_tout))) { in l2c_csm_config()
816 l2c_fcr_adj_monitor_retran_timeout(p_ccb); in l2c_csm_config()
820 p_ccb->fcrb.connect_tick_count = in l2c_csm_config()
824 if (!fixed_queue_is_empty(p_ccb->xmit_hold_q)) { in l2c_csm_config()
825 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL); in l2c_csm_config()
831 p_ccb->local_cid); in l2c_csm_config()
832 (*p_ccb->p_rcb->api.pL2CA_ConfigCfm_Cb)(p_ccb->local_cid, p_cfg); in l2c_csm_config()
837 alarm_cancel(p_ccb->l2c_ccb_timer); in l2c_csm_config()
840 if (!l2c_fcr_renegotiate_chan(p_ccb, p_cfg)) { in l2c_csm_config()
843 p_ccb->local_cid, p_cfg->result); in l2c_csm_config()
844 (*p_ccb->p_rcb->api.pL2CA_ConfigCfm_Cb)(p_ccb->local_cid, p_cfg); in l2c_csm_config()
849 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS, in l2c_csm_config()
850 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_config()
851 p_ccb->chnl_state = CST_W4_L2CA_DISCONNECT_RSP; in l2c_csm_config()
854 p_ccb->local_cid); in l2c_csm_config()
855 (*p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb)(p_ccb->local_cid, true); in l2c_csm_config()
859 l2cu_process_our_cfg_req(p_ccb, p_cfg); in l2c_csm_config()
860 l2cu_send_peer_config_req(p_ccb, p_cfg); in l2c_csm_config()
861 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS, in l2c_csm_config()
862 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_config()
866 l2cu_process_our_cfg_rsp(p_ccb, p_cfg); in l2c_csm_config()
872 l2cu_send_peer_config_rsp(p_ccb, p_cfg); in l2c_csm_config()
878 p_ccb->peer_cfg.mtu_present = false; in l2c_csm_config()
879 p_ccb->peer_cfg.flush_to_present = false; in l2c_csm_config()
880 p_ccb->peer_cfg.qos_present = false; in l2c_csm_config()
882 p_ccb->config_done |= IB_CFG_DONE; in l2c_csm_config()
884 if (p_ccb->config_done & OB_CFG_DONE) { in l2c_csm_config()
886 if (p_ccb->our_cfg.fcr.mode != p_ccb->peer_cfg.fcr.mode) { in l2c_csm_config()
887 l2cu_send_peer_disc_req(p_ccb); in l2c_csm_config()
891 p_ccb->local_cid); in l2c_csm_config()
892 l2cu_release_ccb(p_ccb); in l2c_csm_config()
897 p_ccb->config_done |= RECONFIG_FLAG; in l2c_csm_config()
898 p_ccb->chnl_state = CST_OPEN; in l2c_csm_config()
900 alarm_cancel(p_ccb->l2c_ccb_timer); in l2c_csm_config()
903 l2cu_send_peer_config_rsp(p_ccb, p_cfg); in l2c_csm_config()
906 if (p_ccb->fcrb.wait_ack) l2c_fcr_start_timer(p_ccb); in l2c_csm_config()
909 p_ccb->fcrb.connect_tick_count = in l2c_csm_config()
914 if ((p_ccb->chnl_state == CST_OPEN) && in l2c_csm_config()
915 (!fixed_queue_is_empty(p_ccb->xmit_hold_q))) { in l2c_csm_config()
916 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL); in l2c_csm_config()
921 l2cu_send_peer_config_rsp(p_ccb, p_cfg); in l2c_csm_config()
922 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS, in l2c_csm_config()
923 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_config()
927 l2cu_send_peer_disc_req(p_ccb); in l2c_csm_config()
928 p_ccb->chnl_state = CST_W4_L2CAP_DISCONNECT_RSP; in l2c_csm_config()
929 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS, in l2c_csm_config()
930 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_config()
935 p_ccb->local_cid); in l2c_csm_config()
937 if (p_ccb->local_cid >= L2CAP_FIRST_FIXED_CHNL && in l2c_csm_config()
938 p_ccb->local_cid <= L2CAP_LAST_FIXED_CHNL) { in l2c_csm_config()
939 if (p_ccb->local_cid < L2CAP_BASE_APPL_CID) { in l2c_csm_config()
940 if (l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL] in l2c_csm_config()
942 (*l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL] in l2c_csm_config()
943 .pL2CA_FixedData_Cb)(p_ccb->local_cid, in l2c_csm_config()
944 p_ccb->p_lcb->remote_bd_addr, in l2c_csm_config()
952 (*p_ccb->p_rcb->api.pL2CA_DataInd_Cb)(p_ccb->local_cid, (BT_HDR*)p_data); in l2c_csm_config()
956 if (p_ccb->config_done & OB_CFG_DONE) in l2c_csm_config()
957 l2c_enqueue_peer_data(p_ccb, (BT_HDR*)p_data); in l2c_csm_config()
963 l2cu_send_peer_disc_req(p_ccb); in l2c_csm_config()
966 p_ccb->local_cid); in l2c_csm_config()
967 l2cu_release_ccb(p_ccb); in l2c_csm_config()
983 static void l2c_csm_open(tL2C_CCB* p_ccb, uint16_t event, void* p_data) { in l2c_csm_open() argument
984 uint16_t local_cid = p_ccb->local_cid; in l2c_csm_open()
991 L2CAP_TRACE_EVENT("L2CAP - LCID: 0x%04x st: OPEN evt: %s", p_ccb->local_cid, in l2c_csm_open()
998 p_ccb->local_cid); in l2c_csm_open()
999 l2cu_release_ccb(p_ccb); in l2c_csm_open()
1000 if (p_ccb->p_rcb) in l2c_csm_open()
1001 (*p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb)(local_cid, false); in l2c_csm_open()
1006 if (p_ccb->p_rcb->api.pL2CA_QoSViolationInd_Cb) in l2c_csm_open()
1007 (*p_ccb->p_rcb->api.pL2CA_QoSViolationInd_Cb)( in l2c_csm_open()
1008 p_ccb->p_lcb->remote_bd_addr); in l2c_csm_open()
1014 tempstate = p_ccb->chnl_state; in l2c_csm_open()
1015 tempcfgdone = p_ccb->config_done; in l2c_csm_open()
1016 p_ccb->chnl_state = CST_CONFIG; in l2c_csm_open()
1017 p_ccb->config_done &= ~IB_CFG_DONE; in l2c_csm_open()
1019 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS, in l2c_csm_open()
1020 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_open()
1022 cfg_result = l2cu_process_peer_cfg_req(p_ccb, p_cfg); in l2c_csm_open()
1024 (*p_ccb->p_rcb->api.pL2CA_ConfigInd_Cb)(p_ccb->local_cid, p_cfg); in l2c_csm_open()
1029 alarm_cancel(p_ccb->l2c_ccb_timer); in l2c_csm_open()
1030 p_ccb->chnl_state = tempstate; in l2c_csm_open()
1031 p_ccb->config_done = tempcfgdone; in l2c_csm_open()
1032 l2cu_send_peer_config_rsp(p_ccb, p_cfg); in l2c_csm_open()
1039 l2cu_disconnect_chnl(p_ccb); in l2c_csm_open()
1044 if (p_ccb->p_lcb->transport != BT_TRANSPORT_LE) { in l2c_csm_open()
1050 BTM_SetPowerMode(BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr, in l2c_csm_open()
1055 p_ccb->chnl_state = CST_W4_L2CA_DISCONNECT_RSP; in l2c_csm_open()
1056 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS, in l2c_csm_open()
1057 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_open()
1060 p_ccb->local_cid); in l2c_csm_open()
1061 (*p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb)(p_ccb->local_cid, true); in l2c_csm_open()
1065 if ((p_ccb->p_rcb) && (p_ccb->p_rcb->api.pL2CA_DataInd_Cb)) in l2c_csm_open()
1066 (*p_ccb->p_rcb->api.pL2CA_DataInd_Cb)(p_ccb->local_cid, in l2c_csm_open()
1071 if (p_ccb->p_lcb->transport != BT_TRANSPORT_LE) { in l2c_csm_open()
1077 BTM_SetPowerMode(BTM_PM_SET_ONLY_ID, p_ccb->p_lcb->remote_bd_addr, in l2c_csm_open()
1082 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) in l2c_csm_open()
1083 l2cble_send_peer_disc_req(p_ccb); in l2c_csm_open()
1085 l2cu_send_peer_disc_req(p_ccb); in l2c_csm_open()
1087 p_ccb->chnl_state = CST_W4_L2CAP_DISCONNECT_RSP; in l2c_csm_open()
1088 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_DISCONNECT_TIMEOUT_MS, in l2c_csm_open()
1089 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_open()
1093 l2c_enqueue_peer_data(p_ccb, (BT_HDR*)p_data); in l2c_csm_open()
1094 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL); in l2c_csm_open()
1098 p_ccb->chnl_state = CST_CONFIG; in l2c_csm_open()
1099 p_ccb->config_done &= ~CFG_DONE_MASK; in l2c_csm_open()
1100 l2cu_process_our_cfg_req(p_ccb, (tL2CAP_CFG_INFO*)p_data); in l2c_csm_open()
1101 l2cu_send_peer_config_req(p_ccb, (tL2CAP_CFG_INFO*)p_data); in l2c_csm_open()
1102 alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CFG_TIMEOUT_MS, in l2c_csm_open()
1103 l2c_ccb_timer_timeout, p_ccb); in l2c_csm_open()
1109 if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) in l2c_csm_open()
1110 l2c_fcr_proc_tout(p_ccb); in l2c_csm_open()
1114 l2c_fcr_proc_ack_tout(p_ccb); in l2c_csm_open()
1120 l2cble_send_flow_control_credit(p_ccb, *credit); in l2c_csm_open()
1126 if ((p_ccb->peer_conn_cfg.credits + *credit) > L2CAP_LE_CREDIT_MAX) { in l2c_csm_open()
1130 l2cble_send_peer_disc_req(p_ccb); in l2c_csm_open()
1132 p_ccb->peer_conn_cfg.credits += *credit; in l2c_csm_open()
1135 p_ccb->p_rcb->api.pL2CA_CreditsReceived_Cb; in l2c_csm_open()
1136 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE && (cr_cb)) { in l2c_csm_open()
1137 (*cr_cb)(p_ccb->local_cid, *credit, p_ccb->peer_conn_cfg.credits); in l2c_csm_open()
1139 l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL); in l2c_csm_open()
1155 static void l2c_csm_w4_l2cap_disconnect_rsp(tL2C_CCB* p_ccb, uint16_t event, in l2c_csm_w4_l2cap_disconnect_rsp() argument
1158 p_ccb->p_rcb->api.pL2CA_DisconnectCfm_Cb; in l2c_csm_w4_l2cap_disconnect_rsp()
1159 uint16_t local_cid = p_ccb->local_cid; in l2c_csm_w4_l2cap_disconnect_rsp()
1162 p_ccb->local_cid, l2c_csm_get_event_name(event)); in l2c_csm_w4_l2cap_disconnect_rsp()
1166 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2cap_disconnect_rsp()
1175 l2cu_send_peer_disc_rsp(p_ccb->p_lcb, p_ccb->remote_id, p_ccb->local_cid, in l2c_csm_w4_l2cap_disconnect_rsp()
1176 p_ccb->remote_cid); in l2c_csm_w4_l2cap_disconnect_rsp()
1177 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2cap_disconnect_rsp()
1187 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2cap_disconnect_rsp()
1212 static void l2c_csm_w4_l2ca_disconnect_rsp(tL2C_CCB* p_ccb, uint16_t event, in l2c_csm_w4_l2ca_disconnect_rsp() argument
1215 p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb; in l2c_csm_w4_l2ca_disconnect_rsp()
1216 uint16_t local_cid = p_ccb->local_cid; in l2c_csm_w4_l2ca_disconnect_rsp()
1219 p_ccb->local_cid, l2c_csm_get_event_name(event)); in l2c_csm_w4_l2ca_disconnect_rsp()
1225 p_ccb->local_cid); in l2c_csm_w4_l2ca_disconnect_rsp()
1226 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2ca_disconnect_rsp()
1231 l2cu_send_peer_disc_rsp(p_ccb->p_lcb, p_ccb->remote_id, p_ccb->local_cid, in l2c_csm_w4_l2ca_disconnect_rsp()
1232 p_ccb->remote_cid); in l2c_csm_w4_l2ca_disconnect_rsp()
1235 p_ccb->local_cid); in l2c_csm_w4_l2ca_disconnect_rsp()
1236 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2ca_disconnect_rsp()
1242 l2cu_send_peer_disc_rsp(p_ccb->p_lcb, p_ccb->remote_id, p_ccb->local_cid, in l2c_csm_w4_l2ca_disconnect_rsp()
1243 p_ccb->remote_cid); in l2c_csm_w4_l2ca_disconnect_rsp()
1244 l2cu_release_ccb(p_ccb); in l2c_csm_w4_l2ca_disconnect_rsp()
1357 void l2c_enqueue_peer_data(tL2C_CCB* p_ccb, BT_HDR* p_buf) { in l2c_enqueue_peer_data() argument
1360 if (p_ccb->peer_cfg.fcr.mode != L2CAP_FCR_BASIC_MODE) { in l2c_enqueue_peer_data()
1364 p_buf->event = p_ccb->local_cid; in l2c_enqueue_peer_data()
1375 UINT16_TO_STREAM(p, p_ccb->remote_cid); in l2c_enqueue_peer_data()
1378 if (p_ccb->xmit_hold_q == NULL) { in l2c_enqueue_peer_data()
1382 __func__, p_ccb, p_ccb->in_use, p_ccb->chnl_state, p_ccb->local_cid, in l2c_enqueue_peer_data()
1383 p_ccb->remote_cid); in l2c_enqueue_peer_data()
1385 fixed_queue_enqueue(p_ccb->xmit_hold_q, p_buf); in l2c_enqueue_peer_data()
1387 l2cu_check_channel_congestion(p_ccb); in l2c_enqueue_peer_data()
1391 if ((p_ccb->p_lcb->rr_pri > p_ccb->ccb_priority) && in l2c_enqueue_peer_data()
1392 (p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].quota > 0)) { in l2c_enqueue_peer_data()
1394 p_ccb->p_lcb->rr_pri = p_ccb->ccb_priority; in l2c_enqueue_peer_data()
1399 if (p_ccb->p_lcb->link_xmit_quota == 0) l2cb.check_round_robin = true; in l2c_enqueue_peer_data()