Lines Matching refs:p_lcb
45 tL2C_CCB* l2cu_get_next_channel_in_rr(tL2C_LCB* p_lcb); // TODO Move
59 tL2C_LCB* p_lcb = &l2cb.lcb_pool[0]; in l2cu_allocate_lcb() local
61 for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_lcb++) { in l2cu_allocate_lcb()
62 if (!p_lcb->in_use) { in l2cu_allocate_lcb()
63 alarm_free(p_lcb->l2c_lcb_timer); in l2cu_allocate_lcb()
64 alarm_free(p_lcb->info_resp_timer); in l2cu_allocate_lcb()
65 memset(p_lcb, 0, sizeof(tL2C_LCB)); in l2cu_allocate_lcb()
67 p_lcb->remote_bd_addr = p_bd_addr; in l2cu_allocate_lcb()
69 p_lcb->in_use = true; in l2cu_allocate_lcb()
70 p_lcb->link_state = LST_DISCONNECTED; in l2cu_allocate_lcb()
71 p_lcb->InvalidateHandle(); in l2cu_allocate_lcb()
72 p_lcb->l2c_lcb_timer = alarm_new("l2c_lcb.l2c_lcb_timer"); in l2cu_allocate_lcb()
73 p_lcb->info_resp_timer = alarm_new("l2c_lcb.info_resp_timer"); in l2cu_allocate_lcb()
74 p_lcb->idle_timeout = l2cb.idle_timeout; in l2cu_allocate_lcb()
75 p_lcb->signal_id = 1; /* spec does not allow '0' */ in l2cu_allocate_lcb()
77 p_lcb->SetBonding(); in l2cu_allocate_lcb()
79 p_lcb->ResetBonding(); in l2cu_allocate_lcb()
81 p_lcb->transport = transport; in l2cu_allocate_lcb()
82 p_lcb->tx_data_len = in l2cu_allocate_lcb()
84 p_lcb->le_sec_pending_q = fixed_queue_new(SIZE_MAX); in l2cu_allocate_lcb()
93 p_lcb->link_xmit_data_q = list_new(NULL); in l2cu_allocate_lcb()
94 return (p_lcb); in l2cu_allocate_lcb()
102 void l2cu_set_lcb_handle(struct t_l2c_linkcb& p_lcb, uint16_t handle) { in l2cu_set_lcb_handle() argument
103 if (p_lcb.Handle() != HCI_INVALID_HANDLE) { in l2cu_set_lcb_handle()
105 p_lcb.Handle(), handle); in l2cu_set_lcb_handle()
107 p_lcb.SetHandle(handle); in l2cu_set_lcb_handle()
126 tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(p_bd_addr, BT_TRANSPORT_BR_EDR); in l2cu_update_lcb_4_bonding() local
128 if (p_lcb) { in l2cu_update_lcb_4_bonding()
132 p_lcb->SetBonding(); in l2cu_update_lcb_4_bonding()
134 p_lcb->ResetBonding(); in l2cu_update_lcb_4_bonding()
149 void l2cu_release_lcb(tL2C_LCB* p_lcb) { in l2cu_release_lcb() argument
152 p_lcb->in_use = false; in l2cu_release_lcb()
153 p_lcb->ResetBonding(); in l2cu_release_lcb()
156 alarm_free(p_lcb->l2c_lcb_timer); in l2cu_release_lcb()
157 p_lcb->l2c_lcb_timer = NULL; in l2cu_release_lcb()
158 alarm_free(p_lcb->info_resp_timer); in l2cu_release_lcb()
159 p_lcb->info_resp_timer = NULL; in l2cu_release_lcb()
161 if (p_lcb->transport == BT_TRANSPORT_BR_EDR) /* Release all SCO links */ in l2cu_release_lcb()
162 BTM_RemoveSco(p_lcb->remote_bd_addr); in l2cu_release_lcb()
164 if (p_lcb->sent_not_acked > 0) { in l2cu_release_lcb()
165 if (p_lcb->transport == BT_TRANSPORT_LE) { in l2cu_release_lcb()
166 l2cb.controller_le_xmit_window += p_lcb->sent_not_acked; in l2cu_release_lcb()
171 l2cb.controller_xmit_window += p_lcb->sent_not_acked; in l2cu_release_lcb()
178 l2cu_process_fixed_disc_cback(p_lcb); in l2cu_release_lcb()
181 for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; in l2cu_release_lcb()
182 p_ccb = p_lcb->ccb_queue.p_first_ccb) { in l2cu_release_lcb()
187 if ((p_lcb->link_state == LST_CONNECTED) || in l2cu_release_lcb()
188 (p_lcb->link_state == LST_DISCONNECTING)) in l2cu_release_lcb()
189 btm_acl_removed(p_lcb->Handle()); in l2cu_release_lcb()
192 if (p_lcb->link_xmit_data_q) { in l2cu_release_lcb()
193 while (!list_is_empty(p_lcb->link_xmit_data_q)) { in l2cu_release_lcb()
194 BT_HDR* p_buf = static_cast<BT_HDR*>(list_front(p_lcb->link_xmit_data_q)); in l2cu_release_lcb()
195 list_remove(p_lcb->link_xmit_data_q, p_buf); in l2cu_release_lcb()
198 list_free(p_lcb->link_xmit_data_q); in l2cu_release_lcb()
199 p_lcb->link_xmit_data_q = NULL; in l2cu_release_lcb()
203 if (p_lcb->transport == BT_TRANSPORT_LE) { in l2cu_release_lcb()
214 if (p_lcb->le_sec_pending_q) { in l2cu_release_lcb()
215 while (!fixed_queue_is_empty(p_lcb->le_sec_pending_q)) { in l2cu_release_lcb()
217 (tL2CAP_SEC_DATA*)fixed_queue_try_dequeue(p_lcb->le_sec_pending_q); in l2cu_release_lcb()
219 p_buf->p_callback(p_lcb->remote_bd_addr, p_lcb->transport, in l2cu_release_lcb()
223 fixed_queue_free(p_lcb->le_sec_pending_q, NULL); in l2cu_release_lcb()
224 p_lcb->le_sec_pending_q = NULL; in l2cu_release_lcb()
241 tL2C_LCB* p_lcb = &l2cb.lcb_pool[0]; in l2cu_find_lcb_by_bd_addr() local
243 for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_lcb++) { in l2cu_find_lcb_by_bd_addr()
244 if ((p_lcb->in_use) && p_lcb->transport == transport && in l2cu_find_lcb_by_bd_addr()
245 (p_lcb->remote_bd_addr == p_bd_addr)) { in l2cu_find_lcb_by_bd_addr()
246 return (p_lcb); in l2cu_find_lcb_by_bd_addr()
267 bool l2c_is_cmd_rejected(uint8_t cmd_code, uint8_t signal_id, tL2C_LCB* p_lcb) { in l2c_is_cmd_rejected() argument
277 l2cu_send_peer_cmd_reject(p_lcb, L2CAP_CMD_REJ_MTU_EXCEEDED, signal_id, in l2c_is_cmd_rejected()
296 BT_HDR* l2cu_build_header(tL2C_LCB* p_lcb, uint16_t len, uint8_t cmd, in l2cu_build_header() argument
307 if (p_lcb->transport == BT_TRANSPORT_LE) { in l2cu_build_header()
308 UINT16_TO_STREAM(p, (p_lcb->Handle() | (L2CAP_PKT_START_NON_FLUSHABLE in l2cu_build_header()
311 UINT16_TO_STREAM(p, p_lcb->Handle() | l2cb.non_flushable_pbf); in l2cu_build_header()
317 if (p_lcb->transport == BT_TRANSPORT_LE) { in l2cu_build_header()
341 void l2cu_adj_id(tL2C_LCB* p_lcb) { in l2cu_adj_id() argument
342 if (p_lcb->signal_id == 0) { in l2cu_adj_id()
343 p_lcb->signal_id++; in l2cu_adj_id()
357 void l2cu_send_peer_cmd_reject(tL2C_LCB* p_lcb, uint16_t reason, uint8_t rem_id, in l2cu_send_peer_cmd_reject() argument
371 p_buf = l2cu_build_header(p_lcb, (uint16_t)(L2CAP_CMD_REJECT_LEN + param_len), in l2cu_send_peer_cmd_reject()
387 l2c_link_check_send_pkts(p_lcb, 0, p_buf); in l2cu_send_peer_cmd_reject()
405 p_ccb->p_lcb->signal_id++; in l2cu_send_peer_connect_req()
406 l2cu_adj_id(p_ccb->p_lcb); in l2cu_send_peer_connect_req()
408 p_ccb->local_id = p_ccb->p_lcb->signal_id; in l2cu_send_peer_connect_req()
410 p_buf = l2cu_build_header(p_ccb->p_lcb, L2CAP_CONN_REQ_LEN, in l2cu_send_peer_connect_req()
423 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf); in l2cu_send_peer_connect_req()
448 BT_HDR* p_buf = l2cu_build_header(p_ccb->p_lcb, L2CAP_CONN_RSP_LEN, in l2cu_send_peer_connect_rsp()
463 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf); in l2cu_send_peer_connect_rsp()
477 void l2cu_reject_connection(tL2C_LCB* p_lcb, uint16_t remote_cid, in l2cu_reject_connection() argument
483 l2cu_build_header(p_lcb, L2CAP_CONN_RSP_LEN, L2CAP_CMD_CONN_RSP, rem_id); in l2cu_reject_connection()
497 l2c_link_check_send_pkts(p_lcb, 0, p_buf); in l2cu_reject_connection()
515 tL2C_LCB* p_lcb = p_ccb->p_lcb; in l2cu_send_credit_based_reconfig_req() local
519 sizeof(uint16_t) * p_lcb->pending_ecoc_reconfig_cnt; in l2cu_send_credit_based_reconfig_req()
522 p_lcb->signal_id++; in l2cu_send_credit_based_reconfig_req()
523 l2cu_adj_id(p_lcb); in l2cu_send_credit_based_reconfig_req()
525 p_ccb->local_id = p_lcb->signal_id; in l2cu_send_credit_based_reconfig_req()
527 p_buf = l2cu_build_header(p_lcb, cmd_len, L2CAP_CMD_CREDIT_BASED_RECONFIG_REQ, in l2cu_send_credit_based_reconfig_req()
528 p_lcb->signal_id); in l2cu_send_credit_based_reconfig_req()
538 p_lcb->pending_ecoc_reconfig_cnt, p_cfg->mtu, p_cfg->mps); in l2cu_send_credit_based_reconfig_req()
543 for (p_ccb_temp = p_lcb->ccb_queue.p_first_ccb; p_ccb_temp; in l2cu_send_credit_based_reconfig_req()
550 l2c_link_check_send_pkts(p_lcb, 0, p_buf); in l2cu_send_credit_based_reconfig_req()
569 p_ccb->p_lcb->signal_id++; in l2cu_send_peer_config_req()
570 l2cu_adj_id(p_ccb->p_lcb); in l2cu_send_peer_config_req()
572 p_ccb->local_id = p_ccb->p_lcb->signal_id; in l2cu_send_peer_config_req()
587 p_buf = l2cu_build_header(p_ccb->p_lcb, in l2cu_send_peer_config_req()
651 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf); in l2cu_send_peer_config_req()
681 p_buf = l2cu_build_header(p_ccb->p_lcb, in l2cu_send_peer_config_rsp()
741 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf); in l2cu_send_peer_config_rsp()
780 UINT16_TO_STREAM(p, (p_ccb->p_lcb->Handle() | (L2CAP_PKT_START_NON_FLUSHABLE in l2cu_send_peer_config_rej()
784 UINT16_TO_STREAM(p, (p_ccb->p_lcb->Handle() | in l2cu_send_peer_config_rej()
858 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf); in l2cu_send_peer_config_rej()
875 if ((!p_ccb) || (p_ccb->p_lcb == NULL)) { in l2cu_send_peer_disc_req()
881 p_ccb->p_lcb->signal_id++; in l2cu_send_peer_disc_req()
882 l2cu_adj_id(p_ccb->p_lcb); in l2cu_send_peer_disc_req()
884 p_ccb->local_id = p_ccb->p_lcb->signal_id; in l2cu_send_peer_disc_req()
886 p_buf = l2cu_build_header(p_ccb->p_lcb, L2CAP_DISC_REQ_LEN, in l2cu_send_peer_disc_req()
906 l2c_link_check_send_pkts(p_ccb->p_lcb, p_ccb->local_cid, p_buf2); in l2cu_send_peer_disc_req()
910 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf); in l2cu_send_peer_disc_req()
927 void l2cu_send_peer_disc_rsp(tL2C_LCB* p_lcb, uint8_t remote_id, in l2cu_send_peer_disc_rsp() argument
932 p_buf = l2cu_build_header(p_lcb, L2CAP_DISC_RSP_LEN, L2CAP_CMD_DISC_RSP, in l2cu_send_peer_disc_rsp()
945 l2c_link_check_send_pkts(p_lcb, 0, p_buf); in l2cu_send_peer_disc_rsp()
958 void l2cu_send_peer_echo_rsp(tL2C_LCB* p_lcb, uint8_t signal_id, in l2cu_send_peer_echo_rsp() argument
965 if (!signal_id || signal_id == p_lcb->cur_echo_id) { in l2cu_send_peer_echo_rsp()
971 p_lcb->cur_echo_id = signal_id; in l2cu_send_peer_echo_rsp()
987 p_buf = l2cu_build_header(p_lcb, (uint16_t)(L2CAP_ECHO_RSP_LEN + data_len), in l2cu_send_peer_echo_rsp()
1001 l2c_link_check_send_pkts(p_lcb, 0, p_buf); in l2cu_send_peer_echo_rsp()
1013 void l2cu_send_peer_info_req(tL2C_LCB* p_lcb, uint16_t info_type) { in l2cu_send_peer_info_req() argument
1018 p_lcb->signal_id++; in l2cu_send_peer_info_req()
1019 l2cu_adj_id(p_lcb); in l2cu_send_peer_info_req()
1021 p_buf = l2cu_build_header(p_lcb, 2, L2CAP_CMD_INFO_REQ, p_lcb->signal_id); in l2cu_send_peer_info_req()
1034 p_lcb->w4_info_rsp = true; in l2cu_send_peer_info_req()
1035 alarm_set_on_mloop(p_lcb->info_resp_timer, L2CAP_WAIT_INFO_RSP_TIMEOUT_MS, in l2cu_send_peer_info_req()
1036 l2c_info_resp_timer_timeout, p_lcb); in l2cu_send_peer_info_req()
1038 l2c_link_check_send_pkts(p_lcb, 0, p_buf); in l2cu_send_peer_info_req()
1051 void l2cu_send_peer_info_rsp(tL2C_LCB* p_lcb, uint8_t remote_id, in l2cu_send_peer_info_rsp() argument
1079 p_buf = l2cu_build_header(p_lcb, len, L2CAP_CMD_INFO_RSP, remote_id); in l2cu_send_peer_info_rsp()
1103 if (p_lcb->transport == BT_TRANSPORT_LE) { in l2cu_send_peer_info_rsp()
1145 l2c_link_check_send_pkts(p_lcb, 0, p_buf); in l2cu_send_peer_info_rsp()
1164 if (p_ccb->p_lcb != NULL) p_q = &p_ccb->p_lcb->ccb_queue; in l2cu_enqueue_ccb()
1168 p_ccb->local_cid, p_ccb->in_use, p_ccb->p_lcb); in l2cu_enqueue_ccb()
1213 if (p_ccb->p_lcb != NULL) { in l2cu_enqueue_ccb()
1215 if (p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb == 0) { in l2cu_enqueue_ccb()
1217 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb = p_ccb; in l2cu_enqueue_ccb()
1219 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb = p_ccb; in l2cu_enqueue_ccb()
1221 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].quota = in l2cu_enqueue_ccb()
1225 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb++; in l2cu_enqueue_ccb()
1245 if (p_ccb->p_lcb != NULL) p_q = &p_ccb->p_lcb->ccb_queue; in l2cu_dequeue_ccb()
1251 p_ccb->local_cid, p_ccb->in_use, p_ccb->p_lcb, p_q, in l2cu_dequeue_ccb()
1257 if (p_ccb->p_lcb != NULL) { in l2cu_dequeue_ccb()
1259 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb--; in l2cu_dequeue_ccb()
1262 if (p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb == 0) { in l2cu_dequeue_ccb()
1263 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb = NULL; in l2cu_dequeue_ccb()
1264 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb = NULL; in l2cu_dequeue_ccb()
1267 if (p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb == p_ccb) { in l2cu_dequeue_ccb()
1268 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb = in l2cu_dequeue_ccb()
1272 if (p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb == p_ccb) { in l2cu_dequeue_ccb()
1274 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb = in l2cu_dequeue_ccb()
1275 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb; in l2cu_dequeue_ccb()
1325 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb = 0; in l2cu_change_pri_ccb()
1326 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb = NULL; in l2cu_change_pri_ccb()
1327 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb = NULL; in l2cu_change_pri_ccb()
1331 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_first_ccb = p_ccb; in l2cu_change_pri_ccb()
1332 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].p_serve_ccb = p_ccb; in l2cu_change_pri_ccb()
1333 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].quota = in l2cu_change_pri_ccb()
1335 p_ccb->p_lcb->rr_serv[p_ccb->ccb_priority].num_ccb = 1; in l2cu_change_pri_ccb()
1351 tL2C_CCB* l2cu_allocate_ccb(tL2C_LCB* p_lcb, uint16_t cid) { in l2cu_allocate_ccb() argument
1396 p_ccb->p_lcb = p_lcb; in l2cu_allocate_ccb()
1402 if (p_lcb) l2cu_enqueue_ccb(p_ccb); in l2cu_allocate_ccb()
1490 tL2C_LCB* p_lcb = l2cu_find_lcb_by_handle(handle); in l2cu_start_post_bond_timer() local
1492 if (!p_lcb) return (true); in l2cu_start_post_bond_timer()
1494 p_lcb->ResetBonding(); in l2cu_start_post_bond_timer()
1497 if (p_lcb->ccb_queue.p_first_ccb != NULL) return (false); in l2cu_start_post_bond_timer()
1500 if ((p_lcb->link_state == LST_CONNECTED) || in l2cu_start_post_bond_timer()
1501 (p_lcb->link_state == LST_CONNECTING) || in l2cu_start_post_bond_timer()
1502 (p_lcb->link_state == LST_DISCONNECTING)) { in l2cu_start_post_bond_timer()
1505 if (p_lcb->idle_timeout == 0) { in l2cu_start_post_bond_timer()
1506 acl_disconnect_from_handle(p_lcb->Handle(), HCI_ERR_PEER_USER); in l2cu_start_post_bond_timer()
1507 p_lcb->link_state = LST_DISCONNECTING; in l2cu_start_post_bond_timer()
1510 alarm_set_on_mloop(p_lcb->l2c_lcb_timer, timeout_ms, l2c_lcb_timer_timeout, in l2cu_start_post_bond_timer()
1511 p_lcb); in l2cu_start_post_bond_timer()
1530 tL2C_LCB* p_lcb = p_ccb->p_lcb; in l2cu_release_ccb() local
1540 p_lcb->Handle(), p_ccb->local_cid, p_ccb->remote_cid); in l2cu_release_ccb()
1556 if ((p_lcb) && ((p_ccb->local_cid >= L2CAP_BASE_APPL_CID))) { in l2cu_release_ccb()
1560 p_ccb->p_lcb = NULL; in l2cu_release_ccb()
1580 if ((p_lcb) && p_lcb->in_use) { in l2cu_release_ccb()
1581 if (p_lcb->link_state == LST_CONNECTED) { in l2cu_release_ccb()
1582 if (!p_lcb->ccb_queue.p_first_ccb) { in l2cu_release_ccb()
1585 if (p_lcb->transport == BT_TRANSPORT_LE && in l2cu_release_ccb()
1589 l2cu_no_dynamic_ccbs(p_lcb); in l2cu_release_ccb()
1594 } else if (p_lcb->link_state == LST_CONNECTING) { in l2cu_release_ccb()
1595 if (!p_lcb->ccb_queue.p_first_ccb) { in l2cu_release_ccb()
1596 if (p_lcb->transport == BT_TRANSPORT_LE && in l2cu_release_ccb()
1599 l2cu_no_dynamic_ccbs(p_lcb); in l2cu_release_ccb()
1616 tL2C_CCB* l2cu_find_ccb_by_remote_cid(tL2C_LCB* p_lcb, uint16_t remote_cid) { in l2cu_find_ccb_by_remote_cid() argument
1620 if (!p_lcb) { in l2cu_find_ccb_by_remote_cid()
1623 for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_ccb->p_next_ccb) in l2cu_find_ccb_by_remote_cid()
1983 if ((p_ccb->p_lcb->peer_ext_fea & L2CAP_EXTFEA_NO_CRC) == 0) { in l2cu_process_our_cfg_req()
2032 tL2C_LCB* p_lcb = &l2cb.lcb_pool[0]; in l2cu_device_reset() local
2034 for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_lcb++) { in l2cu_device_reset()
2035 if ((p_lcb->in_use) && (p_lcb->Handle() != HCI_INVALID_HANDLE)) { in l2cu_device_reset()
2036 l2c_link_hci_disc_comp(p_lcb->Handle(), HCI_ERR_UNDEFINED); in l2cu_device_reset()
2043 bool l2cu_create_conn_le(tL2C_LCB* p_lcb) { in l2cu_create_conn_le() argument
2045 p_lcb->transport = BT_TRANSPORT_LE; in l2cu_create_conn_le()
2046 return (l2cble_create_conn(p_lcb)); in l2cu_create_conn_le()
2050 void l2cu_create_conn_br_edr(tL2C_LCB* p_lcb) { in l2cu_create_conn_br_edr() argument
2061 if (p_lcb_cur == p_lcb) continue; in l2cu_create_conn_br_edr()
2068 if (p_lcb->IsLinkRoleCentral()) continue; in l2cu_create_conn_br_edr()
2077 p_lcb->link_state = LST_CONNECTING_WAIT_SWITCH; in l2cu_create_conn_br_edr()
2078 p_lcb->SetLinkRoleAsCentral(); in l2cu_create_conn_br_edr()
2082 alarm_set_on_mloop(p_lcb->l2c_lcb_timer, in l2cu_create_conn_br_edr()
2084 l2c_lcb_timer_timeout, p_lcb); in l2cu_create_conn_br_edr()
2089 p_lcb->link_state = LST_CONNECTING; in l2cu_create_conn_br_edr()
2090 l2cu_create_conn_after_switch(p_lcb); in l2cu_create_conn_br_edr()
2105 tL2C_LCB* p_lcb = &l2cb.lcb_pool[0]; in l2cu_get_num_hi_priority() local
2107 for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_lcb++) { in l2cu_get_num_hi_priority()
2108 if ((p_lcb->in_use) && (p_lcb->acl_priority == L2CAP_PRIORITY_HIGH)) { in l2cu_get_num_hi_priority()
2123 void l2cu_create_conn_after_switch(tL2C_LCB* p_lcb) { in l2cu_create_conn_after_switch() argument
2127 acl_create_classic_connection(p_lcb->remote_bd_addr, in l2cu_create_conn_after_switch()
2129 p_lcb->IsBonding()); in l2cu_create_conn_after_switch()
2131 alarm_set_on_mloop(p_lcb->l2c_lcb_timer, L2CAP_LINK_CONNECT_TIMEOUT_MS, in l2cu_create_conn_after_switch()
2132 l2c_lcb_timer_timeout, p_lcb); in l2cu_create_conn_after_switch()
2147 tL2C_LCB* p_lcb = &l2cb.lcb_pool[0]; in l2cu_find_lcb_by_state() local
2149 for (i = 0; i < MAX_L2CAP_LINKS; i++, p_lcb++) { in l2cu_find_lcb_by_state()
2150 if ((p_lcb->in_use) && (p_lcb->link_state == state)) { in l2cu_find_lcb_by_state()
2151 return (p_lcb); in l2cu_find_lcb_by_state()
2172 tL2C_LCB* p_lcb; in l2cu_lcb_disconnecting() local
2177 p_lcb = &l2cb.lcb_pool[0]; in l2cu_lcb_disconnecting()
2179 for (i = 0; i < MAX_L2CAP_LINKS; i++, p_lcb++) { in l2cu_lcb_disconnecting()
2180 if (p_lcb->in_use) { in l2cu_lcb_disconnecting()
2182 if ((!p_lcb->ccb_queue.p_first_ccb) || in l2cu_lcb_disconnecting()
2183 (p_lcb->link_state == LST_DISCONNECTING)) { in l2cu_lcb_disconnecting()
2188 else if (p_lcb->ccb_queue.p_first_ccb == p_lcb->ccb_queue.p_last_ccb) { in l2cu_lcb_disconnecting()
2189 p_ccb = p_lcb->ccb_queue.p_first_ccb; in l2cu_lcb_disconnecting()
2217 tL2C_LCB* p_lcb; in l2cu_set_acl_priority() local
2225 p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, BT_TRANSPORT_BR_EDR); in l2cu_set_acl_priority()
2226 if (p_lcb == NULL) { in l2cu_set_acl_priority()
2234 if ((!reset_after_rs && (priority != p_lcb->acl_priority)) || in l2cu_set_acl_priority()
2237 (reset_after_rs && p_lcb->acl_priority == L2CAP_PRIORITY_HIGH)) { in l2cu_set_acl_priority()
2243 UINT16_TO_STREAM(pp, p_lcb->Handle()); in l2cu_set_acl_priority()
2253 if (p_lcb->acl_priority != priority) { in l2cu_set_acl_priority()
2254 p_lcb->acl_priority = priority; in l2cu_set_acl_priority()
2297 tL2C_LCB* p_lcb; in l2cu_resubmit_pending_sec_req() local
2306 p_lcb = l2cu_find_lcb_by_bd_addr(*p_bda, BT_TRANSPORT_BR_EDR); in l2cu_resubmit_pending_sec_req()
2309 if (p_lcb) { in l2cu_resubmit_pending_sec_req()
2311 for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_next_ccb) { in l2cu_resubmit_pending_sec_req()
2320 for (xx = 0, p_lcb = &l2cb.lcb_pool[0]; xx < MAX_L2CAP_LINKS; in l2cu_resubmit_pending_sec_req()
2321 xx++, p_lcb++) { in l2cu_resubmit_pending_sec_req()
2322 if (p_lcb->in_use) { in l2cu_resubmit_pending_sec_req()
2324 for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_next_ccb) { in l2cu_resubmit_pending_sec_req()
2360 packet_size = BTM_GetMaxPacketSize(p_ccb->p_lcb->remote_bd_addr); in l2cu_adjust_out_mps()
2405 bool l2cu_initialize_fixed_ccb(tL2C_LCB* p_lcb, uint16_t fixed_cid) { in l2cu_initialize_fixed_ccb() argument
2409 p_ccb = p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]; in l2cu_initialize_fixed_ccb()
2421 alarm_cancel(p_lcb->l2c_lcb_timer); in l2cu_initialize_fixed_ccb()
2430 p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL] = p_ccb; in l2cu_initialize_fixed_ccb()
2431 p_ccb->p_lcb = p_lcb; in l2cu_initialize_fixed_ccb()
2434 if (p_lcb->link_state == LST_CONNECTED) p_ccb->chnl_state = CST_OPEN; in l2cu_initialize_fixed_ccb()
2454 void l2cu_no_dynamic_ccbs(tL2C_LCB* p_lcb) { in l2cu_no_dynamic_ccbs() argument
2456 uint64_t timeout_ms = p_lcb->idle_timeout * 1000; in l2cu_no_dynamic_ccbs()
2462 if ((p_lcb->p_fixed_ccbs[xx] != NULL) && in l2cu_no_dynamic_ccbs()
2463 (p_lcb->p_fixed_ccbs[xx]->fixed_chnl_idle_tout * 1000 > timeout_ms)) { in l2cu_no_dynamic_ccbs()
2465 if (p_lcb->p_fixed_ccbs[xx]->fixed_chnl_idle_tout == L2CAP_NO_IDLE_TIMEOUT) { in l2cu_no_dynamic_ccbs()
2467 p_lcb->p_fixed_ccbs[xx]->local_cid); in l2cu_no_dynamic_ccbs()
2470 timeout_ms = p_lcb->p_fixed_ccbs[xx]->fixed_chnl_idle_tout * 1000; in l2cu_no_dynamic_ccbs()
2475 if (p_lcb->IsBonding()) return; in l2cu_no_dynamic_ccbs()
2481 rc = btm_sec_disconnect(p_lcb->Handle(), HCI_ERR_PEER_USER); in l2cu_no_dynamic_ccbs()
2483 l2cu_process_fixed_disc_cback(p_lcb); in l2cu_no_dynamic_ccbs()
2484 p_lcb->link_state = LST_DISCONNECTING; in l2cu_no_dynamic_ccbs()
2487 l2cu_process_fixed_disc_cback(p_lcb); in l2cu_no_dynamic_ccbs()
2490 p_lcb->link_state = LST_DISCONNECTING; in l2cu_no_dynamic_ccbs()
2492 } else if (p_lcb->IsBonding()) { in l2cu_no_dynamic_ccbs()
2493 acl_disconnect_from_handle(p_lcb->Handle(), HCI_ERR_PEER_USER); in l2cu_no_dynamic_ccbs()
2494 l2cu_process_fixed_disc_cback(p_lcb); in l2cu_no_dynamic_ccbs()
2495 p_lcb->link_state = LST_DISCONNECTING; in l2cu_no_dynamic_ccbs()
2505 alarm_set_on_mloop(p_lcb->l2c_lcb_timer, timeout_ms, l2c_lcb_timer_timeout, in l2cu_no_dynamic_ccbs()
2506 p_lcb); in l2cu_no_dynamic_ccbs()
2508 alarm_cancel(p_lcb->l2c_lcb_timer); in l2cu_no_dynamic_ccbs()
2521 void l2cu_process_fixed_chnl_resp(tL2C_LCB* p_lcb) { in l2cu_process_fixed_chnl_resp() argument
2522 if (p_lcb->transport == BT_TRANSPORT_BR_EDR) { in l2cu_process_fixed_chnl_resp()
2524 p_lcb->peer_chnl_mask[0] &= in l2cu_process_fixed_chnl_resp()
2528 p_lcb->peer_chnl_mask[0] = l2cb.l2c_ble_fixed_chnls_mask; in l2cu_process_fixed_chnl_resp()
2537 if (p_lcb->transport == BT_TRANSPORT_BR_EDR && in l2cu_process_fixed_chnl_resp()
2542 if (p_lcb->transport == BT_TRANSPORT_LE && channel_id == L2CAP_SMP_BR_CID) in l2cu_process_fixed_chnl_resp()
2547 if (p_lcb->peer_chnl_mask[(channel_id) / 8] & (1 << ((channel_id) % 8))) { in l2cu_process_fixed_chnl_resp()
2548 if (p_lcb->p_fixed_ccbs[xx]) in l2cu_process_fixed_chnl_resp()
2549 p_lcb->p_fixed_ccbs[xx]->chnl_state = CST_OPEN; in l2cu_process_fixed_chnl_resp()
2551 channel_id, p_lcb->remote_bd_addr, true, 0, p_lcb->transport); in l2cu_process_fixed_chnl_resp()
2554 channel_id, p_lcb->remote_bd_addr, false, p_lcb->DisconnectReason(), in l2cu_process_fixed_chnl_resp()
2555 p_lcb->transport); in l2cu_process_fixed_chnl_resp()
2557 if (p_lcb->p_fixed_ccbs[xx]) { in l2cu_process_fixed_chnl_resp()
2558 l2cu_release_ccb(p_lcb->p_fixed_ccbs[xx]); in l2cu_process_fixed_chnl_resp()
2559 p_lcb->p_fixed_ccbs[xx] = NULL; in l2cu_process_fixed_chnl_resp()
2575 void l2cu_process_fixed_disc_cback(tL2C_LCB* p_lcb) { in l2cu_process_fixed_disc_cback() argument
2578 uint8_t peer_channel_mask = p_lcb->peer_chnl_mask[0]; in l2cu_process_fixed_disc_cback()
2581 if (p_lcb->transport == BT_TRANSPORT_LE) p_lcb->peer_chnl_mask[0] = 0; in l2cu_process_fixed_disc_cback()
2584 if (p_lcb->p_fixed_ccbs[xx]) { in l2cu_process_fixed_disc_cback()
2585 if (p_lcb->p_fixed_ccbs[xx] != p_lcb->p_pending_ccb) { in l2cu_process_fixed_disc_cback()
2587 p_l2c_chnl_ctrl_block = p_lcb->p_fixed_ccbs[xx]; in l2cu_process_fixed_disc_cback()
2588 p_lcb->p_fixed_ccbs[xx] = NULL; in l2cu_process_fixed_disc_cback()
2591 xx + L2CAP_FIRST_FIXED_CHNL, p_lcb->remote_bd_addr, false, in l2cu_process_fixed_disc_cback()
2592 p_lcb->DisconnectReason(), p_lcb->transport); in l2cu_process_fixed_disc_cback()
2597 xx + L2CAP_FIRST_FIXED_CHNL, p_lcb->remote_bd_addr, false, in l2cu_process_fixed_disc_cback()
2598 p_lcb->DisconnectReason(), p_lcb->transport); in l2cu_process_fixed_disc_cback()
2612 void l2cu_send_peer_ble_par_req(tL2C_LCB* p_lcb, uint16_t min_int, in l2cu_send_peer_ble_par_req() argument
2619 p_lcb->signal_id++; in l2cu_send_peer_ble_par_req()
2620 l2cu_adj_id(p_lcb); in l2cu_send_peer_ble_par_req()
2622 p_buf = l2cu_build_header(p_lcb, L2CAP_CMD_BLE_UPD_REQ_LEN, in l2cu_send_peer_ble_par_req()
2623 L2CAP_CMD_BLE_UPDATE_REQ, p_lcb->signal_id); in l2cu_send_peer_ble_par_req()
2637 l2c_link_check_send_pkts(p_lcb, 0, p_buf); in l2cu_send_peer_ble_par_req()
2650 void l2cu_send_peer_ble_par_rsp(tL2C_LCB* p_lcb, uint16_t reason, in l2cu_send_peer_ble_par_rsp() argument
2655 p_buf = l2cu_build_header(p_lcb, L2CAP_CMD_BLE_UPD_RSP_LEN, in l2cu_send_peer_ble_par_rsp()
2667 l2c_link_check_send_pkts(p_lcb, 0, p_buf); in l2cu_send_peer_ble_par_rsp()
2683 tL2C_LCB* p_lcb = NULL; in l2cu_send_peer_ble_credit_based_conn_req() local
2689 p_lcb = p_ccb->p_lcb; in l2cu_send_peer_ble_credit_based_conn_req()
2692 p_ccb->p_lcb->signal_id++; in l2cu_send_peer_ble_credit_based_conn_req()
2693 l2cu_adj_id(p_ccb->p_lcb); in l2cu_send_peer_ble_credit_based_conn_req()
2695 p_ccb->local_id = p_ccb->p_lcb->signal_id; in l2cu_send_peer_ble_credit_based_conn_req()
2698 l2cu_build_header(p_lcb, L2CAP_CMD_BLE_CREDIT_BASED_CONN_REQ_LEN, in l2cu_send_peer_ble_credit_based_conn_req()
2699 L2CAP_CMD_BLE_CREDIT_BASED_CONN_REQ, p_lcb->signal_id); in l2cu_send_peer_ble_credit_based_conn_req()
2723 l2c_link_check_send_pkts(p_lcb, 0, p_buf); in l2cu_send_peer_ble_credit_based_conn_req()
2739 tL2C_LCB* p_lcb = NULL; in l2cu_send_peer_credit_based_conn_req() local
2746 p_lcb = p_ccb->p_lcb; in l2cu_send_peer_credit_based_conn_req()
2749 p_ccb->p_lcb->signal_id++; in l2cu_send_peer_credit_based_conn_req()
2750 l2cu_adj_id(p_ccb->p_lcb); in l2cu_send_peer_credit_based_conn_req()
2752 p_ccb->local_id = p_lcb->signal_id; in l2cu_send_peer_credit_based_conn_req()
2754 p_buf = l2cu_build_header(p_lcb, in l2cu_send_peer_credit_based_conn_req()
2756 2 * p_lcb->pending_ecoc_conn_cnt, in l2cu_send_peer_credit_based_conn_req()
2773 p_lcb->pending_ecoc_conn_cnt); in l2cu_send_peer_credit_based_conn_req()
2780 for (int i = 0; i < p_lcb->pending_ecoc_conn_cnt; i++) { in l2cu_send_peer_credit_based_conn_req()
2781 uint16_t cid = p_lcb->pending_ecoc_connection_cids[i]; in l2cu_send_peer_credit_based_conn_req()
2786 l2c_link_check_send_pkts(p_lcb, 0, p_buf); in l2cu_send_peer_credit_based_conn_req()
2800 void l2cu_reject_ble_coc_connection(tL2C_LCB* p_lcb, uint8_t rem_id, in l2cu_reject_ble_coc_connection() argument
2805 p_buf = l2cu_build_header(p_lcb, L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES_LEN, in l2cu_reject_ble_coc_connection()
2821 l2c_link_check_send_pkts(p_lcb, 0, p_buf); in l2cu_reject_ble_coc_connection()
2834 void l2cu_reject_credit_based_conn_req(tL2C_LCB* p_lcb, uint8_t rem_id, in l2cu_reject_credit_based_conn_req() argument
2842 p_buf = l2cu_build_header(p_lcb, rsp_len, L2CAP_CMD_CREDIT_BASED_CONN_RES, in l2cu_reject_credit_based_conn_req()
2858 l2c_link_check_send_pkts(p_lcb, 0, p_buf); in l2cu_reject_credit_based_conn_req()
2880 p_ccb->p_lcb->pending_ecoc_conn_cnt * sizeof(uint16_t); in l2cu_send_peer_credit_based_conn_res()
2882 p_buf = l2cu_build_header(p_ccb->p_lcb, rsp_len, in l2cu_send_peer_credit_based_conn_res()
2903 result = p_ccb->p_lcb->pending_l2cap_result; in l2cu_send_peer_credit_based_conn_res()
2913 for (int i = 0; i < p_ccb->p_lcb->pending_ecoc_conn_cnt; i++) { in l2cu_send_peer_credit_based_conn_res()
2914 uint16_t cid = p_ccb->p_lcb->pending_ecoc_connection_cids[i]; in l2cu_send_peer_credit_based_conn_res()
2927 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf); in l2cu_send_peer_credit_based_conn_res()
2945 p_ccb->p_lcb, rem_id, p_ccb->p_lcb->pending_ecoc_reconfig_cnt, result); in l2cu_reject_ble_connection()
2947 l2cu_reject_ble_coc_connection(p_ccb->p_lcb, rem_id, result); in l2cu_reject_ble_connection()
2962 void l2cu_send_ble_reconfig_rsp(tL2C_LCB* p_lcb, uint8_t rem_id, in l2cu_send_ble_reconfig_rsp() argument
2969 p_buf = l2cu_build_header(p_lcb, L2CAP_CMD_CREDIT_BASED_RECONFIG_RES_LEN, in l2cu_send_ble_reconfig_rsp()
2982 l2c_link_check_send_pkts(p_lcb, 0, p_buf); in l2cu_send_ble_reconfig_rsp()
3003 l2cu_build_header(p_ccb->p_lcb, L2CAP_CMD_BLE_CREDIT_BASED_CONN_RES_LEN, in l2cu_send_peer_ble_credit_based_conn_res()
3019 l2c_link_check_send_pkts(p_ccb->p_lcb, 0, p_buf); in l2cu_send_peer_ble_credit_based_conn_res()
3036 tL2C_LCB* p_lcb = NULL; in l2cu_send_peer_ble_flow_control_credit() local
3039 p_lcb = p_ccb->p_lcb; in l2cu_send_peer_ble_flow_control_credit()
3042 p_ccb->p_lcb->signal_id++; in l2cu_send_peer_ble_flow_control_credit()
3043 l2cu_adj_id(p_ccb->p_lcb); in l2cu_send_peer_ble_flow_control_credit()
3045 p_ccb->local_id = p_ccb->p_lcb->signal_id; in l2cu_send_peer_ble_flow_control_credit()
3047 p_buf = l2cu_build_header(p_lcb, L2CAP_CMD_BLE_FLOW_CTRL_CREDIT_LEN, in l2cu_send_peer_ble_flow_control_credit()
3048 L2CAP_CMD_BLE_FLOW_CTRL_CREDIT, p_lcb->signal_id); in l2cu_send_peer_ble_flow_control_credit()
3060 l2c_link_check_send_pkts(p_lcb, 0, p_buf); in l2cu_send_peer_ble_flow_control_credit()
3076 tL2C_LCB* p_lcb = NULL; in l2cu_send_peer_ble_credit_based_disconn_req() local
3080 p_lcb = p_ccb->p_lcb; in l2cu_send_peer_ble_credit_based_disconn_req()
3083 p_ccb->p_lcb->signal_id++; in l2cu_send_peer_ble_credit_based_disconn_req()
3084 l2cu_adj_id(p_ccb->p_lcb); in l2cu_send_peer_ble_credit_based_disconn_req()
3086 p_ccb->local_id = p_ccb->p_lcb->signal_id; in l2cu_send_peer_ble_credit_based_disconn_req()
3087 p_buf = l2cu_build_header(p_lcb, L2CAP_DISC_REQ_LEN, L2CAP_CMD_DISC_REQ, in l2cu_send_peer_ble_credit_based_disconn_req()
3088 p_lcb->signal_id); in l2cu_send_peer_ble_credit_based_disconn_req()
3101 l2c_link_check_send_pkts(p_lcb, 0, p_buf); in l2cu_send_peer_ble_credit_based_disconn_req()
3120 tL2C_LCB* p_lcb = &l2cb.lcb_pool[0]; in l2cu_find_lcb_by_handle() local
3122 for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_lcb++) { in l2cu_find_lcb_by_handle()
3123 if ((p_lcb->in_use) && (p_lcb->Handle() == handle)) { in l2cu_find_lcb_by_handle()
3124 return (p_lcb); in l2cu_find_lcb_by_handle()
3143 tL2C_CCB* l2cu_find_ccb_by_cid(tL2C_LCB* p_lcb, uint16_t local_cid) { in l2cu_find_ccb_by_cid() argument
3158 else if (p_lcb && p_lcb != p_ccb->p_lcb) { in l2cu_find_ccb_by_cid()
3181 if (p_ccb->p_lcb->transport == BT_TRANSPORT_LE) { in l2cu_set_acl_hci_header()
3182 UINT16_TO_STREAM(p, p_ccb->p_lcb->Handle() | (L2CAP_PKT_START_NON_FLUSHABLE in l2cu_set_acl_hci_header()
3197 UINT16_TO_STREAM(p, p_ccb->p_lcb->Handle() | in l2cu_set_acl_hci_header()
3200 UINT16_TO_STREAM(p, p_ccb->p_lcb->Handle() | l2cb.non_flushable_pbf); in l2cu_set_acl_hci_header()
3236 if (p_ccb->p_lcb->p_fixed_ccbs[xx] == p_ccb) { in send_congestion_status_to_all_clients()
3238 (*l2cb.fixed_reg[xx].pL2CA_FixedCong_Cb)(p_ccb->p_lcb->remote_bd_addr, in send_congestion_status_to_all_clients()