Bugfix/btl mstp local broadcast discard (#248)

* Discard Confirmed PDU DNER on local broadcast. Discard DER on local broacast.

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2022-04-02 08:44:04 -05:00
committed by GitHub
parent 050efc2472
commit 12a5e48b3e
10 changed files with 170 additions and 75 deletions
+2 -2
View File
@@ -141,11 +141,11 @@ router-mstp:
# Add "ports" to the build, if desired # Add "ports" to the build, if desired
.PHONY: ports .PHONY: ports
ports: atmega168 bdk-atxx4-mstp at91sam7s stm32f10x ports: atmega168 bdk-atxx4-mstp at91sam7s stm32f10x stm32f4xx
@echo "Built the ARM7 and AVR ports" @echo "Built the ARM7 and AVR ports"
.PHONY: ports-clean .PHONY: ports-clean
ports-clean: atmega168-clean bdk-atxx4-mstp-clean at91sam7s-clean stm32f10x-clean ports-clean: atmega168-clean bdk-atxx4-mstp-clean at91sam7s-clean stm32f10x-clean stm32f4xx-clean
.PHONY: atmega168 .PHONY: atmega168
atmega168: ports/atmega168/Makefile atmega168: ports/atmega168/Makefile
+16 -6
View File
@@ -704,14 +704,24 @@ static bool MSTP_Master_Node_FSM(void)
} }
break; break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
/* indicate successful reception to the higher layers */ if ((DestinationAddress == MSTP_BROADCAST_ADDRESS) &&
MSTP_Flag.ReceivePacketPending = true; (npdu_confirmed_service(InputBuffer, DataLength))) {
/* BTL test: verifies that the IUT will quietly
discard any Confirmed-Request-PDU, whose
destination address is a multicast or
broadcast address, received from the
network layer. */
} else {
/* indicate successful reception to higher layer */
MSTP_Flag.ReceivePacketPending = true;
}
break; break;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
/* indicate successful reception to higher layers */ if (DestinationAddress == MSTP_BROADCAST_ADDRESS) {
MSTP_Flag.ReceivePacketPending = true; /* broadcast DER just remains IDLE */
/* broadcast DER just remains IDLE */ } else {
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) { /* indicate successful reception to higher layers */
MSTP_Flag.ReceivePacketPending = true;
Master_State = Master_State =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST; MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
} }
+16 -6
View File
@@ -613,14 +613,24 @@ static bool MSTP_Master_Node_FSM(void)
} }
break; break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
/* indicate successful reception to the higher layers */ if ((DestinationAddress == MSTP_BROADCAST_ADDRESS) &&
MSTP_Flag.ReceivePacketPending = true; (npdu_confirmed_service(InputBuffer, DataLength))) {
/* BTL test: verifies that the IUT will quietly
discard any Confirmed-Request-PDU, whose
destination address is a multicast or
broadcast address, received from the
network layer. */
} else {
/* indicate successful reception to higher layer */
MSTP_Flag.ReceivePacketPending = true;
}
break; break;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
/* indicate successful reception to the higher layers */ if (DestinationAddress == MSTP_BROADCAST_ADDRESS) {
MSTP_Flag.ReceivePacketPending = true; /* broadcast DER just remains IDLE */
/* broadcast DER just remains IDLE */ } else {
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) { /* indicate successful reception to higher layers */
MSTP_Flag.ReceivePacketPending = true;
Master_State = Master_State =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST; MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
} }
+16 -6
View File
@@ -726,14 +726,24 @@ static bool MSTP_Master_Node_FSM(void)
} }
break; break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
/* indicate successful reception to the higher layers */ if ((DestinationAddress == MSTP_BROADCAST_ADDRESS) &&
MSTP_Flag.ReceivePacketPending = true; (npdu_confirmed_service(InputBuffer, DataLength))) {
/* BTL test: verifies that the IUT will quietly
discard any Confirmed-Request-PDU, whose
destination address is a multicast or
broadcast address, received from the
network layer. */
} else {
/* indicate successful reception to higher layer */
MSTP_Flag.ReceivePacketPending = true;
}
break; break;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
/* indicate successful reception to higher layers */ if (DestinationAddress == MSTP_BROADCAST_ADDRESS) {
MSTP_Flag.ReceivePacketPending = true; /* broadcast DER just remains IDLE */
/* broadcast DER just remains IDLE */ } else {
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) { /* indicate successful reception to higher layers */
MSTP_Flag.ReceivePacketPending = true;
Master_State = Master_State =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST; MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
} }
+24 -13
View File
@@ -752,22 +752,33 @@ bool MSTP_Master_Node_FSM(volatile struct mstp_port_struct_t *mstp_port)
} }
break; break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
/* indicate successful reception to the higher if ((mstp_port->DestinationAddress ==
* layers */ MSTP_BROADCAST_ADDRESS) &&
dlmstp_put_receive(mstp_port->SourceAddress, (npdu_confirmed_service(mstp_port->InputBuffer,
(uint8_t *)&mstp_port->InputBuffer[0], mstp_port->DataLength))) {
mstp_port->DataLength); /* BTL test: verifies that the IUT will quietly
discard any Confirmed-Request-PDU, whose
destination address is a multicast or
broadcast address, received from the
network layer. */
} else {
/* indicate successful reception to the higher
* layers */
dlmstp_put_receive(mstp_port->SourceAddress,
(uint8_t *)&mstp_port->InputBuffer[0],
mstp_port->DataLength);
}
break; break;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
/*mstp_port->ReplyPostponedTimer = 0; */ if (mstp_port->DestinationAddress ==
/* indicate successful reception to the higher
* layers */
dlmstp_put_receive(mstp_port->SourceAddress,
(uint8_t *)&mstp_port->InputBuffer[0],
mstp_port->DataLength);
/* broadcast DER just remains IDLE */
if (mstp_port->DestinationAddress !=
MSTP_BROADCAST_ADDRESS) { MSTP_BROADCAST_ADDRESS) {
/* broadcast DER just remains IDLE */
} else {
/* indicate successful reception to the higher
* layers */
dlmstp_put_receive(mstp_port->SourceAddress,
(uint8_t *)&mstp_port->InputBuffer[0],
mstp_port->DataLength);
mstp_port->master_state = mstp_port->master_state =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST; MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
} }
+24 -13
View File
@@ -760,22 +760,33 @@ bool MSTP_Master_Node_FSM(volatile struct mstp_port_struct_t *mstp_port)
} }
break; break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
/* indicate successful reception to the higher if ((mstp_port->DestinationAddress ==
* layers */ MSTP_BROADCAST_ADDRESS) &&
dlmstp_put_receive(mstp_port->SourceAddress, (npdu_confirmed_service(mstp_port->InputBuffer,
(uint8_t *)&mstp_port->InputBuffer[0], mstp_port->DataLength))) {
mstp_port->DataLength); /* BTL test: verifies that the IUT will quietly
discard any Confirmed-Request-PDU, whose
destination address is a multicast or
broadcast address, received from the
network layer. */
} else {
/* indicate successful reception to the higher
* layers */
dlmstp_put_receive(mstp_port->SourceAddress,
(uint8_t *)&mstp_port->InputBuffer[0],
mstp_port->DataLength);
}
break; break;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
/*mstp_port->ReplyPostponedTimer = 0; */ if (mstp_port->DestinationAddress ==
/* indicate successful reception to the higher
* layers */
dlmstp_put_receive(mstp_port->SourceAddress,
(uint8_t *)&mstp_port->InputBuffer[0],
mstp_port->DataLength);
/* broadcast DER just remains IDLE */
if (mstp_port->DestinationAddress !=
MSTP_BROADCAST_ADDRESS) { MSTP_BROADCAST_ADDRESS) {
/* broadcast DER just remains IDLE */
} else {
/* indicate successful reception to the higher
* layers */
dlmstp_put_receive(mstp_port->SourceAddress,
(uint8_t *)&mstp_port->InputBuffer[0],
mstp_port->DataLength);
mstp_port->master_state = mstp_port->master_state =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST; MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
} }
+16 -6
View File
@@ -807,14 +807,24 @@ static bool MSTP_Master_Node_FSM(void)
} }
break; break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
/* indicate successful reception to the higher layers */ if ((DestinationAddress == MSTP_BROADCAST_ADDRESS) &&
MSTP_Flag.ReceivePacketPending = true; (npdu_confirmed_service(InputBuffer, DataLength))) {
/* BTL test: verifies that the IUT will quietly
discard any Confirmed-Request-PDU, whose
destination address is a multicast or
broadcast address, received from the
network layer. */
} else {
/* indicate successful reception to higher layer */
MSTP_Flag.ReceivePacketPending = true;
}
break; break;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
/* indicate successful reception to higher layers */ if (DestinationAddress == MSTP_BROADCAST_ADDRESS) {
MSTP_Flag.ReceivePacketPending = true; /* broadcast DER just remains IDLE */
/* broadcast DER just remains IDLE */ } else {
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) { /* indicate successful reception to higher layers */
MSTP_Flag.ReceivePacketPending = true;
Master_State = Master_State =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST; MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
} }
+16 -6
View File
@@ -872,14 +872,24 @@ static bool MSTP_Master_Node_FSM(void)
} }
break; break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
/* indicate successful reception to the higher layers */ if ((DestinationAddress == MSTP_BROADCAST_ADDRESS) &&
MSTP_Flag.ReceivePacketPending = true; (npdu_confirmed_service(InputBuffer, DataLength))) {
/* BTL test: verifies that the IUT will quietly
discard any Confirmed-Request-PDU, whose
destination address is a multicast or
broadcast address, received from the
network layer. */
} else {
/* indicate successful reception to higher layer */
MSTP_Flag.ReceivePacketPending = true;
}
break; break;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
/* indicate successful reception to higher layers */ if (DestinationAddress == MSTP_BROADCAST_ADDRESS) {
MSTP_Flag.ReceivePacketPending = true; /* broadcast DER just remains IDLE */
/* broadcast DER just remains IDLE */ } else {
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) { /* indicate successful reception to higher layers */
MSTP_Flag.ReceivePacketPending = true;
Master_State = Master_State =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST; MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
} }
+16 -6
View File
@@ -809,14 +809,24 @@ static bool MSTP_Master_Node_FSM(void)
} }
break; break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
/* indicate successful reception to the higher layers */ if ((DestinationAddress == MSTP_BROADCAST_ADDRESS) &&
MSTP_Flag.ReceivePacketPending = true; (npdu_confirmed_service(InputBuffer, DataLength))) {
/* BTL test: verifies that the IUT will quietly
discard any Confirmed-Request-PDU, whose
destination address is a multicast or
broadcast address, received from the
network layer. */
} else {
/* indicate successful reception to higher layer */
MSTP_Flag.ReceivePacketPending = true;
}
break; break;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
/* indicate successful reception to higher layers */ if (DestinationAddress == MSTP_BROADCAST_ADDRESS) {
MSTP_Flag.ReceivePacketPending = true; /* broadcast DER just remains IDLE */
/* broadcast DER just remains IDLE */ } else {
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) { /* indicate successful reception to higher layers */
MSTP_Flag.ReceivePacketPending = true;
Master_State = Master_State =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST; MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
} }
+24 -11
View File
@@ -55,8 +55,10 @@
#include "crc.h" #include "crc.h"
#include "rs485.h" #include "rs485.h"
#include "bacnet/datalink/mstptext.h" #include "bacnet/datalink/mstptext.h"
#if !defined(DEBUG_ENABLED) #include "bacnet/npdu.h"
#define DEBUG_ENABLED 1
#ifndef DEBUG_ENABLED
#define DEBUG_ENABLED 0
#endif #endif
#include "bacnet/basic/sys/debug.h" #include "bacnet/basic/sys/debug.h"
@@ -655,18 +657,29 @@ bool MSTP_Master_Node_FSM(volatile struct mstp_port_struct_t *mstp_port)
} }
break; break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
/* indicate successful reception to the higher if ((mstp_port->DestinationAddress ==
* layers */ MSTP_BROADCAST_ADDRESS) &&
(void)MSTP_Put_Receive(mstp_port); (npdu_confirmed_service(mstp_port->InputBuffer,
mstp_port->DataLength))) {
/* BTL test: verifies that the IUT will quietly
discard any Confirmed-Request-PDU, whose
destination address is a multicast or
broadcast address, received from the
network layer. */
} else {
/* indicate successful reception to the higher
* layers */
(void)MSTP_Put_Receive(mstp_port);
}
break; break;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY: case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
/*mstp_port->ReplyPostponedTimer = 0; */ if (mstp_port->DestinationAddress ==
/* indicate successful reception to the higher
* layers */
(void)MSTP_Put_Receive(mstp_port);
/* broadcast DER just remains IDLE */
if (mstp_port->DestinationAddress !=
MSTP_BROADCAST_ADDRESS) { MSTP_BROADCAST_ADDRESS) {
/* broadcast DER just remains IDLE */
} else {
/* indicate successful reception to the higher
* layers */
(void)MSTP_Put_Receive(mstp_port);
mstp_port->master_state = mstp_port->master_state =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST; MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
} }