Bugfix/service request refactor size check (#553)

* refactor service requests from service header

* add APDU size checking and length feature

* add unit tests to check for length when passing NULL buffer

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2024-01-05 08:59:45 -06:00
committed by GitHub
parent 5ca14e5320
commit bb081d28da
39 changed files with 2614 additions and 1514 deletions
+27
View File
@@ -44,6 +44,33 @@ int delete_object_encode_service_request(
return apdu_len;
}
/**
* @brief Encode the DeleteObject service request
*
* DeleteObject-Request ::= SEQUENCE {
* object-identifier BACnetObjectIdentifier
* }
*
* @param apdu Pointer to the buffer for encoded values
* @param apdu_size number of bytes available in the buffer
* @param data Pointer to the service data used for encoding values
* @return number of bytes encoded, or zero if unable to encode or too large
*/
int delete_object_service_request_encode(
uint8_t *apdu, size_t apdu_size, BACNET_DELETE_OBJECT_DATA *data)
{
size_t apdu_len = 0; /* total length of the apdu, return value */
apdu_len = delete_object_encode_service_request(NULL, data);
if (apdu_len > apdu_size) {
apdu_len = 0;
} else {
apdu_len = delete_object_encode_service_request(apdu, data);
}
return apdu_len;
}
/**
* @brief Decode the DeleteObject service request
*