connection: only accept management packets in CONNECTING state
This commit is contained in:
parent
22b262f6eb
commit
4c34bcc420
1 changed files with 8 additions and 3 deletions
|
|
@ -238,6 +238,13 @@ result_t connection_handle_packet_prechecked(
|
|||
return ERR_INVALID_ADDRESS;
|
||||
}
|
||||
|
||||
if(header->msg_type == L2_MSG_TYPE_CONN_MGMT) {
|
||||
return handle_conn_mgmt(ctx, header, payload, payload_len);
|
||||
} else if(ctx->conn_state != CONN_STATE_ESTABLISHED) {
|
||||
LOG(LVL_ERR, "Received non-management packet (type %s) in unconnected state %u.", layer2_msg_type_to_string(header->msg_type), ctx->conn_state);
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
LOG(LVL_DEBUG, "Handling %s packet with rx_seq_nr %u, tx_seq_nr %u, tx_request %u.",
|
||||
layer2_msg_type_to_string(header->msg_type), header->rx_seq_nr, header->tx_seq_nr, header->tx_request);
|
||||
|
||||
|
|
@ -247,6 +254,7 @@ result_t connection_handle_packet_prechecked(
|
|||
|
||||
switch(header->msg_type) {
|
||||
case L2_MSG_TYPE_EMPTY:
|
||||
|
||||
LOG(LVL_DEBUG, "Empty packet: accepted ACK for %u.", ctx->last_acked_seq);
|
||||
|
||||
*tx_req_rcvd = header->tx_request;
|
||||
|
|
@ -258,9 +266,6 @@ result_t connection_handle_packet_prechecked(
|
|||
connection_handle_ack(ctx, header->rx_seq_nr);
|
||||
return OK; // do not ACK
|
||||
|
||||
case L2_MSG_TYPE_CONN_MGMT:
|
||||
return handle_conn_mgmt(ctx, header, payload, payload_len);
|
||||
|
||||
case L2_MSG_TYPE_CONNECTIONLESS:
|
||||
LOG(LVL_WARN, "Message type %s is not implemented yet.", layer2_msg_type_to_string(header->msg_type));
|
||||
return OK;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue