summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--audio/manager.c9
-rw-r--r--input/manager.c18
-rw-r--r--network/manager.c9
-rw-r--r--plugins/service.c4
-rw-r--r--serial/manager.c5
-rw-r--r--src/adapter.c7
-rw-r--r--src/adapter.h2
-rw-r--r--src/agent.c5
-rw-r--r--src/dbus-hci.c3
-rw-r--r--src/device.c75
-rw-r--r--src/manager.c8
11 files changed, 75 insertions, 70 deletions
diff --git a/audio/manager.c b/audio/manager.c
index d824548e..a53d2d19 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -673,14 +673,13 @@ static int audio_probe(struct btd_device *device, GSList *records)
{
struct btd_adapter *adapter = device_get_adapter(device);
const gchar *path = device_get_path(device);
- const char *source, *destination;
+ const char *destination;
bdaddr_t src, dst;
struct audio_device *dev;
- source = adapter_get_address(adapter);
+ adapter_get_address(adapter, &src);
destination = device_get_address(device);
- str2ba(source, &src);
str2ba(destination, &dst);
dev = manager_find_device(&dst, NULL, FALSE);
@@ -728,11 +727,9 @@ static struct audio_adapter *get_audio_adapter(struct btd_adapter *adapter)
{
struct audio_adapter *adp;
const gchar *path = adapter_get_path(adapter);
- const char *source;
bdaddr_t src;
- source = adapter_get_address(adapter);
- str2ba(source, &src);
+ adapter_get_address(adapter, &src);
adp = find_adapter(adapters, path);
if (!adp) {
diff --git a/input/manager.c b/input/manager.c
index 8de717ba..57871a34 100644
--- a/input/manager.c
+++ b/input/manager.c
@@ -170,7 +170,7 @@ static int hid_device_probe(struct btd_device *device, GSList *records)
{
struct btd_adapter *adapter = device_get_adapter(device);
const gchar *path = device_get_path(device);
- const char *source, *destination;
+ const char *destination;
struct hidp_connadd_req hidp;
bdaddr_t src, dst;
@@ -178,10 +178,9 @@ static int hid_device_probe(struct btd_device *device, GSList *records)
memset(&hidp, 0, sizeof(hidp));
- source = adapter_get_address(adapter);
+ adapter_get_address(adapter, &src);
destination = device_get_address(device);
- str2ba(source, &src);
str2ba(destination, &dst);
if (load_stored(&src, &dst, &hidp) == 0)
@@ -213,7 +212,7 @@ static int headset_probe(struct btd_device *device, GSList *records)
sdp_record_t *record = records->data;
sdp_list_t *protos;
uint8_t ch;
- const char *source, *destination;
+ const char *destination;
bdaddr_t src, dst;
DBG("path %s", path);
@@ -232,10 +231,9 @@ static int headset_probe(struct btd_device *device, GSList *records)
return -EINVAL;
}
- source = adapter_get_address(adapter);
+ adapter_get_address(adapter, &src);
destination = device_get_address(device);
- str2ba(source, &src);
str2ba(destination, &dst);
return fake_input_register(connection, path, &src, &dst,
@@ -249,22 +247,18 @@ static void headset_remove(struct btd_device *device)
static int hid_server_probe(struct btd_adapter *adapter)
{
- const char *addr;
bdaddr_t src;
- addr = adapter_get_address(adapter);
- str2ba(addr, &src);
+ adapter_get_address(adapter, &src);
return server_start(&src);
}
static void hid_server_remove(struct btd_adapter *adapter)
{
- const char *addr;
bdaddr_t src;
- addr = adapter_get_address(adapter);
- str2ba(addr, &src);
+ adapter_get_address(adapter, &src);
server_stop(&src);
}
diff --git a/network/manager.c b/network/manager.c
index cafb7442..0abd2ce9 100644
--- a/network/manager.c
+++ b/network/manager.c
@@ -196,15 +196,14 @@ static int network_probe(struct btd_device *device, GSList *records,
{
struct btd_adapter *adapter = device_get_adapter(device);
const gchar *path = device_get_path(device);
- const char *source, *destination;
+ const char *destination;
bdaddr_t src, dst;
DBG("path %s", path);
- source = adapter_get_address(adapter);
+ adapter_get_address(adapter, &src);
destination = device_get_address(device);
- str2ba(source, &src);
str2ba(destination, &dst);
return connection_register(path, &src, &dst, id);
@@ -252,7 +251,6 @@ static void nap_remove(struct btd_device *device)
static int network_server_probe(struct btd_adapter *adapter, uint16_t id)
{
const gchar *path = adapter_get_path(adapter);
- const char *source;
bdaddr_t src;
DBG("path %s", path);
@@ -260,8 +258,7 @@ static int network_server_probe(struct btd_adapter *adapter, uint16_t id)
if (!conf.server_enabled)
return 0;
- source = adapter_get_address(adapter);
- str2ba(source, &src);
+ adapter_get_address(adapter, &src);
return server_register(path, &src, id);
}
diff --git a/plugins/service.c b/plugins/service.c
index 97b35e64..12299769 100644
--- a/plugins/service.c
+++ b/plugins/service.c
@@ -442,7 +442,7 @@ static DBusMessage *add_service_record(DBusConnection *conn,
return NULL;
sender = dbus_message_get_sender(msg);
- str2ba(adapter_get_address(adapter), &src);
+ adapter_get_address(adapter, &src);
err = add_xml_record(conn, sender, &src, record, &handle);
if (err < 0)
return failed_strerror(msg, err);
@@ -463,7 +463,7 @@ static DBusMessage *update_service_record(DBusConnection *conn,
struct btd_adapter *adapter = data;
bdaddr_t src;
- str2ba(adapter_get_address(adapter), &src);
+ adapter_get_address(adapter, &src);
return update_xml_record(conn, msg, &src);
}
diff --git a/serial/manager.c b/serial/manager.c
index f4687ccd..2df22e15 100644
--- a/serial/manager.c
+++ b/serial/manager.c
@@ -97,7 +97,7 @@ static int serial_probe(struct btd_device *device, sdp_record_t *rec,
return -EINVAL;
}
- str2ba(adapter_get_address(adapter), &src);
+ adapter_get_address(adapter, &src);
str2ba(device_get_address(device), &dst);
return port_register(connection, path, &src, &dst, name,
@@ -153,11 +153,10 @@ static struct btd_device_driver serial_dialup_driver = {
static int proxy_probe(struct btd_adapter *adapter)
{
const char *path = adapter_get_path(adapter);
- const char *address = adapter_get_address(adapter);
bdaddr_t src;
DBG("path %s", path);
- str2ba(address, &src);
+ adapter_get_address(adapter, &src);
return proxy_register(connection, path, &src);
}
diff --git a/src/adapter.c b/src/adapter.c
index 7fa5adf0..7881a0bd 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2671,12 +2671,9 @@ const gchar *adapter_get_path(struct btd_adapter *adapter)
return adapter->path;
}
-const gchar *adapter_get_address(struct btd_adapter *adapter)
+void adapter_get_address(struct btd_adapter *adapter, bdaddr_t *bdaddr)
{
- if (!adapter)
- return NULL;
-
- return adapter->address;
+ str2ba(adapter->address, bdaddr);
}
static gboolean discov_timeout_handler(void *data)
diff --git a/src/adapter.h b/src/adapter.h
index 1071c69c..df9a59de 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -128,7 +128,7 @@ struct btd_adapter *adapter_create(DBusConnection *conn, int id);
void adapter_remove(struct btd_adapter *adapter);
uint16_t adapter_get_dev_id(struct btd_adapter *adapter);
const gchar *adapter_get_path(struct btd_adapter *adapter);
-const gchar *adapter_get_address(struct btd_adapter *adapter);
+void adapter_get_address(struct btd_adapter *adapter, bdaddr_t *bdaddr);
void adapter_remove(struct btd_adapter *adapter);
void adapter_set_discov_timeout(struct btd_adapter *adapter, guint interval);
void adapter_remove_discov_timeout(struct btd_adapter *adapter);
diff --git a/src/agent.c b/src/agent.c
index 44ce3b11..e8f9c651 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -371,7 +371,8 @@ static void pincode_reply(DBusPendingCall *call, void *user_data)
bdaddr_t sba;
size_t len;
char *pin;
- const gchar *source = adapter_get_address(adapter);
+
+ adapter_get_address(adapter, &sba);
/* steal_reply will always return non-NULL since the callback
* is only called after a reply has been received */
@@ -416,8 +417,6 @@ static void pincode_reply(DBusPendingCall *call, void *user_data)
goto done;
}
- str2ba(source, &sba);
-
set_pin_length(&sba, len);
cb(agent, NULL, pin, req->user_data);
diff --git a/src/dbus-hci.c b/src/dbus-hci.c
index b559e148..77f768c1 100644
--- a/src/dbus-hci.c
+++ b/src/dbus-hci.c
@@ -126,7 +126,6 @@ static void pincode_cb(struct agent *agent, DBusError *err, const char *pincode,
struct pending_auth_info *auth;
const gchar *destination = device_get_address(device);
uint16_t dev_id = adapter_get_dev_id(adapter);
- const gchar *source = adapter_get_address(adapter);
struct bonding_request_info *bonding = adapter_get_bonding_info(adapter);
/* No need to reply anything if the authentication already failed */
@@ -140,7 +139,7 @@ static void pincode_cb(struct agent *agent, DBusError *err, const char *pincode,
return;
}
- str2ba(source, &sba);
+ adapter_get_address(adapter, &sba);
str2ba(destination, &dba);
auth = adapter_find_auth_request(adapter, &dba);
diff --git a/src/device.c b/src/device.c
index 2802b8e3..a4b26d52 100644
--- a/src/device.c
+++ b/src/device.c
@@ -124,12 +124,15 @@ static void device_free(gpointer user_data)
static gboolean device_is_paired(struct btd_device *device)
{
struct btd_adapter *adapter = device->adapter;
- char filename[PATH_MAX + 1], *str;
+ char filename[PATH_MAX + 1], *str, addr[18];
gboolean ret;
- const gchar *source = adapter_get_address(adapter);
+ bdaddr_t bdaddr;
+
+ adapter_get_address(adapter, &bdaddr);
+ ba2str(&bdaddr, addr);
create_name(filename, PATH_MAX, STORAGEDIR,
- source, "linkkeys");
+ addr, "linkkeys");
str = textfile_caseget(filename, device->address);
ret = str ? TRUE : FALSE;
g_free(str);
@@ -146,9 +149,9 @@ static DBusMessage *get_properties(DBusConnection *conn,
DBusMessageIter iter;
DBusMessageIter dict;
bdaddr_t src, dst;
- char name[248];
+ char name[248], src_addr[18];
char **uuids;
- const char *ptr, *source;
+ const char *ptr;
dbus_bool_t boolean;
uint32_t class;
int i;
@@ -173,15 +176,16 @@ static DBusMessage *get_properties(DBusConnection *conn,
/* Name */
ptr = NULL;
memset(name, 0, sizeof(name));
- source = adapter_get_address(adapter);
+ adapter_get_address(adapter, &src);
+ ba2str(&src, src_addr);
- if (read_device_name(source, device->address, name) == 0) {
+ if (read_device_name(src_addr, device->address, name) == 0) {
ptr = name;
dbus_message_iter_append_dict_entry(&dict, "Name",
DBUS_TYPE_STRING, &ptr);
}
- if (read_device_alias(source, device->address, name, sizeof(name)) > 0)
+ if (read_device_alias(src_addr, device->address, name, sizeof(name)) > 0)
ptr = name;
/* Alias: use Name if Alias doesn't exist */
@@ -189,7 +193,6 @@ static DBusMessage *get_properties(DBusConnection *conn,
dbus_message_iter_append_dict_entry(&dict, "Alias",
DBUS_TYPE_STRING, &ptr);
- str2ba(source, &src);
str2ba(device->address, &dst);
/* Class */
@@ -241,11 +244,15 @@ static DBusMessage *set_alias(DBusConnection *conn, DBusMessage *msg,
{
struct btd_device *device = data;
struct btd_adapter *adapter = device->adapter;
- const gchar *source = adapter_get_address(adapter);
+ char addr[18];
+ bdaddr_t bdaddr;
int err;
- /* Remove alias if empty string */
- err = write_device_alias(source, device->address,
+ adapter_get_address(adapter, &bdaddr);
+ ba2str(&bdaddr, addr);
+
+ /* Remove alias if empty string */
+ err = write_device_alias(addr, device->address,
g_str_equal(alias, "") ? NULL : alias);
if (err < 0)
return g_dbus_create_error(msg,
@@ -264,9 +271,14 @@ static DBusMessage *set_trust(DBusConnection *conn, DBusMessage *msg,
{
struct btd_device *device = data;
struct btd_adapter *adapter = device->adapter;
- const gchar *source = adapter_get_address(adapter);
+ char addr[18];
+ bdaddr_t bdaddr;
+
- write_trust(source, device->address, GLOBAL_TRUST, value);
+ adapter_get_address(adapter, &bdaddr);
+ ba2str(&bdaddr, addr);
+
+ write_trust(addr, device->address, GLOBAL_TRUST, value);
dbus_connection_emit_property_changed(conn, dbus_message_get_path(msg),
DEVICE_INTERFACE, "Trusted",
@@ -328,11 +340,11 @@ static void discover_services_req_exit(void *user_data)
struct btd_device *device = user_data;
struct btd_adapter *adapter = device->adapter;
bdaddr_t src, dst;
- const gchar *source = adapter_get_address(adapter);
+
+ adapter_get_address(adapter, &src);
debug("DiscoverDevices requestor exited");
- str2ba(source, &src);
str2ba(device->address, &dst);
bt_cancel_discovery(&src, &dst);
@@ -381,7 +393,8 @@ static DBusMessage *cancel_discover(DBusConnection *conn,
struct btd_device *device = user_data;
struct btd_adapter *adapter = device->adapter;
bdaddr_t src, dst;
- const gchar *source = adapter_get_address(adapter);
+
+ adapter_get_address(adapter, &src);
if (!device->discov_active)
return g_dbus_create_error(msg,
@@ -395,7 +408,6 @@ static DBusMessage *cancel_discover(DBusConnection *conn,
ERROR_INTERFACE ".NotAuthorized",
"Not Authorized");
- str2ba(source, &src);
str2ba(device->address, &dst);
if (bt_cancel_discovery(&src, &dst) < 0)
@@ -621,9 +633,13 @@ void device_probe_drivers(struct btd_device *device, GSList *uuids, sdp_list_t *
void device_remove_drivers(struct btd_device *device, GSList *uuids, sdp_list_t *recs)
{
struct btd_adapter *adapter = device_get_adapter(device);
- const gchar *src = adapter_get_address(adapter);
const gchar *dst = device_get_address(device);
GSList *list;
+ char src_addr[18];
+ bdaddr_t src;
+
+ adapter_get_address(adapter, &src);
+ ba2str(&src, src_addr);
debug("Remove drivers for %s", device->path);
@@ -649,7 +665,7 @@ void device_remove_drivers(struct btd_device *device, GSList *uuids, sdp_list_t
if (!rec)
continue;
- delete_record(src, dst, rec->handle);
+ delete_record(src_addr, dst, rec->handle);
}
}
@@ -779,9 +795,13 @@ static void update_services(struct browse_req *req, sdp_list_t *recs)
{
struct btd_device *device = req->device;
struct btd_adapter *adapter = device_get_adapter(device);
- const gchar *src = adapter_get_address(adapter);
const gchar *dst = device_get_address(device);
sdp_list_t *seq;
+ char src_addr[18];
+ bdaddr_t src;
+
+ adapter_get_address(adapter, &src);
+ ba2str(&src, src_addr);
for (seq = recs; seq; seq = seq->next) {
sdp_record_t *rec = (sdp_record_t *) seq->data;
@@ -805,7 +825,7 @@ static void update_services(struct browse_req *req, sdp_list_t *recs)
if (sdp_list_find(req->records, rec, rec_cmp))
continue;
- store_record(src, dst, rec);
+ store_record(src_addr, dst, rec);
/* Copy record */
if (sdp_gen_record_pdu(rec, &pdu) == 0) {
@@ -838,9 +858,8 @@ static void store(struct btd_device *device)
struct btd_adapter *adapter = device->adapter;
bdaddr_t src, dst;
char *str;
- const gchar *source = adapter_get_address(adapter);
- str2ba(source, &src);
+ adapter_get_address(adapter, &src);
str2ba(device->address, &dst);
if (!device->uuids) {
@@ -861,7 +880,8 @@ static void browse_cb(sdp_list_t *recs, int err, gpointer user_data)
bdaddr_t src, dst;
uuid_t uuid;
DBusMessage *reply;
- const gchar *source = adapter_get_address(adapter);
+
+ adapter_get_address(adapter, &src);
if (err < 0) {
error("%s: error updating services: %s (%d)",
@@ -877,7 +897,6 @@ static void browse_cb(sdp_list_t *recs, int err, gpointer user_data)
if (uuid_list[++req->search_uuid]) {
sdp_uuid16_create(&uuid, uuid_list[req->search_uuid]);
- str2ba(source, &src);
str2ba(device->address, &dst);
bt_search_service(&src, &dst, &uuid, browse_cb, user_data, NULL);
return;
@@ -955,14 +974,14 @@ int device_browse(struct btd_device *device, DBusConnection *conn,
bdaddr_t src, dst;
uuid_t uuid;
GSList *l;
- const gchar *source = adapter_get_address(adapter);
+
+ adapter_get_address(adapter, &src);
req = g_new0(struct browse_req, 1);
req->conn = dbus_connection_ref(conn);
req->msg = dbus_message_ref(msg);
req->device = device;
- str2ba(source, &src);
str2ba(device->address, &dst);
if (search) {
diff --git a/src/manager.c b/src/manager.c
index 793cb497..537582ac 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -301,9 +301,13 @@ static gint adapter_address_cmp(gconstpointer a, gconstpointer b)
{
struct btd_adapter *adapter = (struct btd_adapter *) a;
const char *address = b;
- const gchar *source = adapter_get_address(adapter);
+ bdaddr_t bdaddr;
+ char addr[18];
- return strcmp(source, address);
+ adapter_get_address(adapter, &bdaddr);
+ ba2str(&bdaddr, addr);
+
+ return strcmp(addr, address);
}
struct btd_adapter *manager_find_adapter(const bdaddr_t *sba)