mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2025-01-26 22:33:29 +08:00
Adding adapter_get_address.
Signed-off-by: Alok Barsode <alok.barsode@azingo.com>
This commit is contained in:
parent
ee86cf6916
commit
debc2efd75
@ -2573,3 +2573,11 @@ const gchar *adapter_get_path(struct adapter *adapter)
|
||||
|
||||
return adapter->path;
|
||||
}
|
||||
|
||||
const gchar *adapter_get_address(struct adapter *adapter)
|
||||
{
|
||||
if (!adapter)
|
||||
return NULL;
|
||||
|
||||
return adapter->address;
|
||||
}
|
||||
|
@ -177,3 +177,4 @@ struct pending_auth_info *adapter_new_auth_request(struct adapter *adapter,
|
||||
struct adapter *adapter_create(int id);
|
||||
uint16_t adapter_get_dev_id(struct adapter *adapter);
|
||||
const gchar *adapter_get_path(struct adapter *adapter);
|
||||
const gchar *adapter_get_address(struct adapter *adapter);
|
||||
|
@ -386,6 +386,7 @@ static void pincode_reply(DBusPendingCall *call, void *user_data)
|
||||
bdaddr_t sba;
|
||||
size_t len;
|
||||
char *pin;
|
||||
const gchar *source = adapter_get_address(adapter);
|
||||
|
||||
/* steal_reply will always return non-NULL since the callback
|
||||
* is only called after a reply has been received */
|
||||
@ -423,7 +424,7 @@ static void pincode_reply(DBusPendingCall *call, void *user_data)
|
||||
goto done;
|
||||
}
|
||||
|
||||
str2ba(adapter->address, &sba);
|
||||
str2ba(source, &sba);
|
||||
|
||||
set_pin_length(&sba, len);
|
||||
|
||||
|
@ -324,6 +324,7 @@ 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);
|
||||
|
||||
/* No need to reply anything if the authentication already failed */
|
||||
if (adapter->bonding && adapter->bonding->hci_status)
|
||||
@ -336,7 +337,7 @@ static void pincode_cb(struct agent *agent, DBusError *err, const char *pincode,
|
||||
return;
|
||||
}
|
||||
|
||||
str2ba(adapter->address, &sba);
|
||||
str2ba(source, &sba);
|
||||
str2ba(destination, &dba);
|
||||
|
||||
auth = adapter_find_auth_request(adapter, &dba);
|
||||
|
@ -135,9 +135,10 @@ static gboolean device_is_paired(struct btd_device *device)
|
||||
struct adapter *adapter = device->adapter;
|
||||
char filename[PATH_MAX + 1], *str;
|
||||
gboolean ret;
|
||||
const gchar *source = adapter_get_address(adapter);
|
||||
|
||||
create_name(filename, PATH_MAX, STORAGEDIR,
|
||||
adapter->address, "linkkeys");
|
||||
source, "linkkeys");
|
||||
str = textfile_caseget(filename, device->address);
|
||||
ret = str ? TRUE : FALSE;
|
||||
g_free(str);
|
||||
@ -149,8 +150,9 @@ static char *device_get_name(struct btd_device *device)
|
||||
{
|
||||
struct adapter *adapter = device->adapter;
|
||||
char filename[PATH_MAX + 1];
|
||||
const gchar *source = adapter_get_address(adapter);
|
||||
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "names");
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, source, "names");
|
||||
return textfile_caseget(filename, device->address);
|
||||
}
|
||||
|
||||
@ -172,6 +174,7 @@ static DBusMessage *get_properties(DBusConnection *conn,
|
||||
int i;
|
||||
GSList *l;
|
||||
uint16_t dev_id = adapter_get_dev_id(adapter);
|
||||
const gchar *source = adapter_get_address(adapter);
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
if (!reply)
|
||||
@ -195,7 +198,7 @@ static DBusMessage *get_properties(DBusConnection *conn,
|
||||
DBUS_TYPE_STRING, &name);
|
||||
}
|
||||
|
||||
str2ba(adapter->address, &src);
|
||||
str2ba(source, &src);
|
||||
str2ba(device->address, &dst);
|
||||
|
||||
/* Class */
|
||||
@ -273,15 +276,16 @@ static DBusMessage *set_alias(DBusConnection *conn, DBusMessage *msg,
|
||||
int ecode;
|
||||
char *str, filename[PATH_MAX + 1];
|
||||
uint16_t dev_id = adapter_get_dev_id(adapter);
|
||||
const gchar *source = adapter_get_address(adapter);
|
||||
|
||||
str2ba(device->address, &bdaddr);
|
||||
|
||||
/* Remove alias if empty string */
|
||||
if (g_str_equal(alias, "")) {
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, adapter->address,
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, source,
|
||||
"names");
|
||||
str = textfile_caseget(filename, device->address);
|
||||
ecode = remove_device_alias(adapter->address, device->address);
|
||||
ecode = remove_device_alias(source, device->address);
|
||||
} else {
|
||||
str = g_strdup(alias);
|
||||
ecode = set_device_alias(dev_id, &bdaddr, alias);
|
||||
@ -307,8 +311,9 @@ static DBusMessage *set_trust(DBusConnection *conn, DBusMessage *msg,
|
||||
struct btd_device *device = data;
|
||||
struct adapter *adapter = device->adapter;
|
||||
bdaddr_t local;
|
||||
const gchar *source = adapter_get_address(adapter);
|
||||
|
||||
str2ba(adapter->address, &local);
|
||||
str2ba(source, &local);
|
||||
|
||||
write_trust(&local, device->address, GLOBAL_TRUST, value);
|
||||
|
||||
@ -372,10 +377,11 @@ static void discover_services_req_exit(void *user_data)
|
||||
struct btd_device *device = user_data;
|
||||
struct adapter *adapter = device->adapter;
|
||||
bdaddr_t src, dst;
|
||||
const gchar *source = adapter_get_address(adapter);
|
||||
|
||||
debug("DiscoverDevices requestor exited");
|
||||
|
||||
str2ba(adapter->address, &src);
|
||||
str2ba(source, &src);
|
||||
str2ba(device->address, &dst);
|
||||
|
||||
bt_cancel_discovery(&src, &dst);
|
||||
@ -424,6 +430,7 @@ static DBusMessage *cancel_discover(DBusConnection *conn,
|
||||
struct btd_device *device = user_data;
|
||||
struct adapter *adapter = device->adapter;
|
||||
bdaddr_t src, dst;
|
||||
const gchar *source = adapter_get_address(adapter);
|
||||
|
||||
if (!device->discov_active)
|
||||
return g_dbus_create_error(msg,
|
||||
@ -437,7 +444,7 @@ static DBusMessage *cancel_discover(DBusConnection *conn,
|
||||
ERROR_INTERFACE ".NotAuthorized",
|
||||
"Not Authorized");
|
||||
|
||||
str2ba(adapter->address, &src);
|
||||
str2ba(source, &src);
|
||||
str2ba(device->address, &dst);
|
||||
|
||||
if (bt_cancel_discovery(&src, &dst) < 0)
|
||||
@ -659,7 +666,7 @@ 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 adapter *adapter = device_get_adapter(device);
|
||||
const gchar *src = adapter->address;
|
||||
const gchar *src = adapter_get_address(adapter);
|
||||
const gchar *dst = device_get_address(device);
|
||||
GSList *list;
|
||||
|
||||
@ -806,7 +813,7 @@ static void update_services(struct browse_req *req, sdp_list_t *recs)
|
||||
{
|
||||
struct btd_device *device = req->device;
|
||||
struct adapter *adapter = device_get_adapter(device);
|
||||
const gchar *src = adapter->address;
|
||||
const gchar *src = adapter_get_address(adapter);
|
||||
const gchar *dst = device_get_address(device);
|
||||
sdp_list_t *seq;
|
||||
|
||||
@ -848,8 +855,9 @@ static void store(struct btd_device *device)
|
||||
struct adapter *adapter = device->adapter;
|
||||
bdaddr_t src, dst;
|
||||
char *str;
|
||||
const gchar *source = adapter_get_address(adapter);
|
||||
|
||||
str2ba(adapter->address, &src);
|
||||
str2ba(source, &src);
|
||||
str2ba(device->address, &dst);
|
||||
|
||||
if (!device->uuids) {
|
||||
@ -870,6 +878,7 @@ 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);
|
||||
|
||||
if (err < 0)
|
||||
goto proceed;
|
||||
@ -882,7 +891,7 @@ 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(adapter->address, &src);
|
||||
str2ba(source, &src);
|
||||
str2ba(device->address, &dst);
|
||||
bt_search_service(&src, &dst, &uuid, browse_cb, user_data, NULL);
|
||||
return;
|
||||
@ -958,13 +967,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);
|
||||
|
||||
req = g_new0(struct browse_req, 1);
|
||||
req->conn = dbus_connection_ref(conn);
|
||||
req->msg = dbus_message_ref(msg);
|
||||
req->device = device;
|
||||
|
||||
str2ba(adapter->address, &src);
|
||||
str2ba(source, &src);
|
||||
str2ba(device->address, &dst);
|
||||
|
||||
if (search) {
|
||||
|
@ -105,8 +105,9 @@ int get_device_alias(uint16_t dev_id, const bdaddr_t *bdaddr, char *alias, size_
|
||||
struct adapter *adapter = manager_find_adapter_by_id(dev_id);
|
||||
char filename[PATH_MAX + 1], addr[18], *tmp;
|
||||
int err;
|
||||
const gchar *source = adapter_get_address(adapter);
|
||||
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "aliases");
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, source, "aliases");
|
||||
|
||||
ba2str(bdaddr, addr);
|
||||
|
||||
@ -124,9 +125,10 @@ int get_device_alias(uint16_t dev_id, const bdaddr_t *bdaddr, char *alias, size_
|
||||
int set_device_alias(uint16_t dev_id, const bdaddr_t *bdaddr, const char *alias)
|
||||
{
|
||||
struct adapter *adapter = manager_find_adapter_by_id(dev_id);
|
||||
const gchar *source = adapter_get_address(adapter);
|
||||
char filename[PATH_MAX + 1], addr[18];
|
||||
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, adapter->address, "aliases");
|
||||
create_name(filename, PATH_MAX, STORAGEDIR, source, "aliases");
|
||||
|
||||
create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
|
||||
@ -365,8 +367,9 @@ static gint adapter_address_cmp(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
const struct adapter *adapter = a;
|
||||
const char *address = b;
|
||||
const gchar *source = adapter_get_address(adapter);
|
||||
|
||||
return strcmp(adapter->address, address);
|
||||
return strcmp(source, address);
|
||||
}
|
||||
|
||||
struct adapter *manager_find_adapter(const bdaddr_t *sba)
|
||||
|
@ -175,7 +175,7 @@ int input_probe(struct btd_device_driver *driver,
|
||||
|
||||
memset(&hidp, 0, sizeof(hidp));
|
||||
|
||||
source = adapter->address;
|
||||
source = adapter_get_address(adapter);
|
||||
destination = device_get_address(device);
|
||||
|
||||
if (load_stored(source, destination, &hidp) == 0)
|
||||
@ -234,7 +234,7 @@ int headset_input_probe(struct btd_device_driver *driver,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
source = adapter->address;
|
||||
source = adapter_get_address(adapter);
|
||||
destination = device_get_address(device);
|
||||
|
||||
str2ba(source, &src);
|
||||
|
@ -89,7 +89,7 @@ static int network_probe(struct btd_device *device, uint16_t id)
|
||||
|
||||
DBG("path %s", path);
|
||||
|
||||
source = adapter->address;
|
||||
source = adapter_get_address(adapter);
|
||||
destination = device_get_address(device);
|
||||
|
||||
str2ba(source, &src);
|
||||
|
@ -60,7 +60,7 @@ static DBusMessage *serial_connect(DBusConnection *conn,
|
||||
return NULL;
|
||||
|
||||
src = device_get_address(device);
|
||||
dst = adapter->address;
|
||||
dst = adapter_get_address(adapter);
|
||||
|
||||
service_connect(conn, msg, src, dst, target);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user