summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
Diffstat (limited to 'hcid')
-rw-r--r--hcid/dbus-adapter.c11
-rw-r--r--hcid/dbus.c59
-rw-r--r--hcid/dbus.h1
3 files changed, 17 insertions, 54 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c
index 3e06d50e..54ee49ab 100644
--- a/hcid/dbus-adapter.c
+++ b/hcid/dbus-adapter.c
@@ -1781,9 +1781,7 @@ 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->bonding_requestor = strdup(dbus_message_get_sender(msg));
-
- name_listener_add(conn, dbus_data->bonding_requestor,
+ name_listener_add(conn, dbus_message_get_sender(msg),
(name_cb_t)create_bond_req_exit, dbus_data);
hci_close_dev(dd);
@@ -1826,8 +1824,7 @@ static DBusHandlerResult handle_dev_cancel_bonding_req(DBusConnection *conn, DBu
return error_bonding_not_in_progress(conn, msg);
}
- if (!dbus_data->bonding_requestor || strcmp(dbus_data->bonding_requestor,
- dbus_message_get_sender(msg)))
+ if (strcmp(dbus_message_get_sender(dbus_data->bonding->rq), dbus_message_get_sender(msg)))
return error_not_authorized(conn, msg);
dd = hci_open_dev(dbus_data->dev_id);
@@ -1881,10 +1878,8 @@ static DBusHandlerResult handle_dev_cancel_bonding_req(DBusConnection *conn, DBu
/* Reply to the create bonding request */
error_authentication_canceled(conn, dbus_data->bonding->rq);
- name_listener_remove(conn, dbus_data->bonding_requestor,
+ name_listener_remove(conn, dbus_message_get_sender(dbus_data->bonding->rq),
(name_cb_t)create_bond_req_exit, dbus_data);
- free(dbus_data->bonding_requestor);
- dbus_data->bonding_requestor = NULL;
/* disconnect from the remote device */
if (dbus_data->bonding->disconnect) {
diff --git a/hcid/dbus.c b/hcid/dbus.c
index a73bd823..bb70d34c 100644
--- a/hcid/dbus.c
+++ b/hcid/dbus.c
@@ -363,7 +363,7 @@ static int register_dbus_path(const char *path, uint16_t dev_id,
return 0;
}
-static void reply_pending_requests(const char *path, const struct hci_dbus_data *pdata)
+static void reply_pending_requests(const char *path, struct hci_dbus_data *pdata)
{
DBusMessage *message = NULL;
@@ -371,8 +371,13 @@ static void reply_pending_requests(const char *path, const struct hci_dbus_data
return;
/* pending bonding */
- if (pdata->bonding)
+ if (pdata->bonding) {
error_authentication_canceled(connection, pdata->bonding->rq);
+ name_listener_remove(connection, dbus_message_get_sender(pdata->bonding->rq),
+ (name_cb_t)create_bond_req_exit, pdata);
+ bonding_request_free(pdata->bonding);
+ pdata->bonding = NULL;
+ }
else if (pdata->discover_state != STATE_IDLE) {
/* pending inquiry */
@@ -398,13 +403,6 @@ static int unregister_dbus_path(const char *path)
release_passkey_agents(pdata, 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;
- }
-
if (pdata->discovery_requestor) {
free(pdata->discovery_requestor);
pdata->discovery_requestor = NULL;
@@ -416,11 +414,6 @@ static int unregister_dbus_path(const char *path)
pdata->disc_devices = NULL;
}
- if (pdata->bonding) {
- bonding_request_free(pdata->bonding);
- pdata->bonding = NULL;
- }
-
if (pdata->pending_bondings) {
slist_foreach(pdata->pending_bondings, (slist_func_t)free, NULL);
slist_free(pdata->pending_bondings);
@@ -652,13 +645,6 @@ int hcid_dbus_stop_device(uint16_t id)
release_passkey_agents(pdata, 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;
- }
-
if (pdata->discovery_requestor) {
free(pdata->discovery_requestor);
pdata->discovery_requestor = NULL;
@@ -670,11 +656,6 @@ int hcid_dbus_stop_device(uint16_t id)
pdata->disc_devices = NULL;
}
- if (pdata->bonding) {
- bonding_request_free(pdata->bonding);
- pdata->bonding = NULL;
- }
-
if (pdata->pending_bondings) {
slist_foreach(pdata->pending_bondings, (slist_func_t)free, NULL);
slist_free(pdata->pending_bondings);
@@ -817,14 +798,12 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, const u
message = dbus_msg_new_authentication_return(pdata->bonding->rq, status);
send_reply_and_unref(connection, message);
+ name_listener_remove(connection, dbus_message_get_sender(pdata->bonding->rq),
+ (name_cb_t)create_bond_req_exit, pdata);
+
bonding_request_free(pdata->bonding);
pdata->bonding = NULL;
- name_listener_remove(connection, pdata->bonding_requestor,
- (name_cb_t)create_bond_req_exit, pdata);
- free(pdata->bonding_requestor);
- pdata->bonding_requestor = NULL;
-
failed:
bt_free(local_addr);
bt_free(peer_addr);
@@ -1356,12 +1335,10 @@ void hcid_dbus_conn_complete(bdaddr_t *local, uint8_t status, uint16_t handle, b
bonding_failed:
/* free bonding request if the HCI pairing request was not sent */
+ name_listener_remove(connection, dbus_message_get_sender(pdata->bonding->rq),
+ (name_cb_t)create_bond_req_exit, pdata);
bonding_request_free(pdata->bonding);
pdata->bonding = NULL;
- name_listener_remove(connection, pdata->bonding_requestor,
- (name_cb_t)create_bond_req_exit, pdata);
- free(pdata->bonding_requestor);
- pdata->bonding_requestor = NULL;
done:
if (dd >= 0)
@@ -1422,15 +1399,10 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status, uint16_t handle
message = dbus_msg_new_authentication_return(pdata->bonding->rq, status);
send_reply_and_unref(connection, message);
+ name_listener_remove(connection, dbus_message_get_sender(pdata->bonding->rq),
+ (name_cb_t)create_bond_req_exit, pdata);
bonding_request_free(pdata->bonding);
pdata->bonding = 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);
@@ -2034,7 +2006,4 @@ void create_bond_req_exit(const char *name, struct hci_dbus_data *pdata)
bonding_request_free(pdata->bonding);
pdata->bonding = NULL;
-
- free(pdata->bonding_requestor);
- pdata->bonding_requestor = NULL;
}
diff --git a/hcid/dbus.h b/hcid/dbus.h
index c93f1744..f33ebc3a 100644
--- a/hcid/dbus.h
+++ b/hcid/dbus.h
@@ -106,7 +106,6 @@ struct hci_dbus_data {
int discover_type; /* with/without name resolving */
struct slist *disc_devices;
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;