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
.PHONY: ports
ports: atmega168 bdk-atxx4-mstp at91sam7s stm32f10x
ports: atmega168 bdk-atxx4-mstp at91sam7s stm32f10x stm32f4xx
@echo "Built the ARM7 and AVR ports"
.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
atmega168: ports/atmega168/Makefile
+13 -3
View File
@@ -704,14 +704,24 @@ static bool MSTP_Master_Node_FSM(void)
}
break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
/* indicate successful reception to the higher layers */
if ((DestinationAddress == MSTP_BROADCAST_ADDRESS) &&
(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;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
if (DestinationAddress == MSTP_BROADCAST_ADDRESS) {
/* broadcast DER just remains IDLE */
} else {
/* indicate successful reception to higher layers */
MSTP_Flag.ReceivePacketPending = true;
/* broadcast DER just remains IDLE */
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) {
Master_State =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
}
+14 -4
View File
@@ -613,14 +613,24 @@ static bool MSTP_Master_Node_FSM(void)
}
break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
/* indicate successful reception to the higher layers */
if ((DestinationAddress == MSTP_BROADCAST_ADDRESS) &&
(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;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
/* indicate successful reception to the higher layers */
MSTP_Flag.ReceivePacketPending = true;
if (DestinationAddress == MSTP_BROADCAST_ADDRESS) {
/* broadcast DER just remains IDLE */
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) {
} else {
/* indicate successful reception to higher layers */
MSTP_Flag.ReceivePacketPending = true;
Master_State =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
}
+13 -3
View File
@@ -726,14 +726,24 @@ static bool MSTP_Master_Node_FSM(void)
}
break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
/* indicate successful reception to the higher layers */
if ((DestinationAddress == MSTP_BROADCAST_ADDRESS) &&
(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;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
if (DestinationAddress == MSTP_BROADCAST_ADDRESS) {
/* broadcast DER just remains IDLE */
} else {
/* indicate successful reception to higher layers */
MSTP_Flag.ReceivePacketPending = true;
/* broadcast DER just remains IDLE */
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) {
Master_State =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
}
+15 -4
View File
@@ -752,22 +752,33 @@ bool MSTP_Master_Node_FSM(volatile struct mstp_port_struct_t *mstp_port)
}
break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
if ((mstp_port->DestinationAddress ==
MSTP_BROADCAST_ADDRESS) &&
(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 */
dlmstp_put_receive(mstp_port->SourceAddress,
(uint8_t *)&mstp_port->InputBuffer[0],
mstp_port->DataLength);
}
break;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
/*mstp_port->ReplyPostponedTimer = 0; */
if (mstp_port->DestinationAddress ==
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);
/* broadcast DER just remains IDLE */
if (mstp_port->DestinationAddress !=
MSTP_BROADCAST_ADDRESS) {
mstp_port->master_state =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
}
+15 -4
View File
@@ -760,22 +760,33 @@ bool MSTP_Master_Node_FSM(volatile struct mstp_port_struct_t *mstp_port)
}
break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
if ((mstp_port->DestinationAddress ==
MSTP_BROADCAST_ADDRESS) &&
(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 */
dlmstp_put_receive(mstp_port->SourceAddress,
(uint8_t *)&mstp_port->InputBuffer[0],
mstp_port->DataLength);
}
break;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
/*mstp_port->ReplyPostponedTimer = 0; */
if (mstp_port->DestinationAddress ==
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);
/* broadcast DER just remains IDLE */
if (mstp_port->DestinationAddress !=
MSTP_BROADCAST_ADDRESS) {
mstp_port->master_state =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
}
+13 -3
View File
@@ -807,14 +807,24 @@ static bool MSTP_Master_Node_FSM(void)
}
break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
/* indicate successful reception to the higher layers */
if ((DestinationAddress == MSTP_BROADCAST_ADDRESS) &&
(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;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
if (DestinationAddress == MSTP_BROADCAST_ADDRESS) {
/* broadcast DER just remains IDLE */
} else {
/* indicate successful reception to higher layers */
MSTP_Flag.ReceivePacketPending = true;
/* broadcast DER just remains IDLE */
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) {
Master_State =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
}
+13 -3
View File
@@ -872,14 +872,24 @@ static bool MSTP_Master_Node_FSM(void)
}
break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
/* indicate successful reception to the higher layers */
if ((DestinationAddress == MSTP_BROADCAST_ADDRESS) &&
(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;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
if (DestinationAddress == MSTP_BROADCAST_ADDRESS) {
/* broadcast DER just remains IDLE */
} else {
/* indicate successful reception to higher layers */
MSTP_Flag.ReceivePacketPending = true;
/* broadcast DER just remains IDLE */
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) {
Master_State =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
}
+13 -3
View File
@@ -809,14 +809,24 @@ static bool MSTP_Master_Node_FSM(void)
}
break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
/* indicate successful reception to the higher layers */
if ((DestinationAddress == MSTP_BROADCAST_ADDRESS) &&
(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;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
if (DestinationAddress == MSTP_BROADCAST_ADDRESS) {
/* broadcast DER just remains IDLE */
} else {
/* indicate successful reception to higher layers */
MSTP_Flag.ReceivePacketPending = true;
/* broadcast DER just remains IDLE */
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) {
Master_State =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
}
+19 -6
View File
@@ -55,8 +55,10 @@
#include "crc.h"
#include "rs485.h"
#include "bacnet/datalink/mstptext.h"
#if !defined(DEBUG_ENABLED)
#define DEBUG_ENABLED 1
#include "bacnet/npdu.h"
#ifndef DEBUG_ENABLED
#define DEBUG_ENABLED 0
#endif
#include "bacnet/basic/sys/debug.h"
@@ -655,18 +657,29 @@ bool MSTP_Master_Node_FSM(volatile struct mstp_port_struct_t *mstp_port)
}
break;
case FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY:
if ((mstp_port->DestinationAddress ==
MSTP_BROADCAST_ADDRESS) &&
(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;
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
/*mstp_port->ReplyPostponedTimer = 0; */
if (mstp_port->DestinationAddress ==
MSTP_BROADCAST_ADDRESS) {
/* broadcast DER just remains IDLE */
} else {
/* 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_port->master_state =
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
}