diff options
| author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2006-06-07 21:20:29 +0000 | 
|---|---|---|
| committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2006-06-07 21:20:29 +0000 | 
| commit | 937fd0e66fdb25c78f23e1d856a36484e5a8a96f (patch) | |
| tree | ad9cbfa2b4e8af70bcaf09afcbcce9d27b011815 | |
| parent | 43ebdb300ce2bf9051d777311eb22e4e57d496c9 (diff) | |
Timeout for PIN request
| -rw-r--r-- | hcid/dbus-adapter.c | 37 | ||||
| -rw-r--r-- | hcid/dbus.c | 2 | ||||
| -rw-r--r-- | hcid/dbus.h | 2 | 
3 files changed, 40 insertions, 1 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;  } diff --git a/hcid/dbus.c b/hcid/dbus.c index 93bf23fa..274dd8d8 100644 --- a/hcid/dbus.c +++ b/hcid/dbus.c @@ -646,7 +646,7 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, const u  			memset(&cp, 0, sizeof(cp));  			cp.handle = con->handle; -			cp.reason = HCI_OE_USER_ENDED_CONNECTION; +			cp.reason = (status ? HCI_AUTHENTICATION_FAILURE : HCI_OE_USER_ENDED_CONNECTION);  			data = hci_req_data_new(pdata->dev_id, peer, OGF_LINK_CTL,  						OCF_DISCONNECT, EVT_DISCONN_COMPLETE, diff --git a/hcid/dbus.h b/hcid/dbus.h index 69952bfc..d032f16b 100644 --- a/hcid/dbus.h +++ b/hcid/dbus.h @@ -50,6 +50,8 @@  #define MAX_PATH_LENGTH		64 +#define BONDING_TIMEOUT         45000 /* 45 sec */ +  typedef DBusHandlerResult (*service_handler_func_t) (DBusConnection *conn,  							DBusMessage *msg,  							void *user_data); | 
