Bluetooth: BR/EDR: Add user I/O context during pairing
When during legacy incoming pairing (as acceptor) the runtime is passed to user to enter a PIN, mark such interaction and keep it valid until proper authentication reply API handlers are called. Change-Id: If63015f5beb256873925602adc6a8e5ff9d3b00f Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
parent
998d72a986
commit
f670d06643
2 changed files with 12 additions and 1 deletions
|
@ -1126,6 +1126,11 @@ int bt_conn_auth_pincode_entry(struct bt_conn *conn, const char *pin)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Allow user send entered PIN to remote, then reset user state. */
|
||||||
|
if (!atomic_test_and_clear_bit(conn->flags, BT_CONN_USER)) {
|
||||||
|
return -EPERM;
|
||||||
|
}
|
||||||
|
|
||||||
if (len == 16) {
|
if (len == 16) {
|
||||||
atomic_set_bit(conn->flags, BT_CONN_BR_LEGACY_SECURE);
|
atomic_set_bit(conn->flags, BT_CONN_BR_LEGACY_SECURE);
|
||||||
}
|
}
|
||||||
|
@ -1142,11 +1147,11 @@ void bt_conn_pin_code_req(struct bt_conn *conn)
|
||||||
secure = true;
|
secure = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
atomic_set_bit(conn->flags, BT_CONN_USER);
|
||||||
bt_auth->pincode_entry(conn, secure);
|
bt_auth->pincode_entry(conn, secure);
|
||||||
} else {
|
} else {
|
||||||
pin_code_neg_reply(&conn->br.dst);
|
pin_code_neg_reply(&conn->br.dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_BLUETOOTH_BREDR */
|
#endif /* CONFIG_BLUETOOTH_BREDR */
|
||||||
|
|
||||||
|
@ -1191,6 +1196,11 @@ int bt_conn_auth_cancel(struct bt_conn *conn)
|
||||||
#endif /* CONFIG_BLUETOOTH_SMP */
|
#endif /* CONFIG_BLUETOOTH_SMP */
|
||||||
#if defined(CONFIG_BLUETOOTH_BREDR)
|
#if defined(CONFIG_BLUETOOTH_BREDR)
|
||||||
if (conn->type == BT_CONN_TYPE_BR) {
|
if (conn->type == BT_CONN_TYPE_BR) {
|
||||||
|
/* Allow user cancel authentication, then reset user state. */
|
||||||
|
if (!atomic_test_and_clear_bit(conn->flags, BT_CONN_USER)) {
|
||||||
|
return -EPERM;
|
||||||
|
}
|
||||||
|
|
||||||
return pin_code_neg_reply(&conn->br.dst);
|
return pin_code_neg_reply(&conn->br.dst);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_BLUETOOTH_BREDR */
|
#endif /* CONFIG_BLUETOOTH_BREDR */
|
||||||
|
|
|
@ -30,6 +30,7 @@ typedef enum __packed {
|
||||||
enum {
|
enum {
|
||||||
BT_CONN_AUTO_CONNECT,
|
BT_CONN_AUTO_CONNECT,
|
||||||
BT_CONN_BR_LEGACY_SECURE, /* 16 digits legacy PIN tracker */
|
BT_CONN_BR_LEGACY_SECURE, /* 16 digits legacy PIN tracker */
|
||||||
|
BT_CONN_USER, /* user I/O when pairing */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bt_conn_le {
|
struct bt_conn_le {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue