Coverage Report

Created: 2024-05-20 06:10

/src/bluez/lib/sdp_lib.h
Line
Count
Source (jump to first uncovered line)
1
/* SPDX-License-Identifier: GPL-2.0-or-later */
2
/*
3
 *
4
 *  BlueZ - Bluetooth protocol stack for Linux
5
 *
6
 *  Copyright (C) 2001-2002  Nokia Corporation
7
 *  Copyright (C) 2002-2003  Maxim Krasnyansky <maxk@qualcomm.com>
8
 *  Copyright (C) 2002-2010  Marcel Holtmann <marcel@holtmann.org>
9
 *  Copyright (C) 2002-2003  Stephen Crane <steve.crane@rococosoft.com>
10
 *
11
 *
12
 */
13
14
#ifndef __SDP_LIB_H
15
#define __SDP_LIB_H
16
17
#include <sys/socket.h>
18
#include <bluetooth/bluetooth.h>
19
#include <bluetooth/hci.h>
20
21
#ifdef __cplusplus
22
extern "C" {
23
#endif
24
25
/*
26
 * SDP lists
27
 */
28
typedef void(*sdp_list_func_t)(void *, void *);
29
typedef void(*sdp_free_func_t)(void *);
30
typedef int (*sdp_comp_func_t)(const void *, const void *);
31
32
sdp_list_t *sdp_list_append(sdp_list_t *list, void *d);
33
sdp_list_t *sdp_list_remove(sdp_list_t *list, void *d);
34
sdp_list_t *sdp_list_insert_sorted(sdp_list_t *list, void *data, sdp_comp_func_t f);
35
void        sdp_list_free(sdp_list_t *list, sdp_free_func_t f);
36
37
static inline int sdp_list_len(const sdp_list_t *list)
38
0
{
39
0
  int n = 0;
40
0
  for (; list; list = list->next)
41
0
    n++;
42
0
  return n;
43
0
}
Unexecuted instantiation: fuzz_hci.c:sdp_list_len
Unexecuted instantiation: sdp-xml.c:sdp_list_len
Unexecuted instantiation: fuzz_xml.c:sdp_list_len
Unexecuted instantiation: sdp.c:sdp_list_len
Unexecuted instantiation: fuzz_sdp.c:sdp_list_len
44
45
static inline sdp_list_t *sdp_list_find(sdp_list_t *list, void *u, sdp_comp_func_t f)
46
3.66k
{
47
10.2k
  for (; list; list = list->next)
48
9.42k
    if (f(list->data, u) == 0)
49
2.79k
      return list;
50
868
  return NULL;
51
3.66k
}
Unexecuted instantiation: fuzz_hci.c:sdp_list_find
Unexecuted instantiation: sdp-xml.c:sdp_list_find
Unexecuted instantiation: fuzz_xml.c:sdp_list_find
sdp.c:sdp_list_find
Line
Count
Source
46
3.66k
{
47
10.2k
  for (; list; list = list->next)
48
9.42k
    if (f(list->data, u) == 0)
49
2.79k
      return list;
50
868
  return NULL;
51
3.66k
}
Unexecuted instantiation: fuzz_sdp.c:sdp_list_find
52
53
static inline void sdp_list_foreach(sdp_list_t *list, sdp_list_func_t f, void *u)
54
248
{
55
811
  for (; list; list = list->next)
56
563
    f(list->data, u);
57
248
}
Unexecuted instantiation: fuzz_hci.c:sdp_list_foreach
sdp-xml.c:sdp_list_foreach
Line
Count
Source
54
56
{
55
112
  for (; list; list = list->next)
56
56
    f(list->data, u);
57
56
}
Unexecuted instantiation: fuzz_xml.c:sdp_list_foreach
sdp.c:sdp_list_foreach
Line
Count
Source
54
192
{
55
699
  for (; list; list = list->next)
56
507
    f(list->data, u);
57
192
}
Unexecuted instantiation: fuzz_sdp.c:sdp_list_foreach
58
59
/*
60
 * Values of the flags parameter to sdp_record_register
61
 */
62
#define SDP_RECORD_PERSIST  0x01
63
0
#define SDP_DEVICE_RECORD 0x02
64
65
/*
66
 * Values of the flags parameter to sdp_connect
67
 */
68
0
#define SDP_RETRY_IF_BUSY 0x01
69
0
#define SDP_WAIT_ON_CLOSE 0x02
70
0
#define SDP_NON_BLOCKING  0x04
71
0
#define SDP_LARGE_MTU   0x08
72
73
/*
74
 * a session with an SDP server
75
 */
76
typedef struct {
77
  int sock;
78
  int state;
79
  int local;
80
  int flags;
81
  uint16_t tid; /* Current transaction ID */
82
  void *priv;
83
} sdp_session_t;
84
85
typedef enum {
86
  /*
87
   *  Attributes are specified as individual elements
88
   */
89
  SDP_ATTR_REQ_INDIVIDUAL = 1,
90
  /*
91
   *  Attributes are specified as a range
92
   */
93
  SDP_ATTR_REQ_RANGE
94
} sdp_attrreq_type_t;
95
96
/*
97
 *  When the pdu_id(type) is a sdp error response, check the status value
98
 *  to figure out the error reason. For status values 0x0001-0x0006 check
99
 *  Bluetooth SPEC. If the status is 0xffff, call sdp_get_error function
100
 *  to get the real reason:
101
 *      - wrong transaction ID(EPROTO)
102
 *      - wrong PDU id or(EPROTO)
103
 *      - I/O error
104
 */
105
typedef void sdp_callback_t(uint8_t type, uint16_t status, uint8_t *rsp, size_t size, void *udata);
106
107
/*
108
 * create an L2CAP connection to a Bluetooth device
109
 *
110
 * INPUT:
111
 *
112
 *  bdaddr_t *src:
113
 *  Address of the local device to use to make the connection
114
 *  (or BDADDR_ANY)
115
 *
116
 *  bdaddr_t *dst:
117
 *    Address of the SDP server device
118
 */
119
sdp_session_t *sdp_connect(const bdaddr_t *src, const bdaddr_t *dst, uint32_t flags);
120
int sdp_close(sdp_session_t *session);
121
int sdp_get_socket(const sdp_session_t *session);
122
123
/*
124
 * SDP transaction: functions for asynchronous search.
125
 */
126
sdp_session_t *sdp_create(int sk, uint32_t flags);
127
int sdp_get_error(sdp_session_t *session);
128
int sdp_process(sdp_session_t *session);
129
int sdp_set_notify(sdp_session_t *session, sdp_callback_t *func, void *udata);
130
131
int sdp_service_search_async(sdp_session_t *session, const sdp_list_t *search, uint16_t max_rec_num);
132
int sdp_service_attr_async(sdp_session_t *session, uint32_t handle, sdp_attrreq_type_t reqtype, const sdp_list_t *attrid_list);
133
int sdp_service_search_attr_async(sdp_session_t *session, const sdp_list_t *search, sdp_attrreq_type_t reqtype, const sdp_list_t *attrid_list);
134
135
uint16_t sdp_gen_tid(sdp_session_t *session);
136
137
/*
138
 * find all devices in the piconet
139
 */
140
int sdp_general_inquiry(inquiry_info *ii, int dev_num, int duration, uint8_t *found);
141
142
/* flexible extraction of basic attributes - Jean II */
143
int sdp_get_int_attr(const sdp_record_t *rec, uint16_t attr, int *value);
144
int sdp_get_string_attr(const sdp_record_t *rec, uint16_t attr, char *value,
145
              size_t valuelen);
146
147
/*
148
 * Basic sdp data functions
149
 */
150
sdp_data_t *sdp_data_alloc(uint8_t dtd, const void *value);
151
sdp_data_t *sdp_data_alloc_with_length(uint8_t dtd, const void *value, uint32_t length);
152
void sdp_data_free(sdp_data_t *data);
153
sdp_data_t *sdp_data_get(const sdp_record_t *rec, uint16_t attr_id);
154
155
sdp_data_t *sdp_seq_alloc(void **dtds, void **values, int len);
156
sdp_data_t *sdp_seq_alloc_with_length(void **dtds, void **values, int *length, int len);
157
sdp_data_t *sdp_seq_append(sdp_data_t *seq, sdp_data_t *data);
158
159
int sdp_attr_add(sdp_record_t *rec, uint16_t attr, sdp_data_t *data);
160
void sdp_attr_remove(sdp_record_t *rec, uint16_t attr);
161
void sdp_attr_replace(sdp_record_t *rec, uint16_t attr, sdp_data_t *data);
162
int sdp_set_uuidseq_attr(sdp_record_t *rec, uint16_t attr, sdp_list_t *seq);
163
int sdp_get_uuidseq_attr(const sdp_record_t *rec, uint16_t attr, sdp_list_t **seqp);
164
165
/*
166
 * NOTE that none of the functions below will update the SDP server,
167
 * unless the {register, update}sdp_record_t() function is invoked.
168
 * All functions which return an integer value, return 0 on success
169
 * or -1 on failure.
170
 */
171
172
/*
173
 * Create an attribute and add it to the service record's attribute list.
174
 * This consists of the data type descriptor of the attribute,
175
 * the value of the attribute and the attribute identifier.
176
 */
177
int sdp_attr_add_new(sdp_record_t *rec, uint16_t attr, uint8_t dtd, const void *p);
178
179
/*
180
 * Set the information attributes of the service record.
181
 * The set of attributes comprises service name, description
182
 * and provider name
183
 */
184
void sdp_set_info_attr(sdp_record_t *rec, const char *name, const char *prov, const char *desc);
185
186
/*
187
 * Set the ServiceClassID attribute to the sequence specified by seq.
188
 * Note that the identifiers need to be in sorted order from the most
189
 * specific to the most generic service class that this service
190
 * conforms to.
191
 */
192
static inline int sdp_set_service_classes(sdp_record_t *rec, sdp_list_t *seq)
193
0
{
194
0
  return sdp_set_uuidseq_attr(rec, SDP_ATTR_SVCLASS_ID_LIST, seq);
195
0
}
Unexecuted instantiation: fuzz_hci.c:sdp_set_service_classes
Unexecuted instantiation: sdp-xml.c:sdp_set_service_classes
Unexecuted instantiation: fuzz_xml.c:sdp_set_service_classes
Unexecuted instantiation: sdp.c:sdp_set_service_classes
Unexecuted instantiation: fuzz_sdp.c:sdp_set_service_classes
196
197
/*
198
 * Get the service classes to which the service conforms.
199
 *
200
 * When set, the list contains elements of ServiceClassIdentifer(uint16_t)
201
 * ordered from most specific to most generic
202
 */
203
static inline int sdp_get_service_classes(const sdp_record_t *rec, sdp_list_t **seqp)
204
0
{
205
0
  return sdp_get_uuidseq_attr(rec, SDP_ATTR_SVCLASS_ID_LIST, seqp);
206
0
}
Unexecuted instantiation: fuzz_hci.c:sdp_get_service_classes
Unexecuted instantiation: sdp-xml.c:sdp_get_service_classes
Unexecuted instantiation: fuzz_xml.c:sdp_get_service_classes
Unexecuted instantiation: sdp.c:sdp_get_service_classes
Unexecuted instantiation: fuzz_sdp.c:sdp_get_service_classes
207
208
/*
209
 * Set the BrowseGroupList attribute to the list specified by seq.
210
 *
211
 * A service can belong to one or more service groups
212
 * and the list comprises such group identifiers (UUIDs)
213
 */
214
static inline int sdp_set_browse_groups(sdp_record_t *rec, sdp_list_t *seq)
215
0
{
216
0
  return sdp_set_uuidseq_attr(rec, SDP_ATTR_BROWSE_GRP_LIST, seq);
217
0
}
Unexecuted instantiation: fuzz_hci.c:sdp_set_browse_groups
Unexecuted instantiation: sdp-xml.c:sdp_set_browse_groups
Unexecuted instantiation: fuzz_xml.c:sdp_set_browse_groups
Unexecuted instantiation: sdp.c:sdp_set_browse_groups
Unexecuted instantiation: fuzz_sdp.c:sdp_set_browse_groups
218
219
/*
220
 * Set the access protocols of the record to those specified in proto
221
 */
222
int sdp_set_access_protos(sdp_record_t *rec, const sdp_list_t *proto);
223
224
/*
225
 * Set the additional access protocols of the record to those specified in proto
226
 */
227
int sdp_set_add_access_protos(sdp_record_t *rec, const sdp_list_t *proto);
228
229
/*
230
 * Get protocol port (i.e. PSM for L2CAP, Channel for RFCOMM)
231
 */
232
int sdp_get_proto_port(const sdp_list_t *list, int proto);
233
234
/*
235
 * Get protocol descriptor.
236
 */
237
sdp_data_t *sdp_get_proto_desc(sdp_list_t *list, int proto);
238
239
/*
240
 * Set the LanguageBase attributes to the values specified in list
241
 * (a linked list of sdp_lang_attr_t objects, one for each language in
242
 * which user-visible attributes are present).
243
 */
244
int sdp_set_lang_attr(sdp_record_t *rec, const sdp_list_t *list);
245
246
/*
247
 * Set the ServiceInfoTimeToLive attribute of the service.
248
 * This is the number of seconds that this record is guaranteed
249
 * not to change after being obtained by a client.
250
 */
251
static inline int sdp_set_service_ttl(sdp_record_t *rec, uint32_t ttl)
252
0
{
253
0
  return sdp_attr_add_new(rec, SDP_ATTR_SVCINFO_TTL, SDP_UINT32, &ttl);
254
0
}
Unexecuted instantiation: fuzz_hci.c:sdp_set_service_ttl
Unexecuted instantiation: sdp-xml.c:sdp_set_service_ttl
Unexecuted instantiation: fuzz_xml.c:sdp_set_service_ttl
Unexecuted instantiation: sdp.c:sdp_set_service_ttl
Unexecuted instantiation: fuzz_sdp.c:sdp_set_service_ttl
255
256
/*
257
 * Set the ServiceRecordState attribute of a service. This is
258
 * guaranteed to change if there is any kind of modification to
259
 * the record.
260
 */
261
static inline int sdp_set_record_state(sdp_record_t *rec, uint32_t state)
262
0
{
263
0
  return sdp_attr_add_new(rec, SDP_ATTR_RECORD_STATE, SDP_UINT32, &state);
264
0
}
Unexecuted instantiation: fuzz_hci.c:sdp_set_record_state
Unexecuted instantiation: sdp-xml.c:sdp_set_record_state
Unexecuted instantiation: fuzz_xml.c:sdp_set_record_state
Unexecuted instantiation: sdp.c:sdp_set_record_state
Unexecuted instantiation: fuzz_sdp.c:sdp_set_record_state
265
266
/*
267
 * Set the ServiceID attribute of a service.
268
 */
269
void sdp_set_service_id(sdp_record_t *rec, uuid_t uuid);
270
271
/*
272
 * Set the GroupID attribute of a service
273
 */
274
void sdp_set_group_id(sdp_record_t *rec, uuid_t grouuuid);
275
276
/*
277
 * Set the ServiceAvailability attribute of a service.
278
 *
279
 * Note that this represents the relative availability
280
 * of the service: 0x00 means completely unavailable;
281
 * 0xFF means maximum availability.
282
 */
283
static inline int sdp_set_service_avail(sdp_record_t *rec, uint8_t avail)
284
0
{
285
0
  return sdp_attr_add_new(rec, SDP_ATTR_SERVICE_AVAILABILITY, SDP_UINT8, &avail);
286
0
}
Unexecuted instantiation: fuzz_hci.c:sdp_set_service_avail
Unexecuted instantiation: sdp-xml.c:sdp_set_service_avail
Unexecuted instantiation: fuzz_xml.c:sdp_set_service_avail
Unexecuted instantiation: sdp.c:sdp_set_service_avail
Unexecuted instantiation: fuzz_sdp.c:sdp_set_service_avail
287
288
/*
289
 * Set the profile descriptor list attribute of a record.
290
 *
291
 * Each element in the list is an object of type
292
 * sdp_profile_desc_t which is a definition of the
293
 * Bluetooth profile that this service conforms to.
294
 */
295
int sdp_set_profile_descs(sdp_record_t *rec, const sdp_list_t *desc);
296
297
/*
298
 * Set URL attributes of a record.
299
 *
300
 * ClientExecutableURL: a URL to a client's platform specific (WinCE,
301
 * PalmOS) executable code that can be used to access this service.
302
 *
303
 * DocumentationURL: a URL pointing to service documentation
304
 *
305
 * IconURL: a URL to an icon that can be used to represent this service.
306
 *
307
 * Note: pass NULL for any URLs that you don't want to set or remove
308
 */
309
void sdp_set_url_attr(sdp_record_t *rec, const char *clientExecURL, const char *docURL, const char *iconURL);
310
311
/*
312
 * a service search request.
313
 *
314
 *  INPUT :
315
 *
316
 *    sdp_list_t *search
317
 *      list containing elements of the search
318
 *      pattern. Each entry in the list is a UUID
319
 *      of the service to be searched
320
 *
321
 *    uint16_t max_rec_num
322
 *       An integer specifying the maximum number of
323
 *       entries that the client can handle in the response.
324
 *
325
 *  OUTPUT :
326
 *
327
 *    int return value
328
 *      0
329
 *        The request completed successfully. This does not
330
 *        mean the requested services were found
331
 *      -1
332
 *        The request completed unsuccessfully
333
 *
334
 *    sdp_list_t *rsp_list
335
 *      This variable is set on a successful return if there are
336
 *      non-zero service handles. It is a singly linked list of
337
 *      service record handles (uint16_t)
338
 */
339
int sdp_service_search_req(sdp_session_t *session, const sdp_list_t *search, uint16_t max_rec_num, sdp_list_t **rsp_list);
340
341
/*
342
 *  a service attribute request.
343
 *
344
 *  INPUT :
345
 *
346
 *    uint32_t handle
347
 *      The handle of the service for which the attribute(s) are
348
 *      requested
349
 *
350
 *    sdp_attrreq_type_t reqtype
351
 *      Attribute identifiers are 16 bit unsigned integers specified
352
 *      in one of 2 ways described below :
353
 *      SDP_ATTR_REQ_INDIVIDUAL - 16bit individual identifiers
354
 *         They are the actual attribute identifiers in ascending order
355
 *
356
 *      SDP_ATTR_REQ_RANGE - 32bit identifier range
357
 *         The high-order 16bits is the start of range
358
 *         the low-order 16bits are the end of range
359
 *         0x0000 to 0xFFFF gets all attributes
360
 *
361
 *    sdp_list_t *attrid_list
362
 *      Singly linked list containing attribute identifiers desired.
363
 *      Every element is either a uint16_t(attrSpec = SDP_ATTR_REQ_INDIVIDUAL)
364
 *      or a uint32_t(attrSpec=SDP_ATTR_REQ_RANGE)
365
 *
366
 *  OUTPUT :
367
 *    int return value
368
 *      0
369
 *        The request completed successfully. This does not
370
 *        mean the requested services were found
371
 *      -1
372
 *        The request completed unsuccessfully due to a timeout
373
 */
374
sdp_record_t *sdp_service_attr_req(sdp_session_t *session, uint32_t handle, sdp_attrreq_type_t reqtype, const sdp_list_t *attrid_list);
375
376
/*
377
 *  This is a service search request combined with the service
378
 *  attribute request. First a service class match is done and
379
 *  for matching service, requested attributes are extracted
380
 *
381
 *  INPUT :
382
 *
383
 *    sdp_list_t *search
384
 *      Singly linked list containing elements of the search
385
 *      pattern. Each entry in the list is a UUID(DataTypeSDP_UUID16)
386
 *      of the service to be searched
387
 *
388
 *    AttributeSpecification attrSpec
389
 *      Attribute identifiers are 16 bit unsigned integers specified
390
 *      in one of 2 ways described below :
391
 *      SDP_ATTR_REQ_INDIVIDUAL - 16bit individual identifiers
392
 *         They are the actual attribute identifiers in ascending order
393
 *
394
 *      SDP_ATTR_REQ_RANGE - 32bit identifier range
395
 *         The high-order 16bits is the start of range
396
 *         the low-order 16bits are the end of range
397
 *         0x0000 to 0xFFFF gets all attributes
398
 *
399
 *    sdp_list_t *attrid_list
400
 *      Singly linked list containing attribute identifiers desired.
401
 *      Every element is either a uint16_t(attrSpec = SDP_ATTR_REQ_INDIVIDUAL)
402
 *      or a uint32_t(attrSpec=SDP_ATTR_REQ_RANGE)
403
 *
404
 *  OUTPUT :
405
 *    int return value
406
 *      0
407
 *        The request completed successfully. This does not
408
 *        mean the requested services were found
409
 *      -1
410
 *        The request completed unsuccessfully due to a timeout
411
 *
412
 *    sdp_list_t *rsp_list
413
 *      This variable is set on a successful return to point to
414
 *      service(s) found. Each element of this list is of type
415
 *      sdp_record_t *.
416
 */
417
int sdp_service_search_attr_req(sdp_session_t *session, const sdp_list_t *search, sdp_attrreq_type_t reqtype, const sdp_list_t *attrid_list, sdp_list_t **rsp_list);
418
419
/*
420
 * Allocate/free a service record and its attributes
421
 */
422
sdp_record_t *sdp_record_alloc(void);
423
void sdp_record_free(sdp_record_t *rec);
424
425
/*
426
 * Register a service record.
427
 *
428
 * Note: It is the responsbility of the Service Provider to create the
429
 * record first and set its attributes using setXXX() methods.
430
 *
431
 * The service provider must then call sdp_record_register() to make
432
 * the service record visible to SDP clients.  This function returns 0
433
 * on success or -1 on failure (and sets errno).
434
 */
435
int sdp_device_record_register_binary(sdp_session_t *session, bdaddr_t *device, uint8_t *data, uint32_t size, uint8_t flags, uint32_t *handle);
436
int sdp_device_record_register(sdp_session_t *session, bdaddr_t *device, sdp_record_t *rec, uint8_t flags);
437
int sdp_record_register(sdp_session_t *session, sdp_record_t *rec, uint8_t flags);
438
439
/*
440
 * Unregister a service record.
441
 */
442
int sdp_device_record_unregister_binary(sdp_session_t *session, bdaddr_t *device, uint32_t handle);
443
int sdp_device_record_unregister(sdp_session_t *session, bdaddr_t *device, sdp_record_t *rec);
444
int sdp_record_unregister(sdp_session_t *session, sdp_record_t *rec);
445
446
/*
447
 * Update an existing service record.  (Calling this function
448
 * before a previous call to sdp_record_register() will result
449
 * in an error.)
450
 */
451
int sdp_device_record_update_binary(sdp_session_t *session, bdaddr_t *device, uint32_t handle, uint8_t *data, uint32_t size);
452
int sdp_device_record_update(sdp_session_t *session, bdaddr_t *device, const sdp_record_t *rec);
453
int sdp_record_update(sdp_session_t *sess, const sdp_record_t *rec);
454
455
void sdp_record_print(const sdp_record_t *rec);
456
457
/*
458
 * UUID functions
459
 */
460
uuid_t *sdp_uuid16_create(uuid_t *uuid, uint16_t data);
461
uuid_t *sdp_uuid32_create(uuid_t *uuid, uint32_t data);
462
uuid_t *sdp_uuid128_create(uuid_t *uuid, const void *data);
463
int sdp_uuid16_cmp(const void *p1, const void *p2);
464
int sdp_uuid128_cmp(const void *p1, const void *p2);
465
int sdp_uuid_cmp(const void *p1, const void *p2);
466
uuid_t *sdp_uuid_to_uuid128(const uuid_t *uuid);
467
void sdp_uuid16_to_uuid128(uuid_t *uuid128, const uuid_t *uuid16);
468
void sdp_uuid32_to_uuid128(uuid_t *uuid128, const uuid_t *uuid32);
469
int sdp_uuid128_to_uuid(uuid_t *uuid);
470
int sdp_uuid_to_proto(uuid_t *uuid);
471
int sdp_uuid_extract(const uint8_t *buffer, int bufsize, uuid_t *uuid, int *scanned);
472
void sdp_uuid_print(const uuid_t *uuid);
473
474
#define MAX_LEN_UUID_STR 37
475
#define MAX_LEN_PROTOCOL_UUID_STR 8
476
#define MAX_LEN_SERVICECLASS_UUID_STR 28
477
#define MAX_LEN_PROFILEDESCRIPTOR_UUID_STR 28
478
479
int sdp_uuid2strn(const uuid_t *uuid, char *str, size_t n);
480
int sdp_proto_uuid2strn(const uuid_t *uuid, char *str, size_t n);
481
int sdp_svclass_uuid2strn(const uuid_t *uuid, char *str, size_t n);
482
int sdp_profile_uuid2strn(const uuid_t *uuid, char *str, size_t n);
483
484
/*
485
 * In all the sdp_get_XXX(handle, XXX *xxx) functions below,
486
 * the XXX * is set to point to the value, should it exist
487
 * and 0 is returned. If the value does not exist, -1 is
488
 * returned and errno set to ENODATA.
489
 *
490
 * In all the methods below, the memory management rules are
491
 * simple. Don't free anything! The pointer returned, in the
492
 * case of constructed types, is a pointer to the contents
493
 * of the sdp_record_t.
494
 */
495
496
/*
497
 * Get the access protocols from the service record
498
 */
499
int sdp_get_access_protos(const sdp_record_t *rec, sdp_list_t **protos);
500
501
/*
502
 * Get the additional access protocols from the service record
503
 */
504
int sdp_get_add_access_protos(const sdp_record_t *rec, sdp_list_t **protos);
505
506
/*
507
 * Extract the list of browse groups to which the service belongs.
508
 * When set, seqp contains elements of GroupID (uint16_t)
509
 */
510
static inline int sdp_get_browse_groups(const sdp_record_t *rec, sdp_list_t **seqp)
511
0
{
512
0
  return sdp_get_uuidseq_attr(rec, SDP_ATTR_BROWSE_GRP_LIST, seqp);
513
0
}
Unexecuted instantiation: fuzz_hci.c:sdp_get_browse_groups
Unexecuted instantiation: sdp-xml.c:sdp_get_browse_groups
Unexecuted instantiation: fuzz_xml.c:sdp_get_browse_groups
Unexecuted instantiation: sdp.c:sdp_get_browse_groups
Unexecuted instantiation: fuzz_sdp.c:sdp_get_browse_groups
514
515
/*
516
 * Extract language attribute meta-data of the service record.
517
 * For each language in the service record, LangSeq has a struct of type
518
 * sdp_lang_attr_t.
519
 */
520
int sdp_get_lang_attr(const sdp_record_t *rec, sdp_list_t **langSeq);
521
522
/*
523
 * Extract the Bluetooth profile descriptor sequence from a record.
524
 * Each element in the list is of type sdp_profile_desc_t
525
 * which contains the UUID of the profile and its version number
526
 * (encoded as major and minor in the high-order 8bits
527
 * and low-order 8bits respectively of the uint16_t)
528
 */
529
int sdp_get_profile_descs(const sdp_record_t *rec, sdp_list_t **profDesc);
530
531
/*
532
 * Extract SDP server version numbers
533
 *
534
 * Note: that this is an attribute of the SDP server only and
535
 * contains a list of uint16_t each of which represent the
536
 * major and minor SDP version numbers supported by this server
537
 */
538
int sdp_get_server_ver(const sdp_record_t *rec, sdp_list_t **pVnumList);
539
540
int sdp_get_service_id(const sdp_record_t *rec, uuid_t *uuid);
541
int sdp_get_group_id(const sdp_record_t *rec, uuid_t *uuid);
542
int sdp_get_record_state(const sdp_record_t *rec, uint32_t *svcRecState);
543
int sdp_get_service_avail(const sdp_record_t *rec, uint8_t *svcAvail);
544
int sdp_get_service_ttl(const sdp_record_t *rec, uint32_t *svcTTLInfo);
545
int sdp_get_database_state(const sdp_record_t *rec, uint32_t *svcDBState);
546
547
static inline int sdp_get_service_name(const sdp_record_t *rec, char *str,
548
                size_t len)
549
0
{
550
0
  return sdp_get_string_attr(rec, SDP_ATTR_SVCNAME_PRIMARY, str, len);
551
0
}
Unexecuted instantiation: fuzz_hci.c:sdp_get_service_name
Unexecuted instantiation: sdp-xml.c:sdp_get_service_name
Unexecuted instantiation: fuzz_xml.c:sdp_get_service_name
Unexecuted instantiation: sdp.c:sdp_get_service_name
Unexecuted instantiation: fuzz_sdp.c:sdp_get_service_name
552
553
static inline int sdp_get_service_desc(const sdp_record_t *rec, char *str,
554
                size_t len)
555
0
{
556
0
  return sdp_get_string_attr(rec, SDP_ATTR_SVCDESC_PRIMARY, str, len);
557
0
}
Unexecuted instantiation: fuzz_hci.c:sdp_get_service_desc
Unexecuted instantiation: sdp-xml.c:sdp_get_service_desc
Unexecuted instantiation: fuzz_xml.c:sdp_get_service_desc
Unexecuted instantiation: sdp.c:sdp_get_service_desc
Unexecuted instantiation: fuzz_sdp.c:sdp_get_service_desc
558
559
static inline int sdp_get_provider_name(const sdp_record_t *rec, char *str,
560
                size_t len)
561
0
{
562
0
  return sdp_get_string_attr(rec, SDP_ATTR_PROVNAME_PRIMARY, str, len);
563
0
}
Unexecuted instantiation: fuzz_hci.c:sdp_get_provider_name
Unexecuted instantiation: sdp-xml.c:sdp_get_provider_name
Unexecuted instantiation: fuzz_xml.c:sdp_get_provider_name
Unexecuted instantiation: sdp.c:sdp_get_provider_name
Unexecuted instantiation: fuzz_sdp.c:sdp_get_provider_name
564
565
static inline int sdp_get_doc_url(const sdp_record_t *rec, char *str,
566
                size_t len)
567
0
{
568
0
  return sdp_get_string_attr(rec, SDP_ATTR_DOC_URL, str, len);
569
0
}
Unexecuted instantiation: fuzz_hci.c:sdp_get_doc_url
Unexecuted instantiation: sdp-xml.c:sdp_get_doc_url
Unexecuted instantiation: fuzz_xml.c:sdp_get_doc_url
Unexecuted instantiation: sdp.c:sdp_get_doc_url
Unexecuted instantiation: fuzz_sdp.c:sdp_get_doc_url
570
571
static inline int sdp_get_clnt_exec_url(const sdp_record_t *rec, char *str,
572
                size_t len)
573
0
{
574
0
  return sdp_get_string_attr(rec, SDP_ATTR_CLNT_EXEC_URL, str, len);
575
0
}
Unexecuted instantiation: fuzz_hci.c:sdp_get_clnt_exec_url
Unexecuted instantiation: sdp-xml.c:sdp_get_clnt_exec_url
Unexecuted instantiation: fuzz_xml.c:sdp_get_clnt_exec_url
Unexecuted instantiation: sdp.c:sdp_get_clnt_exec_url
Unexecuted instantiation: fuzz_sdp.c:sdp_get_clnt_exec_url
576
577
static inline int sdp_get_icon_url(const sdp_record_t *rec, char *str,
578
                size_t len)
579
0
{
580
0
  return sdp_get_string_attr(rec, SDP_ATTR_ICON_URL, str, len);
581
0
}
Unexecuted instantiation: fuzz_hci.c:sdp_get_icon_url
Unexecuted instantiation: sdp-xml.c:sdp_get_icon_url
Unexecuted instantiation: fuzz_xml.c:sdp_get_icon_url
Unexecuted instantiation: sdp.c:sdp_get_icon_url
Unexecuted instantiation: fuzz_sdp.c:sdp_get_icon_url
582
583
/*
584
 * Set the supported features
585
 * sf should be a list of list with each feature data
586
 * Returns 0 on success -1 on fail
587
 */
588
int sdp_set_supp_feat(sdp_record_t *rec, const sdp_list_t *sf);
589
590
/*
591
 * Get the supported features
592
 * seqp is set to a list of list with each feature data
593
 * Returns 0 on success, if an error occurred -1 is returned and errno is set
594
 */
595
int sdp_get_supp_feat(const sdp_record_t *rec, sdp_list_t **seqp);
596
597
sdp_record_t *sdp_extract_pdu(const uint8_t *pdata, int bufsize, int *scanned);
598
sdp_record_t *sdp_copy_record(sdp_record_t *rec);
599
600
void sdp_data_print(sdp_data_t *data);
601
void sdp_print_service_attr(sdp_list_t *alist);
602
603
int sdp_attrid_comp_func(const void *key1, const void *key2);
604
605
void sdp_set_seq_len(uint8_t *ptr, uint32_t length);
606
void sdp_set_attrid(sdp_buf_t *pdu, uint16_t id);
607
void sdp_append_to_pdu(sdp_buf_t *dst, sdp_data_t *d);
608
void sdp_append_to_buf(sdp_buf_t *dst, uint8_t *data, uint32_t len);
609
610
int sdp_gen_pdu(sdp_buf_t *pdu, sdp_data_t *data);
611
int sdp_gen_record_pdu(const sdp_record_t *rec, sdp_buf_t *pdu);
612
613
int sdp_extract_seqtype(const uint8_t *buf, int bufsize, uint8_t *dtdp, int *size);
614
615
sdp_data_t *sdp_extract_attr(const uint8_t *pdata, int bufsize, int *extractedLength, sdp_record_t *rec);
616
617
void sdp_pattern_add_uuid(sdp_record_t *rec, uuid_t *uuid);
618
void sdp_pattern_add_uuidseq(sdp_record_t *rec, sdp_list_t *seq);
619
620
int sdp_send_req_w4_rsp(sdp_session_t *session, uint8_t *req, uint8_t *rsp, uint32_t reqsize, uint32_t *rspsize);
621
622
void sdp_add_lang_attr(sdp_record_t *rec);
623
624
#ifdef __cplusplus
625
}
626
#endif
627
628
#endif /* __SDP_LIB_H */