summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/hciops.c72
-rw-r--r--plugins/mgmtops.c2
-rw-r--r--src/device.c6
-rw-r--r--src/device.h1
-rw-r--r--src/event.c16
-rw-r--r--src/event.h3
6 files changed, 43 insertions, 57 deletions
diff --git a/plugins/hciops.c b/plugins/hciops.c
index ae2e4cc3d..c3d6290fd 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -954,11 +954,39 @@ static void return_link_keys(int index, void *ptr)
/* Simple Pairing handling */
+static int hciops_confirm_reply(int index, bdaddr_t *bdaddr, gboolean success)
+{
+ struct dev_info *dev = &devs[index];
+ user_confirm_reply_cp cp;
+ char addr[18];
+ int err;
+
+ ba2str(bdaddr, addr);
+ DBG("hci%d dba %s success %d", index, addr, success);
+
+ memset(&cp, 0, sizeof(cp));
+ bacpy(&cp.bdaddr, bdaddr);
+
+ if (success)
+ err = hci_send_cmd(dev->sk, OGF_LINK_CTL,
+ OCF_USER_CONFIRM_REPLY,
+ USER_CONFIRM_REPLY_CP_SIZE, &cp);
+ else
+ err = hci_send_cmd(dev->sk, OGF_LINK_CTL,
+ OCF_USER_CONFIRM_NEG_REPLY,
+ USER_CONFIRM_REPLY_CP_SIZE, &cp);
+
+ if (err < 0)
+ err = -errno;
+
+ return err;
+}
+
static void user_confirm_request(int index, void *ptr)
{
struct dev_info *dev = &devs[index];
evt_user_confirm_request *req = ptr;
- gboolean loc_mitm, rem_mitm, auto_accept;
+ gboolean loc_mitm, rem_mitm;
struct bt_conn *conn;
DBG("hci%d", index);
@@ -983,12 +1011,18 @@ static void user_confirm_request(int index, void *ptr)
if ((conn->loc_auth == 0xff || !loc_mitm || conn->rem_cap == 0x03) &&
(!rem_mitm || conn->loc_cap == 0x03)) {
DBG("auto accept of confirmation");
- auto_accept = TRUE;
- } else
- auto_accept = FALSE;
+
+ /* Wait 5 milliseconds before doing auto-accept */
+ usleep(5000);
+
+ if (hciops_confirm_reply(index, &req->bdaddr, TRUE) < 0)
+ goto fail;
+
+ return;
+ }
if (btd_event_user_confirm(&dev->bdaddr, &req->bdaddr,
- btohl(req->passkey), auto_accept) == 0)
+ btohl(req->passkey)) == 0)
return;
fail:
@@ -3223,34 +3257,6 @@ static int hciops_pincode_reply(int index, bdaddr_t *bdaddr, const char *pin)
return err;
}
-static int hciops_confirm_reply(int index, bdaddr_t *bdaddr, gboolean success)
-{
- struct dev_info *dev = &devs[index];
- user_confirm_reply_cp cp;
- char addr[18];
- int err;
-
- ba2str(bdaddr, addr);
- DBG("hci%d dba %s success %d", index, addr, success);
-
- memset(&cp, 0, sizeof(cp));
- bacpy(&cp.bdaddr, bdaddr);
-
- if (success)
- err = hci_send_cmd(dev->sk, OGF_LINK_CTL,
- OCF_USER_CONFIRM_REPLY,
- USER_CONFIRM_REPLY_CP_SIZE, &cp);
- else
- err = hci_send_cmd(dev->sk, OGF_LINK_CTL,
- OCF_USER_CONFIRM_NEG_REPLY,
- USER_CONFIRM_REPLY_CP_SIZE, &cp);
-
- if (err < 0)
- err = -errno;
-
- return err;
-}
-
static int hciops_passkey_reply(int index, bdaddr_t *bdaddr, uint32_t passkey)
{
struct dev_info *dev = &devs[index];
diff --git a/plugins/mgmtops.c b/plugins/mgmtops.c
index 9f184a8f3..63b6cf22b 100644
--- a/plugins/mgmtops.c
+++ b/plugins/mgmtops.c
@@ -671,7 +671,7 @@ static void mgmt_user_confirm_request(int sk, void *buf, size_t len)
info = &controllers[index];
err = btd_event_user_confirm(&info->bdaddr, &ev->bdaddr,
- btohl(ev->value), FALSE);
+ btohl(ev->value));
if (err < 0) {
error("btd_event_user_confirm: %s", strerror(-err));
mgmt_confirm_reply(index, &ev->bdaddr, FALSE);
diff --git a/src/device.c b/src/device.c
index 0fef71a32..530296a02 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2222,9 +2222,6 @@ int device_request_authentication(struct btd_device *device, auth_type_t type,
case AUTH_TYPE_NOTIFY:
err = agent_display_passkey(agent, device, passkey);
break;
- case AUTH_TYPE_AUTO:
- err = 0;
- break;
default:
err = -EINVAL;
}
@@ -2263,8 +2260,7 @@ static void cancel_authentication(struct authentication_req *auth)
((agent_passkey_cb) auth->cb)(agent, &err, 0, device);
break;
case AUTH_TYPE_NOTIFY:
- case AUTH_TYPE_AUTO:
- /* User Notify/Auto doesn't require any reply */
+ /* User Notify doesn't require any reply */
break;
}
diff --git a/src/device.h b/src/device.h
index c77fc8d04..3ce212b29 100644
--- a/src/device.h
+++ b/src/device.h
@@ -32,7 +32,6 @@ typedef enum {
AUTH_TYPE_PASSKEY,
AUTH_TYPE_CONFIRM,
AUTH_TYPE_NOTIFY,
- AUTH_TYPE_AUTO,
} auth_type_t;
typedef enum {
diff --git a/src/event.c b/src/event.c
index ba8f84a02..12dbca275 100644
--- a/src/event.c
+++ b/src/event.c
@@ -184,8 +184,7 @@ static void passkey_cb(struct agent *agent, DBusError *err, uint32_t passkey,
btd_adapter_passkey_reply(adapter, &bdaddr, passkey);
}
-int btd_event_user_confirm(bdaddr_t *sba, bdaddr_t *dba, uint32_t passkey,
- gboolean auto_accept)
+int btd_event_user_confirm(bdaddr_t *sba, bdaddr_t *dba, uint32_t passkey)
{
struct btd_adapter *adapter;
struct btd_device *device;
@@ -193,19 +192,6 @@ int btd_event_user_confirm(bdaddr_t *sba, bdaddr_t *dba, uint32_t passkey,
if (!get_adapter_and_device(sba, dba, &adapter, &device, TRUE))
return -ENODEV;
- if (auto_accept) {
- DBG("auto accept of confirmation");
-
- /* Wait 5 milliseconds before doing auto-accept */
- usleep(5000);
-
- if (confirm_reply(adapter, device, TRUE) < 0)
- return -EIO;
-
- return device_request_authentication(device, AUTH_TYPE_AUTO,
- 0, NULL);
- }
-
return device_request_authentication(device, AUTH_TYPE_CONFIRM,
passkey, confirm_cb);
}
diff --git a/src/event.h b/src/event.h
index 80048e220..765390a84 100644
--- a/src/event.h
+++ b/src/event.h
@@ -37,8 +37,7 @@ void btd_event_bonding_complete(bdaddr_t *local, bdaddr_t *peer,
void btd_event_simple_pairing_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t status);
void btd_event_le_set_scan_enable_complete(bdaddr_t *local, uint8_t status);
void btd_event_returned_link_key(bdaddr_t *local, bdaddr_t *peer);
-int btd_event_user_confirm(bdaddr_t *sba, bdaddr_t *dba, uint32_t passkey,
- gboolean auto_accept);
+int btd_event_user_confirm(bdaddr_t *sba, bdaddr_t *dba, uint32_t passkey);
int btd_event_user_passkey(bdaddr_t *sba, bdaddr_t *dba);
int btd_event_user_notify(bdaddr_t *sba, bdaddr_t *dba, uint32_t passkey);
int btd_event_link_key_notify(bdaddr_t *local, bdaddr_t *peer, uint8_t *key,