From 389b6a7d4d2a5c90ebb1d6af6ea72c6b532ea3e4 Mon Sep 17 00:00:00 2001 From: Jonathan <74002342+jd-imi@users.noreply.github.com> Date: Wed, 18 Dec 2024 18:40:23 +0100 Subject: [PATCH] h_dcc.c : Return correct error when no service request (#877) --- src/bacnet/basic/service/h_dcc.c | 20 +++++++++++++++----- src/bacnet/dcc.c | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/bacnet/basic/service/h_dcc.c b/src/bacnet/basic/service/h_dcc.c index 927cc267..448b8162 100644 --- a/src/bacnet/basic/service/h_dcc.c +++ b/src/bacnet/basic/service/h_dcc.c @@ -113,7 +113,17 @@ void handler_device_communication_control( "DeviceCommunicationControl: " "Sending Abort - segmented message.\n"); #endif - goto DCC_ABORT; + goto DCC_FAILURE; + } + + if (!service_request || service_len == 0) { + len = reject_encode_apdu( + &Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, + REJECT_REASON_MISSING_REQUIRED_PARAMETER); +#if PRINT_ENABLED + fprintf(stderr, "DCC: Sending Reject!\n"); +#endif + goto DCC_FAILURE; } /* decode the service request only */ len = dcc_decode_service_request( @@ -146,7 +156,7 @@ void handler_device_communication_control( fprintf(stderr, "DCC: Sending Reject!\n"); #endif } - goto DCC_ABORT; + goto DCC_FAILURE; } #if (BACNET_PROTOCOL_REVISION >= 20) if (state == COMMUNICATION_DISABLE) { @@ -163,7 +173,7 @@ void handler_device_communication_control( "DeviceCommunicationControl: " "Sending Error - DISABLE has been deprecated.\n"); #endif - goto DCC_ABORT; + goto DCC_FAILURE; } #endif if (state >= MAX_BACNET_COMMUNICATION_ENABLE_DISABLE) { @@ -183,7 +193,7 @@ void handler_device_communication_control( SERVICE_SUPPORTED_DEVICE_COMMUNICATION_CONTROL, (int)state, &Handler_Transmit_Buffer[pdu_len], service_data->invoke_id); if (len > 0) { - goto DCC_ABORT; + goto DCC_FAILURE; } #endif if ((My_Password[0] == '\0') || @@ -211,7 +221,7 @@ void handler_device_communication_control( #endif } } -DCC_ABORT: +DCC_FAILURE: pdu_len += len; len = datalink_send_pdu( src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); diff --git a/src/bacnet/dcc.c b/src/bacnet/dcc.c index eddc7901..4dbe1c79 100644 --- a/src/bacnet/dcc.c +++ b/src/bacnet/dcc.c @@ -250,7 +250,7 @@ int dcc_encode_apdu( * @param apdu Pointer to the received request. * @param apdu_len_max Valid count of bytes in the buffer. * @param timeDuration Pointer to the duration given in minutes [optional] - * @param enable_disable Pointer to the variable takingthe communication + * @param enable_disable Pointer to the variable taking the communication * enable/disable. * @param password Pointer to the password [optional] *