summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
Diffstat (limited to 'hcid')
-rw-r--r--hcid/dbus-adapter.c20
-rw-r--r--hcid/dbus.c61
-rw-r--r--hcid/dbus.h3
3 files changed, 50 insertions, 34 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c
index 29eb9ab1..b358a419 100644
--- a/hcid/dbus-adapter.c
+++ b/hcid/dbus-adapter.c
@@ -1709,8 +1709,8 @@ static DBusHandlerResult handle_dev_create_bonding_req(DBusConnection *conn, DBu
if (dbus_data->bonding)
return error_bonding_in_progress(conn, msg);
- /* check if there is a pending discover */
- if (dbus_data->discover_state != STATE_IDLE || dbus_data->requestor_name)
+ /* check if there is a pending discover: requested by D-Bus/non clients */
+ if (dbus_data->discover_state != STATE_IDLE || dbus_data->discovery_requestor)
return error_discover_in_progress(conn, msg);
/* check if a link key already exists */
@@ -1779,9 +1779,9 @@ static DBusHandlerResult handle_dev_create_bonding_req(DBusConnection *conn, DBu
dbus_data->bonding->disconnect = disconnect;
dbus_data->bonding->rq = dbus_message_ref(msg);
- dbus_data->requestor_name = strdup(dbus_message_get_sender(msg));
+ dbus_data->bonding_requestor = strdup(dbus_message_get_sender(msg));
- name_listener_add(conn, dbus_data->requestor_name,
+ name_listener_add(conn, dbus_data->bonding_requestor,
(name_cb_t)create_bond_req_exit, dbus_data);
hci_close_dev(dd);
@@ -1824,7 +1824,7 @@ static DBusHandlerResult handle_dev_cancel_bonding_req(DBusConnection *conn, DBu
return error_bonding_not_in_progress(conn, msg);
}
- if (strcmp(dbus_data->requestor_name, dbus_message_get_sender(msg)))
+ if (strcmp(dbus_data->bonding_requestor, dbus_message_get_sender(msg)))
return error_not_authorized(conn, msg);
dd = hci_open_dev(dbus_data->dev_id);
@@ -2196,7 +2196,7 @@ static DBusHandlerResult handle_dev_discover_devices_req(DBusConnection *conn, D
else
dbus_data->discover_type = RESOLVE_NAME;
- dbus_data->requestor_name = strdup(dbus_message_get_sender(msg));
+ dbus_data->discovery_requestor = strdup(dbus_message_get_sender(msg));
reply = dbus_message_new_method_return(msg);
@@ -2230,7 +2230,7 @@ static DBusHandlerResult handle_dev_cancel_discovery_req(DBusConnection *conn, D
return error_not_authorized(conn, msg); /* FIXME: find a better error name */
/* only the discover requestor can cancel the inquiry process */
- if (strcmp(dbus_data->requestor_name, requestor_name))
+ if (strcmp(dbus_data->discovery_requestor, requestor_name))
return error_not_authorized(conn, msg);
dd = hci_open_dev(dbus_data->dev_id);
@@ -2277,9 +2277,9 @@ static DBusHandlerResult handle_dev_cancel_discovery_req(DBusConnection *conn, D
slist_free(dbus_data->disc_devices);
dbus_data->disc_devices = NULL;
- if (dbus_data->requestor_name) {
- free(dbus_data->requestor_name);
- dbus_data->requestor_name = NULL;
+ if (dbus_data->discovery_requestor) {
+ free(dbus_data->discovery_requestor);
+ dbus_data->discovery_requestor = NULL;
}
reply = dbus_message_new_method_return(msg);
diff --git a/hcid/dbus.c b/hcid/dbus.c
index 2bb9bf85..089dc232 100644
--- a/hcid/dbus.c
+++ b/hcid/dbus.c
@@ -398,10 +398,16 @@ static int unregister_dbus_path(const char *path)
release_passkey_agents(pdata, NULL);
- if (pdata->requestor_name) {
- name_listener_remove(connection, pdata->requestor_name,
+ if (pdata->bonding_requestor) {
+ name_listener_remove(connection, pdata->bonding_requestor,
(name_cb_t)create_bond_req_exit, pdata);
- free(pdata->requestor_name);
+ free(pdata->bonding_requestor);
+ pdata->bonding_requestor = NULL;
+ }
+
+ if (pdata->discovery_requestor) {
+ free(pdata->discovery_requestor);
+ pdata->discovery_requestor = NULL;
}
if (pdata->disc_devices) {
@@ -646,11 +652,16 @@ int hcid_dbus_stop_device(uint16_t id)
release_passkey_agents(pdata, NULL);
- if (pdata->requestor_name) {
- name_listener_remove(connection, pdata->requestor_name,
+ if (pdata->bonding_requestor) {
+ name_listener_remove(connection, pdata->bonding_requestor,
(name_cb_t)create_bond_req_exit, pdata);
- free(pdata->requestor_name);
- pdata->requestor_name = NULL;
+ free(pdata->bonding_requestor);
+ pdata->bonding_requestor = NULL;
+ }
+
+ if (pdata->discovery_requestor) {
+ free(pdata->discovery_requestor);
+ pdata->discovery_requestor = NULL;
}
if (pdata->disc_devices) {
@@ -809,10 +820,10 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, const u
bonding_request_free(pdata->bonding);
pdata->bonding = NULL;
- name_listener_remove(connection, pdata->requestor_name,
+ name_listener_remove(connection, pdata->bonding_requestor,
(name_cb_t)create_bond_req_exit, pdata);
- free(pdata->requestor_name);
- pdata->requestor_name = NULL;
+ free(pdata->bonding_requestor);
+ pdata->bonding_requestor = NULL;
failed:
bt_free(local_addr);
@@ -1049,9 +1060,9 @@ void hcid_dbus_inquiry_complete(bdaddr_t *local)
slist_free(pdata->disc_devices);
pdata->disc_devices = NULL;
- if (pdata->requestor_name) {
- free(pdata->requestor_name);
- pdata->requestor_name = NULL;
+ if (pdata->discovery_requestor) {
+ free(pdata->discovery_requestor);
+ pdata->discovery_requestor = NULL;
}
/* Send discovery completed signal if there isn't name to resolve */
@@ -1239,9 +1250,9 @@ void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, uint8_t status, char
send_reply_and_unref(connection, message);
- if (pdata->requestor_name) {
- free(pdata->requestor_name);
- pdata->requestor_name = NULL;
+ if (pdata->discovery_requestor) {
+ free(pdata->discovery_requestor);
+ pdata->discovery_requestor = NULL;
}
}
@@ -1346,10 +1357,10 @@ bonding_failed:
/* free bonding request if the HCI pairing request was not sent */
bonding_request_free(pdata->bonding);
pdata->bonding = NULL;
- name_listener_remove(connection, pdata->requestor_name,
+ name_listener_remove(connection, pdata->bonding_requestor,
(name_cb_t)create_bond_req_exit, pdata);
- free(pdata->requestor_name);
- pdata->requestor_name = NULL;
+ free(pdata->bonding_requestor);
+ pdata->bonding_requestor = NULL;
done:
if (dd >= 0)
@@ -1413,8 +1424,12 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status, uint16_t handle
bonding_request_free(pdata->bonding);
pdata->bonding = NULL;
- free(pdata->requestor_name);
- pdata->requestor_name = NULL;
+ if (pdata->bonding_requestor) {
+ name_listener_remove(connection, pdata->bonding_requestor,
+ (name_cb_t)create_bond_req_exit, pdata);
+ free(pdata->bonding_requestor);
+ pdata->bonding_requestor = NULL;
+ }
}
cancel_passkey_agent_requests(pdata->passkey_agents, path, &dev->bdaddr);
@@ -2019,6 +2034,6 @@ void create_bond_req_exit(const char *name, struct hci_dbus_data *pdata)
bonding_request_free(pdata->bonding);
pdata->bonding = NULL;
- free(pdata->requestor_name);
- pdata->requestor_name = NULL;
+ free(pdata->bonding_requestor);
+ pdata->bonding_requestor = NULL;
}
diff --git a/hcid/dbus.h b/hcid/dbus.h
index a1d9f18a..c93f1744 100644
--- a/hcid/dbus.h
+++ b/hcid/dbus.h
@@ -105,7 +105,8 @@ struct hci_dbus_data {
discover_state_t discover_state; /* discover states */
int discover_type; /* with/without name resolving */
struct slist *disc_devices;
- char *requestor_name; /* requestor unique name */
+ char *discovery_requestor; /* discovery requestor unique name */
+ char *bonding_requestor; /* bonding requestor unique name */
struct slist *passkey_agents;
struct bonding_request_info *bonding;
struct slist *active_conn;