From 2ad1015a1660a0e87e04adb7b7f5ef0d62e8fc23 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 26 Apr 2011 21:10:40 +0300 Subject: [PATCH] mgmtops: Add support for confirm_hint in mgmt_ev_user_confirm_request Since we don't yet have a proper Agent.ConfirmPairing D-Bus callback, and can't add one before 5.x just do an automatic reply for now. --- lib/mgmt.h | 1 + plugins/mgmtops.c | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/mgmt.h b/lib/mgmt.h index f45321ce8..3578ecd50 100644 --- a/lib/mgmt.h +++ b/lib/mgmt.h @@ -264,6 +264,7 @@ struct mgmt_ev_pin_code_request { #define MGMT_EV_USER_CONFIRM_REQUEST 0x000F struct mgmt_ev_user_confirm_request { bdaddr_t bdaddr; + uint8_t confirm_hint; uint32_t value; } __packed; diff --git a/plugins/mgmtops.c b/plugins/mgmtops.c index bb53e8236..be94267ff 100644 --- a/plugins/mgmtops.c +++ b/plugins/mgmtops.c @@ -601,6 +601,26 @@ static int mgmt_confirm_reply(int index, bdaddr_t *bdaddr, gboolean success) return 0; } +struct confirm_data { + int index; + bdaddr_t bdaddr; +}; + +static gboolean confirm_accept(gpointer user_data) +{ + struct confirm_data *data = user_data; + struct controller_info *info = &controllers[data->index]; + + DBG("auto-accepting incoming pairing request"); + + if (data->index > max_index || !info->valid) + return FALSE; + + mgmt_confirm_reply(data->index, &data->bdaddr, TRUE); + + return FALSE; +} + static void mgmt_user_confirm_request(int sk, uint16_t index, void *buf, size_t len) { @@ -616,7 +636,7 @@ static void mgmt_user_confirm_request(int sk, uint16_t index, void *buf, ba2str(&ev->bdaddr, addr); - DBG("hci%u %s", index, addr); + DBG("hci%u %s confirm_hint %u", index, addr, ev->confirm_hint); if (index > max_index) { error("Unexpected index %u in user_confirm_request event", @@ -624,6 +644,18 @@ static void mgmt_user_confirm_request(int sk, uint16_t index, void *buf, return; } + if (ev->confirm_hint) { + struct confirm_data *data; + + data = g_new0(struct confirm_data, 1); + data->index = index; + bacpy(&data->bdaddr, &ev->bdaddr); + + g_timeout_add_seconds_full(G_PRIORITY_DEFAULT, 1, + confirm_accept, data, g_free); + return; + } + info = &controllers[index]; err = btd_event_user_confirm(&info->bdaddr, &ev->bdaddr, -- 2.47.3