From ad74c6d4ac428069909bff118550c78f6ae49517 Mon Sep 17 00:00:00 2001 From: skarg Date: Thu, 29 Dec 2011 03:37:38 +0000 Subject: [PATCH] Corrected missing packet initialization in DLMSTP for several ports that may result in unusual REPLY-POSTPONED frames emitted for a DATA-EXPECTING-REPLY frame. --- bacnet-stack/ports/at91sam7s/dlmstp.c | 7 ++++--- bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c | 7 ++++--- bacnet-stack/ports/stm32f10x/dlmstp.c | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/bacnet-stack/ports/at91sam7s/dlmstp.c b/bacnet-stack/ports/at91sam7s/dlmstp.c index ed82b5dc..c7fd1ed7 100644 --- a/bacnet-stack/ports/at91sam7s/dlmstp.c +++ b/bacnet-stack/ports/at91sam7s/dlmstp.c @@ -1090,13 +1090,14 @@ static bool MSTP_Master_Node_FSM( /* BACnet Data Expecting Reply, a Test_Request, or */ /* a proprietary frame that expects a reply is received. */ case MSTP_MASTER_STATE_ANSWER_DATA_REQUEST: - matched = false; - if (!Ringbuf_Empty(&PDU_Queue)) { - pkt = (struct mstp_pdu_packet *) Ringbuf_Get_Front(&PDU_Queue); + pkt = (struct mstp_pdu_packet *) Ringbuf_Get_Front(&PDU_Queue); + if (pkt != NULL) { matched = dlmstp_compare_data_expecting_reply(&InputBuffer[0], DataLength, SourceAddress, &pkt->buffer[0], pkt->length, pkt->destination_mac); + } else { + matched = false; } if (matched) { /* Reply */ diff --git a/bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c b/bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c index e985ea68..b9aac6c9 100644 --- a/bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c +++ b/bacnet-stack/ports/bdk-atxx4-mstp/dlmstp.c @@ -1117,13 +1117,14 @@ static bool MSTP_Master_Node_FSM( /* BACnet Data Expecting Reply, a Test_Request, or */ /* a proprietary frame that expects a reply is received. */ case MSTP_MASTER_STATE_ANSWER_DATA_REQUEST: - matched = false; - if (!Ringbuf_Empty(&PDU_Queue)) { - pkt = (struct mstp_pdu_packet *) Ringbuf_Get_Front(&PDU_Queue); + pkt = (struct mstp_pdu_packet *) Ringbuf_Get_Front(&PDU_Queue); + if (pkt != NULL) { matched = dlmstp_compare_data_expecting_reply(&InputBuffer[0], DataLength, SourceAddress, &pkt->buffer[0], pkt->length, pkt->destination_mac); + } else { + matched = false; } if (matched) { /* Reply */ diff --git a/bacnet-stack/ports/stm32f10x/dlmstp.c b/bacnet-stack/ports/stm32f10x/dlmstp.c index 1c1869f0..5c00f24a 100644 --- a/bacnet-stack/ports/stm32f10x/dlmstp.c +++ b/bacnet-stack/ports/stm32f10x/dlmstp.c @@ -1206,13 +1206,14 @@ static bool MSTP_Master_Node_FSM( /* BACnet Data Expecting Reply, a Test_Request, or */ /* a proprietary frame that expects a reply is received. */ case MSTP_MASTER_STATE_ANSWER_DATA_REQUEST: - matched = false; - if (!Ringbuf_Empty(&PDU_Queue)) { - pkt = (struct mstp_pdu_packet *) Ringbuf_Get_Front(&PDU_Queue); + pkt = (struct mstp_pdu_packet *) Ringbuf_Get_Front(&PDU_Queue); + if (pkt != NULL) { matched = dlmstp_compare_data_expecting_reply(&InputBuffer[0], DataLength, SourceAddress, &pkt->buffer[0], pkt->length, pkt->destination_mac); + } else { + matched = false; } if (matched) { /* Reply */