sdp_lib.h 21 KB

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