本文整理汇总了C++中sdp_record_free函数的典型用法代码示例。如果您正苦于以下问题:C++ sdp_record_free函数的具体用法?C++ sdp_record_free怎么用?C++ sdp_record_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sdp_record_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sdp_record_free
static DBusMessage *update_record(DBusConnection *conn, DBusMessage *msg,
struct service_adapter *serv_adapter,
dbus_uint32_t handle, sdp_record_t *sdp_record)
{
bdaddr_t src;
int err;
if (remove_record_from_server(handle) < 0) {
sdp_record_free(sdp_record);
return btd_error_not_available(msg);
}
if (serv_adapter->adapter)
adapter_get_address(serv_adapter->adapter, &src);
else
bacpy(&src, BDADDR_ANY);
sdp_record->handle = handle;
err = add_record_to_server(&src, sdp_record);
if (err < 0) {
sdp_record_free(sdp_record);
error("Failed to update the service record");
return btd_error_failed(msg, strerror(-err));
}
return dbus_message_new_method_return(msg);
}
示例2: bt_pan_register
bool bt_pan_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode)
{
sdp_record_t *nap_rec, *panu_rec;
int err;
DBG("");
bacpy(&adapter_addr, addr);
nap_rec = nap_record();
if (bt_adapter_add_record(nap_rec, SVC_HINT_NETWORKING) < 0) {
sdp_record_free(nap_rec);
error("Failed to allocate PAN-NAP sdp record");
return false;
}
panu_rec = panu_record();
if (bt_adapter_add_record(panu_rec, SVC_HINT_NETWORKING) < 0) {
sdp_record_free(nap_rec);
sdp_record_free(panu_rec);
error("Failed to allocate PAN-PANU sdp record");
return false;
}
err = bnep_init();
if (err < 0) {
error("Failed to init BNEP");
bt_adapter_remove_record(nap_rec->handle);
bt_adapter_remove_record(panu_rec->handle);
return false;
}
err = register_nap_server();
if (err < 0) {
error("Failed to register NAP server");
bt_adapter_remove_record(nap_rec->handle);
bt_adapter_remove_record(panu_rec->handle);
bnep_cleanup();
return false;
}
nap_rec_id = nap_rec->handle;
panu_rec_id = panu_rec->handle;
hal_ipc = ipc;
ipc_register(hal_ipc, HAL_SERVICE_ID_PAN, cmd_handlers,
G_N_ELEMENTS(cmd_handlers));
return true;
}
示例3: DBG
static DBusMessage *add_sap_service_record(DBusConnection *conn, DBusMessage *msg,
void *data)
{
DBG("");
sdp_record_t *record = NULL;
GError *gerr = NULL;
record = create_sap_record(SAP_SERVER_CHANNEL);
if (!record) {
error("Creating SAP SDP record failed.");
goto sdp_err;
}
if (add_record_to_server(&server->src, record) < 0) {
error("Adding SAP SDP record to the SDP server failed.");
sdp_record_free(record);
goto sdp_err;
}
server->record_id = record->handle;
DBG("EXIT");
return dbus_message_new_method_return(msg);
sdp_err:
server_free(server);
sap_exit();
return dbus_message_new_method_return(msg);
}
示例4: del_service
static int del_service(sdp_session_t *session, uint32_t handle)
{
sdp_record_t *rec;
logDebug("Deleting Service Record.\n");
if (!session) {
logDebug("Bad local SDP session!\n");
return -1;
}
rec = sdp_record_alloc();
if (rec == NULL) {
return -1;
}
rec->handle = handle;
if (sdp_device_record_unregister(session, &loc_addr.rc_bdaddr, rec) != 0) {
/*
If Bluetooth is shut off, the sdp daemon will not be running and it is
therefore common that this function will fail in that case. This is fine
since the record is removed when the daemon shuts down. We only have
to free our record handle here then....
*/
//CM_DBG("Failed to unregister service record: %s\n", strerror(errno));
sdp_record_free(rec);
return -1;
}
logDebug("Service Record deleted.");
return 0;
}
示例5: sdp_svcdb_collect_all
/*
* collect all services registered over this socket
*/
void sdp_svcdb_collect_all(int sock)
{
sdp_list_t *p, *q;
for (p = socket_index, q = 0; p; ) {
sdp_indexed_t *item = p->data;
if (item->sock == sock) {
sdp_list_t *next = p->next;
sdp_record_remove(item->record->handle);
sdp_record_free(item->record);
free(item);
if (q)
q->next = next;
else
socket_index = next;
free(p);
p = next;
} else if (item->sock > sock)
return;
else {
q = p;
p = p->next;
}
}
}
示例6: malloc
static sdp_record_t *sdp_xml_parse_record(const char *data, int size)
{
GMarkupParseContext *ctx;
struct context_data *ctx_data;
sdp_record_t *record;
ctx_data = malloc(sizeof(*ctx_data));
if (!ctx_data)
return NULL;
record = sdp_record_alloc();
if (!record) {
free(ctx_data);
return NULL;
}
memset(ctx_data, 0, sizeof(*ctx_data));
ctx_data->record = record;
ctx = g_markup_parse_context_new(&parser, 0, ctx_data, NULL);
if (g_markup_parse_context_parse(ctx, data, size, NULL) == FALSE) {
error("XML parsing error");
g_markup_parse_context_free(ctx);
sdp_record_free(record);
free(ctx_data);
return NULL;
}
g_markup_parse_context_free(ctx);
free(ctx_data);
return record;
}
示例7: service_remove_req
/*
* Remove a registered service record
*/
int service_remove_req(sdp_req_t *req, sdp_buf_t *rsp)
{
uint8_t *p = req->buf + sizeof(sdp_pdu_hdr_t);
uint32_t handle = bt_get_be32(p);
sdp_record_t *rec;
int status = 0;
/* extract service record handle */
rec = sdp_record_find(handle);
if (rec) {
sdp_svcdb_collect(rec);
status = sdp_record_remove(handle);
sdp_record_free(rec);
if (status == 0)
update_db_timestamp();
} else {
status = SDP_INVALID_RECORD_HANDLE;
SDPDBG("Could not find record : 0x%x", handle);
}
p = rsp->data;
bt_put_be16(status, p);
rsp->data_size = sizeof(uint16_t);
return status;
}
示例8: g_new0
static struct a2dp_sep *a2dp_add_sep(DBusConnection *conn, uint8_t type,
uint8_t codec)
{
struct a2dp_sep *sep;
GSList **l;
sdp_record_t *(*create_record)(void);
uint32_t *record_id;
sdp_record_t *record;
struct avdtp_sep_ind *ind;
sep = g_new0(struct a2dp_sep, 1);
ind = (codec == A2DP_CODEC_MPEG12) ? &mpeg_ind : &sbc_ind;
sep->sep = avdtp_register_sep(type, AVDTP_MEDIA_TYPE_AUDIO, codec,
ind, &cfm, sep);
if (sep->sep == NULL) {
g_free(sep);
return NULL;
}
sep->codec = codec;
sep->type = type;
if (type == AVDTP_SEP_TYPE_SOURCE) {
l = &sources;
create_record = a2dp_source_record;
record_id = &source_record_id;
} else {
l = &sinks;
create_record = a2dp_sink_record;
record_id = &sink_record_id;
}
if (*record_id != 0)
goto add;
record = create_record();
if (!record) {
error("Unable to allocate new service record");
avdtp_unregister_sep(sep->sep);
g_free(sep);
return NULL;
}
if (add_record_to_server(BDADDR_ANY, record) < 0) {
error("Unable to register A2DP service record");\
sdp_record_free(record);
avdtp_unregister_sep(sep->sep);
g_free(sep);
return NULL;
}
*record_id = record->handle;
add:
*l = g_slist_append(*l, sep);
return sep;
}
示例9: hdp_update_sdp_record
gboolean hdp_update_sdp_record(struct hdp_adapter *adapter, GSList *app_list)
{
sdp_record_t *sdp_record;
bdaddr_t addr;
if (adapter->sdp_handler)
remove_record_from_server(adapter->sdp_handler);
if (!app_list) {
adapter->sdp_handler = 0;
return TRUE;
}
sdp_record = sdp_record_alloc();
if (!sdp_record)
return FALSE;
if (adapter->sdp_handler)
sdp_record->handle = adapter->sdp_handler;
else
sdp_record->handle = 0xffffffff; /* Set automatically */
if (is_app_role(app_list, HDP_SINK))
set_sdp_services_uuid(sdp_record, HDP_SINK);
if (is_app_role(app_list, HDP_SOURCE))
set_sdp_services_uuid(sdp_record, HDP_SOURCE);
if (!register_service_protocols(adapter, sdp_record))
goto fail;
if (!register_service_profiles(sdp_record))
goto fail;
if (!register_service_additional_protocols(adapter, sdp_record))
goto fail;
sdp_set_info_attr(sdp_record, HDP_SERVICE_NAME, HDP_SERVICE_PROVIDER,
HDP_SERVICE_DSC);
if (!register_service_sup_features(app_list, sdp_record))
goto fail;
if (!register_data_exchange_spec(sdp_record))
goto fail;
register_mcap_features(sdp_record);
if (sdp_set_record_state(sdp_record, adapter->record_state++))
goto fail;
adapter_get_address(adapter->btd_adapter, &addr);
if (add_record_to_server(&addr, sdp_record) < 0)
goto fail;
adapter->sdp_handler = sdp_record->handle;
return TRUE;
fail:
if (sdp_record)
sdp_record_free(sdp_record);
return FALSE;
}
示例10: g_new0
static struct a2dp_sep *a2dp_add_sep(struct a2dp_server *server, uint8_t type,
uint8_t codec, gboolean delay_reporting)
{
struct a2dp_sep *sep;
GSList **l;
uint32_t *record_id;
sdp_record_t *record;
struct avdtp_sep_ind *ind;
sep = g_new0(struct a2dp_sep, 1);
ind = (codec == A2DP_CODEC_MPEG12) ? &mpeg_ind : &sbc_ind;
sep->sep = avdtp_register_sep(&server->src, type,
AVDTP_MEDIA_TYPE_AUDIO, codec,
delay_reporting, ind, &cfm, sep);
if (sep->sep == NULL) {
g_free(sep);
return NULL;
}
sep->codec = codec;
sep->type = type;
sep->delay_reporting = delay_reporting;
if (type == AVDTP_SEP_TYPE_SOURCE) {
l = &server->sources;
record_id = &server->source_record_id;
} else {
l = &server->sinks;
record_id = &server->sink_record_id;
}
if (*record_id != 0)
goto add;
record = a2dp_record(type, server->version);
if (!record) {
error("Unable to allocate new service record");
avdtp_unregister_sep(sep->sep);
g_free(sep);
return NULL;
}
if (add_record_to_server(&server->src, record) < 0) {
error("Unable to register A2DP service record");
\
sdp_record_free(record);
avdtp_unregister_sep(sep->sep);
g_free(sep);
return NULL;
}
*record_id = record->handle;
add:
*l = g_slist_append(*l, sep);
return sep;
}
示例11: main
int main(int argc, char const *argv[])
{
uint32_t svc_uuid_int[] = {0, 0, 0, 0xABCD};
int status;
bdaddr_t target, source;
uuid_t svc_uuid;
sdp_list_t *response_list, *search_list, *attrid_list;
sdp_session_t *session = 0;
uint32_t range = 0x0000ffff;
uint8_t port = 0;
//connect to the SDP server running on the remote machine
str2ba(dest, &target);
str2ba(src, &source);
session = sdp_connect(&source, &target, 0);
if (session == NULL) {
perror("sdp_connect");
exit(1);
}
sdp_uuid128_create(&svc_uuid, &svc_uuid_int);
search_list = sdp_list_append(0, &svc_uuid);
attrid_list = sdp_list_append(0, &range);
//get a list of service records that have UUID 0xabcd
response_list = NULL;
status = sdp_service_search_attr_req(session, search_list, SDP_ATTR_REQ_RANGE, attrid_list, &response_list);
if (status == 0) {
sdp_list_t *proto_list = NULL;
sdp_list_t *r = response_list;
//go through each of the service records
for (; r; r = r->next) {
sdp_record_t *rec = (sdp_record_t *)r->data;
//get a list of the protocol sequences
if (sdp_get_access_protos(rec, &proto_list) == 0) {
// get the RFCOMM port number
port = sdp_get_proto_port(proto_list, RFCOMM_UUID);
sdp_list_free(proto_list, 0);
}
sdp_record_free(rec);
}
}
sdp_list_free(response_list, 0);
sdp_list_free(search_list, 0);
sdp_list_free(attrid_list, 0);
sdp_close(session);
if (port != 0) {
printf("found service running on RFCOMM Port %d\n", port);
}
return 0;
}
示例12: gateway_server_init
static int gateway_server_init(struct audio_adapter *adapter)
{
uint8_t chan = DEFAULT_HFP_HS_CHANNEL;
sdp_record_t *record;
gboolean master = TRUE;
GError *err = NULL;
GIOChannel *io;
bdaddr_t src;
if (config) {
gboolean tmp;
tmp = g_key_file_get_boolean(config, "General", "Master",
&err);
if (err) {
DBG("audio.conf: %s", err->message);
g_clear_error(&err);
} else
master = tmp;
}
adapter_get_address(adapter->btd_adapter, &src);
io = bt_io_listen(BT_IO_RFCOMM, NULL, hf_io_cb, adapter, NULL, &err,
BT_IO_OPT_SOURCE_BDADDR, &src,
BT_IO_OPT_CHANNEL, chan,
BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_MEDIUM,
BT_IO_OPT_MASTER, master,
BT_IO_OPT_INVALID);
if (!io) {
error("%s", err->message);
g_error_free(err);
return -1;
}
adapter->hfp_hs_server = io;
record = hfp_hs_record(chan);
if (!record) {
error("Unable to allocate new service record");
return -1;
}
if (add_record_to_server(&src, record) < 0) {
error("Unable to register HFP HS service record");
sdp_record_free(record);
g_io_channel_unref(adapter->hfp_hs_server);
adapter->hfp_hs_server = NULL;
return -1;
}
adapter->hfp_hs_record_id = record->handle;
return 0;
}
示例13: failed
static DBusMessage *proxy_enable(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct serial_proxy *prx = data;
sdp_record_t *record;
GError *err = NULL;
DBusMessage *reply;
if (prx->io)
return failed(msg, "Already enabled");
/* Listen */
prx->io = bt_io_listen(BT_IO_RFCOMM, NULL, confirm_event_cb, prx,
NULL, &err,
BT_IO_OPT_SOURCE_BDADDR, &prx->src,
BT_IO_OPT_INVALID);
if (!prx->io)
goto failed;
bt_io_get(prx->io, BT_IO_RFCOMM, &err,
BT_IO_OPT_CHANNEL, &prx->channel,
BT_IO_OPT_INVALID);
if (err) {
g_io_channel_unref(prx->io);
prx->io = NULL;
goto failed;
}
debug("Allocated channel %d", prx->channel);
g_io_channel_set_close_on_unref(prx->io, TRUE);
record = proxy_record_new(prx->uuid128, prx->channel);
if (!record) {
g_io_channel_unref(prx->io);
return failed(msg, "Unable to allocate new service record");
}
if (add_record_to_server(&prx->src, record) < 0) {
sdp_record_free(record);
g_io_channel_unref(prx->io);
return failed(msg, "Service registration failed");
}
prx->record_id = record->handle;
return dbus_message_new_method_return(msg);
failed:
error("%s", err->message);
reply = failed(msg, err->message);
g_error_free(err);
return reply;
}
示例14: sdp_record_free
static DBusMessage *update_record(DBusMessage *msg,
struct service_adapter *serv_adapter,
dbus_uint32_t handle, sdp_record_t *sdp_record)
{
int err;
if (remove_record_from_server(handle) < 0) {
sdp_record_free(sdp_record);
return btd_error_not_available(msg);
}
sdp_record->handle = handle;
err = add_record_to_server(get_address(serv_adapter), sdp_record);
if (err < 0) {
sdp_record_free(sdp_record);
error("Failed to update the service record");
return btd_error_failed(msg, strerror(-err));
}
return dbus_message_new_method_return(msg);
}
示例15: enable_proxy
static int enable_proxy(struct serial_proxy *prx)
{
sdp_record_t *record;
GError *gerr = NULL;
int err;
if (prx->io)
return -EALREADY;
/* Listen */
prx->io = bt_io_listen(BT_IO_RFCOMM, NULL, confirm_event_cb, prx,
NULL, &gerr,
BT_IO_OPT_SOURCE_BDADDR, &prx->src,
BT_IO_OPT_INVALID);
if (!prx->io)
goto failed;
bt_io_get(prx->io, BT_IO_RFCOMM, &gerr,
BT_IO_OPT_CHANNEL, &prx->channel,
BT_IO_OPT_INVALID);
if (gerr) {
g_io_channel_unref(prx->io);
prx->io = NULL;
goto failed;
}
debug("Allocated channel %d", prx->channel);
g_io_channel_set_close_on_unref(prx->io, TRUE);
record = proxy_record_new(prx->uuid128, prx->channel);
if (!record) {
g_io_channel_unref(prx->io);
return -ENOMEM;
}
err = add_record_to_server(&prx->src, record);
if (err < 0) {
sdp_record_free(record);
g_io_channel_unref(prx->io);
return err;
}
prx->record_id = record->handle;
return 0;
failed:
error("%s", gerr->message);
g_error_free(gerr);
return -EIO;
}