l2cap-ertm: handle fallback for optional ERTM

This commit is contained in:
Matthias Ringwald 2017-07-12 12:56:01 +02:00
parent 45caebe58e
commit f2fa388d63

View File

@ -1510,6 +1510,7 @@ static void l2cap_signaling_handle_configure_request(l2cap_channel_t *channel, u
if (option_type == 2 && length == 2){ if (option_type == 2 && length == 2){
channel->flush_timeout = little_endian_read_16(command, pos); channel->flush_timeout = little_endian_read_16(command, pos);
} }
#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE #ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE
// Retransmission and Flow Control Option // Retransmission and Flow Control Option
if (option_type == 4 && length == 9){ if (option_type == 4 && length == 9){
@ -1534,10 +1535,11 @@ static void l2cap_signaling_handle_configure_request(l2cap_channel_t *channel, u
} }
} }
static void l2cap_signaling_handle_configure_response(l2cap_channel_t *channel, uint8_t *command){ static void l2cap_signaling_handle_configure_response(l2cap_channel_t *channel, uint8_t result, uint8_t *command){
log_info("l2cap_signaling_handle_configure_response");
#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE #ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE
uint16_t end_pos = 4 + little_endian_read_16(command, L2CAP_SIGNALING_COMMAND_LENGTH_OFFSET); uint16_t end_pos = 4 + little_endian_read_16(command, L2CAP_SIGNALING_COMMAND_LENGTH_OFFSET);
uint16_t pos = 8; uint16_t pos = 10;
while (pos < end_pos){ while (pos < end_pos){
uint8_t option_hint = command[pos] >> 7; uint8_t option_hint = command[pos] >> 7;
uint8_t option_type = command[pos] & 0x7f; uint8_t option_type = command[pos] & 0x7f;
@ -1545,18 +1547,19 @@ static void l2cap_signaling_handle_configure_response(l2cap_channel_t *channel,
pos++; pos++;
uint8_t length = command[pos++]; uint8_t length = command[pos++];
#if 0
// Retransmission and Flow Control Option // Retransmission and Flow Control Option
if (option_type == 4 && length == 9){ if (option_type == 4 && length == 9){
if (channel->mode == L2CAP_CHANNEL_MODE_ENHANCED_RETRANSMISSION && channel->ertm_mandatory){ if (channel->mode == L2CAP_CHANNEL_MODE_ENHANCED_RETRANSMISSION){
// ertm mandatory, but remote doens't offer ERTM -> disconnect if (channel->ertm_mandatory){
l2cap_channel_mode_t mode = (l2cap_channel_mode_t) command[pos]; //
if (mode != L2CAP_CHANNEL_MODE_ENHANCED_RETRANSMISSION){ } else {
channel->state = L2CAP_STATE_WILL_SEND_DISCONNECT_REQUEST; // On 'Reject - Unacceptable Parameters', fall back to BASIC mode
if (result == 1){
channel->mode = L2CAP_CHANNEL_MODE_BASIC;
}
} }
} }
} }
#endif
// check for unknown options // check for unknown options
if (option_hint == 0 && (option_type == 0 || option_type >= 0x07)){ if (option_hint == 0 && (option_type == 0 || option_type >= 0x07)){
@ -1660,9 +1663,9 @@ static void l2cap_signaling_handler_channel(l2cap_channel_t *channel, uint8_t *c
break; break;
case CONFIGURE_RESPONSE: case CONFIGURE_RESPONSE:
l2cap_stop_rtx(channel); l2cap_stop_rtx(channel);
l2cap_signaling_handle_configure_response(channel, result, command);
switch (result){ switch (result){
case 0: // success case 0: // success
l2cap_signaling_handle_configure_response(channel, command);
channelStateVarSetFlag(channel, L2CAP_CHANNEL_STATE_VAR_RCVD_CONF_RSP); channelStateVarSetFlag(channel, L2CAP_CHANNEL_STATE_VAR_RCVD_CONF_RSP);
break; break;
case 4: // pending case 4: // pending