Home | History | Annotate | Download | only in gap

Lines Matching full:p_ccb

44 static void      gap_release_ccb (tGAP_CCB *p_ccb);
126 tGAP_CCB *p_ccb;
133 if ((p_ccb = gap_allocate_ccb()) == NULL)
141 p_ccb->rem_addr_specified = TRUE;
143 memcpy (&p_ccb->rem_dev_address[0], p_rem_bda, BD_ADDR_LEN);
152 if (!p_ccb->rem_addr_specified && !is_server)
154 gap_release_ccb (p_ccb);
161 p_ccb->cfg = *p_cfg;
163 p_ccb->p_callback = p_cb;
179 if ((p_ccb->psm = L2CA_REGISTER (psm, &gap_cb.conn.reg_info, AMP_AUTOSWITCH_ALLOWED|AMP_USE_AMP_IF_POSSIBLE)) == 0)
182 gap_release_ccb (p_ccb);
187 p_ccb->service_id = service_id;
188 if (!BTM_SetSecurityLevel ((UINT8)!is_server, p_serv_name, p_ccb->service_id, security, p_ccb->psm, 0, 0))
191 gap_release_ccb (p_ccb);
196 if( p_ccb->cfg.fcr_present )
198 p_ccb->ertm_info.preferred_mode = p_ccb->cfg.fcr.mode;
199 p_ccb->ertm_info.user_rx_pool_id = GAP_DATA_POOL_ID;
200 p_ccb->ertm_info.user_tx_pool_id = GAP_DATA_POOL_ID;
201 p_ccb->ertm_info.fcr_rx_pool_id = L2CAP_DEFAULT_ERM_POOL_ID;
202 p_ccb->ertm_info.fcr_tx_pool_id = L2CAP_DEFAULT_ERM_POOL_ID;
206 p_ccb->ertm_info.allowed_modes = (chan_mode_mask) ? chan_mode_mask : (UINT8)L2CAP_FCR_CHAN_OPT_BASIC;
210 p_ccb->con_flags |= GAP_CCB_FLAGS_SEC_DONE; /* assume btm/l2cap would handle it */
211 p_ccb->con_state = GAP_CCB_STATE_LISTENING;
212 return (p_ccb->gap_handle);
217 p_ccb->con_flags = GAP_CCB_FLAGS_IS_ORIG;
220 p_ccb->con_state = GAP_CCB_STATE_CONN_SETUP;
224 p_ccb->con_flags |= GAP_CCB_FLAGS_SEC_DONE;
227 if (p_rem_bda && ((cid = L2CA_CONNECT_REQ (p_ccb->psm, p_rem_bda, &p_ccb->ertm_info, &bt_uuid)) != 0))
229 p_ccb->connection_id = cid;
230 return (p_ccb->gap_handle);
234 gap_release_ccb (p_ccb);
255 tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
259 if (p_ccb)
262 if (p_ccb->con_state != GAP_CCB_STATE_LISTENING)
263 L2CA_DISCONNECT_REQ (p_ccb->connection_id);
265 gap_release_ccb (p_ccb);
294 tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
298 if (!p_ccb)
303 p_buf = (BT_HDR *)GKI_getfirst (&p_ccb->rx_queue);
332 GKI_freebuf (GKI_dequeue (&p_ccb->rx_queue));
336 p_ccb->rx_queue_size -= *p_len;
341 p_ccb->rx_queue_size, *p_len);
359 tGAP_CCB *p_ccb;
365 p_ccb = &gap_cb.conn.ccb_pool[handle];
367 if (p_ccb->con_state == GAP_CCB_STATE_CONNECTED)
369 *p_rx_queue_count = p_ccb->rx_queue_size;
400 tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
403 if (!p_ccb)
406 p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->rx_queue);
412 p_ccb->rx_queue_size -= p_buf->len;
439 tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
441 if (!p_ccb)
447 if (p_ccb->con_state != GAP_CCB_STATE_CONNECTED)
459 GKI_enqueue (&p_ccb->tx_queue, p_buf);
461 if (p_ccb->is_congested)
470 while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL)
472 p_ccb->connection_id, p_buf);
476 p_ccb->is_congested = TRUE;
507 tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
512 if (!p_ccb)
515 if (p_ccb->con_state != GAP_CCB_STATE_CONNECTED)
520 if (p_ccb->cfg.fcr.mode == L2CAP_FCR_ERTM_MODE)
522 if ((p_buf = (BT_HDR *)GKI_getpoolbuf (p_ccb->ertm_info.user_tx_pool_id)) == NULL)
532 p_buf->len = (p_ccb->rem_mtu_size < max_len) ? p_ccb->rem_mtu_size : max_len;
543 GKI_enqueue (&p_ccb->tx_queue, p_buf);
546 if (p_ccb->is_congested)
555 while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL)
557 UINT8 status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf);
561 p_ccb->is_congested = TRUE;
587 tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
589 if (!p_ccb)
592 p_ccb->cfg = *p_cfg;
594 if (p_ccb->con_state == GAP_CCB_STATE_CONNECTED)
595 L2CA_CONFIG_REQ (p_ccb->connection_id, p_cfg);
625 tGAP_CCB *p_ccb;
627 if ((p_ccb = gap_find_ccb_by_handle (gap_handle)) == NULL)
630 if (L2CA_SetIdleTimeout (p_ccb->connection_id, timeout, FALSE))
653 tGAP_CCB *p_ccb = gap_find_ccb_by_handle (gap_handle);
657 if ((p_ccb) && (p_ccb->con_state > GAP_CCB_STATE_LISTENING))
660 p_ccb->rem_dev_address[0],p_ccb->rem_dev_address[1],p_ccb->rem_dev_address[2],
661 p_ccb->rem_dev_address[3],p_ccb->rem_dev_address[4],p_ccb->rem_dev_address[5]);
662 return (p_ccb->rem_dev_address);
685 tGAP_CCB *p_ccb;
687 if ((p_ccb = gap_find_ccb_by_handle (gap_handle)) == NULL)
690 return (p_ccb->rem_mtu_size);
707 tGAP_CCB *p_ccb;
709 if ((p_ccb = gap_find_ccb_by_handle (gap_handle)) == NULL)
712 return (p_ccb->connection_id);
730 tGAP_CCB *p_ccb;
734 for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++)
736 if ((p_ccb->con_state == GAP_CCB_STATE_LISTENING)
737 && (p_ccb->psm == psm)
738 && ((p_ccb->rem_addr_specified == FALSE)
739 || (!memcmp (bd_addr, p_ccb->rem_dev_address, BD_ADDR_LEN))))
755 p_ccb->con_state = GAP_CCB_STATE_CFG_SETUP;
758 memcpy (&p_ccb->rem_dev_address[0], bd_addr, BD_ADDR_LEN);
759 p_ccb->connection_id = l2cap_cid;
762 L2CA_CONNECT_RSP (bd_addr, l2cap_id, l2cap_cid, L2CAP_CONN_OK, L2CAP_CONN_OK, &p_ccb->ertm_info, &bt_uuid);
764 GAP_TRACE_EVENT("GAP_CONN - Rcvd L2CAP conn ind, CID: 0x%x", p_ccb->connection_id);
767 L2CA_CONFIG_REQ (l2cap_cid, &p_ccb->cfg);
780 static void gap_checks_con_flags (tGAP_CCB *p_ccb)
782 GAP_TRACE_EVENT ("gap_checks_con_flags conn_flags:0x%x, ", p_ccb->con_flags);
784 if ((p_ccb->con_flags & GAP_CCB_FLAGS_CONN_DONE) == GAP_CCB_FLAGS_CONN_DONE)
786 p_ccb->con_state = GAP_CCB_STATE_CONNECTED;
788 p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_CONN_OPENED);
804 tGAP_CCB *p_ccb = (tGAP_CCB *)p_ref_data;
809 p_ccb->con_state, p_ccb->con_flags, res);
810 if (p_ccb->con_state == GAP_CCB_STATE_IDLE)
815 p_ccb->con_flags |= GAP_CCB_FLAGS_SEC_DONE;
816 gap_checks_con_flags (p_ccb);
821 L2CA_DISCONNECT_REQ (p_ccb->connection_id);
838 tGAP_CCB *p_ccb;
841 if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL)
845 if ( (p_ccb->con_flags & GAP_CCB_FLAGS_SEC_DONE) == 0)
847 btm_sec_mx_access_request (p_ccb->rem_dev_address, p_ccb->psm, TRUE,
848 0, 0, &gap_sec_check_complete, p_ccb);
853 if ((result == L2CAP_CONN_OK) && (p_ccb->con_state == GAP_CCB_STATE_CONN_SETUP))
855 p_ccb->con_state = GAP_CCB_STATE_CFG_SETUP;
858 L2CA_CONFIG_REQ (l2cap_cid, &p_ccb->cfg);
863 if (p_ccb->p_callback)
864 (*p_ccb->p_callback) (p_ccb->gap_handle, GAP_EVT_CONN_CLOSED);
866 gap_release_ccb (p_ccb);
882 tGAP_CCB *p_ccb;
886 if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL)
891 if (p_ccb->cfg.fcr.mode == L2CAP_FCR_ERTM_MODE)
893 local_mtu_size = GKI_get_pool_bufsize (p_ccb->ertm_info.user_tx_pool_id)
901 p_ccb->rem_mtu_size = local_mtu_size;
904 p_ccb->rem_mtu_size = p_cfg->mtu;
914 p_ccb->con_flags |= GAP_CCB_FLAGS_HIS_CFG_DONE;
916 gap_checks_con_flags (p_ccb);
932 tGAP_CCB *p_ccb;
935 if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL)
940 p_ccb->con_flags |= GAP_CCB_FLAGS_MY_CFG_DONE;
943 if (p_ccb->cfg.fcr_present)
944 p_ccb->cfg.fcr.mode = p_cfg->fcr.mode;
946 p_ccb->cfg.fcr.mode = L2CAP_FCR_BASIC_MODE;
948 gap_checks_con_flags (p_ccb);
952 p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_CONN_CLOSED);
953 gap_release_ccb (p_ccb);
970 tGAP_CCB *p_ccb;
975 if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL)
981 p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_CONN_CLOSED);
982 gap_release_ccb (p_ccb);
997 tGAP_CCB *p_ccb;
1000 if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL)
1006 if (p_ccb->con_state == GAP_CCB_STATE_CONNECTED)
1008 GKI_enqueue (&p_ccb->rx_queue, p_msg);
1010 p_ccb->rx_queue_size += p_msg->len;
1013 p_ccb->rx_queue_size, p_msg->len);
1016 p_ccb->p_callback (p_ccb->gap_handle, GAP_EVT_CONN_DATA_AVAIL);
1035 tGAP_CCB *p_ccb;
1044 if ((p_ccb = gap_find_ccb_by_cid (lcid)) == NULL)
1047 p_ccb->is_congested = is_congested;
1050 p_ccb->p_callback (p_ccb->gap_handle, event);
1054 while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL)
1056 status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf);
1060 p_ccb->is_congested = TRUE;
1083 tGAP_CCB *p_ccb;
1086 for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++)
1088 if ((p_ccb->con_state != GAP_CCB_STATE_IDLE) && (p_ccb->connection_id == cid))
1089 return (p_ccb);
1109 tGAP_CCB *p_ccb;
1114 p_ccb = &gap_cb.conn.ccb_pool[handle];
1116 if (p_ccb->con_state != GAP_CCB_STATE_IDLE)
1117 return (p_ccb);
1137 tGAP_CCB *p_ccb;
1140 for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++)
1142 if (p_ccb->con_state == GAP_CCB_STATE_IDLE)
1144 memset (p_ccb, 0, sizeof (tGAP_CCB));
1146 p_ccb->gap_handle = xx;
1147 p_ccb->rem_mtu_size = L2CAP_MTU_SIZE;
1149 return (p_ccb);
1167 static void gap_release_ccb (tGAP_CCB *p_ccb)
1170 UINT16 psm = p_ccb->psm;
1171 UINT8 service_id = p_ccb->service_id;
1174 p_ccb->rx_queue_size = 0;
1176 while (p_ccb->rx_queue.p_first)
1177 GKI_freebuf (GKI_dequeue (&p_ccb->rx_queue));
1179 while (p_ccb->tx_queue.p_first)
1180 GKI_freebuf (GKI_dequeue (&p_ccb->tx_queue));
1182 p_ccb->con_state = GAP_CCB_STATE_IDLE;
1185 for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++)
1187 if ((p_ccb->con_state != GAP_CCB_STATE_IDLE) && (p_ccb->psm == psm))
1237 tGAP_CCB *p_ccb = gap_find_ccb_by_handle (p_msg->layer_specific);
1241 if (!p_ccb)
1246 if (p_ccb->con_state != GAP_CCB_STATE_CONNECTED)
1251 if (p_ccb->is_congested)
1258 while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL)
1260 status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf);
1264 p_ccb->is_congested = TRUE;