Lines Matching refs:p_ccb
47 static void process_service_search_rsp(tCONN_CB* p_ccb, uint8_t* p_reply,
49 static void process_service_attr_rsp(tCONN_CB* p_ccb, uint8_t* p_reply,
51 static void process_service_search_attr_rsp(tCONN_CB* p_ccb, uint8_t* p_reply,
53 static uint8_t* save_attr_seq(tCONN_CB* p_ccb, uint8_t* p, uint8_t* p_msg_end);
120 static void sdp_snd_service_search_req(tCONN_CB* p_ccb, uint8_t cont_len, in sdp_snd_service_search_req() argument
132 UINT16_TO_BE_STREAM(p, p_ccb->transaction_id); in sdp_snd_service_search_req()
133 p_ccb->transaction_id++; in sdp_snd_service_search_req()
140 p = sdpu_build_uuid_seq(p, p_ccb->p_db->num_uuid_filters, in sdp_snd_service_search_req()
141 p_ccb->p_db->uuid_filters); in sdp_snd_service_search_req()
159 p_ccb->disc_state = SDP_DISC_WAIT_HANDLES; in sdp_snd_service_search_req()
164 L2CA_DataWrite(p_ccb->connection_id, p_cmd); in sdp_snd_service_search_req()
167 alarm_set_on_mloop(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS, in sdp_snd_service_search_req()
168 sdp_conn_timer_timeout, p_ccb); in sdp_snd_service_search_req()
181 void sdp_disc_connected(tCONN_CB* p_ccb) { in sdp_disc_connected() argument
182 if (p_ccb->is_attr_search) { in sdp_disc_connected()
183 p_ccb->disc_state = SDP_DISC_WAIT_SEARCH_ATTR; in sdp_disc_connected()
185 process_service_search_attr_rsp(p_ccb, NULL, NULL); in sdp_disc_connected()
191 p_ccb->num_handles = 0; in sdp_disc_connected()
192 sdp_snd_service_search_req(p_ccb, 0, NULL); in sdp_disc_connected()
206 void sdp_disc_server_rsp(tCONN_CB* p_ccb, BT_HDR* p_msg) { in sdp_disc_server_rsp() argument
211 alarm_cancel(p_ccb->sdp_conn_timer); in sdp_disc_server_rsp()
219 sdp_disconnect(p_ccb, SDP_GENERIC_ERROR); in sdp_disc_server_rsp()
229 if (p_ccb->disc_state == SDP_DISC_WAIT_HANDLES) { in sdp_disc_server_rsp()
230 process_service_search_rsp(p_ccb, p, p_end); in sdp_disc_server_rsp()
236 if (p_ccb->disc_state == SDP_DISC_WAIT_ATTR) { in sdp_disc_server_rsp()
237 process_service_attr_rsp(p_ccb, p, p_end); in sdp_disc_server_rsp()
243 if (p_ccb->disc_state == SDP_DISC_WAIT_SEARCH_ATTR) { in sdp_disc_server_rsp()
244 process_service_search_attr_rsp(p_ccb, p, p_end); in sdp_disc_server_rsp()
252 p_ccb->disc_state); in sdp_disc_server_rsp()
253 sdp_disconnect(p_ccb, SDP_GENERIC_ERROR); in sdp_disc_server_rsp()
267 static void process_service_search_rsp(tCONN_CB* p_ccb, uint8_t* p_reply, in process_service_search_rsp() argument
275 sdp_disconnect(p_ccb, SDP_GENERIC_ERROR); in process_service_search_rsp()
283 orig = p_ccb->num_handles; in process_service_search_rsp()
284 p_ccb->num_handles += cur_handles; in process_service_search_rsp()
285 if (p_ccb->num_handles == 0) { in process_service_search_rsp()
287 sdp_disconnect(p_ccb, SDP_NO_RECS_MATCH); in process_service_search_rsp()
293 if (p_ccb->num_handles > sdp_cb.max_recs_per_search) in process_service_search_rsp()
294 p_ccb->num_handles = sdp_cb.max_recs_per_search; in process_service_search_rsp()
296 if (p_reply + ((p_ccb->num_handles - orig) * 4) + 1 > p_reply_end) { in process_service_search_rsp()
298 sdp_disconnect(p_ccb, SDP_GENERIC_ERROR); in process_service_search_rsp()
302 for (xx = orig; xx < p_ccb->num_handles; xx++) in process_service_search_rsp()
303 BE_STREAM_TO_UINT32(p_ccb->handles[xx], p_reply); in process_service_search_rsp()
308 sdp_disconnect(p_ccb, SDP_INVALID_CONT_STATE); in process_service_search_rsp()
313 sdp_disconnect(p_ccb, SDP_INVALID_CONT_STATE); in process_service_search_rsp()
317 sdp_snd_service_search_req(p_ccb, cont_len, p_reply); in process_service_search_rsp()
320 p_ccb->disc_state = SDP_DISC_WAIT_ATTR; in process_service_search_rsp()
323 process_service_attr_rsp(p_ccb, NULL, NULL); in process_service_search_rsp()
340 static bool sdp_copy_raw_data(tCONN_CB* p_ccb, bool offset) { in sdp_copy_raw_data() argument
347 if (p_ccb->p_db->raw_data) { in sdp_copy_raw_data()
348 cpy_len = p_ccb->p_db->raw_size - p_ccb->p_db->raw_used; in sdp_copy_raw_data()
349 list_len = p_ccb->list_len; in sdp_copy_raw_data()
350 p = &p_ccb->rsp_list[0]; in sdp_copy_raw_data()
351 p_end = &p_ccb->rsp_list[0] + list_len; in sdp_copy_raw_data()
371 rem_len = SDP_MAX_LIST_BYTE_COUNT - (unsigned int)(p - &p_ccb->rsp_list[0]); in sdp_copy_raw_data()
376 memcpy(&p_ccb->p_db->raw_data[p_ccb->p_db->raw_used], p, cpy_len); in sdp_copy_raw_data()
377 p_ccb->p_db->raw_used += cpy_len; in sdp_copy_raw_data()
393 static void process_service_attr_rsp(tCONN_CB* p_ccb, uint8_t* p_reply, in process_service_attr_rsp() argument
403 sdp_disconnect(p_ccb, SDP_INVALID_PDU_SIZE); in process_service_attr_rsp()
414 if ((p_ccb->list_len + list_byte_count) > SDP_MAX_LIST_BYTE_COUNT) { in process_service_attr_rsp()
415 sdp_disconnect(p_ccb, SDP_INVALID_PDU_SIZE); in process_service_attr_rsp()
419 if (p_ccb->rsp_list == NULL) in process_service_attr_rsp()
420 p_ccb->rsp_list = (uint8_t*)osi_malloc(SDP_MAX_LIST_BYTE_COUNT); in process_service_attr_rsp()
421 memcpy(&p_ccb->rsp_list[p_ccb->list_len], p_reply, list_byte_count); in process_service_attr_rsp()
422 p_ccb->list_len += list_byte_count; in process_service_attr_rsp()
426 sdp_disconnect(p_ccb, SDP_INVALID_CONT_STATE); in process_service_attr_rsp()
433 if (!sdp_copy_raw_data(p_ccb, false)) { in process_service_attr_rsp()
435 sdp_disconnect(p_ccb, SDP_ILLEGAL_PARAMETER); in process_service_attr_rsp()
442 if (!save_attr_seq(p_ccb, &p_ccb->rsp_list[0], in process_service_attr_rsp()
443 &p_ccb->rsp_list[p_ccb->list_len])) { in process_service_attr_rsp()
444 sdp_disconnect(p_ccb, SDP_DB_FULL); in process_service_attr_rsp()
447 p_ccb->list_len = 0; in process_service_attr_rsp()
448 p_ccb->cur_handle++; in process_service_attr_rsp()
453 if (p_ccb->cur_handle < p_ccb->num_handles) { in process_service_attr_rsp()
462 UINT16_TO_BE_STREAM(p, p_ccb->transaction_id); in process_service_attr_rsp()
463 p_ccb->transaction_id++; in process_service_attr_rsp()
469 UINT32_TO_BE_STREAM(p, p_ccb->handles[p_ccb->cur_handle]); in process_service_attr_rsp()
475 if (p_ccb->p_db->num_attr_filters) in process_service_attr_rsp()
476 p = sdpu_build_attrib_seq(p, p_ccb->p_db->attr_filters, in process_service_attr_rsp()
477 p_ccb->p_db->num_attr_filters); in process_service_attr_rsp()
499 L2CA_DataWrite(p_ccb->connection_id, p_msg); in process_service_attr_rsp()
502 alarm_set_on_mloop(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS, in process_service_attr_rsp()
503 sdp_conn_timer_timeout, p_ccb); in process_service_attr_rsp()
505 sdpu_log_attribute_metrics(p_ccb->device_address, p_ccb->p_db); in process_service_attr_rsp()
506 sdp_disconnect(p_ccb, SDP_SUCCESS); in process_service_attr_rsp()
521 static void process_service_search_attr_rsp(tCONN_CB* p_ccb, uint8_t* p_reply, in process_service_search_attr_rsp() argument
534 sdp_disconnect(p_ccb, SDP_INVALID_PDU_SIZE); in process_service_search_attr_rsp()
545 if ((p_ccb->list_len + lists_byte_count) > SDP_MAX_LIST_BYTE_COUNT) { in process_service_search_attr_rsp()
546 sdp_disconnect(p_ccb, SDP_INVALID_PDU_SIZE); in process_service_search_attr_rsp()
552 sdp_disconnect(p_ccb, SDP_INVALID_PDU_SIZE); in process_service_search_attr_rsp()
556 if (p_ccb->rsp_list == NULL) in process_service_search_attr_rsp()
557 p_ccb->rsp_list = (uint8_t*)osi_malloc(SDP_MAX_LIST_BYTE_COUNT); in process_service_search_attr_rsp()
558 memcpy(&p_ccb->rsp_list[p_ccb->list_len], p_reply, lists_byte_count); in process_service_search_attr_rsp()
559 p_ccb->list_len += lists_byte_count; in process_service_search_attr_rsp()
563 sdp_disconnect(p_ccb, SDP_INVALID_CONT_STATE); in process_service_search_attr_rsp()
581 UINT16_TO_BE_STREAM(p, p_ccb->transaction_id); in process_service_search_attr_rsp()
582 p_ccb->transaction_id++; in process_service_search_attr_rsp()
589 p = sdpu_build_uuid_seq(p, p_ccb->p_db->num_uuid_filters, in process_service_search_attr_rsp()
590 p_ccb->p_db->uuid_filters); in process_service_search_attr_rsp()
596 if (p_ccb->p_db->num_attr_filters) in process_service_search_attr_rsp()
597 p = sdpu_build_attrib_seq(p, p_ccb->p_db->attr_filters, in process_service_search_attr_rsp()
598 p_ccb->p_db->num_attr_filters); in process_service_search_attr_rsp()
620 L2CA_DataWrite(p_ccb->connection_id, p_msg); in process_service_search_attr_rsp()
623 alarm_set_on_mloop(p_ccb->sdp_conn_timer, SDP_INACT_TIMEOUT_MS, in process_service_search_attr_rsp()
624 sdp_conn_timer_timeout, p_ccb); in process_service_search_attr_rsp()
634 if (!sdp_copy_raw_data(p_ccb, true)) { in process_service_search_attr_rsp()
636 sdp_disconnect(p_ccb, SDP_ILLEGAL_PARAMETER); in process_service_search_attr_rsp()
641 p = &p_ccb->rsp_list[0]; in process_service_search_attr_rsp()
650 p = sdpu_get_len_from_type(p, p + p_ccb->list_len, type, &seq_len); in process_service_search_attr_rsp()
651 if (p == NULL || (p + seq_len) > (p + p_ccb->list_len)) { in process_service_search_attr_rsp()
653 sdp_disconnect(p_ccb, SDP_ILLEGAL_PARAMETER); in process_service_search_attr_rsp()
656 p_end = &p_ccb->rsp_list[p_ccb->list_len]; in process_service_search_attr_rsp()
659 sdp_disconnect(p_ccb, SDP_INVALID_CONT_STATE); in process_service_search_attr_rsp()
664 p = save_attr_seq(p_ccb, p, &p_ccb->rsp_list[p_ccb->list_len]); in process_service_search_attr_rsp()
666 sdp_disconnect(p_ccb, SDP_DB_FULL); in process_service_search_attr_rsp()
672 sdpu_log_attribute_metrics(p_ccb->device_address, p_ccb->p_db); in process_service_search_attr_rsp()
673 sdp_disconnect(p_ccb, SDP_SUCCESS); in process_service_search_attr_rsp()
686 static uint8_t* save_attr_seq(tCONN_CB* p_ccb, uint8_t* p, uint8_t* p_msg_end) { in save_attr_seq() argument
705 p_rec = add_record(p_ccb->p_db, p_ccb->device_address); in save_attr_seq()
729 p = add_attr(p, p_seq_end, p_ccb->p_db, p_rec, attr_id, NULL, 0); in save_attr_seq()