Lines Matching refs:p_ccb
98 static void gap_release_ccb(tGAP_CCB* p_ccb);
99 static void gap_checks_con_flags(tGAP_CCB* p_ccb);
165 tGAP_CCB* p_ccb; in GAP_ConnOpen() local
171 p_ccb = gap_allocate_ccb(); in GAP_ConnOpen()
172 if (p_ccb == NULL) return (GAP_INVALID_HANDLE); in GAP_ConnOpen()
175 p_ccb->transport = transport; in GAP_ConnOpen()
178 p_ccb->service_id = service_id; in GAP_ConnOpen()
183 if (*p_rem_bda != RawAddress::kAny) p_ccb->rem_addr_specified = true; in GAP_ConnOpen()
185 p_ccb->rem_dev_address = *p_rem_bda; in GAP_ConnOpen()
188 gap_release_ccb(p_ccb); in GAP_ConnOpen()
193 if (!p_ccb->rem_addr_specified && !is_server) { in GAP_ConnOpen()
194 gap_release_ccb(p_ccb); in GAP_ConnOpen()
201 if (p_cfg) p_ccb->cfg = *p_cfg; in GAP_ConnOpen()
205 p_ccb->local_coc_cfg.credits = L2CAP_LE_CREDIT_DEFAULT; in GAP_ConnOpen()
206 p_ccb->local_coc_cfg.mtu = p_cfg->mtu; in GAP_ConnOpen()
213 p_ccb->local_coc_cfg.mps = le_mps; in GAP_ConnOpen()
215 VLOG(2) << __func__ << ": credits=" << p_ccb->local_coc_cfg.credits in GAP_ConnOpen()
216 << ", mps=" << p_ccb->local_coc_cfg.mps in GAP_ConnOpen()
217 << ", mtu=" << p_ccb->local_coc_cfg.mtu; in GAP_ConnOpen()
220 p_ccb->p_callback = p_cb; in GAP_ConnOpen()
229 if (p_ccb->cfg.fcr_present) { in GAP_ConnOpen()
231 p_ccb->ertm_info.preferred_mode = p_ccb->cfg.fcr.mode; in GAP_ConnOpen()
233 p_ccb->ertm_info = *ertm_info; in GAP_ConnOpen()
239 p_ccb->psm = in GAP_ConnOpen()
241 &p_ccb->ertm_info, L2CAP_SDU_LENGTH_MAX, 0, security); in GAP_ConnOpen()
242 if (p_ccb->psm == 0) { in GAP_ConnOpen()
245 gap_release_ccb(p_ccb); in GAP_ConnOpen()
251 p_ccb->psm = in GAP_ConnOpen()
252 L2CA_RegisterLECoc(psm, conn.reg_info, security, p_ccb->local_coc_cfg); in GAP_ConnOpen()
253 if (p_ccb->psm == 0) { in GAP_ConnOpen()
256 gap_release_ccb(p_ccb); in GAP_ConnOpen()
262 p_ccb->con_flags |= in GAP_ConnOpen()
264 p_ccb->con_state = GAP_CCB_STATE_LISTENING; in GAP_ConnOpen()
265 return (p_ccb->gap_handle); in GAP_ConnOpen()
268 p_ccb->con_flags = GAP_CCB_FLAGS_IS_ORIG; in GAP_ConnOpen()
272 p_ccb->con_state = GAP_CCB_STATE_CONN_SETUP; in GAP_ConnOpen()
276 p_ccb->con_flags |= GAP_CCB_FLAGS_SEC_DONE; in GAP_ConnOpen()
280 cid = L2CA_ConnectReq2(p_ccb->psm, *p_rem_bda, security); in GAP_ConnOpen()
282 p_ccb->connection_id = cid; in GAP_ConnOpen()
283 return (p_ccb->gap_handle); in GAP_ConnOpen()
288 cid = L2CA_ConnectLECocReq(p_ccb->psm, *p_rem_bda, &p_ccb->local_coc_cfg, in GAP_ConnOpen()
291 p_ccb->connection_id = cid; in GAP_ConnOpen()
292 return (p_ccb->gap_handle); in GAP_ConnOpen()
296 gap_release_ccb(p_ccb); in GAP_ConnOpen()
314 tGAP_CCB* p_ccb = gap_find_ccb_by_handle(gap_handle); in GAP_ConnClose() local
318 if (p_ccb) { in GAP_ConnClose()
320 if (p_ccb->con_state != GAP_CCB_STATE_LISTENING) { in GAP_ConnClose()
321 if (p_ccb->transport == BT_TRANSPORT_LE) { in GAP_ConnClose()
322 L2CA_DisconnectLECocReq(p_ccb->connection_id); in GAP_ConnClose()
324 L2CA_DisconnectReq(p_ccb->connection_id); in GAP_ConnClose()
328 gap_release_ccb(p_ccb); in GAP_ConnClose()
355 tGAP_CCB* p_ccb = gap_find_ccb_by_handle(gap_handle); in GAP_ConnReadData() local
358 if (!p_ccb) return (GAP_ERR_BAD_HANDLE); in GAP_ConnReadData()
362 if (fixed_queue_is_empty(p_ccb->rx_queue)) return (GAP_NO_DATA_AVAIL); in GAP_ConnReadData()
368 static_cast<BT_HDR*>(fixed_queue_try_peek_first(p_ccb->rx_queue)); in GAP_ConnReadData()
384 osi_free(fixed_queue_try_dequeue(p_ccb->rx_queue)); in GAP_ConnReadData()
387 p_ccb->rx_queue_size -= *p_len; in GAP_ConnReadData()
393 p_ccb->rx_queue_size, *p_len); in GAP_ConnReadData()
410 tGAP_CCB* p_ccb; in GAP_GetRxQueueCnt() local
415 p_ccb = &conn.ccb_pool[handle]; in GAP_GetRxQueueCnt()
417 if (p_ccb->con_state == GAP_CCB_STATE_CONNECTED) { in GAP_GetRxQueueCnt()
418 *p_rx_queue_count = p_ccb->rx_queue_size; in GAP_GetRxQueueCnt()
432 static bool gap_try_write_queued_data(tGAP_CCB* p_ccb) { in gap_try_write_queued_data() argument
433 if (p_ccb->is_congested) return true; in gap_try_write_queued_data()
437 while ((p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_ccb->tx_queue)) != NULL) { in gap_try_write_queued_data()
439 if (p_ccb->transport == BT_TRANSPORT_LE) { in gap_try_write_queued_data()
440 status = L2CA_LECocDataWrite(p_ccb->connection_id, p_buf); in gap_try_write_queued_data()
442 status = L2CA_DataWrite(p_ccb->connection_id, p_buf); in gap_try_write_queued_data()
446 p_ccb->is_congested = true; in gap_try_write_queued_data()
472 tGAP_CCB* p_ccb = gap_find_ccb_by_handle(gap_handle); in GAP_ConnWriteData() local
474 if (!p_ccb) { in GAP_ConnWriteData()
479 if (p_ccb->con_state != GAP_CCB_STATE_CONNECTED) { in GAP_ConnWriteData()
484 if (msg->len > p_ccb->rem_mtu_size) { in GAP_ConnWriteData()
491 fixed_queue_enqueue(p_ccb->tx_queue, msg); in GAP_ConnWriteData()
493 if (!gap_try_write_queued_data(p_ccb)) return GAP_ERR_BAD_STATE; in GAP_ConnWriteData()
512 tGAP_CCB* p_ccb = gap_find_ccb_by_handle(gap_handle); in GAP_ConnGetRemoteAddr() local
516 if ((p_ccb) && (p_ccb->con_state > GAP_CCB_STATE_LISTENING)) { in GAP_ConnGetRemoteAddr()
517 DVLOG(1) << __func__ << " BDA: " << p_ccb->rem_dev_address; in GAP_ConnGetRemoteAddr()
518 return &p_ccb->rem_dev_address; in GAP_ConnGetRemoteAddr()
538 tGAP_CCB* p_ccb; in GAP_ConnGetRemMtuSize() local
540 p_ccb = gap_find_ccb_by_handle(gap_handle); in GAP_ConnGetRemMtuSize()
541 if (p_ccb == NULL) return (0); in GAP_ConnGetRemMtuSize()
543 return (p_ccb->rem_mtu_size); in GAP_ConnGetRemMtuSize()
559 tGAP_CCB* p_ccb; in GAP_ConnGetL2CAPCid() local
561 p_ccb = gap_find_ccb_by_handle(gap_handle); in GAP_ConnGetL2CAPCid()
562 if (p_ccb == NULL) return (0); in GAP_ConnGetL2CAPCid()
564 return (p_ccb->connection_id); in GAP_ConnGetL2CAPCid()
578 tGAP_CCB* p_ccb = gap_find_ccb_by_cid(l2cap_cid); in gap_tx_complete_ind() local
579 if (p_ccb == NULL) return; in gap_tx_complete_ind()
581 if ((p_ccb->con_state == GAP_CCB_STATE_CONNECTED) && (sdu_sent == 0xFFFF)) { in gap_tx_complete_ind()
583 p_ccb->p_callback(p_ccb->gap_handle, GAP_EVT_TX_EMPTY, nullptr); in gap_tx_complete_ind()
601 tGAP_CCB* p_ccb; in gap_connect_ind() local
604 for (xx = 0, p_ccb = conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++) { in gap_connect_ind()
605 if ((p_ccb->con_state == GAP_CCB_STATE_LISTENING) && (p_ccb->psm == psm) && in gap_connect_ind()
606 (!p_ccb->rem_addr_specified || (bd_addr == p_ccb->rem_dev_address))) in gap_connect_ind()
617 if (p_ccb->transport == BT_TRANSPORT_LE) { in gap_connect_ind()
626 if (p_ccb->transport == BT_TRANSPORT_BR_EDR) in gap_connect_ind()
627 p_ccb->con_state = GAP_CCB_STATE_CFG_SETUP; in gap_connect_ind()
630 p_ccb->rem_dev_address = bd_addr; in gap_connect_ind()
631 p_ccb->connection_id = l2cap_cid; in gap_connect_ind()
633 if (p_ccb->transport == BT_TRANSPORT_LE) { in gap_connect_ind()
635 L2CA_GetPeerLECocConfig(l2cap_cid, &p_ccb->peer_coc_cfg); in gap_connect_ind()
636 p_ccb->rem_mtu_size = p_ccb->peer_coc_cfg.mtu; in gap_connect_ind()
639 p_ccb->con_flags |= GAP_CCB_FLAGS_HIS_CFG_DONE; in gap_connect_ind()
640 p_ccb->con_flags |= GAP_CCB_FLAGS_MY_CFG_DONE; in gap_connect_ind()
641 gap_checks_con_flags(p_ccb); in gap_connect_ind()
645 p_ccb->connection_id); in gap_connect_ind()
658 static void gap_checks_con_flags(tGAP_CCB* p_ccb) { in gap_checks_con_flags() argument
659 DVLOG(1) << __func__ << " conn_flags:0x" << +p_ccb->con_flags; in gap_checks_con_flags()
661 if ((p_ccb->con_flags & GAP_CCB_FLAGS_CONN_DONE) == GAP_CCB_FLAGS_CONN_DONE) { in gap_checks_con_flags()
662 p_ccb->con_state = GAP_CCB_STATE_CONNECTED; in gap_checks_con_flags()
664 p_ccb->p_callback(p_ccb->gap_handle, GAP_EVT_CONN_OPENED, nullptr); in gap_checks_con_flags()
678 static void gap_sec_check_complete(tGAP_CCB* p_ccb) { in gap_sec_check_complete() argument
679 if (p_ccb->con_state == GAP_CCB_STATE_IDLE) return; in gap_sec_check_complete()
680 p_ccb->con_flags |= GAP_CCB_FLAGS_SEC_DONE; in gap_sec_check_complete()
681 gap_checks_con_flags(p_ccb); in gap_sec_check_complete()
685 tGAP_CCB* p_ccb = gap_find_ccb_by_cid(l2cap_cid); in gap_on_l2cap_error() local
686 if (p_ccb == nullptr) return; in gap_on_l2cap_error()
689 if (p_ccb->p_callback) in gap_on_l2cap_error()
690 (*p_ccb->p_callback)(p_ccb->gap_handle, GAP_EVT_CONN_CLOSED, nullptr); in gap_on_l2cap_error()
692 gap_release_ccb(p_ccb); in gap_on_l2cap_error()
707 tGAP_CCB* p_ccb; in gap_connect_cfm() local
710 p_ccb = gap_find_ccb_by_cid(l2cap_cid); in gap_connect_cfm()
711 if (p_ccb == NULL) return; in gap_connect_cfm()
714 if ((p_ccb->con_flags & GAP_CCB_FLAGS_SEC_DONE) == 0 && in gap_connect_cfm()
715 p_ccb->transport != BT_TRANSPORT_LE) { in gap_connect_cfm()
717 gap_sec_check_complete(p_ccb); in gap_connect_cfm()
723 (p_ccb->con_state == GAP_CCB_STATE_CONN_SETUP)) { in gap_connect_cfm()
724 if (p_ccb->transport == BT_TRANSPORT_BR_EDR) { in gap_connect_cfm()
725 p_ccb->con_state = GAP_CCB_STATE_CFG_SETUP; in gap_connect_cfm()
728 if (p_ccb->transport == BT_TRANSPORT_LE) { in gap_connect_cfm()
730 L2CA_GetPeerLECocConfig(l2cap_cid, &p_ccb->peer_coc_cfg); in gap_connect_cfm()
731 p_ccb->rem_mtu_size = p_ccb->peer_coc_cfg.mtu; in gap_connect_cfm()
734 p_ccb->con_flags |= GAP_CCB_FLAGS_HIS_CFG_DONE; in gap_connect_cfm()
735 p_ccb->con_flags |= GAP_CCB_FLAGS_MY_CFG_DONE; in gap_connect_cfm()
736 p_ccb->con_flags |= GAP_CCB_FLAGS_SEC_DONE; in gap_connect_cfm()
737 gap_checks_con_flags(p_ccb); in gap_connect_cfm()
753 tGAP_CCB* p_ccb; in gap_config_ind() local
757 p_ccb = gap_find_ccb_by_cid(l2cap_cid); in gap_config_ind()
758 if (p_ccb == NULL) return; in gap_config_ind()
762 if (p_ccb->cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) { in gap_config_ind()
768 p_ccb->rem_mtu_size = local_mtu_size; in gap_config_ind()
770 p_ccb->rem_mtu_size = p_cfg->mtu; in gap_config_ind()
787 tGAP_CCB* p_ccb; in gap_config_cfm() local
790 p_ccb = gap_find_ccb_by_cid(l2cap_cid); in gap_config_cfm()
791 if (p_ccb == NULL) return; in gap_config_cfm()
793 p_ccb->con_flags |= GAP_CCB_FLAGS_MY_CFG_DONE; in gap_config_cfm()
794 p_ccb->con_flags |= GAP_CCB_FLAGS_HIS_CFG_DONE; in gap_config_cfm()
795 gap_checks_con_flags(p_ccb); in gap_config_cfm()
809 tGAP_CCB* p_ccb; in gap_disconnect_ind() local
814 p_ccb = gap_find_ccb_by_cid(l2cap_cid); in gap_disconnect_ind()
815 if (p_ccb == NULL) return; in gap_disconnect_ind()
817 p_ccb->p_callback(p_ccb->gap_handle, GAP_EVT_CONN_CLOSED, nullptr); in gap_disconnect_ind()
818 gap_release_ccb(p_ccb); in gap_disconnect_ind()
831 tGAP_CCB* p_ccb; in gap_data_ind() local
834 p_ccb = gap_find_ccb_by_cid(l2cap_cid); in gap_data_ind()
835 if (p_ccb == NULL) { in gap_data_ind()
840 if (p_ccb->con_state == GAP_CCB_STATE_CONNECTED) { in gap_data_ind()
841 fixed_queue_enqueue(p_ccb->rx_queue, p_msg); in gap_data_ind()
843 p_ccb->rx_queue_size += p_msg->len; in gap_data_ind()
849 p_ccb->p_callback(p_ccb->gap_handle, GAP_EVT_CONN_DATA_AVAIL, nullptr); in gap_data_ind()
867 tGAP_CCB* p_ccb = gap_find_ccb_by_cid(lcid); /* Find CCB based on CID */ in gap_congestion_ind() local
868 if (!p_ccb) return; in gap_congestion_ind()
870 p_ccb->is_congested = is_congested; in gap_congestion_ind()
872 p_ccb->p_callback( in gap_congestion_ind()
873 p_ccb->gap_handle, in gap_congestion_ind()
877 gap_try_write_queued_data(p_ccb); in gap_congestion_ind()
892 tGAP_CCB* p_ccb; in gap_find_ccb_by_cid() local
895 for (xx = 0, p_ccb = conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++) { in gap_find_ccb_by_cid()
896 if ((p_ccb->con_state != GAP_CCB_STATE_IDLE) && in gap_find_ccb_by_cid()
897 (p_ccb->connection_id == cid)) in gap_find_ccb_by_cid()
898 return (p_ccb); in gap_find_ccb_by_cid()
916 tGAP_CCB* p_ccb; in gap_find_ccb_by_handle() local
920 p_ccb = &conn.ccb_pool[handle]; in gap_find_ccb_by_handle()
922 if (p_ccb->con_state != GAP_CCB_STATE_IDLE) return (p_ccb); in gap_find_ccb_by_handle()
940 tGAP_CCB* p_ccb; in gap_allocate_ccb() local
943 for (xx = 0, p_ccb = conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++) { in gap_allocate_ccb()
944 if (p_ccb->con_state == GAP_CCB_STATE_IDLE) { in gap_allocate_ccb()
945 memset(p_ccb, 0, sizeof(tGAP_CCB)); in gap_allocate_ccb()
946 p_ccb->tx_queue = fixed_queue_new(SIZE_MAX); in gap_allocate_ccb()
947 p_ccb->rx_queue = fixed_queue_new(SIZE_MAX); in gap_allocate_ccb()
949 p_ccb->gap_handle = xx; in gap_allocate_ccb()
950 p_ccb->rem_mtu_size = L2CAP_MTU_SIZE; in gap_allocate_ccb()
952 return (p_ccb); in gap_allocate_ccb()
969 static void gap_release_ccb(tGAP_CCB* p_ccb) { in gap_release_ccb() argument
971 p_ccb->rx_queue_size = 0; in gap_release_ccb()
973 while (!fixed_queue_is_empty(p_ccb->rx_queue)) in gap_release_ccb()
974 osi_free(fixed_queue_try_dequeue(p_ccb->rx_queue)); in gap_release_ccb()
975 fixed_queue_free(p_ccb->rx_queue, NULL); in gap_release_ccb()
976 p_ccb->rx_queue = NULL; in gap_release_ccb()
978 while (!fixed_queue_is_empty(p_ccb->tx_queue)) in gap_release_ccb()
979 osi_free(fixed_queue_try_dequeue(p_ccb->tx_queue)); in gap_release_ccb()
980 fixed_queue_free(p_ccb->tx_queue, NULL); in gap_release_ccb()
981 p_ccb->tx_queue = NULL; in gap_release_ccb()
983 p_ccb->con_state = GAP_CCB_STATE_IDLE; in gap_release_ccb()
989 (p_ccb_local->psm == p_ccb->psm)) { in gap_release_ccb()
997 BTM_SecClrServiceByPsm(p_ccb->psm); in gap_release_ccb()
998 if (p_ccb->transport == BT_TRANSPORT_BR_EDR) L2CA_Deregister(p_ccb->psm); in gap_release_ccb()
999 if (p_ccb->transport == BT_TRANSPORT_LE) L2CA_DeregisterLECoc(p_ccb->psm); in gap_release_ccb()