Added segmentation support for server reply. (#974)

Added segmentation support for server devices for some services. Configure BACNET_SEGMENTATION_ENABLED=1 to include in the library, and adjust BACNET_MAX_SEGMENTS_ACCEPTED for maximum number of segments.
This commit is contained in:
Steve Karg
2025-11-15 13:33:36 -06:00
committed by GitHub
parent bea2ceba11
commit 3ea710f92f
25 changed files with 2112 additions and 144 deletions
+40 -2
View File
@@ -45,6 +45,10 @@ static struct Address_Cache_Entry {
uint8_t Flags;
uint32_t device_id;
unsigned max_apdu;
#if BACNET_SEGMENTATION_ENABLED
uint8_t segmentation;
uint16_t maxsegments;
#endif
BACNET_ADDRESS address;
uint32_t TimeToLive;
} Address_Cache[MAX_ADDRESS_CACHE];
@@ -346,9 +350,16 @@ void address_set_device_TTL(
* @param device_id Device-Id
* @param max_apdu Pointer to a variable, taking the maximum APDU size.
* @param src Pointer to address structure for return.
* @param segmentation Pointer to a variable, taking the BACNET_SEGMENTATION
* flag.
* @param maxsegments Pointer to a variable, taking the maximum segments.
*/
bool address_get_by_device(
uint32_t device_id, unsigned *max_apdu, BACNET_ADDRESS *src)
bool address_segment_get_by_device(
uint32_t device_id,
unsigned *max_apdu,
BACNET_ADDRESS *src,
uint8_t *segmentation,
uint16_t *maxsegments)
{
struct Address_Cache_Entry *pMatch;
bool found = false; /* return value */
@@ -364,6 +375,20 @@ bool address_get_by_device(
if (max_apdu) {
*max_apdu = pMatch->max_apdu;
}
if (segmentation) {
#if BACNET_SEGMENTATION_ENABLED
*segmentation = pMatch->segmentation;
#else
*segmentation = SEGMENTATION_NONE;
#endif
}
if (maxsegments) {
#if BACNET_SEGMENTATION_ENABLED
*maxsegments = pMatch->maxsegments;
#else
*maxsegments = 1;
#endif
}
/* Prove we found it */
found = true;
}
@@ -375,6 +400,19 @@ bool address_get_by_device(
return found;
}
/**
* @brief Return the cached addresBACNET_STACK_EXPORT
s for the given device-id
* @param device_id Device-Id
* @param max_apdu Pointer to a variable, taking the maximum APDU size.
* @param src Pointer to address structure for return.
*/
bool address_get_by_device(
uint32_t device_id, unsigned *max_apdu, BACNET_ADDRESS *src)
{
return address_segment_get_by_device(device_id, max_apdu, src, NULL, NULL);
}
/**
* Find a device id from a given MAC address.
*
+8
View File
@@ -43,6 +43,14 @@ BACNET_STACK_EXPORT
bool address_get_by_device(
uint32_t device_id, unsigned *max_apdu, BACNET_ADDRESS *src);
BACNET_STACK_EXPORT
bool address_segment_get_by_device(
uint32_t device_id,
unsigned *max_apdu,
BACNET_ADDRESS *src,
uint8_t *segmentation,
uint16_t *maxsegments);
BACNET_STACK_EXPORT
bool address_get_by_index(
unsigned index,