📄 sdp_lib.h
字号:
/* * a service search request. * * INPUT : * * sdp_list_t *search_list * list containing elements of the search * pattern. Each entry in the list is a UUID * of the service to be searched * * uint16_t max_rec_num * An integer specifying the maximum number of * entries that the client can handle in the response. * * OUTPUT : * * int return value * 0 * The request completed successfully. This does not * mean the requested services were found * -1 * The request completed unsuccessfully * * sdp_list_t *rsp_list * This variable is set on a successful return if there are * non-zero service handles. It is a singly linked list of * service records (sdp_record_t) */int sdp_service_search_req(sdp_session_t *session, const sdp_list_t *search_list, uint16_t max_rec_num, sdp_list_t **rsp_list);/* * a service attribute request. * * INPUT : * * uint32_t handle * The handle of the service for which the attribute(s) are * requested * * sdp_attrreq_type_t reqtype * Attribute identifiers are 16 bit unsigned integers specified * in one of 2 ways described below : * SDP_ATTR_REQ_INDIVIDUAL - 16bit individual identifiers * They are the actual attribute identifiers in ascending order * * SDP_ATTR_REQ_RANGE - 32bit identifier range * The high-order 16bits is the start of range * the low-order 16bits are the end of range * 0x0000 to 0xFFFF gets all attributes * * sdp_list_t *attrid_list * Singly linked list containing attribute identifiers desired. * Every element is either a uint16_t(attrSpec = SDP_ATTR_REQ_INDIVIDUAL) * or a uint32_t(attrSpec=SDP_ATTR_REQ_RANGE) * * OUTPUT : * int return value * 0 * The request completed successfully. This does not * mean the requested services were found * -1 * The request completed unsuccessfully due to a timeout */typedef enum { /* * Attributes are specified as individual elements */ SDP_ATTR_REQ_INDIVIDUAL = 1, /* * Attributes are specified as a range */ SDP_ATTR_REQ_RANGE} sdp_attrreq_type_t;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);/* * This is a service search request combined with the service * attribute request. First a service class match is done and * for matching service, requested attributes are extracted * * INPUT : * * sdp_list_t *search_list * Singly linked list containing elements of the search * pattern. Each entry in the list is a UUID(DataTypeSDP_UUID16) * of the service to be searched * * AttributeSpecification attrSpec * Attribute identifiers are 16 bit unsigned integers specified * in one of 2 ways described below : * SDP_ATTR_REQ_INDIVIDUAL - 16bit individual identifiers * They are the actual attribute identifiers in ascending order * * SDP_ATTR_REQ_RANGE - 32bit identifier range * The high-order 16bits is the start of range * the low-order 16bits are the end of range * 0x0000 to 0xFFFF gets all attributes * * sdp_list_t *attrid_list * Singly linked list containing attribute identifiers desired. * Every element is either a uint16_t(attrSpec = SDP_ATTR_REQ_INDIVIDUAL) * or a uint32_t(attrSpec=SDP_ATTR_REQ_RANGE) * * OUTPUT : * int return value * 0 * The request completed successfully. This does not * mean the requested services were found * -1 * The request completed unsuccessfully due to a timeout * * sdp_list_t *rsp_list * This variable is set on a successful return to point to * service(s) found. Each element of this list is of type * sdp_record_t *. */int sdp_service_search_attr_req(sdp_session_t *session, const sdp_list_t *search_list, sdp_attrreq_type_t reqtype, const sdp_list_t *attrid_list, sdp_list_t **rsp_list);/* * Allocate/free a service record and its attributes */sdp_record_t *sdp_record_alloc(void);void sdp_record_free(sdp_record_t *rec);/* * Register a service record. * * Note: It is the responsbility of the Service Provider to create the * record first and set its attributes using setXXX() methods. * * The service provider must then call sdp_record_register() to make * the service record visible to SDP clients. */int sdp_record_register(sdp_session_t *sess, sdp_record_t *rec, uint8_t flags);/* * Unregister a service record. */int sdp_record_unregister(sdp_session_t *sess, sdp_record_t *rec);/* * Update an existing service record. (Calling this function * before a previous call to sdp_record_register() will result * in an error.) */int sdp_record_update(sdp_session_t *sess, const sdp_record_t *rec);void sdp_record_print(const sdp_record_t *rec);/* * UUID functions */uuid_t *sdp_uuid16_create(uuid_t *uuid, uint16_t data);uuid_t *sdp_uuid32_create(uuid_t *uuid, uint32_t data);uuid_t *sdp_uuid128_create(uuid_t *uuid, const void *data);int sdp_uuid16_cmp(const void *p1, const void *p2);int sdp_uuid128_cmp(const void *p1, const void *p2);uuid_t *sdp_uuid_to_uuid128(uuid_t *uuid);void sdp_uuid16_to_uuid128(uuid_t *uuid128, uuid_t *uuid16);int sdp_uuid128_to_uuid(uuid_t *uuid);int sdp_uuid_to_proto(uuid_t *uuid);int sdp_uuid_extract(const char *buffer, uuid_t *uuid, int *scanned);void sdp_uuid_print(const uuid_t *uuid);#define MAX_LEN_UUID_STR 37#define MAX_LEN_PROTOCOL_UUID_STR 8#define MAX_LEN_SERVICECLASS_UUID_STR 24#define MAX_LEN_PROFILEDESCRIPTOR_UUID_STR 22int sdp_uuid2strn(const uuid_t *uuid, char *str, size_t n);int sdp_proto_uuid2strn(const uuid_t *uuid, char *str, size_t n);int sdp_svclass_uuid2strn(const uuid_t *uuid, char *str, size_t n);int sdp_profile_uuid2strn(const uuid_t *uuid, char *str, size_t n);/* * In all the sdp_get_XXX(handle, XXX *xxx) functions below, * the XXX * is set to point to the value, should it exist * and 0 is returned. If the value does not exist, -1 is * returned and errno set to ENODATA. * * In all the methods below, the memory management rules are * simple. Don't free anything! The pointer returned, in the * case of constructed types, is a pointer to the contents * of the sdp_record_t. *//* * Get the access protocols from the service record */int sdp_get_access_protos(const sdp_record_t *rec, sdp_list_t **protos);/* * Extract the list of browse groups to which the service belongs. * When set, seqp contains elements of GroupID (uint16_t) */static inline int sdp_get_browse_groups(const sdp_record_t *rec, sdp_list_t **seqp){ return sdp_get_uuidseq_attr(rec, SDP_ATTR_BROWSE_GRP_LIST, seqp);}/* * Extract language attribute meta-data of the service record. * For each language in the service record, LangSeq has a struct of type * sdp_lang_attr_t. */int sdp_get_lang_attr(const sdp_record_t *rec, sdp_list_t **langSeq);/* * Extract the Bluetooth profile descriptor sequence from a record. * Each element in the list is of type sdp_profile_desc_t * which contains the UUID of the profile and its version number * (encoded as major and minor in the high-order 8bits * and low-order 8bits respectively of the uint16_t) */int sdp_get_profile_descs(const sdp_record_t *rec, sdp_list_t **profDesc);/* * Extract SDP server version numbers * * Note: that this is an attribute of the SDP server only and * contains a list of uint16_t each of which represent the * major and minor SDP version numbers supported by this server */int sdp_get_server_ver(const sdp_record_t *rec, sdp_list_t **pVnumList);int sdp_get_service_id(const sdp_record_t *rec, uuid_t *uuid);int sdp_get_group_id(const sdp_record_t *rec, uuid_t *uuid);int sdp_get_record_state(const sdp_record_t *rec, uint32_t *svcRecState);int sdp_get_service_avail(const sdp_record_t *rec, uint8_t *svcAvail);int sdp_get_service_ttl(const sdp_record_t *rec, uint32_t *svcTTLInfo);int sdp_get_database_state(const sdp_record_t *rec, uint32_t *svcDBState);static inline int sdp_get_service_name(const sdp_record_t *rec, char *str, int len){ return sdp_get_string_attr(rec, SDP_ATTR_SVCNAME_PRIMARY, str, len);}static inline int sdp_get_service_desc(const sdp_record_t *rec, char *str, int len){ return sdp_get_string_attr(rec, SDP_ATTR_SVCDESC_PRIMARY, str, len);}static inline int sdp_get_provider_name(const sdp_record_t *rec, char *str, int len){ return sdp_get_string_attr(rec, SDP_ATTR_PROVNAME_PRIMARY, str, len);}static inline int sdp_get_doc_url(const sdp_record_t *rec, char *str, int len){ return sdp_get_string_attr(rec, SDP_ATTR_DOC_URL, str, len);}static inline int sdp_get_clnt_exec_url(const sdp_record_t *rec, char *str, int len){ return sdp_get_string_attr(rec, SDP_ATTR_CLNT_EXEC_URL, str, len);}static inline int sdp_get_icon_url(const sdp_record_t *rec, char *str, int len){ return sdp_get_string_attr(rec, SDP_ATTR_ICON_URL, str, len);}#ifdef __cplusplus}#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -