sdp_lib.h 21 KB

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