1 /******************************************************************************
2 *
3 * Copyright 1999-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 /******************************************************************************
20 *
21 * this file contains SDP interface functions
22 *
23 ******************************************************************************/
24
25 #define LOG_TAG "sdp_api"
26
27 #include "stack/include/sdp_api.h"
28
29 #include <bluetooth/log.h>
30 #include <string.h>
31
32 #include <cstdint>
33
34 #include "internal_include/bt_target.h"
35 #include "os/log.h"
36 #include "stack/include/bt_types.h"
37 #include "stack/include/bt_uuid16.h"
38 #include "stack/include/sdp_api.h"
39 #include "stack/include/sdpdefs.h"
40 #include "stack/sdp/internal/sdp_api.h"
41 #include "stack/sdp/sdpint.h"
42 #include "types/bluetooth/uuid.h"
43 #include "types/raw_address.h"
44
45 using bluetooth::Uuid;
46 using namespace bluetooth;
47
48 /*******************************************************************************
49 *
50 * Function SDP_InitDiscoveryDb
51 *
52 * Description This function is called to initialize a discovery database.
53 *
54 * Parameters: p_db - (input) address of an area of memory where the
55 * discovery database is managed.
56 * len - (input) size (in bytes) of the memory
57 * NOTE: This must be larger than
58 * sizeof(tSDP_DISCOVERY_DB)
59 * num_uuid - (input) number of UUID filters applied
60 * p_uuid_list - (input) list of UUID filters
61 * num_attr - (input) number of attribute filters applied
62 * p_attr_list - (input) list of attribute filters
63 *
64 *
65 * Returns bool
66 * true if successful
67 * false if one or more parameters are bad
68 *
69 ******************************************************************************/
SDP_InitDiscoveryDb(tSDP_DISCOVERY_DB * p_db,uint32_t len,uint16_t num_uuid,const Uuid * p_uuid_list,uint16_t num_attr,const uint16_t * p_attr_list)70 bool SDP_InitDiscoveryDb(tSDP_DISCOVERY_DB* p_db, uint32_t len,
71 uint16_t num_uuid, const Uuid* p_uuid_list,
72 uint16_t num_attr, const uint16_t* p_attr_list) {
73 uint16_t xx;
74
75 /* verify the parameters */
76 if (p_db == NULL || (sizeof(tSDP_DISCOVERY_DB) > len) ||
77 num_attr > SDP_MAX_ATTR_FILTERS || num_uuid > SDP_MAX_UUID_FILTERS) {
78 log::error(
79 "SDP_InitDiscoveryDb Illegal param: p_db {}, len {}, num_uuid {}, "
80 "num_attr {}",
81 fmt::ptr(p_db), len, num_uuid, num_attr);
82
83 return (false);
84 }
85
86 memset(p_db, 0, (size_t)len);
87
88 p_db->mem_size = len - sizeof(tSDP_DISCOVERY_DB);
89 p_db->mem_free = p_db->mem_size;
90 p_db->p_first_rec = NULL;
91 p_db->p_free_mem = (uint8_t*)(p_db + 1);
92
93 for (xx = 0; xx < num_uuid; xx++) p_db->uuid_filters[xx] = *p_uuid_list++;
94
95 p_db->num_uuid_filters = num_uuid;
96
97 for (xx = 0; xx < num_attr; xx++) p_db->attr_filters[xx] = *p_attr_list++;
98
99 /* sort attributes */
100 sdpu_sort_attr_list(num_attr, p_db);
101
102 p_db->num_attr_filters = num_attr;
103 return (true);
104 }
105
106 /*******************************************************************************
107 *
108 * Function SDP_CancelServiceSearch
109 *
110 * Description This function cancels an active query to an SDP server.
111 *
112 * Returns true if discovery cancelled, false if a matching activity is
113 * not found.
114 *
115 ******************************************************************************/
SDP_CancelServiceSearch(const tSDP_DISCOVERY_DB * p_db)116 bool SDP_CancelServiceSearch(const tSDP_DISCOVERY_DB* p_db) {
117 tCONN_CB* p_ccb = sdpu_find_ccb_by_db(p_db);
118 if (!p_ccb) return (false);
119
120 sdp_disconnect(p_ccb, SDP_CANCEL);
121 p_ccb->disc_state = SDP_DISC_WAIT_CANCEL;
122 return (true);
123 }
124
125 /*******************************************************************************
126 *
127 * Function SDP_ServiceSearchRequest
128 *
129 * Description This function queries an SDP server for information.
130 *
131 * Returns true if discovery started, false if failed.
132 *
133 ******************************************************************************/
SDP_ServiceSearchRequest(const RawAddress & bd_addr,tSDP_DISCOVERY_DB * p_db,tSDP_DISC_CMPL_CB * p_cb)134 bool SDP_ServiceSearchRequest(const RawAddress& bd_addr,
135 tSDP_DISCOVERY_DB* p_db,
136 tSDP_DISC_CMPL_CB* p_cb) {
137 tCONN_CB* p_ccb;
138
139 /* Specific BD address */
140 p_ccb = sdp_conn_originate(bd_addr);
141
142 if (!p_ccb) return (false);
143
144 p_ccb->disc_state = SDP_DISC_WAIT_CONN;
145 p_ccb->p_db = p_db;
146 p_ccb->p_cb = p_cb;
147
148 return (true);
149 }
150
151 /*******************************************************************************
152 *
153 * Function SDP_ServiceSearchAttributeRequest
154 *
155 * Description This function queries an SDP server for information.
156 *
157 * The difference between this API function and the function
158 * SDP_ServiceSearchRequest is that this one does a
159 * combined ServiceSearchAttributeRequest SDP function.
160 * (This is for Unplug Testing)
161 *
162 * Returns true if discovery started, false if failed.
163 *
164 ******************************************************************************/
SDP_ServiceSearchAttributeRequest(const RawAddress & bd_addr,tSDP_DISCOVERY_DB * p_db,tSDP_DISC_CMPL_CB * p_cb)165 bool SDP_ServiceSearchAttributeRequest(const RawAddress& bd_addr,
166 tSDP_DISCOVERY_DB* p_db,
167 tSDP_DISC_CMPL_CB* p_cb) {
168 tCONN_CB* p_ccb;
169
170 /* Specific BD address */
171 p_ccb = sdp_conn_originate(bd_addr);
172
173 if (!p_ccb) return (false);
174
175 p_ccb->disc_state = SDP_DISC_WAIT_CONN;
176 p_ccb->p_db = p_db;
177 p_ccb->p_cb = p_cb;
178
179 p_ccb->is_attr_search = true;
180
181 return (true);
182 }
183 /*******************************************************************************
184 *
185 * Function SDP_ServiceSearchAttributeRequest2
186 *
187 * Description This function queries an SDP server for information.
188 *
189 * The difference between this API function and the function
190 * SDP_ServiceSearchRequest is that this one does a
191 * combined ServiceSearchAttributeRequest SDP function.
192 * (This is for Unplug Testing)
193 *
194 * Returns true if discovery started, false if failed.
195 *
196 ******************************************************************************/
SDP_ServiceSearchAttributeRequest2(const RawAddress & bd_addr,tSDP_DISCOVERY_DB * p_db,base::RepeatingCallback<tSDP_DISC_CMPL_CB> complete_callback)197 bool SDP_ServiceSearchAttributeRequest2(
198 const RawAddress& bd_addr, tSDP_DISCOVERY_DB* p_db,
199 base::RepeatingCallback<tSDP_DISC_CMPL_CB> complete_callback) {
200 tCONN_CB* p_ccb;
201
202 /* Specific BD address */
203 p_ccb = sdp_conn_originate(bd_addr);
204
205 if (!p_ccb) return (false);
206
207 p_ccb->disc_state = SDP_DISC_WAIT_CONN;
208 p_ccb->p_db = p_db;
209 p_ccb->complete_callback = std::move(complete_callback);
210
211 p_ccb->is_attr_search = true;
212
213 return (true);
214 }
215
216 /*******************************************************************************
217 *
218 * Function SDP_FindAttributeInRec
219 *
220 * Description This function searches an SDP discovery record for a
221 * specific attribute.
222 *
223 * Returns Pointer to matching attribute entry, or NULL
224 *
225 ******************************************************************************/
SDP_FindAttributeInRec(const tSDP_DISC_REC * p_rec,uint16_t attr_id)226 tSDP_DISC_ATTR* SDP_FindAttributeInRec(const tSDP_DISC_REC* p_rec,
227 uint16_t attr_id) {
228 tSDP_DISC_ATTR* p_attr;
229
230 p_attr = p_rec->p_first_attr;
231 while (p_attr) {
232 if (p_attr->attr_id == attr_id) return (p_attr);
233
234 p_attr = p_attr->p_next_attr;
235 }
236
237 /* If here, no matching attribute found */
238 return (NULL);
239 }
240
241 /*******************************************************************************
242 *
243 * Function SDP_FindServiceUUIDInRec
244 *
245 * Description This function is called to read the service UUID within a
246 * record if there is any.
247 *
248 * Parameters: p_rec - pointer to a SDP record.
249 * p_uuid - output parameter to save the UUID found.
250 *
251 * Returns true if found, otherwise false.
252 *
253 ******************************************************************************/
SDP_FindServiceUUIDInRec(const tSDP_DISC_REC * p_rec,Uuid * p_uuid)254 bool SDP_FindServiceUUIDInRec(const tSDP_DISC_REC* p_rec, Uuid* p_uuid) {
255 tSDP_DISC_ATTR *p_attr, *p_sattr, *p_extra_sattr;
256
257 p_attr = p_rec->p_first_attr;
258
259 while (p_attr) {
260 if ((p_attr->attr_id == ATTR_ID_SERVICE_CLASS_ID_LIST) &&
261 (SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) == DATA_ELE_SEQ_DESC_TYPE)) {
262 for (p_sattr = p_attr->attr_value.v.p_sub_attr; p_sattr;
263 p_sattr = p_sattr->p_next_attr) {
264 if (SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UUID_DESC_TYPE) {
265 if (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == Uuid::kNumBytes16) {
266 *p_uuid = Uuid::From16Bit(p_sattr->attr_value.v.u16);
267 } else if (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) ==
268 Uuid::kNumBytes128) {
269 *p_uuid = Uuid::From128BitBE(p_sattr->attr_value.v.array);
270 } else if (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) ==
271 Uuid::kNumBytes32) {
272 *p_uuid = Uuid::From32Bit(p_sattr->attr_value.v.u32);
273 }
274
275 return (true);
276 }
277
278 /* Checking for Toyota G Block Car Kit:
279 ** This car kit puts an extra data element sequence
280 ** where the UUID is suppose to be!!!
281 */
282 else {
283 if (SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) ==
284 DATA_ELE_SEQ_DESC_TYPE) {
285 /* Look through data element sequence until no more UUIDs */
286 for (p_extra_sattr = p_sattr->attr_value.v.p_sub_attr;
287 p_extra_sattr; p_extra_sattr = p_extra_sattr->p_next_attr) {
288 /* Increment past this to see if the next attribut is UUID */
289 if ((SDP_DISC_ATTR_TYPE(p_extra_sattr->attr_len_type) ==
290 UUID_DESC_TYPE)
291 /* only support 16 bits UUID for now */
292 && (SDP_DISC_ATTR_LEN(p_extra_sattr->attr_len_type) == 2)) {
293 *p_uuid = Uuid::From16Bit(p_extra_sattr->attr_value.v.u16);
294 return (true);
295 }
296 }
297 }
298 }
299 }
300 break;
301 } else if (p_attr->attr_id == ATTR_ID_SERVICE_ID) {
302 if ((SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) == UUID_DESC_TYPE)
303 /* only support 16 bits UUID for now */
304 && (SDP_DISC_ATTR_LEN(p_attr->attr_len_type) == 2)) {
305 *p_uuid = Uuid::From16Bit(p_attr->attr_value.v.u16);
306 return (true);
307 }
308 }
309 p_attr = p_attr->p_next_attr;
310 }
311 return false;
312 }
313
314 /*******************************************************************************
315 *
316 * Function SDP_FindServiceUUIDInRec_128bit
317 *
318 * Description This function is called to read the 128-bit service UUID
319 * within a record if there is any.
320 *
321 * Parameters: p_rec - pointer to a SDP record.
322 * p_uuid - output parameter to save the UUID found.
323 *
324 * Returns true if found, otherwise false.
325 *
326 ******************************************************************************/
SDP_FindServiceUUIDInRec_128bit(const tSDP_DISC_REC * p_rec,Uuid * p_uuid)327 bool SDP_FindServiceUUIDInRec_128bit(const tSDP_DISC_REC* p_rec, Uuid* p_uuid) {
328 tSDP_DISC_ATTR* p_attr = p_rec->p_first_attr;
329 while (p_attr) {
330 if ((p_attr->attr_id == ATTR_ID_SERVICE_CLASS_ID_LIST) &&
331 (SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) == DATA_ELE_SEQ_DESC_TYPE)) {
332 tSDP_DISC_ATTR* p_sattr = p_attr->attr_value.v.p_sub_attr;
333 while (p_sattr) {
334 if (SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UUID_DESC_TYPE) {
335 /* only support 128 bits UUID for now */
336 if (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == 16) {
337 *p_uuid = Uuid::From128BitBE(p_sattr->attr_value.v.array);
338 }
339 return (true);
340 }
341
342 p_sattr = p_sattr->p_next_attr;
343 }
344 break;
345 } else if (p_attr->attr_id == ATTR_ID_SERVICE_ID) {
346 if ((SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) == UUID_DESC_TYPE)
347 /* only support 128 bits UUID for now */
348 && (SDP_DISC_ATTR_LEN(p_attr->attr_len_type) == 16)) {
349 *p_uuid = Uuid::From128BitBE(p_attr->attr_value.v.array);
350 return (true);
351 }
352 }
353 p_attr = p_attr->p_next_attr;
354 }
355 return false;
356 }
357
358 /*******************************************************************************
359 *
360 * Function SDP_FindServiceInDb
361 *
362 * Description This function queries an SDP database for a specific
363 * service. If the p_start_rec pointer is NULL, it looks from
364 * the beginning of the database, else it continues from the
365 * next record after p_start_rec.
366 *
367 * Returns Pointer to record containing service class, or NULL
368 *
369 ******************************************************************************/
SDP_FindServiceInDb(const tSDP_DISCOVERY_DB * p_db,uint16_t service_uuid,tSDP_DISC_REC * p_start_rec)370 tSDP_DISC_REC* SDP_FindServiceInDb(const tSDP_DISCOVERY_DB* p_db,
371 uint16_t service_uuid,
372 tSDP_DISC_REC* p_start_rec) {
373 tSDP_DISC_REC* p_rec;
374 tSDP_DISC_ATTR *p_attr, *p_sattr, *p_extra_sattr;
375
376 /* Must have a valid database */
377 if (p_db == NULL) return (NULL);
378
379 if (!p_start_rec)
380 p_rec = p_db->p_first_rec;
381 else
382 p_rec = p_start_rec->p_next_rec;
383
384 while (p_rec) {
385 p_attr = p_rec->p_first_attr;
386 while (p_attr) {
387 if ((p_attr->attr_id == ATTR_ID_SERVICE_CLASS_ID_LIST) &&
388 (SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) ==
389 DATA_ELE_SEQ_DESC_TYPE)) {
390 for (p_sattr = p_attr->attr_value.v.p_sub_attr; p_sattr;
391 p_sattr = p_sattr->p_next_attr) {
392 if ((SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UUID_DESC_TYPE) &&
393 (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == 2)) {
394 log::verbose(
395 "SDP_FindServiceInDb - p_sattr value = 0x{:x} serviceuuid = "
396 "0x{:x}",
397 p_sattr->attr_value.v.u16, service_uuid);
398 if (service_uuid == UUID_SERVCLASS_HDP_PROFILE) {
399 if ((p_sattr->attr_value.v.u16 == UUID_SERVCLASS_HDP_SOURCE) ||
400 (p_sattr->attr_value.v.u16 == UUID_SERVCLASS_HDP_SINK)) {
401 log::verbose("SDP_FindServiceInDb found HDP source or sink\n");
402 return (p_rec);
403 }
404 }
405 }
406
407 if (SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UUID_DESC_TYPE &&
408 (service_uuid == 0 ||
409 (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == 2 &&
410 p_sattr->attr_value.v.u16 == service_uuid)))
411 /* for a specific uuid, or any one */
412 {
413 return (p_rec);
414 }
415
416 /* Checking for Toyota G Block Car Kit:
417 ** This car kit puts an extra data element sequence
418 ** where the UUID is suppose to be!!!
419 */
420 else {
421 if (SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) ==
422 DATA_ELE_SEQ_DESC_TYPE) {
423 /* Look through data element sequence until no more UUIDs */
424 for (p_extra_sattr = p_sattr->attr_value.v.p_sub_attr;
425 p_extra_sattr; p_extra_sattr = p_extra_sattr->p_next_attr) {
426 /* Increment past this to see if the next attribut is UUID */
427 if ((SDP_DISC_ATTR_TYPE(p_extra_sattr->attr_len_type) ==
428 UUID_DESC_TYPE) &&
429 (SDP_DISC_ATTR_LEN(p_extra_sattr->attr_len_type) == 2)
430 /* for a specific uuid, or any one */
431 && ((p_extra_sattr->attr_value.v.u16 == service_uuid) ||
432 (service_uuid == 0))) {
433 return (p_rec);
434 }
435 }
436 }
437 }
438 }
439 break;
440 } else if (p_attr->attr_id == ATTR_ID_SERVICE_ID) {
441 if ((SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) == UUID_DESC_TYPE) &&
442 (SDP_DISC_ATTR_LEN(p_attr->attr_len_type) == 2)
443 /* find a specific UUID or anyone */
444 &&
445 ((p_attr->attr_value.v.u16 == service_uuid) || service_uuid == 0))
446 return (p_rec);
447 }
448
449 p_attr = p_attr->p_next_attr;
450 }
451
452 p_rec = p_rec->p_next_rec;
453 }
454 /* If here, no matching UUID found */
455 return (NULL);
456 }
457
458 /*******************************************************************************
459 *
460 * Function SDP_FindServiceInDb_128bit
461 *
462 * Description Query an SDP database for a specific service. If the
463 * p_start_rec pointer is NULL, it looks from the beginning of
464 * the database, else it continues from the next record after
465 * p_start_rec.
466 *
467 * This function is kept separate from SDP_FindServiceInDb
468 * since that API is expected to return only 16-bit UUIDs
469 *
470 * Returns Pointer to record containing service class, or NULL
471 *
472 ******************************************************************************/
SDP_FindServiceInDb_128bit(const tSDP_DISCOVERY_DB * p_db,tSDP_DISC_REC * p_start_rec)473 tSDP_DISC_REC* SDP_FindServiceInDb_128bit(const tSDP_DISCOVERY_DB* p_db,
474 tSDP_DISC_REC* p_start_rec) {
475 tSDP_DISC_REC* p_rec;
476 tSDP_DISC_ATTR *p_attr, *p_sattr;
477
478 /* Must have a valid database */
479 if (p_db == NULL) return (NULL);
480
481 if (!p_start_rec)
482 p_rec = p_db->p_first_rec;
483 else
484 p_rec = p_start_rec->p_next_rec;
485
486 while (p_rec) {
487 p_attr = p_rec->p_first_attr;
488 while (p_attr) {
489 if ((p_attr->attr_id == ATTR_ID_SERVICE_CLASS_ID_LIST) &&
490 (SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) ==
491 DATA_ELE_SEQ_DESC_TYPE)) {
492 for (p_sattr = p_attr->attr_value.v.p_sub_attr; p_sattr;
493 p_sattr = p_sattr->p_next_attr) {
494 if ((SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UUID_DESC_TYPE) &&
495 (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == 16)) {
496 return (p_rec);
497 }
498 }
499 break;
500 } else if (p_attr->attr_id == ATTR_ID_SERVICE_ID) {
501 if ((SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) == UUID_DESC_TYPE) &&
502 (SDP_DISC_ATTR_LEN(p_attr->attr_len_type) == 16))
503 return (p_rec);
504 }
505
506 p_attr = p_attr->p_next_attr;
507 }
508
509 p_rec = p_rec->p_next_rec;
510 }
511 /* If here, no matching UUID found */
512 return (NULL);
513 }
514
515 /*******************************************************************************
516 *
517 * Function SDP_FindServiceUUIDInDb
518 *
519 * Description Query an SDP database for a specific service. If the
520 * p_start_rec pointer is NULL, it looks from the beginning of
521 * the database, else it continues from the next record after
522 * p_start_rec.
523 *
524 * NOTE the only difference between this function and the previous
525 * function "SDP_FindServiceInDb()" is that this function takes
526 * a Uuid input
527 *
528 * Returns Pointer to record containing service class, or NULL
529 *
530 ******************************************************************************/
SDP_FindServiceUUIDInDb(const tSDP_DISCOVERY_DB * p_db,const Uuid & uuid,tSDP_DISC_REC * p_start_rec)531 tSDP_DISC_REC* SDP_FindServiceUUIDInDb(const tSDP_DISCOVERY_DB* p_db,
532 const Uuid& uuid,
533 tSDP_DISC_REC* p_start_rec) {
534 tSDP_DISC_REC* p_rec;
535 tSDP_DISC_ATTR *p_attr, *p_sattr;
536
537 /* Must have a valid database */
538 if (p_db == NULL) return (NULL);
539
540 if (!p_start_rec)
541 p_rec = p_db->p_first_rec;
542 else
543 p_rec = p_start_rec->p_next_rec;
544
545 while (p_rec) {
546 p_attr = p_rec->p_first_attr;
547 while (p_attr) {
548 if ((p_attr->attr_id == ATTR_ID_SERVICE_CLASS_ID_LIST) &&
549 (SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) ==
550 DATA_ELE_SEQ_DESC_TYPE)) {
551 for (p_sattr = p_attr->attr_value.v.p_sub_attr; p_sattr;
552 p_sattr = p_sattr->p_next_attr) {
553 if (SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UUID_DESC_TYPE) {
554 if (sdpu_compare_uuid_with_attr(uuid, p_sattr)) return (p_rec);
555 }
556 }
557 break;
558 } else if (p_attr->attr_id == ATTR_ID_SERVICE_ID) {
559 if (SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) == UUID_DESC_TYPE) {
560 if (sdpu_compare_uuid_with_attr(uuid, p_attr)) return (p_rec);
561 }
562 }
563
564 p_attr = p_attr->p_next_attr;
565 }
566
567 p_rec = p_rec->p_next_rec;
568 }
569 /* If here, no matching UUID found */
570 return (NULL);
571 }
572
573 /*******************************************************************************
574 *
575 * Function sdp_fill_proto_elem
576 *
577 * Description This function retrieves the protocol element.
578 *
579 * Returns true if found, false if not
580 * If found, the passed protocol list element is filled in.
581 *
582 ******************************************************************************/
sdp_fill_proto_elem(const tSDP_DISC_ATTR * p_attr,uint16_t layer_uuid,tSDP_PROTOCOL_ELEM * p_elem)583 static bool sdp_fill_proto_elem(const tSDP_DISC_ATTR* p_attr,
584 uint16_t layer_uuid,
585 tSDP_PROTOCOL_ELEM* p_elem) {
586 tSDP_DISC_ATTR* p_sattr;
587
588 /* Walk through the protocol descriptor list */
589 for (p_attr = p_attr->attr_value.v.p_sub_attr; p_attr;
590 p_attr = p_attr->p_next_attr) {
591 /* Safety check - each entry should itself be a sequence */
592 if (SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) != DATA_ELE_SEQ_DESC_TYPE)
593 return (false);
594
595 /* Now, see if the entry contains the layer we are interested in */
596 for (p_sattr = p_attr->attr_value.v.p_sub_attr; p_sattr;
597 p_sattr = p_sattr->p_next_attr) {
598 /* LOG_VERBOSE ("SDP - p_sattr 0x%x, layer_uuid:0x%x, u16:0x%x####",
599 p_sattr, layer_uuid, p_sattr->attr_value.v.u16); */
600
601 if ((SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UUID_DESC_TYPE) &&
602 (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == 2) &&
603 (p_sattr->attr_value.v.u16 == layer_uuid)) {
604 /* Bingo. Now fill in the passed element */
605 p_elem->protocol_uuid = layer_uuid;
606 p_elem->num_params = 0;
607
608 /* Store the parameters, if any */
609 for (p_sattr = p_sattr->p_next_attr; p_sattr;
610 p_sattr = p_sattr->p_next_attr) {
611 if (SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) != UINT_DESC_TYPE)
612 break;
613
614 if (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == 2)
615 p_elem->params[p_elem->num_params++] = p_sattr->attr_value.v.u16;
616 else
617 p_elem->params[p_elem->num_params++] = p_sattr->attr_value.v.u8;
618
619 if (p_elem->num_params >= SDP_MAX_PROTOCOL_PARAMS) break;
620 }
621 return (true);
622 }
623 }
624 }
625
626 return (false);
627 }
628
629 /*******************************************************************************
630 *
631 * Function SDP_FindProtocolListElemInRec
632 *
633 * Description This function looks at a specific discovery record for a
634 * protocol list element.
635 *
636 * Returns true if found, false if not
637 * If found, the passed protocol list element is filled in.
638 *
639 ******************************************************************************/
SDP_FindProtocolListElemInRec(const tSDP_DISC_REC * p_rec,uint16_t layer_uuid,tSDP_PROTOCOL_ELEM * p_elem)640 bool SDP_FindProtocolListElemInRec(const tSDP_DISC_REC* p_rec,
641 uint16_t layer_uuid,
642 tSDP_PROTOCOL_ELEM* p_elem) {
643 tSDP_DISC_ATTR* p_attr;
644
645 p_attr = p_rec->p_first_attr;
646 while (p_attr) {
647 /* Find the protocol descriptor list */
648 if ((p_attr->attr_id == ATTR_ID_PROTOCOL_DESC_LIST) &&
649 (SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) == DATA_ELE_SEQ_DESC_TYPE)) {
650 return sdp_fill_proto_elem(p_attr, layer_uuid, p_elem);
651 }
652 p_attr = p_attr->p_next_attr;
653 }
654 /* If here, no match found */
655 return (false);
656 }
657
658 /*******************************************************************************
659 *
660 * Function SDP_FindProfileVersionInRec
661 *
662 * Description This function looks at a specific discovery record for the
663 * Profile list descriptor, and pulls out the version number.
664 * The version number consists of an 8-bit major version and
665 * an 8-bit minor version.
666 *
667 * Returns true if found, false if not
668 * If found, the major and minor version numbers that were
669 * passed in are filled in.
670 *
671 ******************************************************************************/
SDP_FindProfileVersionInRec(const tSDP_DISC_REC * p_rec,uint16_t profile_uuid,uint16_t * p_version)672 bool SDP_FindProfileVersionInRec(const tSDP_DISC_REC* p_rec,
673 uint16_t profile_uuid, uint16_t* p_version) {
674 tSDP_DISC_ATTR *p_attr, *p_sattr;
675
676 p_attr = p_rec->p_first_attr;
677 while (p_attr) {
678 /* Find the profile descriptor list */
679 if ((p_attr->attr_id == ATTR_ID_BT_PROFILE_DESC_LIST) &&
680 (SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) == DATA_ELE_SEQ_DESC_TYPE)) {
681 /* Walk through the protocol descriptor list */
682 for (p_attr = p_attr->attr_value.v.p_sub_attr; p_attr;
683 p_attr = p_attr->p_next_attr) {
684 /* Safety check - each entry should itself be a sequence */
685 if (SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) != DATA_ELE_SEQ_DESC_TYPE)
686 return (false);
687
688 /* Now, see if the entry contains the profile UUID we are interested in
689 */
690 for (p_sattr = p_attr->attr_value.v.p_sub_attr; p_sattr;
691 p_sattr = p_sattr->p_next_attr) {
692 if ((SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UUID_DESC_TYPE) &&
693 (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) ==
694 2) /* <- This is bytes, not size code! */
695 && (p_sattr->attr_value.v.u16 == profile_uuid)) {
696 /* Now fill in the major and minor numbers */
697 /* if the attribute matches the description for version (type UINT,
698 * size 2 bytes) */
699 p_sattr = p_sattr->p_next_attr;
700
701 if ((SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) ==
702 UINT_DESC_TYPE) &&
703 (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == 2)) {
704 /* The high order 8 bits is the major number, low order is the
705 * minor number (big endian) */
706 *p_version = p_sattr->attr_value.v.u16;
707
708 return (true);
709 } else
710 return (false); /* The type and/or size was not valid for the
711 profile list version */
712 }
713 }
714 }
715
716 return (false);
717 }
718 p_attr = p_attr->p_next_attr;
719 }
720
721 /* If here, no match found */
722 return (false);
723 }
724
725 /*******************************************************************************
726 * Device Identification (DI) Client Functions
727 ******************************************************************************/
728
729 /*******************************************************************************
730 *
731 * Function SDP_DiDiscover
732 *
733 * Description This function queries a remote device for DI information.
734 *
735 * Returns SDP_SUCCESS if query started successfully, else error
736 *
737 ******************************************************************************/
SDP_DiDiscover(const RawAddress & remote_device,tSDP_DISCOVERY_DB * p_db,uint32_t len,tSDP_DISC_CMPL_CB * p_cb)738 tSDP_STATUS SDP_DiDiscover(const RawAddress& remote_device,
739 tSDP_DISCOVERY_DB* p_db, uint32_t len,
740 tSDP_DISC_CMPL_CB* p_cb) {
741 tSDP_STATUS result = SDP_DI_DISC_FAILED;
742 uint16_t num_uuids = 1;
743 uint16_t di_uuid = UUID_SERVCLASS_PNP_INFORMATION;
744
745 /* build uuid for db init */
746 Uuid init_uuid = Uuid::From16Bit(di_uuid);
747
748 if (SDP_InitDiscoveryDb(p_db, len, num_uuids, &init_uuid, 0, NULL))
749 if (SDP_ServiceSearchRequest(remote_device, p_db, p_cb))
750 result = SDP_SUCCESS;
751
752 return result;
753 }
754
755 /*******************************************************************************
756 *
757 * Function SDP_GetNumDiRecords
758 *
759 * Description Searches specified database for DI records
760 *
761 * Returns number of DI records found
762 *
763 ******************************************************************************/
SDP_GetNumDiRecords(const tSDP_DISCOVERY_DB * p_db)764 uint8_t SDP_GetNumDiRecords(const tSDP_DISCOVERY_DB* p_db) {
765 uint8_t num_records = 0;
766 tSDP_DISC_REC* p_curr_record = NULL;
767
768 do {
769 p_curr_record = SDP_FindServiceInDb(p_db, UUID_SERVCLASS_PNP_INFORMATION,
770 p_curr_record);
771 if (p_curr_record) num_records++;
772 } while (p_curr_record);
773
774 return num_records;
775 }
776
777 /*******************************************************************************
778 *
779 * Function SDP_AttrStringCopy
780 *
781 * Description This function copy given attribute to specified buffer as a
782 * string
783 *
784 * Returns none
785 *
786 ******************************************************************************/
SDP_AttrStringCopy(char * dst,const tSDP_DISC_ATTR * p_attr,uint16_t dst_size,uint8_t expected_type)787 static void SDP_AttrStringCopy(char* dst, const tSDP_DISC_ATTR* p_attr,
788 uint16_t dst_size,
789 uint8_t expected_type) {
790 if (dst == NULL)
791 return;
792
793 dst[0] = '\0';
794
795 if (p_attr) {
796 uint8_t type = SDP_DISC_ATTR_TYPE(p_attr->attr_len_type);
797
798 if (type == expected_type) {
799 uint16_t len = SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
800 if (len > dst_size - 1) {
801 len = dst_size - 1;
802 }
803 memcpy(dst, (const void*)p_attr->attr_value.v.array, len);
804 dst[len] = '\0';
805 } else {
806 log::error("unexpected attr type={}, expected={}", type, expected_type);
807 }
808 } else {
809 log::error("p_attr is NULL");
810 }
811 }
812
813 /*******************************************************************************
814 *
815 * Function SDP_GetDiRecord
816 *
817 * Description This function retrieves a remote device's DI record from
818 * the specified database.
819 *
820 * Returns SDP_SUCCESS if record retrieved, else error
821 *
822 ******************************************************************************/
SDP_GetDiRecord(uint8_t get_record_index,tSDP_DI_GET_RECORD * p_device_info,const tSDP_DISCOVERY_DB * p_db)823 uint16_t SDP_GetDiRecord(uint8_t get_record_index,
824 tSDP_DI_GET_RECORD* p_device_info,
825 const tSDP_DISCOVERY_DB* p_db) {
826 uint16_t result = SDP_NO_DI_RECORD_FOUND;
827 uint8_t curr_record_index = 1;
828
829 tSDP_DISC_REC* p_curr_record = NULL;
830
831 /* find the requested SDP record in the discovery database */
832 do {
833 p_curr_record = SDP_FindServiceInDb(p_db, UUID_SERVCLASS_PNP_INFORMATION,
834 p_curr_record);
835 if (p_curr_record) {
836 if (curr_record_index++ == get_record_index) {
837 result = SDP_SUCCESS;
838 break;
839 }
840 }
841 } while (p_curr_record);
842
843 if (result == SDP_SUCCESS) {
844 /* copy the information from the SDP record to the DI record */
845 tSDP_DISC_ATTR* p_curr_attr = NULL;
846
847 /* ClientExecutableURL is optional */
848 p_curr_attr = SDP_FindAttributeInRec(p_curr_record, ATTR_ID_CLIENT_EXE_URL);
849 SDP_AttrStringCopy(p_device_info->rec.client_executable_url, p_curr_attr,
850 SDP_MAX_ATTR_LEN, URL_DESC_TYPE);
851
852 /* Service Description is optional */
853 /* 5.1.16 ServiceDescription attribute */
854 p_curr_attr =
855 SDP_FindAttributeInRec(p_curr_record, ATTR_ID_SERVICE_DESCRIPTION);
856 SDP_AttrStringCopy(p_device_info->rec.service_description, p_curr_attr,
857 SDP_MAX_ATTR_LEN, TEXT_STR_DESC_TYPE);
858
859 /* DocumentationURL is optional */
860 p_curr_attr =
861 SDP_FindAttributeInRec(p_curr_record, ATTR_ID_DOCUMENTATION_URL);
862 SDP_AttrStringCopy(p_device_info->rec.documentation_url, p_curr_attr,
863 SDP_MAX_ATTR_LEN, URL_DESC_TYPE);
864
865 p_curr_attr =
866 SDP_FindAttributeInRec(p_curr_record, ATTR_ID_SPECIFICATION_ID);
867 if (p_curr_attr &&
868 SDP_DISC_ATTR_TYPE(p_curr_attr->attr_len_type) == UINT_DESC_TYPE &&
869 SDP_DISC_ATTR_LEN(p_curr_attr->attr_len_type) >= 2)
870 p_device_info->spec_id = p_curr_attr->attr_value.v.u16;
871 else
872 result = SDP_ERR_ATTR_NOT_PRESENT;
873
874 p_curr_attr = SDP_FindAttributeInRec(p_curr_record, ATTR_ID_VENDOR_ID);
875 if (p_curr_attr &&
876 SDP_DISC_ATTR_TYPE(p_curr_attr->attr_len_type) == UINT_DESC_TYPE &&
877 SDP_DISC_ATTR_LEN(p_curr_attr->attr_len_type) >= 2)
878 p_device_info->rec.vendor = p_curr_attr->attr_value.v.u16;
879 else
880 result = SDP_ERR_ATTR_NOT_PRESENT;
881
882 p_curr_attr =
883 SDP_FindAttributeInRec(p_curr_record, ATTR_ID_VENDOR_ID_SOURCE);
884 if (p_curr_attr &&
885 SDP_DISC_ATTR_TYPE(p_curr_attr->attr_len_type) == UINT_DESC_TYPE &&
886 SDP_DISC_ATTR_LEN(p_curr_attr->attr_len_type) >= 2)
887 p_device_info->rec.vendor_id_source = p_curr_attr->attr_value.v.u16;
888 else
889 result = SDP_ERR_ATTR_NOT_PRESENT;
890
891 p_curr_attr = SDP_FindAttributeInRec(p_curr_record, ATTR_ID_PRODUCT_ID);
892 if (p_curr_attr &&
893 SDP_DISC_ATTR_TYPE(p_curr_attr->attr_len_type) == UINT_DESC_TYPE &&
894 SDP_DISC_ATTR_LEN(p_curr_attr->attr_len_type) >= 2)
895 p_device_info->rec.product = p_curr_attr->attr_value.v.u16;
896 else
897 result = SDP_ERR_ATTR_NOT_PRESENT;
898
899 p_curr_attr =
900 SDP_FindAttributeInRec(p_curr_record, ATTR_ID_PRODUCT_VERSION);
901 if (p_curr_attr &&
902 SDP_DISC_ATTR_TYPE(p_curr_attr->attr_len_type) == UINT_DESC_TYPE &&
903 SDP_DISC_ATTR_LEN(p_curr_attr->attr_len_type) >= 2)
904 p_device_info->rec.version = p_curr_attr->attr_value.v.u16;
905 else
906 result = SDP_ERR_ATTR_NOT_PRESENT;
907
908 p_curr_attr = SDP_FindAttributeInRec(p_curr_record, ATTR_ID_PRIMARY_RECORD);
909 if (p_curr_attr &&
910 SDP_DISC_ATTR_TYPE(p_curr_attr->attr_len_type) == BOOLEAN_DESC_TYPE &&
911 SDP_DISC_ATTR_LEN(p_curr_attr->attr_len_type) >= 1)
912 p_device_info->rec.primary_record = (bool)p_curr_attr->attr_value.v.u8;
913 else
914 result = SDP_ERR_ATTR_NOT_PRESENT;
915 }
916
917 return result;
918 }
919
920 /*******************************************************************************
921 * Device Identification (DI) Server Functions
922 ******************************************************************************/
923
924 /*******************************************************************************
925 *
926 * Function SDP_SetLocalDiRecord
927 *
928 * Description This function adds a DI record to the local SDP database.
929 *
930 *
931 *
932 * Returns Returns SDP_SUCCESS if record added successfully, else error
933 *
934 ******************************************************************************/
SDP_SetLocalDiRecord(const tSDP_DI_RECORD * p_device_info,uint32_t * p_handle)935 uint16_t SDP_SetLocalDiRecord(const tSDP_DI_RECORD* p_device_info,
936 uint32_t* p_handle) {
937 uint16_t result = SDP_SUCCESS;
938 uint32_t handle;
939 uint16_t di_uuid = UUID_SERVCLASS_PNP_INFORMATION;
940 uint16_t di_specid = BLUETOOTH_DI_SPECIFICATION;
941 uint8_t temp_u16[2];
942 uint8_t* p_temp;
943 uint8_t u8;
944
945 *p_handle = 0;
946 if (p_device_info == NULL) return SDP_ILLEGAL_PARAMETER;
947
948 /* if record is to be primary record, get handle to replace old primary */
949 if (p_device_info->primary_record && sdp_cb.server_db.di_primary_handle)
950 handle = sdp_cb.server_db.di_primary_handle;
951 else {
952 handle = SDP_CreateRecord();
953 if (handle == 0) return SDP_NO_RESOURCES;
954 }
955
956 *p_handle = handle;
957
958 /* build the SDP entry */
959 /* Add the UUID to the Service Class ID List */
960 if (!(SDP_AddServiceClassIdList(handle, 1, &di_uuid)))
961 result = SDP_DI_REG_FAILED;
962
963 /* mandatory */
964 if (result == SDP_SUCCESS) {
965 p_temp = temp_u16;
966 UINT16_TO_BE_STREAM(p_temp, di_specid);
967 if (!(SDP_AddAttribute(handle, ATTR_ID_SPECIFICATION_ID, UINT_DESC_TYPE,
968 sizeof(di_specid), temp_u16)))
969 result = SDP_DI_REG_FAILED;
970 }
971
972 /* optional - if string is null, do not add attribute */
973 if (result == SDP_SUCCESS) {
974 if (p_device_info->client_executable_url[0] != '\0') {
975 if (!((strlen(p_device_info->client_executable_url) + 1 <=
976 SDP_MAX_ATTR_LEN) &&
977 SDP_AddAttribute(
978 handle, ATTR_ID_CLIENT_EXE_URL, URL_DESC_TYPE,
979 (uint32_t)(strlen(p_device_info->client_executable_url) + 1),
980 (uint8_t*)p_device_info->client_executable_url)))
981 result = SDP_DI_REG_FAILED;
982 }
983 }
984
985 /* optional - if string is null, do not add attribute */
986 if (result == SDP_SUCCESS) {
987 if (p_device_info->service_description[0] != '\0') {
988 if (!((strlen(p_device_info->service_description) + 1 <=
989 SDP_MAX_ATTR_LEN) &&
990 SDP_AddAttribute(
991 handle, ATTR_ID_SERVICE_DESCRIPTION, TEXT_STR_DESC_TYPE,
992 (uint32_t)(strlen(p_device_info->service_description) + 1),
993 (uint8_t*)p_device_info->service_description)))
994 result = SDP_DI_REG_FAILED;
995 }
996 }
997
998 /* optional - if string is null, do not add attribute */
999 if (result == SDP_SUCCESS) {
1000 if (p_device_info->documentation_url[0] != '\0') {
1001 if (!((strlen(p_device_info->documentation_url) + 1 <=
1002 SDP_MAX_ATTR_LEN) &&
1003 SDP_AddAttribute(
1004 handle, ATTR_ID_DOCUMENTATION_URL, URL_DESC_TYPE,
1005 (uint32_t)(strlen(p_device_info->documentation_url) + 1),
1006 (uint8_t*)p_device_info->documentation_url)))
1007 result = SDP_DI_REG_FAILED;
1008 }
1009 }
1010
1011 /* mandatory */
1012 if (result == SDP_SUCCESS) {
1013 p_temp = temp_u16;
1014 UINT16_TO_BE_STREAM(p_temp, p_device_info->vendor);
1015 if (!(SDP_AddAttribute(handle, ATTR_ID_VENDOR_ID, UINT_DESC_TYPE,
1016 sizeof(p_device_info->vendor), temp_u16)))
1017 result = SDP_DI_REG_FAILED;
1018 }
1019
1020 /* mandatory */
1021 if (result == SDP_SUCCESS) {
1022 p_temp = temp_u16;
1023 UINT16_TO_BE_STREAM(p_temp, p_device_info->product);
1024 if (!(SDP_AddAttribute(handle, ATTR_ID_PRODUCT_ID, UINT_DESC_TYPE,
1025 sizeof(p_device_info->product), temp_u16)))
1026 result = SDP_DI_REG_FAILED;
1027 }
1028
1029 /* mandatory */
1030 if (result == SDP_SUCCESS) {
1031 p_temp = temp_u16;
1032 UINT16_TO_BE_STREAM(p_temp, p_device_info->version);
1033 if (!(SDP_AddAttribute(handle, ATTR_ID_PRODUCT_VERSION, UINT_DESC_TYPE,
1034 sizeof(p_device_info->version), temp_u16)))
1035 result = SDP_DI_REG_FAILED;
1036 }
1037
1038 /* mandatory */
1039 if (result == SDP_SUCCESS) {
1040 u8 = (uint8_t)p_device_info->primary_record;
1041 if (!(SDP_AddAttribute(handle, ATTR_ID_PRIMARY_RECORD, BOOLEAN_DESC_TYPE, 1,
1042 &u8)))
1043 result = SDP_DI_REG_FAILED;
1044 }
1045
1046 /* mandatory */
1047 if (result == SDP_SUCCESS) {
1048 p_temp = temp_u16;
1049 UINT16_TO_BE_STREAM(p_temp, p_device_info->vendor_id_source);
1050 if (!(SDP_AddAttribute(handle, ATTR_ID_VENDOR_ID_SOURCE, UINT_DESC_TYPE,
1051 sizeof(p_device_info->vendor_id_source), temp_u16)))
1052 result = SDP_DI_REG_FAILED;
1053 }
1054
1055 if (result != SDP_SUCCESS)
1056 SDP_DeleteRecord(handle);
1057 else if (p_device_info->primary_record)
1058 sdp_cb.server_db.di_primary_handle = handle;
1059
1060 return result;
1061 }
1062
1063 namespace {
1064 bluetooth::legacy::stack::sdp::tSdpApi api_ = {
1065 .service =
1066 {
1067 .SDP_InitDiscoveryDb = ::SDP_InitDiscoveryDb,
1068 .SDP_CancelServiceSearch = ::SDP_CancelServiceSearch,
1069 .SDP_ServiceSearchRequest = ::SDP_ServiceSearchRequest,
1070 .SDP_ServiceSearchAttributeRequest =
1071 ::SDP_ServiceSearchAttributeRequest,
1072 .SDP_ServiceSearchAttributeRequest2 =
1073 ::SDP_ServiceSearchAttributeRequest2,
1074 },
1075 .db =
1076 {
1077 .SDP_FindServiceInDb = ::SDP_FindServiceInDb,
1078 .SDP_FindServiceUUIDInDb = ::SDP_FindServiceUUIDInDb,
1079 .SDP_FindServiceInDb_128bit = ::SDP_FindServiceInDb_128bit,
1080 },
1081 .record =
1082 {
1083 .SDP_FindAttributeInRec = ::SDP_FindAttributeInRec,
1084 .SDP_FindServiceUUIDInRec_128bit =
1085 ::SDP_FindServiceUUIDInRec_128bit,
1086 .SDP_FindProtocolListElemInRec = ::SDP_FindProtocolListElemInRec,
1087 .SDP_FindProfileVersionInRec = ::SDP_FindProfileVersionInRec,
1088 .SDP_FindServiceUUIDInRec = ::SDP_FindServiceUUIDInRec,
1089 },
1090 .handle =
1091 {
1092 .SDP_CreateRecord = ::SDP_CreateRecord,
1093 .SDP_DeleteRecord = ::SDP_DeleteRecord,
1094 .SDP_AddAttribute = ::SDP_AddAttribute,
1095 .SDP_AddSequence = ::SDP_AddSequence,
1096 .SDP_AddUuidSequence = ::SDP_AddUuidSequence,
1097 .SDP_AddProtocolList = ::SDP_AddProtocolList,
1098 .SDP_AddAdditionProtoLists = ::SDP_AddAdditionProtoLists,
1099 .SDP_AddProfileDescriptorList = ::SDP_AddProfileDescriptorList,
1100 .SDP_AddLanguageBaseAttrIDList = ::SDP_AddLanguageBaseAttrIDList,
1101 .SDP_AddServiceClassIdList = ::SDP_AddServiceClassIdList,
1102 },
1103 .device_id =
1104 {
1105 .SDP_SetLocalDiRecord = ::SDP_SetLocalDiRecord,
1106 .SDP_DiDiscover = ::SDP_DiDiscover,
1107 .SDP_GetNumDiRecords = ::SDP_GetNumDiRecords,
1108 .SDP_GetDiRecord = ::SDP_GetDiRecord,
1109 },
1110 };
1111 } // namespace
1112
1113 const bluetooth::legacy::stack::sdp::tSdpApi*
get_legacy_stack_sdp_api()1114 bluetooth::legacy::stack::sdp::get_legacy_stack_sdp_api() {
1115 return &api_;
1116 }
1117