added l2cap_require_security_level_2_for_outgoing_sdp

This commit is contained in:
matthias.ringwald@gmail.com 2014-01-28 21:53:35 +00:00
parent e80b2cf9cd
commit ac301f9556
2 changed files with 13 additions and 3 deletions

View File

@ -79,6 +79,7 @@ static int new_credits_blocked = 0;
static btstack_packet_handler_t attribute_protocol_packet_handler;
static btstack_packet_handler_t security_protocol_packet_handler;
static uint8_t require_security_level2_for_outgoing_sdp;
// prototypes
static void l2cap_finialize_channel_close(l2cap_channel_t *channel);
@ -100,6 +101,8 @@ void l2cap_init(){
attribute_protocol_packet_handler = NULL;
security_protocol_packet_handler = NULL;
require_security_level2_for_outgoing_sdp = 0;
//
// register callback with HCI
//
@ -288,8 +291,12 @@ static void l2cap_start_ertx(l2cap_channel_t * channel){
run_loop_add_timer(&channel->rtx);
}
void l2cap_require_security_level_2_for_outgoing_sdp(){
require_security_level2_for_outgoing_sdp = 1;
}
static int l2cap_security_level_0_allowed_for_PSM(uint16_t psm){
return psm != PSM_SDP;
return (psm == PSM_SDP) && (!require_security_level2_for_outgoing_sdp);
}
int l2cap_send_signaling_packet(hci_con_handle_t handle, L2CAP_SIGNALING_COMMANDS cmd, uint8_t identifier, ...){
@ -615,6 +622,7 @@ static void l2cap_handle_remote_supported_features_received(l2cap_channel_t * ch
if (channel->state != L2CAP_STATE_WAIT_REMOTE_SUPPORTED_FEATURES) return;
// we have been waiting for remote supported features, if both support SSP,
log_info("l2cap received remote supported features, sec_level_0_allowed for psm %u = %u", channel->psm, l2cap_security_level_0_allowed_for_PSM(channel->psm));
if (hci_ssp_supported_on_both_sides(channel->handle) && !l2cap_security_level_0_allowed_for_PSM(channel->psm)){
// request security level 2
channel->state = L2CAP_STATE_WAIT_OUTGOING_SECURITY_LEVEL_UPDATE;

View File

@ -216,6 +216,8 @@ void l2cap_close_connection(void *connection);
int l2cap_send_echo_request(uint16_t handle, uint8_t *data, uint16_t len);
void l2cap_require_security_level_2_for_outgoing_sdp(); // testing
/** Embedded API **/
// Set up L2CAP and register L2CAP with HCI layer.