本文整理汇总了C++中sdp_data_alloc函数的典型用法代码示例。如果您正苦于以下问题:C++ sdp_data_alloc函数的具体用法?C++ sdp_data_alloc怎么用?C++ sdp_data_alloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sdp_data_alloc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sdp_record_alloc
static sdp_record_t *a2dp_record(void)
{
sdp_list_t *svclass_id, *pfseq, *apseq, *root;
uuid_t root_uuid, l2cap_uuid, avdtp_uuid, a2dp_uuid;
sdp_profile_desc_t profile[1];
sdp_list_t *aproto, *proto[2];
sdp_record_t *record;
sdp_data_t *psm, *version, *features;
uint16_t lp = AVDTP_UUID;
uint16_t a2dp_ver = 0x0103, avdtp_ver = 0x0103, feat = 0x000f;
record = sdp_record_alloc();
if (!record)
return NULL;
sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
root = sdp_list_append(NULL, &root_uuid);
sdp_set_browse_groups(record, root);
sdp_uuid16_create(&a2dp_uuid, AUDIO_SOURCE_SVCLASS_ID);
svclass_id = sdp_list_append(NULL, &a2dp_uuid);
sdp_set_service_classes(record, svclass_id);
sdp_uuid16_create(&profile[0].uuid, ADVANCED_AUDIO_PROFILE_ID);
profile[0].version = a2dp_ver;
pfseq = sdp_list_append(NULL, &profile[0]);
sdp_set_profile_descs(record, pfseq);
sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
proto[0] = sdp_list_append(NULL, &l2cap_uuid);
psm = sdp_data_alloc(SDP_UINT16, &lp);
proto[0] = sdp_list_append(proto[0], psm);
apseq = sdp_list_append(NULL, proto[0]);
sdp_uuid16_create(&avdtp_uuid, AVDTP_UUID);
proto[1] = sdp_list_append(NULL, &avdtp_uuid);
version = sdp_data_alloc(SDP_UINT16, &avdtp_ver);
proto[1] = sdp_list_append(proto[1], version);
apseq = sdp_list_append(apseq, proto[1]);
aproto = sdp_list_append(NULL, apseq);
sdp_set_access_protos(record, aproto);
features = sdp_data_alloc(SDP_UINT16, &feat);
sdp_attr_add(record, SDP_ATTR_SUPPORTED_FEATURES, features);
sdp_set_info_attr(record, "Audio Source", NULL, NULL);
sdp_data_free(psm);
sdp_data_free(version);
sdp_list_free(proto[0], NULL);
sdp_list_free(proto[1], NULL);
sdp_list_free(apseq, NULL);
sdp_list_free(pfseq, NULL);
sdp_list_free(aproto, NULL);
sdp_list_free(root, NULL);
sdp_list_free(svclass_id, NULL);
return record;
}
示例2: DBG
static sdp_list_t *mdeps_to_sdp_features(struct mdep_cfg *mdep)
{
sdp_data_t *mdepid, *dtype = NULL, *role = NULL, *descr = NULL;
sdp_list_t *f_list = NULL;
DBG("");
mdepid = sdp_data_alloc(SDP_UINT8, &mdep->id);
if (!mdepid)
return NULL;
dtype = sdp_data_alloc(SDP_UINT16, &mdep->data_type);
if (!dtype)
goto fail;
role = sdp_data_alloc(SDP_UINT8, &mdep->role);
if (!role)
goto fail;
if (mdep->descr) {
descr = sdp_data_alloc(SDP_TEXT_STR8, mdep->descr);
if (!descr)
goto fail;
}
f_list = sdp_list_append(NULL, mdepid);
if (!f_list)
goto fail;
if (!sdp_list_append(f_list, dtype))
goto fail;
if (!sdp_list_append(f_list, role))
goto fail;
if (descr && !sdp_list_append(f_list, descr))
goto fail;
return f_list;
fail:
sdp_list_free(f_list, NULL);
if (mdepid)
sdp_data_free(mdepid);
if (dtype)
sdp_data_free(dtype);
if (role)
sdp_data_free(role);
if (descr)
sdp_data_free(descr);
return NULL;
}
示例3: sdp_data_alloc
static sdp_list_t *app_to_sdplist(struct hdp_application *app)
{
sdp_data_t *mdepid,
*dtype = NULL,
*role = NULL,
*desc = NULL;
sdp_list_t *f_list = NULL;
mdepid = sdp_data_alloc(SDP_UINT8, &app->id);
if (mdepid == NULL)
return NULL;
dtype = sdp_data_alloc(SDP_UINT16, &app->data_type);
if (dtype == NULL)
goto fail;
role = sdp_data_alloc(SDP_UINT8, &app->role);
if (role == NULL)
goto fail;
if (app->description != NULL) {
desc = sdp_data_alloc(SDP_TEXT_STR8, app->description);
if (desc == NULL)
goto fail;
}
f_list = sdp_list_append(NULL, mdepid);
if (f_list == NULL)
goto fail;
if (sdp_list_append(f_list, dtype) == NULL)
goto fail;
if (sdp_list_append(f_list, role) == NULL)
goto fail;
if (desc != NULL)
if (sdp_list_append(f_list, desc) == NULL)
goto fail;
return f_list;
fail:
if (f_list != NULL)
sdp_list_free(f_list, NULL);
if (mdepid != NULL)
sdp_data_free(mdepid);
if (dtype != NULL)
sdp_data_free(dtype);
if (role != NULL)
sdp_data_free(role);
if (desc != NULL)
sdp_data_free(desc);
return NULL;
}
示例4: DBG
static sdp_list_t *app_to_sdplist(struct mcap_application *app)
{ DBG("");
sdp_data_t *mdepid,
*dtype = NULL,
*role = NULL,
*desc = NULL;
sdp_list_t *f_list = NULL;
mdepid = sdp_data_alloc(SDP_UINT8, &app->id);
if (!mdepid)
return NULL;
dtype = sdp_data_alloc(SDP_UINT16, &app->data_type);
if (!dtype)
goto fail;
role = sdp_data_alloc(SDP_UINT8, &app->role);
if (!role)
goto fail;
if (app->description) {
desc = sdp_data_alloc(SDP_TEXT_STR8, app->description);
if (!desc)
goto fail;
}
f_list = sdp_list_append(NULL, mdepid);
if (!f_list)
goto fail;
if (!sdp_list_append(f_list, dtype))
goto fail;
if (!sdp_list_append(f_list, role))
goto fail;
if (desc)
if (!sdp_list_append(f_list, desc))
goto fail;
return f_list;
fail:
if (f_list)
sdp_list_free(f_list, NULL);
if (mdepid)
sdp_data_free(mdepid);
if (dtype)
sdp_data_free(dtype);
if (role)
sdp_data_free(role);
if (desc)
sdp_data_free(desc);
return NULL;
}
示例5: update_db_timestamp
/*
* The service database state is an attribute of the service record
* of the SDP server itself. This attribute is guaranteed to
* change if any of the contents of the service repository
* changes. This function updates the timestamp of value of
* the svcDBState attribute
* Set the SDP server DB. Simply a timestamp which is the marker
* when the DB was modified.
*/
static void update_db_timestamp(void)
{
if (fixed_dbts) {
sdp_data_t *d = sdp_data_alloc(SDP_UINT32, &fixed_dbts);
sdp_attr_replace(server, SDP_ATTR_SVCDB_STATE, d);
} else {
uint32_t dbts = sdp_get_time();
sdp_data_t *d = sdp_data_alloc(SDP_UINT32, &dbts);
sdp_attr_replace(server, SDP_ATTR_SVCDB_STATE, d);
}
}
示例6: sdp_record_alloc
static sdp_record_t *create_rfcomm_record(uint8_t chan, uuid_t *uuid,
const char *svc_name,
bool has_obex)
{
sdp_list_t *svclass_id;
sdp_list_t *seq, *proto_seq, *pbg_seq;
sdp_list_t *proto[3];
uuid_t l2cap_uuid, rfcomm_uuid, obex_uuid, pbg_uuid;
sdp_data_t *channel;
sdp_record_t *record;
record = sdp_record_alloc();
if (!record)
return NULL;
record->handle = sdp_next_handle();
svclass_id = sdp_list_append(NULL, uuid);
sdp_set_service_classes(record, svclass_id);
sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
proto[0] = sdp_list_append(NULL, &l2cap_uuid);
seq = sdp_list_append(NULL, proto[0]);
sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
proto[1] = sdp_list_append(NULL, &rfcomm_uuid);
channel = sdp_data_alloc(SDP_UINT8, &chan);
proto[1] = sdp_list_append(proto[1], channel);
seq = sdp_list_append(seq, proto[1]);
if (has_obex) {
sdp_uuid16_create(&obex_uuid, OBEX_UUID);
proto[2] = sdp_list_append(NULL, &obex_uuid);
seq = sdp_list_append(seq, proto[2]);
}
proto_seq = sdp_list_append(NULL, seq);
sdp_set_access_protos(record, proto_seq);
sdp_uuid16_create(&pbg_uuid, PUBLIC_BROWSE_GROUP);
pbg_seq = sdp_list_append(NULL, &pbg_uuid);
sdp_set_browse_groups(record, pbg_seq);
if (svc_name)
sdp_set_info_attr(record, svc_name, NULL, NULL);
sdp_data_free(channel);
sdp_list_free(proto[0], NULL);
sdp_list_free(proto[1], NULL);
if (has_obex)
sdp_list_free(proto[2], NULL);
sdp_list_free(seq, NULL);
sdp_list_free(proto_seq, NULL);
sdp_list_free(pbg_seq, NULL);
sdp_list_free(svclass_id, NULL);
return record;
}
示例7: register_device_id
void register_device_id(const uint16_t vendor, const uint16_t product,
const uint16_t version)
{
const uint16_t spec = 0x0102, source = 0x0002;
const uint8_t primary = 1;
sdp_list_t *class_list, *group_list, *profile_list;
uuid_t class_uuid, group_uuid;
sdp_data_t *sdp_data, *primary_data, *source_data;
sdp_data_t *spec_data, *vendor_data, *product_data, *version_data;
sdp_profile_desc_t profile;
sdp_record_t *record = sdp_record_alloc();
info("Adding device id record for %04x:%04x", vendor, product);
btd_manager_set_did(vendor, product, version);
record->handle = sdp_next_handle();
sdp_record_add(BDADDR_ANY, record);
sdp_data = sdp_data_alloc(SDP_UINT32, &record->handle);
sdp_attr_add(record, SDP_ATTR_RECORD_HANDLE, sdp_data);
sdp_uuid16_create(&class_uuid, PNP_INFO_SVCLASS_ID);
class_list = sdp_list_append(0, &class_uuid);
sdp_set_service_classes(record, class_list);
sdp_list_free(class_list, NULL);
sdp_uuid16_create(&group_uuid, PUBLIC_BROWSE_GROUP);
group_list = sdp_list_append(NULL, &group_uuid);
sdp_set_browse_groups(record, group_list);
sdp_list_free(group_list, NULL);
sdp_uuid16_create(&profile.uuid, PNP_INFO_PROFILE_ID);
profile.version = spec;
profile_list = sdp_list_append(NULL, &profile);
sdp_set_profile_descs(record, profile_list);
sdp_list_free(profile_list, NULL);
spec_data = sdp_data_alloc(SDP_UINT16, &spec);
sdp_attr_add(record, 0x0200, spec_data);
vendor_data = sdp_data_alloc(SDP_UINT16, &vendor);
sdp_attr_add(record, 0x0201, vendor_data);
product_data = sdp_data_alloc(SDP_UINT16, &product);
sdp_attr_add(record, 0x0202, product_data);
version_data = sdp_data_alloc(SDP_UINT16, &version);
sdp_attr_add(record, 0x0203, version_data);
primary_data = sdp_data_alloc(SDP_BOOL, &primary);
sdp_attr_add(record, 0x0204, primary_data);
source_data = sdp_data_alloc(SDP_UINT16, &source);
sdp_attr_add(record, 0x0205, source_data);
update_db_timestamp();
}
示例8: sdp_record_alloc
static sdp_record_t *create_sap_record(uint8_t channel)
{
sdp_list_t *apseq, *aproto, *profiles, *proto[2], *root, *svclass_id;
uuid_t sap_uuid, gt_uuid, root_uuid, l2cap, rfcomm;
sdp_profile_desc_t profile;
sdp_record_t *record;
sdp_data_t *ch;
record = sdp_record_alloc();
if (!record)
return NULL;
sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
root = sdp_list_append(NULL, &root_uuid);
sdp_set_browse_groups(record, root);
sdp_list_free(root, NULL);
sdp_uuid16_create(&sap_uuid, SAP_SVCLASS_ID);
svclass_id = sdp_list_append(NULL, &sap_uuid);
sdp_uuid16_create(>_uuid, GENERIC_TELEPHONY_SVCLASS_ID);
svclass_id = sdp_list_append(svclass_id, >_uuid);
sdp_set_service_classes(record, svclass_id);
sdp_list_free(svclass_id, NULL);
sdp_uuid16_create(&profile.uuid, SAP_PROFILE_ID);
profile.version = SAP_VERSION;
profiles = sdp_list_append(NULL, &profile);
sdp_set_profile_descs(record, profiles);
sdp_list_free(profiles, NULL);
sdp_uuid16_create(&l2cap, L2CAP_UUID);
proto[0] = sdp_list_append(NULL, &l2cap);
apseq = sdp_list_append(NULL, proto[0]);
sdp_uuid16_create(&rfcomm, RFCOMM_UUID);
proto[1] = sdp_list_append(NULL, &rfcomm);
ch = sdp_data_alloc(SDP_UINT8, &channel);
proto[1] = sdp_list_append(proto[1], ch);
apseq = sdp_list_append(apseq, proto[1]);
aproto = sdp_list_append(NULL, apseq);
sdp_set_access_protos(record, aproto);
sdp_set_info_attr(record, "SIM Access Server",
NULL, NULL);
sdp_data_free(ch);
sdp_list_free(proto[0], NULL);
sdp_list_free(proto[1], NULL);
sdp_list_free(apseq, NULL);
sdp_list_free(aproto, NULL);
return record;
}
示例9: sdp_record_alloc
static sdp_record_t *hfp_hs_record(uint8_t ch)
{
sdp_list_t *svclass_id, *pfseq, *apseq, *root;
uuid_t root_uuid, svclass_uuid, ga_svclass_uuid;
uuid_t l2cap_uuid, rfcomm_uuid;
sdp_profile_desc_t profile;
sdp_record_t *record;
sdp_list_t *aproto, *proto[2];
sdp_data_t *channel;
record = sdp_record_alloc();
if (!record)
return NULL;
sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
root = sdp_list_append(0, &root_uuid);
sdp_set_browse_groups(record, root);
sdp_uuid16_create(&svclass_uuid, HANDSFREE_SVCLASS_ID);
svclass_id = sdp_list_append(0, &svclass_uuid);
sdp_uuid16_create(&ga_svclass_uuid, GENERIC_AUDIO_SVCLASS_ID);
svclass_id = sdp_list_append(svclass_id, &ga_svclass_uuid);
sdp_set_service_classes(record, svclass_id);
sdp_uuid16_create(&profile.uuid, HANDSFREE_PROFILE_ID);
profile.version = 0x0105;
pfseq = sdp_list_append(0, &profile);
sdp_set_profile_descs(record, pfseq);
sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
proto[0] = sdp_list_append(0, &l2cap_uuid);
apseq = sdp_list_append(0, proto[0]);
sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
proto[1] = sdp_list_append(0, &rfcomm_uuid);
channel = sdp_data_alloc(SDP_UINT8, &ch);
proto[1] = sdp_list_append(proto[1], channel);
apseq = sdp_list_append(apseq, proto[1]);
aproto = sdp_list_append(0, apseq);
sdp_set_access_protos(record, aproto);
sdp_set_info_attr(record, "Hands-Free", 0, 0);
sdp_data_free(channel);
sdp_list_free(proto[0], 0);
sdp_list_free(proto[1], 0);
sdp_list_free(apseq, 0);
sdp_list_free(pfseq, 0);
sdp_list_free(aproto, 0);
sdp_list_free(root, 0);
sdp_list_free(svclass_id, 0);
return record;
}
示例10: sdp_record_alloc
static sdp_record_t *proxy_record_new(const char *uuid128, uint8_t channel)
{
sdp_list_t *apseq, *aproto, *profiles, *proto[2], *root, *svclass_id;
uuid_t uuid, root_uuid, l2cap, rfcomm;
sdp_profile_desc_t profile;
sdp_record_t *record;
sdp_data_t *ch;
record = sdp_record_alloc();
if (!record)
return NULL;
sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
root = sdp_list_append(NULL, &root_uuid);
sdp_set_browse_groups(record, root);
sdp_list_free(root, NULL);
bt_string2uuid(&uuid, uuid128);
svclass_id = sdp_list_append(NULL, &uuid);
sdp_set_service_classes(record, svclass_id);
sdp_list_free(svclass_id, NULL);
sdp_uuid16_create(&profile.uuid, SERIAL_PORT_PROFILE_ID);
profile.version = 0x0100;
profiles = sdp_list_append(NULL, &profile);
sdp_set_profile_descs(record, profiles);
sdp_list_free(profiles, NULL);
sdp_uuid16_create(&l2cap, L2CAP_UUID);
proto[0] = sdp_list_append(NULL, &l2cap);
apseq = sdp_list_append(NULL, proto[0]);
sdp_uuid16_create(&rfcomm, RFCOMM_UUID);
proto[1] = sdp_list_append(NULL, &rfcomm);
ch = sdp_data_alloc(SDP_UINT8, &channel);
proto[1] = sdp_list_append(proto[1], ch);
apseq = sdp_list_append(apseq, proto[1]);
aproto = sdp_list_append(NULL, apseq);
sdp_set_access_protos(record, aproto);
add_lang_attr(record);
sdp_set_info_attr(record, "Port Proxy Entity",
NULL, "Port Proxy Entity");
sdp_data_free(ch);
sdp_list_free(proto[0], NULL);
sdp_list_free(proto[1], NULL);
sdp_list_free(apseq, NULL);
sdp_list_free(aproto, NULL);
return record;
}
示例11: sdp_record_alloc
static sdp_record_t *dun_record(uint8_t ch)
{
sdp_list_t *svclass_id, *pfseq, *apseq, *root, *aproto;
uuid_t root_uuid, dun, gn, l2cap, rfcomm;
sdp_profile_desc_t profile;
sdp_list_t *proto[2];
sdp_record_t *record;
sdp_data_t *channel;
record = sdp_record_alloc();
if (!record)
return NULL;
sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
root = sdp_list_append(NULL, &root_uuid);
sdp_set_browse_groups(record, root);
sdp_uuid16_create(&dun, DIALUP_NET_SVCLASS_ID);
svclass_id = sdp_list_append(NULL, &dun);
sdp_uuid16_create(&gn, GENERIC_NETWORKING_SVCLASS_ID);
svclass_id = sdp_list_append(svclass_id, &gn);
sdp_set_service_classes(record, svclass_id);
sdp_uuid16_create(&profile.uuid, DIALUP_NET_PROFILE_ID);
profile.version = 0x0100;
pfseq = sdp_list_append(NULL, &profile);
sdp_set_profile_descs(record, pfseq);
sdp_uuid16_create(&l2cap, L2CAP_UUID);
proto[0] = sdp_list_append(NULL, &l2cap);
apseq = sdp_list_append(NULL, proto[0]);
sdp_uuid16_create(&rfcomm, RFCOMM_UUID);
proto[1] = sdp_list_append(NULL, &rfcomm);
channel = sdp_data_alloc(SDP_UINT8, &ch);
proto[1] = sdp_list_append(proto[1], channel);
apseq = sdp_list_append(apseq, proto[1]);
aproto = sdp_list_append(0, apseq);
sdp_set_access_protos(record, aproto);
sdp_set_info_attr(record, "Dial-Up Networking", 0, 0);
sdp_data_free(channel);
sdp_list_free(root, NULL);
sdp_list_free(svclass_id, NULL);
sdp_list_free(proto[0], NULL);
sdp_list_free(proto[1], NULL);
sdp_list_free(pfseq, NULL);
sdp_list_free(apseq, NULL);
sdp_list_free(aproto, NULL);
return record;
}
示例12: register_server_service
/*
* The SDP server must present its own service record to
* the service repository. This can be accessed by service
* discovery clients. This method constructs a service record
* and stores it in the repository
*/
void register_server_service(void)
{
sdp_list_t *classIDList;
uuid_t classID;
void **versions, **versionDTDs;
uint8_t dtd;
sdp_data_t *pData;
int i;
server = sdp_record_alloc();
server->pattern = NULL;
/* Force the record to be SDP_SERVER_RECORD_HANDLE */
server->handle = SDP_SERVER_RECORD_HANDLE;
sdp_record_add(BDADDR_ANY, server);
sdp_attr_add(server, SDP_ATTR_RECORD_HANDLE,
sdp_data_alloc(SDP_UINT32, &server->handle));
sdp_uuid16_create(&classID, SDP_SERVER_SVCLASS_ID);
classIDList = sdp_list_append(0, &classID);
sdp_set_service_classes(server, classIDList);
sdp_list_free(classIDList, 0);
/*
* Set the version numbers supported, these are passed as arguments
* to the server on command line. Now defaults to 1.0
* Build the version number sequence first
*/
versions = malloc(sdpServerVnumEntries * sizeof(void *));
versionDTDs = malloc(sdpServerVnumEntries * sizeof(void *));
dtd = SDP_UINT16;
for (i = 0; i < sdpServerVnumEntries; i++) {
uint16_t *version = malloc(sizeof(uint16_t));
*version = sdpVnumArray[i].major;
*version = (*version << 8);
*version |= sdpVnumArray[i].minor;
versions[i] = version;
versionDTDs[i] = &dtd;
}
pData = sdp_seq_alloc(versionDTDs, versions, sdpServerVnumEntries);
for (i = 0; i < sdpServerVnumEntries; i++)
free(versions[i]);
free(versions);
free(versionDTDs);
sdp_attr_add(server, SDP_ATTR_VERSION_NUM_LIST, pData);
update_db_timestamp();
}
示例13: register_data_exchange_spec
static gboolean register_data_exchange_spec(sdp_record_t *record)
{
sdp_data_t *spec;
uint8_t data_spec = DATA_EXCHANGE_SPEC_11073;
/* As by now 11073 is the only supported we set it by default */
spec = sdp_data_alloc(SDP_UINT8, &data_spec);
if (spec == NULL)
return FALSE;
if (sdp_attr_add(record, SDP_ATTR_DATA_EXCHANGE_SPEC, spec) < 0) {
sdp_data_free(spec);
return FALSE;
}
return TRUE;
}
示例14: register_mcap_features
static gboolean register_mcap_features(sdp_record_t *sdp_record)
{
sdp_data_t *mcap_proc;
uint8_t mcap_sup_proc = MCAP_SUP_PROC;
mcap_proc = sdp_data_alloc(SDP_UINT8, &mcap_sup_proc);
if (mcap_proc == NULL)
return FALSE;
if (sdp_attr_add(sdp_record, SDP_ATTR_MCAP_SUPPORTED_PROCEDURES,
mcap_proc) < 0) {
sdp_data_free(mcap_proc);
return FALSE;
}
return TRUE;
}
示例15: register_data_exchange_spec
static int register_data_exchange_spec(sdp_record_t *rec)
{
sdp_data_t *spec;
uint8_t data_spec = DATA_EXCHANGE_SPEC_11073;
/* As of now only 11073 is supported, so we set it as default */
DBG("");
spec = sdp_data_alloc(SDP_UINT8, &data_spec);
if (!spec)
return -1;
if (sdp_attr_add(rec, SDP_ATTR_DATA_EXCHANGE_SPEC, spec) < 0) {
sdp_data_free(spec);
return -1;
}
return 0;
}