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:
@@ -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
|
||||||
|
|||||||
@@ -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) &&
|
||||||
|
(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;
|
MSTP_Flag.ReceivePacketPending = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
|
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
|
||||||
|
if (DestinationAddress == MSTP_BROADCAST_ADDRESS) {
|
||||||
|
/* broadcast DER just remains IDLE */
|
||||||
|
} else {
|
||||||
/* indicate successful reception to higher layers */
|
/* indicate successful reception to higher layers */
|
||||||
MSTP_Flag.ReceivePacketPending = true;
|
MSTP_Flag.ReceivePacketPending = true;
|
||||||
/* broadcast DER just remains IDLE */
|
|
||||||
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) {
|
|
||||||
Master_State =
|
Master_State =
|
||||||
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
|
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) &&
|
||||||
|
(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;
|
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 */
|
||||||
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) {
|
} else {
|
||||||
|
/* 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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) &&
|
||||||
|
(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;
|
MSTP_Flag.ReceivePacketPending = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
|
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
|
||||||
|
if (DestinationAddress == MSTP_BROADCAST_ADDRESS) {
|
||||||
|
/* broadcast DER just remains IDLE */
|
||||||
|
} else {
|
||||||
/* indicate successful reception to higher layers */
|
/* indicate successful reception to higher layers */
|
||||||
MSTP_Flag.ReceivePacketPending = true;
|
MSTP_Flag.ReceivePacketPending = true;
|
||||||
/* broadcast DER just remains IDLE */
|
|
||||||
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) {
|
|
||||||
Master_State =
|
Master_State =
|
||||||
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
|
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-4
@@ -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:
|
||||||
|
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
|
/* indicate successful reception to the higher
|
||||||
* layers */
|
* layers */
|
||||||
dlmstp_put_receive(mstp_port->SourceAddress,
|
dlmstp_put_receive(mstp_port->SourceAddress,
|
||||||
(uint8_t *)&mstp_port->InputBuffer[0],
|
(uint8_t *)&mstp_port->InputBuffer[0],
|
||||||
mstp_port->DataLength);
|
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 ==
|
||||||
|
MSTP_BROADCAST_ADDRESS) {
|
||||||
|
/* broadcast DER just remains IDLE */
|
||||||
|
} else {
|
||||||
/* indicate successful reception to the higher
|
/* indicate successful reception to the higher
|
||||||
* layers */
|
* layers */
|
||||||
dlmstp_put_receive(mstp_port->SourceAddress,
|
dlmstp_put_receive(mstp_port->SourceAddress,
|
||||||
(uint8_t *)&mstp_port->InputBuffer[0],
|
(uint8_t *)&mstp_port->InputBuffer[0],
|
||||||
mstp_port->DataLength);
|
mstp_port->DataLength);
|
||||||
/* broadcast DER just remains IDLE */
|
|
||||||
if (mstp_port->DestinationAddress !=
|
|
||||||
MSTP_BROADCAST_ADDRESS) {
|
|
||||||
mstp_port->master_state =
|
mstp_port->master_state =
|
||||||
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
|
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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:
|
||||||
|
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
|
/* indicate successful reception to the higher
|
||||||
* layers */
|
* layers */
|
||||||
dlmstp_put_receive(mstp_port->SourceAddress,
|
dlmstp_put_receive(mstp_port->SourceAddress,
|
||||||
(uint8_t *)&mstp_port->InputBuffer[0],
|
(uint8_t *)&mstp_port->InputBuffer[0],
|
||||||
mstp_port->DataLength);
|
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 ==
|
||||||
|
MSTP_BROADCAST_ADDRESS) {
|
||||||
|
/* broadcast DER just remains IDLE */
|
||||||
|
} else {
|
||||||
/* indicate successful reception to the higher
|
/* indicate successful reception to the higher
|
||||||
* layers */
|
* layers */
|
||||||
dlmstp_put_receive(mstp_port->SourceAddress,
|
dlmstp_put_receive(mstp_port->SourceAddress,
|
||||||
(uint8_t *)&mstp_port->InputBuffer[0],
|
(uint8_t *)&mstp_port->InputBuffer[0],
|
||||||
mstp_port->DataLength);
|
mstp_port->DataLength);
|
||||||
/* broadcast DER just remains IDLE */
|
|
||||||
if (mstp_port->DestinationAddress !=
|
|
||||||
MSTP_BROADCAST_ADDRESS) {
|
|
||||||
mstp_port->master_state =
|
mstp_port->master_state =
|
||||||
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
|
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) &&
|
||||||
|
(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;
|
MSTP_Flag.ReceivePacketPending = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
|
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
|
||||||
|
if (DestinationAddress == MSTP_BROADCAST_ADDRESS) {
|
||||||
|
/* broadcast DER just remains IDLE */
|
||||||
|
} else {
|
||||||
/* indicate successful reception to higher layers */
|
/* indicate successful reception to higher layers */
|
||||||
MSTP_Flag.ReceivePacketPending = true;
|
MSTP_Flag.ReceivePacketPending = true;
|
||||||
/* broadcast DER just remains IDLE */
|
|
||||||
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) {
|
|
||||||
Master_State =
|
Master_State =
|
||||||
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
|
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) &&
|
||||||
|
(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;
|
MSTP_Flag.ReceivePacketPending = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
|
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
|
||||||
|
if (DestinationAddress == MSTP_BROADCAST_ADDRESS) {
|
||||||
|
/* broadcast DER just remains IDLE */
|
||||||
|
} else {
|
||||||
/* indicate successful reception to higher layers */
|
/* indicate successful reception to higher layers */
|
||||||
MSTP_Flag.ReceivePacketPending = true;
|
MSTP_Flag.ReceivePacketPending = true;
|
||||||
/* broadcast DER just remains IDLE */
|
|
||||||
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) {
|
|
||||||
Master_State =
|
Master_State =
|
||||||
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
|
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-3
@@ -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) &&
|
||||||
|
(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;
|
MSTP_Flag.ReceivePacketPending = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
|
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
|
||||||
|
if (DestinationAddress == MSTP_BROADCAST_ADDRESS) {
|
||||||
|
/* broadcast DER just remains IDLE */
|
||||||
|
} else {
|
||||||
/* indicate successful reception to higher layers */
|
/* indicate successful reception to higher layers */
|
||||||
MSTP_Flag.ReceivePacketPending = true;
|
MSTP_Flag.ReceivePacketPending = true;
|
||||||
/* broadcast DER just remains IDLE */
|
|
||||||
if (DestinationAddress != MSTP_BROADCAST_ADDRESS) {
|
|
||||||
Master_State =
|
Master_State =
|
||||||
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
|
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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:
|
||||||
|
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
|
/* indicate successful reception to the higher
|
||||||
* layers */
|
* layers */
|
||||||
(void)MSTP_Put_Receive(mstp_port);
|
(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 ==
|
||||||
|
MSTP_BROADCAST_ADDRESS) {
|
||||||
|
/* broadcast DER just remains IDLE */
|
||||||
|
} else {
|
||||||
/* indicate successful reception to the higher
|
/* indicate successful reception to the higher
|
||||||
* layers */
|
* layers */
|
||||||
(void)MSTP_Put_Receive(mstp_port);
|
(void)MSTP_Put_Receive(mstp_port);
|
||||||
/* broadcast DER just remains IDLE */
|
|
||||||
if (mstp_port->DestinationAddress !=
|
|
||||||
MSTP_BROADCAST_ADDRESS) {
|
|
||||||
mstp_port->master_state =
|
mstp_port->master_state =
|
||||||
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
|
MSTP_MASTER_STATE_ANSWER_DATA_REQUEST;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user