mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-24 06:02:43 +00:00
hci: introduce SEND_IO_CAPABILITIES_NEGATIVE_REPLY
This commit is contained in:
parent
aaa6d7d5fc
commit
11b03efaa1
52
src/hci.c
52
src/hci.c
@ -2575,7 +2575,12 @@ static void event_handler(uint8_t *packet, uint16_t size){
|
|||||||
|
|
||||||
case HCI_EVENT_IO_CAPABILITY_REQUEST:
|
case HCI_EVENT_IO_CAPABILITY_REQUEST:
|
||||||
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], RECV_IO_CAPABILITIES_REQUEST);
|
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], RECV_IO_CAPABILITIES_REQUEST);
|
||||||
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], SEND_IO_CAPABILITIES_REPLY);
|
log_info("IO Capability Request received, stack bondable %u, io cap %u", hci_stack->bondable, hci_stack->ssp_io_capability);
|
||||||
|
if (hci_stack->bondable && (hci_stack->ssp_io_capability != SSP_IO_CAPABILITY_UNKNOWN)){
|
||||||
|
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], SEND_IO_CAPABILITIES_REPLY);
|
||||||
|
} else {
|
||||||
|
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], SEND_IO_CAPABILITIES_NEGATIVE_REPLY);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef ENABLE_CLASSIC_PAIRING_OOB
|
#ifdef ENABLE_CLASSIC_PAIRING_OOB
|
||||||
@ -4214,29 +4219,30 @@ static bool hci_run_general_pending_commands(void){
|
|||||||
|
|
||||||
if (connection->authentication_flags & SEND_IO_CAPABILITIES_REPLY){
|
if (connection->authentication_flags & SEND_IO_CAPABILITIES_REPLY){
|
||||||
connectionClearAuthenticationFlags(connection, SEND_IO_CAPABILITIES_REPLY);
|
connectionClearAuthenticationFlags(connection, SEND_IO_CAPABILITIES_REPLY);
|
||||||
log_info("IO Capability Request received, stack bondable %u, io cap %u", hci_stack->bondable, hci_stack->ssp_io_capability);
|
// tweak authentication requirements
|
||||||
if (hci_stack->bondable && (hci_stack->ssp_io_capability != SSP_IO_CAPABILITY_UNKNOWN)){
|
uint8_t authreq = hci_stack->ssp_authentication_requirement;
|
||||||
// tweak authentication requirements
|
if (connection->bonding_flags & BONDING_DEDICATED){
|
||||||
uint8_t authreq = hci_stack->ssp_authentication_requirement;
|
authreq = SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_DEDICATED_BONDING;
|
||||||
if (connection->bonding_flags & BONDING_DEDICATED){
|
|
||||||
authreq = SSP_IO_AUTHREQ_MITM_PROTECTION_NOT_REQUIRED_DEDICATED_BONDING;
|
|
||||||
}
|
|
||||||
if (gap_mitm_protection_required_for_security_level(connection->requested_security_level)){
|
|
||||||
authreq |= 1;
|
|
||||||
}
|
|
||||||
uint8_t have_oob_data = 0;
|
|
||||||
#ifdef ENABLE_CLASSIC_PAIRING_OOB
|
|
||||||
if (connection->classic_oob_c_192 != NULL){
|
|
||||||
have_oob_data |= 1;
|
|
||||||
}
|
|
||||||
if (connection->classic_oob_c_256 != NULL){
|
|
||||||
have_oob_data |= 2;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
hci_send_cmd(&hci_io_capability_request_reply, &connection->address, hci_stack->ssp_io_capability, have_oob_data, authreq);
|
|
||||||
} else {
|
|
||||||
hci_send_cmd(&hci_io_capability_request_negative_reply, &connection->address, ERROR_CODE_PAIRING_NOT_ALLOWED);
|
|
||||||
}
|
}
|
||||||
|
if (gap_mitm_protection_required_for_security_level(connection->requested_security_level)){
|
||||||
|
authreq |= 1;
|
||||||
|
}
|
||||||
|
uint8_t have_oob_data = 0;
|
||||||
|
#ifdef ENABLE_CLASSIC_PAIRING_OOB
|
||||||
|
if (connection->classic_oob_c_192 != NULL){
|
||||||
|
have_oob_data |= 1;
|
||||||
|
}
|
||||||
|
if (connection->classic_oob_c_256 != NULL){
|
||||||
|
have_oob_data |= 2;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
hci_send_cmd(&hci_io_capability_request_reply, &connection->address, hci_stack->ssp_io_capability, have_oob_data, authreq);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (connection->authentication_flags & SEND_IO_CAPABILITIES_NEGATIVE_REPLY) {
|
||||||
|
connectionClearAuthenticationFlags(connection, SEND_IO_CAPABILITIES_NEGATIVE_REPLY);
|
||||||
|
hci_send_cmd(&hci_io_capability_request_negative_reply, &connection->address, ERROR_CODE_PAIRING_NOT_ALLOWED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
src/hci.h
19
src/hci.h
@ -196,23 +196,24 @@ typedef enum {
|
|||||||
DENY_PIN_CODE_REQUEST = 0x0040,
|
DENY_PIN_CODE_REQUEST = 0x0040,
|
||||||
RECV_IO_CAPABILITIES_REQUEST = 0x0080,
|
RECV_IO_CAPABILITIES_REQUEST = 0x0080,
|
||||||
SEND_IO_CAPABILITIES_REPLY = 0x0100,
|
SEND_IO_CAPABILITIES_REPLY = 0x0100,
|
||||||
SEND_USER_CONFIRM_REPLY = 0x0200,
|
SEND_IO_CAPABILITIES_NEGATIVE_REPLY = 0x0200,
|
||||||
SEND_USER_PASSKEY_REPLY = 0x0400,
|
SEND_USER_CONFIRM_REPLY = 0x0400,
|
||||||
|
SEND_USER_PASSKEY_REPLY = 0x0800,
|
||||||
|
|
||||||
// Classic OOB
|
// Classic OOB
|
||||||
SEND_REMOTE_OOB_DATA_REPLY = 0x0800,
|
SEND_REMOTE_OOB_DATA_REPLY = 0x1800,
|
||||||
|
|
||||||
// pairing status
|
// pairing status
|
||||||
LEGACY_PAIRING_ACTIVE = 0x1000,
|
LEGACY_PAIRING_ACTIVE = 0x2000,
|
||||||
SSP_PAIRING_ACTIVE = 0x2000,
|
SSP_PAIRING_ACTIVE = 0x4000,
|
||||||
|
|
||||||
// connection status
|
// connection status
|
||||||
CONNECTION_AUTHENTICATED = 0x4000,
|
CONNECTION_AUTHENTICATED = 0x8000,
|
||||||
CONNECTION_ENCRYPTED = 0x8000,
|
CONNECTION_ENCRYPTED = 0x10000,
|
||||||
|
|
||||||
// errands
|
// errands
|
||||||
READ_RSSI = 0x10000,
|
READ_RSSI = 0x20000,
|
||||||
WRITE_SUPERVISION_TIMEOUT = 0x20000,
|
WRITE_SUPERVISION_TIMEOUT = 0x40000,
|
||||||
|
|
||||||
} hci_authentication_flags_t;
|
} hci_authentication_flags_t;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user