1 /****************************************************************************** 2 * 3 * Copyright 1998-2012 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 #include <string.h> 20 21 #include "bt_target.h" 22 #if (HL_INCLUDED == TRUE) 23 24 #include "bta_hl_int.h" 25 #include "osi/include/osi.h" 26 #include "sdp_api.h" 27 #include "utl.h" 28 29 /******************************************************************************* 30 * 31 * Function bta_hl_fill_sup_feature_list 32 * 33 * Description Fill the supported features from teh SDP record 34 * 35 * Returns true if found, false if not 36 * If found, the passed protocol list element is filled in. 37 * 38 ******************************************************************************/ 39 bool bta_hl_fill_sup_feature_list(const tSDP_DISC_ATTR* p_attr, 40 tBTA_HL_SUP_FEATURE_LIST_ELEM* p_list) { 41 tSDP_DISC_ATTR* p_sattr; 42 uint8_t item_cnt; 43 uint8_t list_cnt = 0; 44 bool status = true; 45 46 for (p_attr = p_attr->attr_value.v.p_sub_attr; p_attr; 47 p_attr = p_attr->p_next_attr) { 48 /* mdep sequence */ 49 if (SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) != DATA_ELE_SEQ_DESC_TYPE) { 50 return (false); 51 } 52 53 item_cnt = 0; 54 55 for (p_sattr = p_attr->attr_value.v.p_sub_attr; p_sattr && (item_cnt < 4); 56 p_sattr = p_sattr->p_next_attr) { 57 /* for each mdep list */ 58 59 p_list->list_elem[list_cnt].p_mdep_desp = NULL; 60 switch (item_cnt) { 61 case 0: 62 p_list->list_elem[list_cnt].mdep_id = p_sattr->attr_value.v.u8; 63 break; 64 case 1: 65 p_list->list_elem[list_cnt].data_type = p_sattr->attr_value.v.u16; 66 break; 67 case 2: 68 p_list->list_elem[list_cnt].mdep_role = 69 (tBTA_HL_MDEP_ROLE)p_sattr->attr_value.v.u8; 70 break; 71 case 3: 72 p_list->list_elem[list_cnt].p_mdep_desp = 73 (char*)p_sattr->attr_value.v.array; 74 break; 75 } 76 77 item_cnt++; 78 } 79 list_cnt++; 80 } 81 p_list->num_elems = list_cnt; 82 return (status); 83 } 84 85 /******************************************************************************* 86 * 87 * Function bta_hl_compose_supported_feature_list 88 * 89 * Description This function is called to compose a data sequence from 90 * the supported feature element list struct pointer 91 * 92 * Returns the length of the data sequence 93 * 94 ******************************************************************************/ 95 int bta_hl_compose_supported_feature_list( 96 uint8_t* p, uint16_t num_elem, 97 const tBTA_HL_SUP_FEATURE_ELEM* p_elem_list) { 98 uint16_t xx, str_len, seq_len; 99 uint8_t* p_head = p; 100 101 for (xx = 0; xx < num_elem; xx++, p_elem_list++) { 102 UINT8_TO_BE_STREAM(p, (DATA_ELE_SEQ_DESC_TYPE << 3) | SIZE_IN_NEXT_BYTE); 103 seq_len = 7; 104 str_len = 0; 105 if (p_elem_list->p_mdep_desp) { 106 str_len = strlen(p_elem_list->p_mdep_desp) + 1; 107 seq_len += str_len + 2; /* todo add a # symbol for 2 */ 108 } 109 110 *p++ = (uint8_t)seq_len; 111 112 UINT8_TO_BE_STREAM(p, (UINT_DESC_TYPE << 3) | SIZE_ONE_BYTE); 113 UINT8_TO_BE_STREAM(p, p_elem_list->mdep_id); 114 UINT8_TO_BE_STREAM(p, (UINT_DESC_TYPE << 3) | SIZE_TWO_BYTES); 115 UINT16_TO_BE_STREAM(p, p_elem_list->data_type); 116 UINT8_TO_BE_STREAM(p, (UINT_DESC_TYPE << 3) | SIZE_ONE_BYTE); 117 UINT8_TO_BE_STREAM(p, p_elem_list->mdep_role); 118 119 if (str_len) { 120 UINT8_TO_BE_STREAM(p, (TEXT_STR_DESC_TYPE << 3) | SIZE_IN_NEXT_BYTE); 121 UINT8_TO_BE_STREAM(p, str_len); 122 ARRAY_TO_BE_STREAM(p, p_elem_list->p_mdep_desp, str_len); 123 } 124 } 125 126 return (p - p_head); 127 } 128 129 /******************************************************************************* 130 * 131 * Function bta_hl_add_sup_feature_list 132 * 133 * Description This function is called to add a protocol descriptor list to 134 * a record. This would be through the SDP database maintenance 135 * API. If the protocol list already exists in the record, it 136 * is replaced with the new list. 137 * 138 * Returns true if added OK, else false 139 * 140 ******************************************************************************/ 141 bool bta_hl_add_sup_feature_list(uint32_t handle, uint16_t num_elem, 142 const tBTA_HL_SUP_FEATURE_ELEM* p_elem_list) { 143 int offset; 144 bool result; 145 uint8_t* p_buf = (uint8_t*)osi_malloc(BTA_HL_SUP_FEATURE_SDP_BUF_SIZE); 146 147 offset = bta_hl_compose_supported_feature_list(p_buf, num_elem, p_elem_list); 148 result = SDP_AddAttribute(handle, ATTR_ID_HDP_SUP_FEAT_LIST, 149 DATA_ELE_SEQ_DESC_TYPE, (uint32_t)offset, p_buf); 150 osi_free(p_buf); 151 152 return result; 153 } 154 155 /***************************************************************************** 156 * 157 * Function: bta_hl_sdp_update 158 * 159 * Purpose: Register an HDP application with SDP 160 * 161 * Parameters: 162 * 163 * Returns: void 164 * 165 ****************************************************************************/ 166 tBTA_HL_STATUS bta_hl_sdp_update(UNUSED_ATTR uint8_t app_id) { 167 uint16_t svc_class_id_list[BTA_HL_NUM_SVC_ELEMS]; 168 tSDP_PROTOCOL_ELEM proto_elem_list[BTA_HL_NUM_PROTO_ELEMS]; 169 tSDP_PROTO_LIST_ELEM add_proto_list; 170 tBTA_HL_SUP_FEATURE_LIST_ELEM sup_feature_list; 171 uint16_t browse_list[] = {UUID_SERVCLASS_PUBLIC_BROWSE_GROUP}; 172 uint8_t i, j, cnt, mdep_id, mdep_role; 173 uint8_t data_exchange_spec = BTA_HL_SDP_IEEE_11073_20601; 174 uint8_t mcap_sup_proc = BTA_HL_MCAP_SUP_PROC_MASK; 175 uint16_t profile_uuid = UUID_SERVCLASS_HDP_PROFILE; 176 uint16_t version = BTA_HL_VERSION; 177 uint8_t num_services = 1; 178 tBTA_HL_APP_CB* p_cb = BTA_HL_GET_APP_CB_PTR(0); 179 bool result = true; 180 tBTA_HL_STATUS status = BTA_HL_STATUS_OK; 181 182 if ((p_cb->sup_feature.app_role_mask == BTA_HL_MDEP_ROLE_MASK_SOURCE) && 183 (!p_cb->sup_feature.advertize_source_sdp)) { 184 return BTA_HL_STATUS_OK; 185 } 186 187 num_services = 1; 188 svc_class_id_list[0] = UUID_SERVCLASS_HDP_SOURCE; 189 if (p_cb->sup_feature.app_role_mask == BTA_HL_MDEP_ROLE_MASK_SINK) { 190 svc_class_id_list[0] = UUID_SERVCLASS_HDP_SINK; 191 } else { 192 if (p_cb->sup_feature.app_role_mask != BTA_HL_MDEP_ROLE_MASK_SOURCE) { 193 /* dual role */ 194 num_services = 2; 195 svc_class_id_list[1] = UUID_SERVCLASS_HDP_SINK; 196 } 197 } 198 result &= SDP_AddServiceClassIdList(p_cb->sdp_handle, num_services, 199 svc_class_id_list); 200 201 if (result) { 202 /* add the protocol element sequence */ 203 proto_elem_list[0].protocol_uuid = UUID_PROTOCOL_L2CAP; 204 proto_elem_list[0].num_params = 1; 205 proto_elem_list[0].params[0] = p_cb->ctrl_psm; 206 proto_elem_list[1].protocol_uuid = UUID_PROTOCOL_MCAP_CTRL; 207 proto_elem_list[1].num_params = 1; 208 proto_elem_list[1].params[0] = version; 209 result &= SDP_AddProtocolList(p_cb->sdp_handle, BTA_HL_NUM_PROTO_ELEMS, 210 proto_elem_list); 211 212 result &= 213 SDP_AddProfileDescriptorList(p_cb->sdp_handle, profile_uuid, version); 214 } 215 216 if (result) { 217 add_proto_list.num_elems = BTA_HL_NUM_ADD_PROTO_ELEMS; 218 add_proto_list.list_elem[0].protocol_uuid = UUID_PROTOCOL_L2CAP; 219 add_proto_list.list_elem[0].num_params = 1; 220 add_proto_list.list_elem[0].params[0] = p_cb->data_psm; 221 add_proto_list.list_elem[1].protocol_uuid = UUID_PROTOCOL_MCAP_DATA; 222 add_proto_list.list_elem[1].num_params = 0; 223 result &= SDP_AddAdditionProtoLists( 224 p_cb->sdp_handle, BTA_HL_NUM_ADD_PROTO_LISTS, &add_proto_list); 225 } 226 227 if (result) { 228 if (p_cb->srv_name[0]) { 229 result &= SDP_AddAttribute( 230 p_cb->sdp_handle, (uint16_t)ATTR_ID_SERVICE_NAME, 231 (uint8_t)TEXT_STR_DESC_TYPE, (uint32_t)(strlen(p_cb->srv_name) + 1), 232 (uint8_t*)p_cb->srv_name); 233 } /* end of setting optional service name */ 234 } 235 236 if (result) { 237 if (p_cb->srv_desp[0]) { 238 result &= SDP_AddAttribute( 239 p_cb->sdp_handle, (uint16_t)ATTR_ID_SERVICE_DESCRIPTION, 240 (uint8_t)TEXT_STR_DESC_TYPE, (uint32_t)(strlen(p_cb->srv_desp) + 1), 241 (uint8_t*)p_cb->srv_desp); 242 243 } /* end of setting optional service description */ 244 } 245 246 if (result) { 247 if (p_cb->provider_name[0]) { 248 result &= 249 SDP_AddAttribute(p_cb->sdp_handle, (uint16_t)ATTR_ID_PROVIDER_NAME, 250 (uint8_t)TEXT_STR_DESC_TYPE, 251 (uint32_t)(strlen(p_cb->provider_name) + 1), 252 (uint8_t*)p_cb->provider_name); 253 } /* end of setting optional provider name */ 254 } 255 256 /* add supported feture list */ 257 258 if (result) { 259 cnt = 0; 260 for (i = 1; i < BTA_HL_NUM_MDEPS; i++) { 261 if (p_cb->sup_feature.mdep[i].mdep_id) { 262 mdep_id = (uint8_t)p_cb->sup_feature.mdep[i].mdep_id; 263 mdep_role = (uint8_t)p_cb->sup_feature.mdep[i].mdep_cfg.mdep_role; 264 265 APPL_TRACE_DEBUG( 266 "num_of_mdep_data_types %d ", 267 p_cb->sup_feature.mdep[i].mdep_cfg.num_of_mdep_data_types); 268 for (j = 0; 269 j < p_cb->sup_feature.mdep[i].mdep_cfg.num_of_mdep_data_types; 270 j++) { 271 sup_feature_list.list_elem[cnt].mdep_id = mdep_id; 272 sup_feature_list.list_elem[cnt].mdep_role = mdep_role; 273 sup_feature_list.list_elem[cnt].data_type = 274 p_cb->sup_feature.mdep[i].mdep_cfg.data_cfg[j].data_type; 275 if (p_cb->sup_feature.mdep[i].mdep_cfg.data_cfg[j].desp[0] != '\0') { 276 sup_feature_list.list_elem[cnt].p_mdep_desp = 277 p_cb->sup_feature.mdep[i].mdep_cfg.data_cfg[j].desp; 278 } else { 279 sup_feature_list.list_elem[cnt].p_mdep_desp = NULL; 280 } 281 282 cnt++; 283 if (cnt == BTA_HL_NUM_SUP_FEATURE_ELEMS) { 284 result = false; 285 break; 286 } 287 } 288 } 289 } 290 sup_feature_list.num_elems = cnt; 291 result &= bta_hl_add_sup_feature_list(p_cb->sdp_handle, 292 sup_feature_list.num_elems, 293 sup_feature_list.list_elem); 294 } 295 if (result) { 296 result &= SDP_AddAttribute(p_cb->sdp_handle, ATTR_ID_HDP_DATA_EXCH_SPEC, 297 UINT_DESC_TYPE, (uint32_t)1, 298 (uint8_t*)&data_exchange_spec); 299 } 300 301 if (result) { 302 result &= 303 SDP_AddAttribute(p_cb->sdp_handle, ATTR_ID_HDP_MCAP_SUP_PROC, 304 UINT_DESC_TYPE, (uint32_t)1, (uint8_t*)&mcap_sup_proc); 305 } 306 307 if (result) { 308 result &= SDP_AddUuidSequence(p_cb->sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 309 1, browse_list); 310 } 311 312 if (result) { 313 for (i = 0; i < num_services; i++) { 314 bta_sys_add_uuid(svc_class_id_list[i]); 315 APPL_TRACE_DEBUG("dbg bta_sys_add_uuid i=%d uuid=0x%x", i, 316 svc_class_id_list[i]); // todo 317 } 318 } else { 319 if (p_cb->sdp_handle) { 320 SDP_DeleteRecord(p_cb->sdp_handle); 321 p_cb->sdp_handle = 0; 322 } 323 status = BTA_HL_STATUS_SDP_FAIL; 324 } 325 #if (BTA_HL_DEBUG == TRUE) 326 APPL_TRACE_DEBUG("bta_hl_sdp_update status=%s", bta_hl_status_code(status)); 327 #endif 328 return status; 329 } 330 331 /***************************************************************************** 332 * 333 * Function: bta_hl_sdp_register 334 * 335 * Purpose: Register an HDP application with SDP 336 * 337 * Parameters: p_cb - Pointer to MA instance control block 338 * p_service_name - MA server name 339 * inst_id - MAS instance ID 340 * msg_type - Supported message type(s) 341 * 342 * 343 * Returns: void 344 * 345 ****************************************************************************/ 346 tBTA_HL_STATUS bta_hl_sdp_register(uint8_t app_idx) { 347 uint16_t svc_class_id_list[BTA_HL_NUM_SVC_ELEMS]; 348 tSDP_PROTOCOL_ELEM proto_elem_list[BTA_HL_NUM_PROTO_ELEMS]; 349 tSDP_PROTO_LIST_ELEM add_proto_list; 350 tBTA_HL_SUP_FEATURE_LIST_ELEM sup_feature_list; 351 uint16_t browse_list[] = {UUID_SERVCLASS_PUBLIC_BROWSE_GROUP}; 352 uint8_t i, j, cnt, mdep_id, mdep_role; 353 uint8_t data_exchange_spec = BTA_HL_SDP_IEEE_11073_20601; 354 uint8_t mcap_sup_proc = BTA_HL_MCAP_SUP_PROC_MASK; 355 uint16_t profile_uuid = UUID_SERVCLASS_HDP_PROFILE; 356 uint16_t version = BTA_HL_VERSION; 357 uint8_t num_services = 1; 358 tBTA_HL_APP_CB* p_cb = BTA_HL_GET_APP_CB_PTR(app_idx); 359 bool result = true; 360 tBTA_HL_STATUS status = BTA_HL_STATUS_OK; 361 362 #if (BTA_HL_DEBUG == TRUE) 363 APPL_TRACE_DEBUG("bta_hl_sdp_register app_idx=%d", app_idx); 364 #endif 365 366 if ((p_cb->sup_feature.app_role_mask == BTA_HL_MDEP_ROLE_MASK_SOURCE) && 367 (!p_cb->sup_feature.advertize_source_sdp)) { 368 return BTA_HL_STATUS_OK; 369 } 370 371 p_cb->sdp_handle = SDP_CreateRecord(); 372 if (p_cb->sdp_handle == 0) { 373 return BTA_HL_STATUS_SDP_NO_RESOURCE; 374 } 375 376 num_services = 1; 377 svc_class_id_list[0] = UUID_SERVCLASS_HDP_SOURCE; 378 if (p_cb->sup_feature.app_role_mask == BTA_HL_MDEP_ROLE_MASK_SINK) { 379 svc_class_id_list[0] = UUID_SERVCLASS_HDP_SINK; 380 } else { 381 if (p_cb->sup_feature.app_role_mask != BTA_HL_MDEP_ROLE_MASK_SOURCE) { 382 /* dual role */ 383 num_services = 2; 384 svc_class_id_list[1] = UUID_SERVCLASS_HDP_SINK; 385 } 386 } 387 result &= SDP_AddServiceClassIdList(p_cb->sdp_handle, num_services, 388 svc_class_id_list); 389 390 if (result) { 391 /* add the protocol element sequence */ 392 proto_elem_list[0].protocol_uuid = UUID_PROTOCOL_L2CAP; 393 proto_elem_list[0].num_params = 1; 394 proto_elem_list[0].params[0] = p_cb->ctrl_psm; 395 proto_elem_list[1].protocol_uuid = UUID_PROTOCOL_MCAP_CTRL; 396 proto_elem_list[1].num_params = 1; 397 proto_elem_list[1].params[0] = version; 398 result &= SDP_AddProtocolList(p_cb->sdp_handle, BTA_HL_NUM_PROTO_ELEMS, 399 proto_elem_list); 400 401 result &= 402 SDP_AddProfileDescriptorList(p_cb->sdp_handle, profile_uuid, version); 403 } 404 405 if (result) { 406 add_proto_list.num_elems = BTA_HL_NUM_ADD_PROTO_ELEMS; 407 add_proto_list.list_elem[0].protocol_uuid = UUID_PROTOCOL_L2CAP; 408 add_proto_list.list_elem[0].num_params = 1; 409 add_proto_list.list_elem[0].params[0] = p_cb->data_psm; 410 add_proto_list.list_elem[1].protocol_uuid = UUID_PROTOCOL_MCAP_DATA; 411 add_proto_list.list_elem[1].num_params = 0; 412 result &= SDP_AddAdditionProtoLists( 413 p_cb->sdp_handle, BTA_HL_NUM_ADD_PROTO_LISTS, &add_proto_list); 414 } 415 416 if (result) { 417 if (p_cb->srv_name[0]) { 418 result &= SDP_AddAttribute( 419 p_cb->sdp_handle, (uint16_t)ATTR_ID_SERVICE_NAME, 420 (uint8_t)TEXT_STR_DESC_TYPE, (uint32_t)(strlen(p_cb->srv_name) + 1), 421 (uint8_t*)p_cb->srv_name); 422 } /* end of setting optional service name */ 423 } 424 425 if (result) { 426 if (p_cb->srv_desp[0]) { 427 result &= SDP_AddAttribute( 428 p_cb->sdp_handle, (uint16_t)ATTR_ID_SERVICE_DESCRIPTION, 429 (uint8_t)TEXT_STR_DESC_TYPE, (uint32_t)(strlen(p_cb->srv_desp) + 1), 430 (uint8_t*)p_cb->srv_desp); 431 432 } /* end of setting optional service description */ 433 } 434 435 if (result) { 436 if (p_cb->provider_name[0]) { 437 result &= 438 SDP_AddAttribute(p_cb->sdp_handle, (uint16_t)ATTR_ID_PROVIDER_NAME, 439 (uint8_t)TEXT_STR_DESC_TYPE, 440 (uint32_t)(strlen(p_cb->provider_name) + 1), 441 (uint8_t*)p_cb->provider_name); 442 } /* end of setting optional provider name */ 443 } 444 445 /* add supported feture list */ 446 447 if (result) { 448 cnt = 0; 449 for (i = 1; i <= p_cb->sup_feature.num_of_mdeps; i++) { 450 mdep_id = (uint8_t)p_cb->sup_feature.mdep[i].mdep_id; 451 mdep_role = (uint8_t)p_cb->sup_feature.mdep[i].mdep_cfg.mdep_role; 452 453 for (j = 0; j < p_cb->sup_feature.mdep[i].mdep_cfg.num_of_mdep_data_types; 454 j++) { 455 sup_feature_list.list_elem[cnt].mdep_id = mdep_id; 456 sup_feature_list.list_elem[cnt].mdep_role = mdep_role; 457 sup_feature_list.list_elem[cnt].data_type = 458 p_cb->sup_feature.mdep[i].mdep_cfg.data_cfg[j].data_type; 459 if (p_cb->sup_feature.mdep[i].mdep_cfg.data_cfg[j].desp[0] != '\0') { 460 sup_feature_list.list_elem[cnt].p_mdep_desp = 461 p_cb->sup_feature.mdep[i].mdep_cfg.data_cfg[j].desp; 462 } else { 463 sup_feature_list.list_elem[cnt].p_mdep_desp = NULL; 464 } 465 466 cnt++; 467 if (cnt == BTA_HL_NUM_SUP_FEATURE_ELEMS) { 468 result = false; 469 break; 470 } 471 } 472 } 473 sup_feature_list.num_elems = cnt; 474 result &= bta_hl_add_sup_feature_list(p_cb->sdp_handle, 475 sup_feature_list.num_elems, 476 sup_feature_list.list_elem); 477 } 478 if (result) { 479 result &= SDP_AddAttribute(p_cb->sdp_handle, ATTR_ID_HDP_DATA_EXCH_SPEC, 480 UINT_DESC_TYPE, (uint32_t)1, 481 (uint8_t*)&data_exchange_spec); 482 } 483 484 if (result) { 485 result &= 486 SDP_AddAttribute(p_cb->sdp_handle, ATTR_ID_HDP_MCAP_SUP_PROC, 487 UINT_DESC_TYPE, (uint32_t)1, (uint8_t*)&mcap_sup_proc); 488 } 489 490 if (result) { 491 result &= SDP_AddUuidSequence(p_cb->sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 492 1, browse_list); 493 } 494 495 if (result) { 496 for (i = 0; i < num_services; i++) { 497 bta_sys_add_uuid(svc_class_id_list[i]); 498 APPL_TRACE_DEBUG("dbg bta_sys_add_uuid i=%d uuid=0x%x", i, 499 svc_class_id_list[i]); // todo 500 } 501 } else { 502 if (p_cb->sdp_handle) { 503 SDP_DeleteRecord(p_cb->sdp_handle); 504 p_cb->sdp_handle = 0; 505 } 506 status = BTA_HL_STATUS_SDP_FAIL; 507 } 508 #if (BTA_HL_DEBUG == TRUE) 509 APPL_TRACE_DEBUG("bta_hl_sdp_register status=%s", bta_hl_status_code(status)); 510 #endif 511 return status; 512 } 513 514 /******************************************************************************* 515 * 516 * Function bta_hl_find_sink_or_src_srv_class_in_db 517 * 518 * Description This function queries an SDP database for either a HDP Sink 519 * or Source service class ID. 520 * If the p_start_rec pointer is NULL, it looks from the 521 * beginning of the database, else it continues from the next 522 * record after p_start_rec. 523 * 524 * Returns Pointer to record containing service class, or NULL 525 * 526 ******************************************************************************/ 527 tSDP_DISC_REC* bta_hl_find_sink_or_src_srv_class_in_db( 528 const tSDP_DISCOVERY_DB* p_db, const tSDP_DISC_REC* p_start_rec) { 529 tSDP_DISC_REC* p_rec; 530 tSDP_DISC_ATTR *p_attr, *p_sattr; 531 532 /* Must have a valid database */ 533 if (p_db == NULL) return (NULL); 534 535 if (!p_start_rec) { 536 p_rec = p_db->p_first_rec; 537 } else { 538 p_rec = p_start_rec->p_next_rec; 539 } 540 541 while (p_rec) { 542 p_attr = p_rec->p_first_attr; 543 while (p_attr) { 544 if ((p_attr->attr_id == ATTR_ID_SERVICE_CLASS_ID_LIST) && 545 (SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) == 546 DATA_ELE_SEQ_DESC_TYPE)) { 547 for (p_sattr = p_attr->attr_value.v.p_sub_attr; p_sattr; 548 p_sattr = p_sattr->p_next_attr) { 549 if ((SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UUID_DESC_TYPE) && 550 (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == 2) && 551 ((p_sattr->attr_value.v.u16 == UUID_SERVCLASS_HDP_SINK) || 552 (p_sattr->attr_value.v.u16 == UUID_SERVCLASS_HDP_SOURCE))) { 553 return (p_rec); 554 } 555 } 556 break; 557 } 558 559 p_attr = p_attr->p_next_attr; 560 } 561 562 p_rec = p_rec->p_next_rec; 563 } 564 /* If here, no matching UUID found */ 565 566 #if (BTA_HL_DEBUG == TRUE) 567 APPL_TRACE_DEBUG("bta_hl_find_sink_or_src_srv_class_in_db failed"); 568 #endif 569 570 return (NULL); 571 } 572 #endif /* HL_INCLUDED */ 573