connection: only accept management packets in CONNECTING state
All checks were successful
/ build-hamnet70 (push) Successful in 37s
/ build-doc (push) Successful in 21s
/ deploy-doc (push) Has been skipped

This commit is contained in:
Thomas Kolb 2025-02-15 01:37:46 +01:00
commit 4c34bcc420

View file

@ -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;