Diff between 36bf8e76a652d98774719fcc9945e7814d8a752b and e29c9c5663e0adef4984c127ae508c7da851d456

Changed Files

File Additions Deletions Status
src/adapter.c +20 -0 modified
src/mgmt.c +1 -15 modified

Full Patch

diff --git a/src/adapter.c b/src/adapter.c
index 2f5419f..ad9c6b6 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -4358,6 +4358,21 @@ void adapter_bonding_complete(struct btd_adapter *adapter,
 	check_oob_bonding_complete(adapter, bdaddr, status);
 }
 
+static void auth_failed_callback(uint16_t index, uint16_t length,
+					const void *param, void *user_data)
+{
+	const struct mgmt_ev_auth_failed *ev = param;
+	struct btd_adapter *adapter = user_data;
+
+	if (length < sizeof(*ev)) {
+		error("Too small auth failed mgmt event");
+		return;
+	}
+
+	adapter_bonding_complete(adapter, &ev->addr.bdaddr, ev->addr.type,
+								ev->status);
+}
+
 int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap)
 {
 	struct mgmt_cp_set_io_capability cp;
@@ -4857,6 +4872,11 @@ static void read_info_complete(uint8_t status, uint16_t length,
 						unpaired_callback,
 						adapter, NULL);
 
+	mgmt_register(adapter->mgmt, MGMT_EV_AUTH_FAILED,
+						adapter->dev_id,
+						auth_failed_callback,
+						adapter, NULL);
+
 	set_dev_class(adapter, adapter->major_class, adapter->minor_class);
 
 	set_name(adapter, btd_adapter_get_name(adapter));
diff --git a/src/mgmt.c b/src/mgmt.c
index be29568..64a8093 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -589,20 +589,6 @@ static void mgmt_cmd_status(uint16_t index, void *buf, size_t len)
 			ev->status);
 }
 
-static void mgmt_auth_failed(uint16_t index, void *buf, size_t len)
-{
-	struct mgmt_ev_auth_failed *ev = buf;
-
-	if (len < sizeof(*ev)) {
-		error("Too small mgmt_auth_failed event packet");
-		return;
-	}
-
-	DBG("hci%u auth failed status %u", index, ev->status);
-
-	bonding_complete(index, &ev->addr, ev->status);
-}
-
 static void mgmt_device_blocked(uint16_t index, void *buf, size_t len)
 {
 	struct btd_adapter *adapter;
@@ -821,7 +807,7 @@ static gboolean mgmt_event(GIOChannel *channel, GIOCondition cond,
 		mgmt_user_confirm_request(index, buf + MGMT_HDR_SIZE, len);
 		break;
 	case MGMT_EV_AUTH_FAILED:
-		mgmt_auth_failed(index, buf + MGMT_HDR_SIZE, len);
+		DBG("auth_failed event");
 		break;
 	case MGMT_EV_DEVICE_FOUND:
 		DBG("device_found event");