summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2006-07-10 19:23:14 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2006-07-10 19:23:14 +0000
commitd65752b7f39adca50c35d5f1ba0f4368d6efaa2d (patch)
tree625615e63d666e0414752b16336b347a49b99616
parentb0f139af155d04ef8c399e77e89707af98441693 (diff)
Don't send BondingCreated on link key renew
-rw-r--r--hcid/dbus.c48
-rw-r--r--hcid/dbus.h1
-rw-r--r--hcid/hcid.h1
-rw-r--r--hcid/security.c2
4 files changed, 47 insertions, 5 deletions
diff --git a/hcid/dbus.c b/hcid/dbus.c
index 7c1d3e34..9a805cd9 100644
--- a/hcid/dbus.c
+++ b/hcid/dbus.c
@@ -593,6 +593,36 @@ failed:
return ret;
}
+int pending_bonding_cmp(const void *p1, const void *p2)
+{
+ const bdaddr_t *peer1 = p1;
+ const bdaddr_t *peer2 = p2;
+
+ if (peer2)
+ return bacmp(peer1, peer2);
+ return -1;
+}
+
+void hcid_dbus_pending_bonding_add(bdaddr_t *sba, bdaddr_t *dba)
+{
+ char path[MAX_PATH_LENGTH], addr[18];
+ struct hci_dbus_data *pdata;
+ bdaddr_t *peer;
+
+ ba2str(sba, addr);
+
+ snprintf(path, sizeof(path), "%s/hci%d", BASE_PATH, hci_devid(addr));
+
+ if (!dbus_connection_get_object_path_data(connection, path, (void *) &pdata)) {
+ error("Getting %s path data failed!", path);
+ return;
+ }
+
+ peer = malloc(sizeof(bdaddr_t));
+ bacpy(peer, dba);
+ pdata->pending_bondings = slist_append(pdata->pending_bondings, peer);
+}
+
void hcid_dbus_request_pin(int dev, bdaddr_t *sba, struct hci_conn_info *ci)
{
char path[MAX_PATH_LENGTH], addr[18];
@@ -609,7 +639,7 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, const u
struct hci_dbus_data *pdata;
DBusMessage *message;
char *local_addr, *peer_addr;
- const char *name;
+ struct slist *l;
bdaddr_t tmp;
char path[MAX_PATH_LENGTH];
int id;
@@ -644,12 +674,20 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, const u
send_reply_and_unref(connection, message);
#endif
- if (!status) {
- name = "BondingCreated";
- message = dev_signal_factory(pdata->dev_id, name,
+
+ l = slist_find(pdata->pending_bondings, peer, pending_bonding_cmp);
+ if (l) {
+ bdaddr_t *p = l->data;
+ pdata->pending_bondings = slist_remove(pdata->pending_bondings, p);
+ free(p);
+
+ if (!status) {
+ const char *name = "BondingCreated";
+ message = dev_signal_factory(pdata->dev_id, name,
DBUS_TYPE_STRING, &peer_addr,
DBUS_TYPE_INVALID);
- send_reply_and_unref(connection, message);
+ send_reply_and_unref(connection, message);
+ }
}
if (!pdata->bonding || bacmp(&pdata->bonding->bdaddr, peer))
diff --git a/hcid/dbus.h b/hcid/dbus.h
index 5bab94ce..5c775871 100644
--- a/hcid/dbus.h
+++ b/hcid/dbus.h
@@ -108,6 +108,7 @@ struct hci_dbus_data {
struct slist *passkey_agents;
struct bonding_request_info *bonding;
struct slist *active_conn;
+ struct slist *pending_bondings;
};
struct passkey_agent {
diff --git a/hcid/hcid.h b/hcid/hcid.h
index 3714a666..cbaa6048 100644
--- a/hcid/hcid.h
+++ b/hcid/hcid.h
@@ -146,6 +146,7 @@ void hcid_dbus_set_experimental();
int hcid_dbus_use_experimental();
int hcid_dbus_register_device(uint16_t id);
int hcid_dbus_unregister_device(uint16_t id);
+void hcid_dbus_pending_bonding_add(bdaddr_t *sba, bdaddr_t *dba);
void hcid_dbus_request_pin(int dev, bdaddr_t *sba, struct hci_conn_info *ci);
void hcid_dbus_inquiry_start(bdaddr_t *local);
diff --git a/hcid/security.c b/hcid/security.c
index 25bfeac2..d8b6affb 100644
--- a/hcid/security.c
+++ b/hcid/security.c
@@ -379,6 +379,8 @@ static void pin_code_request(int dev, bdaddr_t *sba, bdaddr_t *dba)
hcid_dbus_request_pin(dev, sba, ci);
}
+ hcid_dbus_pending_bonding_add(sba, &ci->bdaddr);
+
free(cr);
return;