mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-28 08:37:22 +00:00
l2cap: streamline secure connections only mode
If SC Only Mode is enabled, map all security levels to level 4 unless it is level 0
This commit is contained in:
parent
bc00e12c3f
commit
d7387af38d
@ -3503,6 +3503,9 @@ void gap_set_security_level(gap_security_level_t security_level){
|
|||||||
}
|
}
|
||||||
|
|
||||||
gap_security_level_t gap_get_security_level(void){
|
gap_security_level_t gap_get_security_level(void){
|
||||||
|
if (hci_stack->gap_secure_connections_only_mode){
|
||||||
|
return LEVEL_4;
|
||||||
|
}
|
||||||
return hci_stack->gap_security_level;
|
return hci_stack->gap_security_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/l2cap.c
10
src/l2cap.c
@ -2360,8 +2360,7 @@ static void l2cap_handle_security_level(hci_con_handle_t handle, gap_security_le
|
|||||||
|
|
||||||
switch (channel->state){
|
switch (channel->state){
|
||||||
case L2CAP_STATE_WAIT_INCOMING_SECURITY_LEVEL_UPDATE:
|
case L2CAP_STATE_WAIT_INCOMING_SECURITY_LEVEL_UPDATE:
|
||||||
if ((actual_level >= required_level) &&
|
if (actual_level >= required_level){
|
||||||
((gap_get_secure_connections_only_mode() == false) || gap_secure_connection(channel->con_handle))){
|
|
||||||
#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE
|
#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE
|
||||||
// we need to know if ERTM is supported before sending a config response
|
// we need to know if ERTM is supported before sending a config response
|
||||||
hci_connection_t * connection = hci_connection_for_handle(channel->con_handle);
|
hci_connection_t * connection = hci_connection_for_handle(channel->con_handle);
|
||||||
@ -2601,9 +2600,12 @@ static void l2cap_handle_connection_request(hci_con_handle_t handle, uint8_t sig
|
|||||||
}
|
}
|
||||||
|
|
||||||
// alloc structure
|
// alloc structure
|
||||||
// log_info("l2cap_handle_connection_request register channel");
|
gap_security_level_t required_level = service->required_security_level;
|
||||||
|
if (gap_get_secure_connections_only_mode() && (required_level != LEVEL_0)){
|
||||||
|
required_level = LEVEL_4;
|
||||||
|
}
|
||||||
l2cap_channel_t * channel = l2cap_create_channel_entry(service->packet_handler, L2CAP_CHANNEL_TYPE_CLASSIC, hci_connection->address, BD_ADDR_TYPE_ACL,
|
l2cap_channel_t * channel = l2cap_create_channel_entry(service->packet_handler, L2CAP_CHANNEL_TYPE_CLASSIC, hci_connection->address, BD_ADDR_TYPE_ACL,
|
||||||
psm, service->mtu, service->required_security_level);
|
psm, service->mtu, required_level);
|
||||||
if (!channel){
|
if (!channel){
|
||||||
// 0x0004 No resources available
|
// 0x0004 No resources available
|
||||||
l2cap_register_signaling_response(handle, CONNECTION_REQUEST, sig_id, source_cid, 0x0004);
|
l2cap_register_signaling_response(handle, CONNECTION_REQUEST, sig_id, source_cid, 0x0004);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user