Lines Matching refs:p_ccb

43 static void      gap_release_ccb (tGAP_CCB *p_ccb);
125 tGAP_CCB *p_ccb;
132 if ((p_ccb = gap_allocate_ccb()) == NULL)
140 p_ccb->rem_addr_specified = TRUE;
142 memcpy (&p_ccb->rem_dev_address[0], p_rem_bda, BD_ADDR_LEN);
151 if (!p_ccb->rem_addr_specified && !is_server)
153 gap_release_ccb (p_ccb);
160 p_ccb->cfg = *p_cfg;
162 p_ccb->p_callback = p_cb;
178 if ((p_ccb->psm = L2CA_REGISTER (psm, &gap_cb.conn.reg_info, AMP_AUTOSWITCH_ALLOWED|AMP_USE_AMP_IF_POSSIBLE)) == 0)
181 gap_release_ccb (p_ccb);
186 p_ccb->service_id = service_id;
187 if (!BTM_SetSecurityLevel ((UINT8)!is_server, p_serv_name, p_ccb->service_id, security, p_ccb->psm, 0, 0))
190 gap_release_ccb (p_ccb);
195 if( p_ccb->cfg.fcr_present )
197 p_ccb->ertm_info.preferred_mode = p_ccb->cfg.fcr.mode;
198 p_ccb->ertm_info.user_rx_pool_id = GAP_DATA_POOL_ID;
199 p_ccb->ertm_info.user_tx_pool_id = GAP_DATA_POOL_ID;
200 p_ccb->ertm_info.fcr_rx_pool_id = L2CAP_DEFAULT_ERM_POOL_ID;
201 p_ccb->ertm_info.fcr_tx_pool_id = L2CAP_DEFAULT_ERM_POOL_ID;
205 p_ccb->ertm_info.allowed_modes = (chan_mode_mask) ? chan_mode_mask : (UINT8)L2CAP_FCR_CHAN_OPT_BASIC;
209 p_ccb->con_flags |= GAP_CCB_FLAGS_SEC_DONE; /* assume btm/l2cap would handle it */
210 p_ccb->con_state = GAP_CCB_STATE_LISTENING;
211 return (p_ccb->gap_handle);
216 p_ccb->con_flags = GAP_CCB_FLAGS_IS_ORIG;
219 p_ccb->con_state = GAP_CCB_STATE_CONN_SETUP;
223 p_ccb->con_flags |= GAP_CCB_FLAGS_SEC_DONE;
226 if (p_rem_bda && ((cid = L2CA_CONNECT_REQ (p_ccb->psm, p_rem_bda, &p_ccb->ertm_info, &bt_uuid)) != 0))
228 p_ccb->connection_id = cid;
229 return (p_ccb->gap_handle);
233 gap_release_ccb (p_ccb);
254 tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
258 if (p_ccb)
261 if (p_ccb->con_state != GAP_CCB_STATE_LISTENING)
262 L2CA_DISCONNECT_REQ (p_ccb->connection_id);
264 gap_release_ccb (p_ccb);
293 tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
297 if (!p_ccb)
302 p_buf = (BT_HDR *)GKI_getfirst (&p_ccb->rx_queue);
331 GKI_freebuf (GKI_dequeue (&p_ccb->rx_queue));
335 p_ccb->rx_queue_size -= *p_len;
340 p_ccb->rx_queue_size, *p_len);
358 tGAP_CCB *p_ccb;
364 p_ccb = &gap_cb.conn.ccb_pool[handle];
366 if (p_ccb->con_state == GAP_CCB_STATE_CONNECTED)
368 *p_rx_queue_count = p_ccb->rx_queue_size;
399 tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
402 if (!p_ccb)
405 p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->rx_queue);
411 p_ccb->rx_queue_size -= p_buf->len;
438 tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
440 if (!p_ccb)
446 if (p_ccb->con_state != GAP_CCB_STATE_CONNECTED)
458 GKI_enqueue (&p_ccb->tx_queue, p_buf);
460 if (p_ccb->is_congested)
469 while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL)
471 UINT8 status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf);
475 p_ccb->is_congested = TRUE;
506 tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
511 if (!p_ccb)
514 if (p_ccb->con_state != GAP_CCB_STATE_CONNECTED)
519 if (p_ccb->cfg.fcr.mode == L2CAP_FCR_ERTM_MODE)
521 if ((p_buf = (BT_HDR *)GKI_getpoolbuf (p_ccb->ertm_info.user_tx_pool_id)) == NULL)
531 p_buf->len = (p_ccb->rem_mtu_size < max_len) ? p_ccb->rem_mtu_size : max_len;
542 GKI_enqueue (&p_ccb->tx_queue, p_buf);
545 if (p_ccb->is_congested)
554 while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL)
556 UINT8 status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf);
560 p_ccb->is_congested = TRUE;
586 tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
588 if (!p_ccb)
591 p_ccb->cfg = *p_cfg;
593 if (p_ccb->con_state == GAP_CCB_STATE_CONNECTED)
594 L2CA_CONFIG_REQ (p_ccb->connection_id, p_cfg);
624 tGAP_CCB *p_ccb;
626 if ((p_ccb = gap_find_ccb_by_handle (gap_handle)) == NULL)
629 if (L2CA_SetIdleTimeout (p_ccb->connection_id, timeout, FALSE))
652 tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
656 if ((p_ccb) && (p_ccb->con_state > GAP_CCB_STATE_LISTENING))
659 p_ccb->rem_dev_address[0],p_ccb->rem_dev_address[1],p_ccb->rem_dev_address[2],
660 p_ccb->rem_dev_address[3],p_ccb->rem_dev_address[4],p_ccb->rem_dev_address[5]);
661 return (p_ccb->rem_dev_address);
684 tGAP_CCB *p_ccb;
686 if ((p_ccb = gap_find_ccb_by_handle (gap_handle)) == NULL)
689 return (p_ccb->rem_mtu_size);
706 tGAP_CCB *p_ccb;
708 if ((p_ccb = gap_find_ccb_by_handle (gap_handle)) == NULL)
711 return (p_ccb->connection_id);
729 tGAP_CCB *p_ccb;
733 for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++)
735 if ((p_ccb->con_state == GAP_CCB_STATE_LISTENING)
736 && (p_ccb->psm == psm)
737 && ((p_ccb->rem_addr_specified == FALSE)
738 || (!memcmp (bd_addr, p_ccb->rem_dev_address, BD_ADDR_LEN))))
754 p_ccb->con_state = GAP_CCB_STATE_CFG_SETUP;
757 memcpy (&p_ccb->rem_dev_address[0], bd_addr, BD_ADDR_LEN);
758 p_ccb->connection_id = l2cap_cid;
761 L2CA_CONNECT_RSP (bd_addr, l2cap_id, l2cap_cid, L2CAP_CONN_OK, L2CAP_CONN_OK, &p_ccb->ertm_info, &bt_uuid);
763 GAP_TRACE_EVENT1("GAP_CONN - Rcvd L2CAP conn ind, CID: 0x%x", p_ccb->connection_id);
766 L2CA_CONFIG_REQ (l2cap_cid, &p_ccb->cfg);
779 static void gap_checks_con_flags (tGAP_CCB *p_ccb)
781 GAP_TRACE_EVENT1 ("gap_checks_con_flags conn_flags:0x%x, ", p_ccb->con_flags);
783 if ((p_ccb->con_flags & GAP_CCB_FLAGS_CONN_DONE) == GAP_CCB_FLAGS_CONN_DONE)
785 p_ccb->con_state = GAP_CCB_STATE_CONNECTED;
787 p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_CONN_OPENED);
803 tGAP_CCB *p_ccb = (tGAP_CCB *)p_ref_data;
806 p_ccb->con_state, p_ccb->con_flags, res);
807 if (p_ccb->con_state == GAP_CCB_STATE_IDLE)
812 p_ccb->con_flags |= GAP_CCB_FLAGS_SEC_DONE;
813 gap_checks_con_flags (p_ccb);
818 L2CA_DISCONNECT_REQ (p_ccb->connection_id);
835 tGAP_CCB *p_ccb;
838 if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL)
842 if ( (p_ccb->con_flags & GAP_CCB_FLAGS_SEC_DONE) == 0)
844 btm_sec_mx_access_request (p_ccb->rem_dev_address, p_ccb->psm, TRUE,
845 0, 0, &gap_sec_check_complete, p_ccb);
850 if ((result == L2CAP_CONN_OK) && (p_ccb->con_state == GAP_CCB_STATE_CONN_SETUP))
852 p_ccb->con_state = GAP_CCB_STATE_CFG_SETUP;
855 L2CA_CONFIG_REQ (l2cap_cid, &p_ccb->cfg);
860 if (p_ccb->p_callback)
861 (*p_ccb->p_callback) (p_ccb->gap_handle, GAP_EVT_CONN_CLOSED);
863 gap_release_ccb (p_ccb);
879 tGAP_CCB *p_ccb;
883 if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL)
888 if (p_ccb->cfg.fcr.mode == L2CAP_FCR_ERTM_MODE)
890 local_mtu_size = GKI_get_pool_bufsize (p_ccb->ertm_info.user_tx_pool_id)
898 p_ccb->rem_mtu_size = local_mtu_size;
901 p_ccb->rem_mtu_size = p_cfg->mtu;
911 p_ccb->con_flags |= GAP_CCB_FLAGS_HIS_CFG_DONE;
913 gap_checks_con_flags (p_ccb);
929 tGAP_CCB *p_ccb;
932 if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL)
937 p_ccb->con_flags |= GAP_CCB_FLAGS_MY_CFG_DONE;
940 if (p_ccb->cfg.fcr_present)
941 p_ccb->cfg.fcr.mode = p_cfg->fcr.mode;
943 p_ccb->cfg.fcr.mode = L2CAP_FCR_BASIC_MODE;
945 gap_checks_con_flags (p_ccb);
949 p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_CONN_CLOSED);
950 gap_release_ccb (p_ccb);
967 tGAP_CCB *p_ccb;
972 if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL)
978 p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_CONN_CLOSED);
979 gap_release_ccb (p_ccb);
994 tGAP_CCB *p_ccb;
997 if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL)
1003 if (p_ccb->con_state == GAP_CCB_STATE_CONNECTED)
1005 GKI_enqueue (&p_ccb->rx_queue, p_msg);
1007 p_ccb->rx_queue_size += p_msg->len;
1010 p_ccb->rx_queue_size, p_msg->len);
1013 p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_CONN_DATA_AVAIL);
1032 tGAP_CCB *p_ccb;
1041 if ((p_ccb = gap_find_ccb_by_cid (lcid)) == NULL)
1044 p_ccb->is_congested = is_congested;
1047 p_ccb->p_callback (p_ccb->gap_handle, event);
1051 while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL)
1053 status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf);
1057 p_ccb->is_congested = TRUE;
1080 tGAP_CCB *p_ccb;
1083 for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++)
1085 if ((p_ccb->con_state != GAP_CCB_STATE_IDLE) && (p_ccb->connection_id == cid))
1086 return (p_ccb);
1106 tGAP_CCB *p_ccb;
1111 p_ccb = &gap_cb.conn.ccb_pool[handle];
1113 if (p_ccb->con_state != GAP_CCB_STATE_IDLE)
1114 return (p_ccb);
1134 tGAP_CCB *p_ccb;
1137 for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++)
1139 if (p_ccb->con_state == GAP_CCB_STATE_IDLE)
1141 memset (p_ccb, 0, sizeof (tGAP_CCB));
1143 p_ccb->gap_handle = xx;
1144 p_ccb->rem_mtu_size = L2CAP_MTU_SIZE;
1146 return (p_ccb);
1164 static void gap_release_ccb (tGAP_CCB *p_ccb)
1167 UINT16 psm = p_ccb->psm;
1168 UINT8 service_id = p_ccb->service_id;
1171 p_ccb->rx_queue_size = 0;
1173 while (p_ccb->rx_queue.p_first)
1174 GKI_freebuf (GKI_dequeue (&p_ccb->rx_queue));
1176 while (p_ccb->tx_queue.p_first)
1177 GKI_freebuf (GKI_dequeue (&p_ccb->tx_queue));
1179 p_ccb->con_state = GAP_CCB_STATE_IDLE;
1182 for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++)
1184 if ((p_ccb->con_state != GAP_CCB_STATE_IDLE) && (p_ccb->psm == psm))
1234 tGAP_CCB *p_ccb = gap_find_ccb_by_handle (p_msg->layer_specific);
1238 if (!p_ccb)
1243 if (p_ccb->con_state != GAP_CCB_STATE_CONNECTED)
1248 if (p_ccb->is_congested)
1255 while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL)
1257 status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf);
1261 p_ccb->is_congested = TRUE;