summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2009-02-03 12:15:07 -0800
committerJohan Hedberg <johan.hedberg@nokia.com>2009-02-03 12:19:00 -0800
commite35dd0c0246236371269b79cc28b1a23f4999560 (patch)
tree59d611de1106fc3db522ac998e73234035a2c855 /src
parentf7d1ee361e410e096929bd3918178af356c50bbd (diff)
Add support for HCI_Simple_Pairing_Complete event
When we are the acceptors of a pairing request and we have used the Agent.DisplayPasskey we need to use the Simple Pairing Complete HCI event for calling Agent.Cancel.
Diffstat (limited to 'src')
-rw-r--r--src/dbus-hci.c25
-rw-r--r--src/dbus-hci.h1
-rw-r--r--src/device.c15
-rw-r--r--src/device.h1
-rw-r--r--src/security.c11
5 files changed, 53 insertions, 0 deletions
diff --git a/src/dbus-hci.c b/src/dbus-hci.c
index 8059478d..7950ce79 100644
--- a/src/dbus-hci.c
+++ b/src/dbus-hci.c
@@ -445,6 +445,31 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer,
device_bonding_complete(device, status);
}
+void hcid_dbus_simple_pairing_complete(bdaddr_t *local, bdaddr_t *peer,
+ uint8_t status)
+{
+ struct btd_adapter *adapter; char peer_addr[18];
+ struct btd_device *device;
+
+ debug("hcid_dbus_simple_pairing_complete: status=%02x", status);
+
+ adapter = manager_find_adapter(local);
+ if (!adapter) {
+ error("Unable to find matching adapter");
+ return;
+ }
+
+ ba2str(peer, peer_addr);
+
+ device = adapter_find_device(adapter, peer_addr);
+ if (!device) {
+ error("Unable to get device object!");
+ return;
+ }
+
+ device_simple_pairing_complete(device, status);
+}
+
void hcid_dbus_inquiry_start(bdaddr_t *local)
{
struct btd_adapter *adapter;
diff --git a/src/dbus-hci.h b/src/dbus-hci.h
index 7481522e..b930e893 100644
--- a/src/dbus-hci.h
+++ b/src/dbus-hci.h
@@ -34,6 +34,7 @@ void hcid_dbus_remote_name(bdaddr_t *local, bdaddr_t *peer, uint8_t status, char
void hcid_dbus_conn_complete(bdaddr_t *local, uint8_t status, uint16_t handle, bdaddr_t *peer);
void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status, uint16_t handle, uint8_t reason);
void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t status);
+void hcid_dbus_simple_pairing_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t status);
void hcid_dbus_setname_complete(bdaddr_t *local);
void hcid_dbus_setscan_enable_complete(bdaddr_t *local);
void hcid_dbus_write_class_complete(bdaddr_t *local);
diff --git a/src/device.c b/src/device.c
index 926d9591..df68639d 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1816,9 +1816,24 @@ DBusMessage *device_create_bonding(struct btd_device *device,
return NULL;
}
+void device_simple_pairing_complete(struct btd_device *device, uint8_t status)
+{
+ struct authentication_req *auth = device->authr;
+
+ if (auth && auth->type == AUTH_TYPE_NOTIFY && auth->agent)
+ agent_cancel(auth->agent);
+
+ g_free(auth);
+ device->authr = NULL;
+}
+
void device_bonding_complete(struct btd_device *device, uint8_t status)
{
struct bonding_req *bonding = device->bonding;
+ struct authentication_req *auth = device->authr;
+
+ if (auth && auth->type == AUTH_TYPE_NOTIFY && auth->agent)
+ agent_cancel(auth->agent);
if (status)
goto failed;
diff --git a/src/device.h b/src/device.h
index 6b750a82..19112d20 100644
--- a/src/device.h
+++ b/src/device.h
@@ -64,6 +64,7 @@ DBusMessage *device_create_bonding(struct btd_device *device,
const char *agent_path, uint8_t capability);
void device_remove_bondind(struct btd_device *device, DBusConnection *connection);
void device_bonding_complete(struct btd_device *device, uint8_t status);
+void device_simple_pairing_complete(struct btd_device *device, uint8_t status);
gboolean device_is_bonding(struct btd_device *device, const char *sender);
void device_cancel_bonding(struct btd_device *device, uint8_t status);
int device_request_authentication(struct btd_device *device, auth_type_t type,
diff --git a/src/security.c b/src/security.c
index 1ab952ae..1a33a9d2 100644
--- a/src/security.c
+++ b/src/security.c
@@ -784,6 +784,13 @@ static inline void auth_complete(int dev, bdaddr_t *sba, void *ptr)
hcid_dbus_bonding_process_complete(sba, &dba, evt->status);
}
+static inline void simple_pairing_complete(int dev, bdaddr_t *sba, void *ptr)
+{
+ evt_simple_pairing_complete *evt = ptr;
+
+ hcid_dbus_simple_pairing_complete(sba, &evt->bdaddr, evt->status);
+}
+
static inline void conn_request(int dev, bdaddr_t *sba, void *ptr)
{
evt_conn_request *evt = ptr;
@@ -894,6 +901,10 @@ static gboolean io_security_event(GIOChannel *chan, GIOCondition cond, gpointer
auth_complete(dev, &di->bdaddr, ptr);
break;
+ case EVT_SIMPLE_PAIRING_COMPLETE:
+ simple_pairing_complete(dev, &di->bdaddr, ptr);
+ break;
+
case EVT_CONN_REQUEST:
conn_request(dev, &di->bdaddr, ptr);
break;