summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2011-02-17 11:31:35 -0300
committerJohan Hedberg <johan.hedberg@nokia.com>2011-02-17 11:31:35 -0300
commit4d21e85715580f468c7f190a3cd25d7fadaba9aa (patch)
tree70670cb17532b0a2f6bfbc04f6389ce74d927c71 /plugins
parentdba40c880f0eac0ab670e2fd6ad9259dcbc93260 (diff)
downloadbluez-4d21e85715580f468c7f190a3cd25d7fadaba9aa.tar.gz
Move SSP auto-accept handling completely inside hciops
There's no need to expose the auto-accept case to the core daemon so move it to hciops. For the management interface this will all be handled on the kernel side.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/hciops.c72
-rw-r--r--plugins/mgmtops.c2
2 files changed, 40 insertions, 34 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);