/******************************************************************************* ** ** Function sdp_conn_originate ** ** Description This function is called from the API to originate a ** connection. ** ** Returns void ** *******************************************************************************/ tCONN_CB *sdp_conn_originate (UINT8 *p_bd_addr) { tCONN_CB *p_ccb; UINT16 cid; /* Allocate a new CCB. Return if none available. */ if ((p_ccb = sdpu_allocate_ccb()) == NULL) { SDP_TRACE_WARNING ("SDP - no spare CCB for orig\n"); return (NULL); } SDP_TRACE_EVENT ("SDP - Originate started\n"); /* We are the originator of this connection */ p_ccb->con_flags |= SDP_FLAGS_IS_ORIG; /* Save the BD Address and Channel ID. */ memcpy (&p_ccb->device_address[0], p_bd_addr, sizeof (BD_ADDR)); /* Transition to the next appropriate state, waiting for connection confirm. */ p_ccb->con_state = SDP_STATE_CONN_SETUP; cid = L2CA_ConnectReq (SDP_PSM, p_bd_addr); /* Check if L2CAP started the connection process */ if (cid != 0) { p_ccb->connection_id = cid; return (p_ccb); } else { SDP_TRACE_WARNING ("SDP - Originate failed\n"); sdpu_release_ccb (p_ccb); return (NULL); } }
/******************************************************************************* ** ** Function sdp_conn_originate ** ** Description This function is called from the API to originate a ** connection. ** ** Returns void ** *******************************************************************************/ tCONN_CB* sdp_conn_originate (UINT8 *p_bd_addr) { tCONN_CB *p_ccb; UINT16 cid; /* Allocate a new CCB. Return if none available. */ if ((p_ccb = sdpu_allocate_ccb()) == NULL) { SDP_TRACE_WARNING0 ("SDP - no spare CCB for orig"); return (NULL); } SDP_TRACE_EVENT0 ("SDP - Originate started"); /* We are the originator of this connection */ p_ccb->con_flags |= SDP_FLAGS_IS_ORIG; /* Save the BD Address and Channel ID. */ memcpy (&p_ccb->device_address[0], p_bd_addr, sizeof (BD_ADDR)); /* Transition to the next appropriate state, waiting for connection confirm. */ p_ccb->con_state = SDP_STATE_CONN_SETUP; // btla-specific ++ #ifndef ANDROID_APP_INCLUDED /* Skip for Android: Do not need to set out_service for sdp, since sdp does not use sec. Prevents over-writing service_rec of a connection already in progress */ BTM_SetOutService(p_bd_addr, BTM_SEC_SERVICE_SDP_SERVER, 0); #endif // btla-specific -- cid = L2CA_ConnectReq (SDP_PSM, p_bd_addr); /* Check if L2CAP started the connection process */ if (cid != 0) { p_ccb->connection_id = cid; return (p_ccb); } else { SDP_TRACE_WARNING0 ("SDP - Originate failed"); sdpu_release_ccb (p_ccb); return (NULL); } }
/******************************************************************************* ** ** Function sdp_connect_ind ** ** Description This function handles an inbound connection indication ** from L2CAP. This is the case where we are acting as a ** server. ** ** Returns void ** *******************************************************************************/ static void sdp_connect_ind (BD_ADDR bd_addr, UINT16 l2cap_cid, UINT16 psm, UINT8 l2cap_id) { #if SDP_SERVER_ENABLED == TRUE tCONN_CB *p_ccb; /* Allocate a new CCB. Return if none available. */ if ((p_ccb = sdpu_allocate_ccb()) == NULL) return; /* Transition to the next appropriate state, waiting for config setup. */ p_ccb->con_state = SDP_STATE_CFG_SETUP; /* Save the BD Address and Channel ID. */ memcpy (&p_ccb->device_address[0], bd_addr, sizeof (BD_ADDR)); p_ccb->connection_id = l2cap_cid; /* Send response to the L2CAP layer. */ L2CA_ConnectRsp (bd_addr, l2cap_id, l2cap_cid, L2CAP_CONN_OK, L2CAP_CONN_OK); { tL2CAP_CFG_INFO cfg = sdp_cb.l2cap_my_cfg; if (cfg.fcr_present) { SDP_TRACE_DEBUG6("sdp_connect_ind: mode %u, txwinsz %u, max_trans %u, rtrans_tout %u, mon_tout %u, mps %u", cfg.fcr.mode, cfg.fcr.tx_win_sz, cfg.fcr.max_transmit, cfg.fcr.rtrans_tout,cfg.fcr.mon_tout, cfg.fcr.mps); } if ((!L2CA_ConfigReq (l2cap_cid, &cfg)) && cfg.fcr_present && cfg.fcr.mode != L2CAP_FCR_BASIC_MODE) { /* FCR not desired; try again in basic mode */ cfg.fcr.mode = L2CAP_FCR_BASIC_MODE; cfg.fcr_present = FALSE; L2CA_ConfigReq (l2cap_cid, &cfg); } } SDP_TRACE_EVENT1 ("SDP - Rcvd L2CAP conn ind, sent config req, CID 0x%x", p_ccb->connection_id); #else /* No server */ /* Reject the connection */ L2CA_ConnectRsp (bd_addr, l2cap_id, l2cap_cid, L2CAP_CONN_NO_PSM, 0); #endif }