Bluetooth: BR/EDR: Initial IO Capability reply to remote

Enables IO Capability Request event in controller.
Adds handler to react on controller's IO Capability Request event during
incoming pairing.
As a initial case respond to the request with negative reply setting
reason as 'pairing not allowed'.

Change-Id: I161c7ab7f1031a78cfa50444f41624232e5c5146
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
Arkadiusz Lichwa 2016-01-29 13:08:59 +01:00 committed by Gerrit Code Review
commit 2697d4fd5e
2 changed files with 44 additions and 0 deletions

View file

@ -66,6 +66,7 @@ static inline void bt_addr_le_copy(bt_addr_le_t *dst, const bt_addr_le_t *src)
#define BT_HCI_ERR_AUTHENTICATION_FAIL 0x05
#define BT_HCI_ERR_INSUFFICIENT_RESOURCES 0x0d
#define BT_HCI_ERR_REMOTE_USER_TERM_CONN 0x13
#define BT_HCI_ERR_PAIRING_NOT_ALLOWED 0x18
#define BT_HCI_ERR_UNSUPP_REMOTE_FEATURE 0x1a
#define BT_HCI_ERR_INVALID_LL_PARAMS 0x1e
#define BT_HCI_ERR_UNSPECIFIED 0x1f
@ -207,6 +208,20 @@ struct bt_hci_rp_pin_code_neg_reply {
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_OP_IO_CAPABILITY_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002b)
struct bt_hci_cp_io_capability_reply {
bt_addr_t bdaddr;
uint8_t capability;
uint8_t oob_data;
uint8_t authentication;
} __packed;
#define BT_HCI_OP_IO_CAPABILITY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x0034)
struct bt_hci_cp_io_capability_neg_reply {
bt_addr_t bdaddr;
uint8_t reason;
} __packed;
#define BT_HCI_OP_SET_EVENT_MASK BT_OP(BT_OGF_BASEBAND, 0x0001)
struct bt_hci_cp_set_event_mask {
uint8_t events[8];
@ -555,6 +570,11 @@ struct bt_hci_evt_encrypt_key_refresh_complete {
uint16_t handle;
} __packed;
#define BT_HCI_EVT_IO_CAPA_REQ 0x31
struct bt_hci_evt_io_capa_req {
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_EVT_IO_CAPA_RESP 0x32
struct bt_hci_evt_io_capa_resp {
bt_addr_t bdaddr;

View file

@ -1133,6 +1133,26 @@ static void io_capa_resp(struct net_buf *buf)
conn->br.remote_auth = evt->authentication;
bt_conn_unref(conn);
}
static void io_capa_req(struct net_buf *buf)
{
struct bt_hci_evt_io_capa_req *evt = (void *)buf->data;
struct net_buf *resp_buf;
struct bt_hci_cp_io_capability_neg_reply *cp;
BT_DBG("");
resp_buf = bt_hci_cmd_create(BT_HCI_OP_IO_CAPABILITY_NEG_REPLY,
sizeof(*cp));
if (!resp_buf) {
return;
}
cp = net_buf_add(resp_buf, sizeof(*cp));
bt_addr_copy(&cp->bdaddr, &evt->bdaddr);
cp->reason = BT_HCI_ERR_PAIRING_NOT_ALLOWED;
bt_hci_cmd_send_sync(BT_HCI_OP_IO_CAPABILITY_NEG_REPLY, resp_buf, NULL);
}
#endif
#if defined(CONFIG_BLUETOOTH_SMP) || defined(CONFIG_BLUETOOTH_BREDR)
@ -1816,6 +1836,9 @@ static void hci_event(struct net_buf *buf)
case BT_HCI_EVT_IO_CAPA_RESP:
io_capa_resp(buf);
break;
case BT_HCI_EVT_IO_CAPA_REQ:
io_capa_req(buf);
break;
#endif
#if defined(CONFIG_BLUETOOTH_CONN)
case BT_HCI_EVT_DISCONN_COMPLETE:
@ -2275,6 +2298,7 @@ static int set_event_mask(void)
ev->events[2] |= 0x20; /* Pin Code Request */
ev->events[2] |= 0x40; /* Link Key Request */
ev->events[2] |= 0x80; /* Link Key Notif */
ev->events[6] |= 0x01; /* IO Capability Request */
ev->events[6] |= 0x02; /* IO Capability Response */
#endif
ev->events[1] |= 0x20; /* Command Complete */