Fixed BACnet/SC secure connect VMAC, UUID, and initialization sequence (#1142)
* Refactored the BACnet/SC datalink initialization order by moving certificate file checks and hub connection registration to occur after datalink initialization * Replaced stdlib rand() with platform-specific cryptographically secure random functions (RtlGenRandom for Windows, getrandom for Linux, arc4random_buf for BSD) to generate UUID and VMAC addresses, preventing duplicates that broke connections * Enabled conditional debug output in BACnet/SC components when BUILD=debug is specified
This commit is contained in:
@@ -558,15 +558,12 @@ uint32_t bacfile_write(
|
||||
BACNET_UNSIGNED_INTEGER bacfile_file_size(uint32_t object_instance)
|
||||
{
|
||||
const char *pathname = NULL;
|
||||
long file_position = 0;
|
||||
BACNET_UNSIGNED_INTEGER file_size = 0;
|
||||
|
||||
pathname = bacfile_pathname(object_instance);
|
||||
if (pathname) {
|
||||
file_position = bacfile_file_size_callback(pathname);
|
||||
if (file_position >= 0) {
|
||||
file_size = (BACNET_UNSIGNED_INTEGER)file_position;
|
||||
}
|
||||
file_size =
|
||||
(BACNET_UNSIGNED_INTEGER)bacfile_file_size_callback(pathname);
|
||||
}
|
||||
|
||||
return file_size;
|
||||
|
||||
@@ -19,6 +19,25 @@
|
||||
#include "bacnet/datalink/bsc/bsc-conf.h"
|
||||
#include "bacnet/datalink/bsc/bvlc-sc.h"
|
||||
|
||||
#ifndef SC_NETPORT_BVLC_MAX
|
||||
#define SC_NETPORT_BVLC_MAX 1500
|
||||
#endif
|
||||
#ifndef SC_NETPORT_NPDU_MAX
|
||||
#define SC_NETPORT_NPDU_MAX 1500
|
||||
#endif
|
||||
#ifndef SC_NETPORT_CONNECT_TIMEOUT
|
||||
#define SC_NETPORT_CONNECT_TIMEOUT 5
|
||||
#endif
|
||||
#ifndef SC_NETPORT_HEARTBEAT_TIMEOUT
|
||||
#define SC_NETPORT_HEARTBEAT_TIMEOUT 60
|
||||
#endif
|
||||
#ifndef SC_NETPORT_DISCONNECT_TIMEOUT
|
||||
#define SC_NETPORT_DISCONNECT_TIMEOUT 150
|
||||
#endif
|
||||
#ifndef SC_NETPORT_RECONNECT_TIME
|
||||
#define SC_NETPORT_RECONNECT_TIME 2
|
||||
#endif
|
||||
|
||||
/* BACnet file instance numbers */
|
||||
#ifndef BSC_ISSUER_CERTIFICATE_FILE_1_INSTANCE
|
||||
#define BSC_ISSUER_CERTIFICATE_FILE_1_INSTANCE \
|
||||
|
||||
Reference in New Issue
Block a user