本文整理汇总了C++中sdp_list_append函数的典型用法代码示例。如果您正苦于以下问题:C++ sdp_list_append函数的具体用法?C++ sdp_list_append怎么用?C++ sdp_list_append使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sdp_list_append函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: connect_watch
static gboolean connect_watch(GIOChannel *chan, GIOCondition cond,
gpointer user_data)
{
struct search_context *ctxt = user_data;
sdp_list_t *search, *attrids;
uint32_t range = 0x0000ffff;
socklen_t len;
int sk, err = 0;
sk = g_io_channel_unix_get_fd(chan);
ctxt->io_id = 0;
len = sizeof(err);
if (getsockopt(sk, SOL_SOCKET, SO_ERROR, &err, &len) < 0) {
err = errno;
goto failed;
}
if (err != 0)
goto failed;
if (sdp_set_notify(ctxt->session, search_completed_cb, ctxt) < 0) {
err = EIO;
goto failed;
}
search = sdp_list_append(NULL, &ctxt->uuid);
attrids = sdp_list_append(NULL, &range);
if (sdp_service_search_attr_async(ctxt->session,
search, SDP_ATTR_REQ_RANGE, attrids) < 0) {
sdp_list_free(attrids, NULL);
sdp_list_free(search, NULL);
err = EIO;
goto failed;
}
sdp_list_free(attrids, NULL);
sdp_list_free(search, NULL);
/* Set callback responsible for update the internal SDP transaction */
ctxt->io_id = g_io_add_watch(chan,
G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
search_process_cb, ctxt);
return FALSE;
failed:
sdp_close(ctxt->session);
ctxt->session = NULL;
if (ctxt->cb)
ctxt->cb(NULL, -err, ctxt->user_data);
search_context_cleanup(ctxt);
return FALSE;
}
示例4: service_callback
static gboolean service_callback(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
struct bluetooth_session *session = user_data;
sdp_list_t *search, *attrid;
uint32_t range = 0x0000ffff;
GError *gerr = NULL;
uuid_t uuid;
if (cond & G_IO_NVAL)
return FALSE;
if (cond & G_IO_ERR)
goto failed;
if (sdp_set_notify(session->sdp, search_callback, session) < 0)
goto failed;
if (bt_string2uuid(&uuid, session->service) < 0)
goto failed;
sdp_uuid128_to_uuid(&uuid);
search = sdp_list_append(NULL, &uuid);
attrid = sdp_list_append(NULL, &range);
if (sdp_service_search_attr_async(session->sdp,
search, SDP_ATTR_REQ_RANGE, attrid) < 0) {
sdp_list_free(attrid, NULL);
sdp_list_free(search, NULL);
goto failed;
}
sdp_list_free(attrid, NULL);
sdp_list_free(search, NULL);
g_io_add_watch(io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
process_callback, session);
return FALSE;
failed:
g_io_channel_shutdown(session->io, TRUE, NULL);
g_io_channel_unref(session->io);
session->io = NULL;
g_set_error(&gerr, OBC_BT_ERROR, -EIO,
"Unable to find service record");
if (session->func)
session->func(session->io, gerr, session->user_data);
g_clear_error(&gerr);
session_destroy(session);
return FALSE;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: sdp_uuid16_create
static sdp_record_t *create_mas_record(uint8_t chan, const char *svc_name)
{
sdp_list_t *seq;
sdp_profile_desc_t profile[1];
uint8_t minst = DEFAULT_MAS_INSTANCE;
uint8_t mtype = DEFAULT_MAS_MSG_TYPE;
sdp_record_t *record;
uuid_t uuid;
sdp_uuid16_create(&uuid, MAP_MSE_SVCLASS_ID);
record = create_rfcomm_record(chan, &uuid, svc_name, true);
if (!record)
return NULL;
sdp_uuid16_create(&profile[0].uuid, MAP_PROFILE_ID);
profile[0].version = 0x0101;
seq = sdp_list_append(NULL, profile);
sdp_set_profile_descs(record, seq);
sdp_attr_add_new(record, SDP_ATTR_MAS_INSTANCE_ID, SDP_UINT8, &minst);
sdp_attr_add_new(record, SDP_ATTR_SUPPORTED_MESSAGE_TYPES, SDP_UINT8,
&mtype);
sdp_list_free(seq, NULL);
return record;
}
示例10: is_hid_sdp_record_registered
/**
* Lookup for HID service records. This function returns:
* - SDP HID record handle, if there is already a HID SDP record
* 0 if there is no HID SDP record
* <0 if any error occur. In this case, the value returned is the errno.
*
*/
int is_hid_sdp_record_registered() {
int handle;
uuid_t svc_uuid;
int err;
sdp_list_t *response_list = NULL, *search_list, *attrid_list;
sdp_uuid16_create(&svc_uuid, HID_SVCLASS_ID);
search_list = sdp_list_append(NULL, &svc_uuid);
uint32_t range = 0x0000ffff;
attrid_list = sdp_list_append(NULL, &range);
err = sdp_service_search_attr_req(sdp_session, search_list, SDP_ATTR_REQ_RANGE, attrid_list, &response_list);
sdp_list_free(search_list, NULL);
sdp_list_free(attrid_list, NULL);
if (err < 0) {
return err;
}
if (response_list != NULL) {
sdp_record_t *rec = (sdp_record_t *)response_list->data;
int handle = rec->handle;
sdp_list_free(response_list, NULL);
return handle;
} else {
return 0;
}
/*
* code below illustrates how to iterate through records.
*
sdp_list_t *r = response_list;
for (; r; r = r->next) {
sdp_record_t *rec = (sdp_record_t *)r->data;
if (rec != NULL) {
printf("rec: 0x%X\n", rec->handle);
}
sdp_record_free(rec);
}
*/
}
示例11: service_callback
static gboolean service_callback(GIOChannel *io, GIOCondition cond,
gpointer user_data)
{
struct callback_data *callback = user_data;
sdp_list_t *search, *attrid;
uint32_t range = 0x0000ffff;
GError *gerr = NULL;
if (cond & (G_IO_NVAL | G_IO_ERR))
goto failed;
if (sdp_set_notify(callback->sdp, search_callback, callback) < 0)
goto failed;
search = sdp_list_append(NULL, &callback->session->uuid);
attrid = sdp_list_append(NULL, &range);
if (sdp_service_search_attr_async(callback->sdp,
search, SDP_ATTR_REQ_RANGE, attrid) < 0) {
sdp_list_free(attrid, NULL);
sdp_list_free(search, NULL);
goto failed;
}
sdp_list_free(attrid, NULL);
sdp_list_free(search, NULL);
g_io_add_watch(io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
process_callback, callback);
return FALSE;
failed:
sdp_close(callback->sdp);
g_set_error(&gerr, OBEX_IO_ERROR, -EIO,
"Unable to find service record");
callback->func(callback->session, gerr, callback->data);
g_clear_error(&gerr);
session_unref(callback->session);
g_free(callback);
return FALSE;
}
示例12: find_service_channel
/*
* Determine whether the given device supports Serial or Dial-Up Networking,
* and if so what the RFCOMM channel number for the service is.
*/
static int find_service_channel(bdaddr_t *adapter, bdaddr_t *device, int only_gnapplet, uint16_t svclass_id)
{
sdp_session_t *sdp = NULL;
sdp_list_t *search = NULL, *attrs = NULL, *recs = NULL, *tmp;
uuid_t browse_uuid, service_id;
uint32_t range = 0x0000ffff;
int channel = -1;
sdp = sdp_connect(adapter, device, SDP_RETRY_IF_BUSY);
if (!sdp)
goto end;
sdp_uuid16_create(&browse_uuid, PUBLIC_BROWSE_GROUP);
sdp_uuid16_create(&service_id, svclass_id);
search = sdp_list_append(NULL, &browse_uuid);
search = sdp_list_append(search, &service_id);
attrs = sdp_list_append(NULL, &range);
if (sdp_service_search_attr_req(sdp, search,
SDP_ATTR_REQ_RANGE, attrs,
&recs))
goto end;
for (tmp = recs; tmp != NULL; tmp = tmp->next) {
sdp_record_t *rec = tmp->data;
/*
* If this service is better than what we've
* previously seen, try and get the channel number.
*/
channel = get_rfcomm_channel(rec, only_gnapplet);
if (channel > 0)
goto end;
}
end:
sdp_list_free(recs, (sdp_free_func_t)sdp_record_free);
sdp_list_free(search, NULL);
sdp_list_free(attrs, NULL);
sdp_close(sdp);
return channel;
}
示例13: get_channel
static uint8_t get_channel(const char *svr, uint16_t uuid)
{
sdp_session_t *sdp;
sdp_list_t *srch, *attrs, *rsp;
uuid_t svclass;
uint16_t attr;
bdaddr_t dst;
uint8_t channel = 0;
int err;
str2ba(svr, &dst);
sdp = sdp_connect(&bdaddr, &dst, SDP_RETRY_IF_BUSY);
if (!sdp)
return 0;
sdp_uuid16_create(&svclass, uuid);
srch = sdp_list_append(NULL, &svclass);
attr = SDP_ATTR_PROTO_DESC_LIST;
attrs = sdp_list_append(NULL, &attr);
err = sdp_service_search_attr_req(sdp, srch,
SDP_ATTR_REQ_INDIVIDUAL, attrs, &rsp);
if (err)
goto done;
for (; rsp; rsp = rsp->next) {
sdp_record_t *rec = (sdp_record_t *) rsp->data;
sdp_list_t *protos;
if (!sdp_get_access_protos(rec, &protos)) {
channel = sdp_get_proto_port(protos, RFCOMM_UUID);
if (channel > 0)
break;
}
}
done:
sdp_close(sdp);
return channel;
}
示例14: sdp_list_append
/**
* Retrieves SDP record identified by "handle". Session must be already opened.
*/
sdp_record_t *get_sdp_record(sdp_session_t *session, int handle) {
sdp_list_t *attrid;
uint32_t range = 0x0000ffff;
sdp_record_t *rec;
attrid = sdp_list_append(0, &range);
rec = sdp_service_attr_req(session, handle, SDP_ATTR_REQ_RANGE, attrid);
sdp_list_free(attrid,0);
return rec;
}
示例15: add_lang_attr
static void add_lang_attr(sdp_record_t *r)
{
sdp_lang_attr_t base_lang;
sdp_list_t *langs = 0;
/* UTF-8 MIBenum (http://www.iana.org/assignments/character-sets) */
base_lang.code_ISO639 = (0x65 << 8) | 0x6e;
base_lang.encoding = 106;
base_lang.base_offset = SDP_PRIMARY_LANG_BASE;
langs = sdp_list_append(0, &base_lang);
sdp_set_lang_attr(r, langs);
sdp_list_free(langs, 0);
}