summaryrefslogtreecommitdiffstats
path: root/hcid/dbus-adapter.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2006-06-07 21:20:29 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2006-06-07 21:20:29 +0000
commit937fd0e66fdb25c78f23e1d856a36484e5a8a96f (patch)
treead9cbfa2b4e8af70bcaf09afcbcce9d27b011815 /hcid/dbus-adapter.c
parent43ebdb300ce2bf9051d777311eb22e4e57d496c9 (diff)
Timeout for PIN request
Diffstat (limited to 'hcid/dbus-adapter.c')
-rw-r--r--hcid/dbus-adapter.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c
index 62280f24..3b56ced4 100644
--- a/hcid/dbus-adapter.c
+++ b/hcid/dbus-adapter.c
@@ -1552,6 +1552,37 @@ static DBusHandlerResult handle_dev_disconnect_remote_device_req(DBusConnection
}
+static int bonding_timeout_handler(void *data)
+{
+ struct hci_dbus_data *dbus_data = data;
+ struct active_conn_info *con;
+ struct slist *l;
+ int dd = -1;
+
+ if (!dbus_data->bonding || !dbus_data->bonding->disconnect)
+ return -1;
+
+ l = slist_find(dbus_data->active_conn, &dbus_data->bonding->bdaddr, active_conn_find_by_bdaddr);
+ if (!l)
+ return -1;
+
+ con = l->data;
+
+ dd = hci_open_dev(dbus_data->dev_id);
+ if (dd < 0) {
+ error("HCI device open failed: hci%d", dbus_data->dev_id);
+ return -1;
+ }
+
+ if (hci_disconnect(dd, htobs(con->handle), HCI_AUTHENTICATION_FAILURE, 1000) < 0)
+ error("Disconnect failed");
+
+ if (dd >= 0)
+ close(dd);
+
+ return -1;
+}
+
static DBusHandlerResult handle_dev_create_bonding_req(DBusConnection *conn, DBusMessage *msg, void *data)
{
char filename[PATH_MAX + 1];
@@ -1669,6 +1700,12 @@ static DBusHandlerResult handle_dev_create_bonding_req(DBusConnection *conn, DBu
hci_close_dev(dd);
+ /*
+ * Create a timeout to disconnect automatically if no passkey is provided
+ * Broadcom chips doesn't handle timeout for PIN code request command
+ */
+ g_timeout_add(BONDING_TIMEOUT, bonding_timeout_handler, dbus_data);
+
return DBUS_HANDLER_RESULT_HANDLED;
}