Bugfix/win32 build warnings (#936)
* Changed win32 port of localtime to use secure OS API functions when compiled with MSVC * Changed all the sprintf to use snprintf instead in BSC tests to ensure null string endings.
This commit is contained in:
+3
-2
@@ -422,8 +422,9 @@ static bool PrettyPrintPropertyValue(
|
||||
/* eg, property == PROP_LOCAL_DATE
|
||||
* VTS needs (3-Aug-2011,4) or (8/3/11,4), so we'll use the
|
||||
* clearer, international form. */
|
||||
strncpy(short_month, bactext_month_name(value->type.Date.month), 3);
|
||||
short_month[3] = 0;
|
||||
snprintf(
|
||||
short_month, sizeof(short_month), "%s",
|
||||
bactext_month_name(value->type.Date.month));
|
||||
fprintf(
|
||||
stream, "(%u-%3s-%u, %u)", (unsigned)value->type.Date.day,
|
||||
short_month, (unsigned)value->type.Date.year,
|
||||
|
||||
@@ -137,9 +137,9 @@ static void ProcessPT(BACNET_PRIVATE_TRANSFER_DATA *data)
|
||||
decode_character_string(
|
||||
&data->serviceParameters[iLen], len_value_type, &bsTemp);
|
||||
/* Only copy as much as we can accept */
|
||||
strncpy(
|
||||
(char *)MyData[(int8_t)cBlockNumber].sMyString,
|
||||
characterstring_value(&bsTemp), MY_MAX_STR);
|
||||
snprintf(
|
||||
(char *)MyData[(int8_t)cBlockNumber].sMyString, MY_MAX_STR,
|
||||
"%s", characterstring_value(&bsTemp));
|
||||
/* Make sure it is nul terminated */
|
||||
MyData[(int8_t)cBlockNumber].sMyString[MY_MAX_STR] = '\0';
|
||||
/* Signal success */
|
||||
|
||||
@@ -76,10 +76,9 @@ static void DecodeBlock(char cBlockNum, uint8_t *pData)
|
||||
}
|
||||
|
||||
iLen += decode_character_string(&pData[iLen], len_value_type, &bsName);
|
||||
strncpy(
|
||||
(char *)Response.sMyString, characterstring_value(&bsName), MY_MAX_STR);
|
||||
Response.sMyString[MY_MAX_STR] = '\0'; /* Make sure it is nul terminated */
|
||||
|
||||
snprintf(
|
||||
(char *)Response.sMyString, MY_MAX_STR, "%s",
|
||||
characterstring_value(&bsName));
|
||||
printf("Private Transfer Read Block Response\n");
|
||||
printf("Data Block: %d\n", (int)cBlockNum);
|
||||
printf(" First Byte : %d\n", (int)Response.cMyByte1);
|
||||
|
||||
+5
-6
@@ -261,9 +261,8 @@ bool read_config(const char *filepath)
|
||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (fd) {
|
||||
struct ifreq ifr;
|
||||
strncpy(
|
||||
ifr.ifr_name, current->iface,
|
||||
sizeof(ifr.ifr_name) - 1);
|
||||
snprintf(
|
||||
ifr.ifr_name, sizeof(ifr.ifr_name), "%s", iface);
|
||||
result = ioctl(fd, SIOCGIFADDR, &ifr);
|
||||
if (result != -1) {
|
||||
close(fd);
|
||||
@@ -468,9 +467,9 @@ bool parse_cmd(int argc, char *argv[])
|
||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (fd) {
|
||||
struct ifreq ifr;
|
||||
strncpy(
|
||||
ifr.ifr_name, current->iface,
|
||||
sizeof(ifr.ifr_name) - 1);
|
||||
snprintf(
|
||||
ifr.ifr_name, sizeof(ifr.ifr_name), "%s",
|
||||
current->iface);
|
||||
result = ioctl(fd, SIOCGIFADDR, &ifr);
|
||||
if (result != -1) {
|
||||
close(fd);
|
||||
|
||||
@@ -466,7 +466,8 @@ static char *ifname_default(void)
|
||||
if (BIP_Interface_Name[0] != 0) {
|
||||
return BIP_Interface_Name;
|
||||
}
|
||||
strncpy(BIP_Interface_Name, "en0", sizeof(BIP_Interface_Name));
|
||||
snprintf(BIP_Interface_Name, sizeof(BIP_Interface_Name), "%s", "en0");
|
||||
|
||||
return BIP_Interface_Name;
|
||||
}
|
||||
|
||||
|
||||
@@ -115,9 +115,9 @@ static int arcnet_bind(const char *interface_name)
|
||||
ARCNET_Socket_Address.sa_data, '\0',
|
||||
sizeof(ARCNET_Socket_Address.sa_data));
|
||||
/* Strcpy the interface name into the address */
|
||||
strncpy(
|
||||
ARCNET_Socket_Address.sa_data, interface_name,
|
||||
sizeof(ARCNET_Socket_Address.sa_data) - 1);
|
||||
snprintf(
|
||||
ARCNET_Socket_Address.sa_data,
|
||||
sizeof(ARCNET_Socket_Address.sa_data), "%s", interface_name);
|
||||
fprintf(
|
||||
stderr, "arcnet: binding \"%s\"\n", ARCNET_Socket_Address.sa_data);
|
||||
if (bind(
|
||||
@@ -140,7 +140,7 @@ static int arcnet_bind(const char *interface_name)
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
strncpy(ifr.ifr_name, interface_name, sizeof(ifr.ifr_name));
|
||||
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", interface_name);
|
||||
rv = ioctl(sock_fd, SIOCGIFHWADDR, &ifr);
|
||||
if (rv != -1) { /* worked okay */
|
||||
ARCNET_MAC_Address = ifr.ifr_hwaddr.sa_data[0];
|
||||
@@ -153,9 +153,9 @@ static int arcnet_bind(const char *interface_name)
|
||||
ARCNET_Socket_Address.sa_data, '\0',
|
||||
sizeof(ARCNET_Socket_Address.sa_data));
|
||||
/* Strcpy the interface name into the address */
|
||||
strncpy(
|
||||
ARCNET_Socket_Address.sa_data, interface_name,
|
||||
sizeof(ARCNET_Socket_Address.sa_data) - 1);
|
||||
snprintf(
|
||||
ARCNET_Socket_Address.sa_data, sizeof(ARCNET_Socket_Address.sa_data),
|
||||
"%s", interface_name);
|
||||
fprintf(
|
||||
stderr, "arcnet: MAC=%02Xh iface=\"%s\"\n", ARCNET_MAC_Address,
|
||||
ARCNET_Socket_Address.sa_data);
|
||||
|
||||
@@ -475,7 +475,7 @@ get_local_ifr_ioctl(const char *ifname, struct ifreq *ifr, int request)
|
||||
int fd;
|
||||
int rv; /* return value */
|
||||
|
||||
strncpy(ifr->ifr_name, ifname, sizeof(ifr->ifr_name) - 1);
|
||||
snprintf(ifr->ifr_name, sizeof(ifr->ifr_name), "%s", ifname);
|
||||
ifr->ifr_name[sizeof(ifr->ifr_name) - 1] = 0;
|
||||
|
||||
fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
|
||||
|
||||
@@ -120,7 +120,8 @@ static int ethernet_bind(struct sockaddr *eth_addr, const char *interface_name)
|
||||
/* Clear the memory before copying */
|
||||
memset(eth_addr->sa_data, '\0', sizeof(eth_addr->sa_data));
|
||||
/* Strcpy the interface name into the address */
|
||||
strncpy(eth_addr->sa_data, interface_name, sizeof(eth_addr->sa_data) - 1);
|
||||
snprintf(
|
||||
eth_addr->sa_data, sizeof(eth_addr->sa_data), "%s", interface_name);
|
||||
fprintf(stderr, "ethernet: binding \"%s\"\n", eth_addr->sa_data);
|
||||
/* Attempt to bind the socket to the interface */
|
||||
if (bind(sock_fd, eth_addr, sizeof(struct sockaddr)) != 0) {
|
||||
|
||||
@@ -116,8 +116,7 @@ static int network_init(const char *name, int protocol)
|
||||
struct ifreq ifr;
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
strncpy(ifr.ifr_name, name, strlen(name));
|
||||
|
||||
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", name);
|
||||
if (ioctl(sockfd, SIOCGIFINDEX, &ifr) == -1) {
|
||||
perror("Unable to get interface index");
|
||||
return -1;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include "bacnet/basic/sys/debug.h"
|
||||
#include "bacnet/datalink/bsc/bsc-event.h"
|
||||
|
||||
#define DEBUG_BSC_EVENT 0
|
||||
|
||||
@@ -51,6 +51,8 @@ int gettimeofday(struct timeval *tp, void *tzp)
|
||||
{
|
||||
static int tzflag = 0;
|
||||
struct timezone *tz;
|
||||
long tz_seconds = 0;
|
||||
int tz_hours = 0;
|
||||
/* start calendar time in microseconds */
|
||||
static LONGLONG usec_timer = 0;
|
||||
LONGLONG usec_elapsed = 0;
|
||||
@@ -86,8 +88,10 @@ int gettimeofday(struct timeval *tp, void *tzp)
|
||||
tzflag++;
|
||||
}
|
||||
tz = tzp;
|
||||
tz->tz_minuteswest = _timezone / 60;
|
||||
tz->tz_dsttime = _daylight;
|
||||
(void)_get_timezone(&tz_seconds);
|
||||
tz->tz_minuteswest = tz_seconds / 60;
|
||||
(void)_get_daylight(&tz_hours);
|
||||
tz->tz_dsttime = tz_hours;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -125,15 +129,18 @@ bool datetime_local(
|
||||
bool *dst_active)
|
||||
{
|
||||
bool status = false;
|
||||
struct tm *tblock = NULL;
|
||||
struct tm *tblock;
|
||||
#if defined(_MSC_VER)
|
||||
time_t tTemp;
|
||||
struct tm newtime = { 0 };
|
||||
__time64_t long_time = 0;
|
||||
#else
|
||||
struct timeval tv;
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
time(&tTemp);
|
||||
tblock = (struct tm *)localtime(&tTemp);
|
||||
_time64(&long_time);
|
||||
(void)localtime_s(&newtime, &long_time);
|
||||
tblock = &newtime;
|
||||
#else
|
||||
if (gettimeofday(&tv, NULL) == 0) {
|
||||
tblock = (struct tm *)localtime((const time_t *)&tv.tv_sec);
|
||||
@@ -181,7 +188,7 @@ bool datetime_local(
|
||||
/* timezone is set to the difference, in seconds,
|
||||
between Coordinated Universal Time (UTC) and
|
||||
local standard time */
|
||||
*utc_offset_minutes = timezone / 60;
|
||||
*utc_offset_minutes = (int16_t)(timezone / 60);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -467,16 +467,16 @@ bool bacnet_discover_property_name(
|
||||
device_id, object_type, object_instance, object_property, &value);
|
||||
if (status && value.tag == BACNET_APPLICATION_TAG_CHARACTER_STRING) {
|
||||
if (characterstring_valid(&value.type.Character_String)) {
|
||||
strncpy(
|
||||
buffer, characterstring_value(&value.type.Character_String),
|
||||
buffer_len - 1);
|
||||
snprintf(
|
||||
buffer, buffer_len, "%s",
|
||||
characterstring_value(&value.type.Character_String));
|
||||
} else {
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!status) {
|
||||
strncpy(buffer, default_string, buffer_len);
|
||||
snprintf(buffer, buffer_len, "%s", default_string);
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
@@ -450,10 +450,11 @@ BSC_SC_RET bsc_hub_connector_start(
|
||||
c->primary_url[0] = 0;
|
||||
c->failover_url[0] = 0;
|
||||
c->user_arg = user_arg;
|
||||
strncpy((char *)c->primary_url, primaryURL, sizeof(c->primary_url) - 1);
|
||||
snprintf((char *)c->primary_url, sizeof(c->primary_url), "%s", primaryURL);
|
||||
if (failoverURL) {
|
||||
strncpy(
|
||||
(char *)c->failover_url, failoverURL, sizeof(c->failover_url) - 1);
|
||||
snprintf(
|
||||
(char *)c->failover_url, sizeof(c->failover_url), "%s",
|
||||
failoverURL);
|
||||
}
|
||||
c->event_func = event_func;
|
||||
bsc_init_ctx_cfg(
|
||||
|
||||
@@ -267,10 +267,10 @@ copy_urls(BSC_NODE_SWITCH_CTX *ctx, int index, BSC_ADDRESS_RESOLUTION *r)
|
||||
int i;
|
||||
for (i = 0; i < r->urls_num; i++) {
|
||||
ctx->initiator.urls[index].utf8_urls[i][0] = 0;
|
||||
strncpy(
|
||||
snprintf(
|
||||
(char *)&ctx->initiator.urls[index].utf8_urls[i][0],
|
||||
(char *)&r->utf8_urls[i][0],
|
||||
sizeof(ctx->initiator.urls[index].utf8_urls[i]) - 1);
|
||||
sizeof(ctx->initiator.urls[index].utf8_urls[i]), "%s",
|
||||
(char *)r->utf8_urls[i]);
|
||||
}
|
||||
ctx->initiator.urls[index].urls_cnt = r->urls_num;
|
||||
}
|
||||
@@ -288,9 +288,9 @@ copy_urls2(BSC_NODE_SWITCH_CTX *ctx, int index, char **urls, size_t urls_cnt)
|
||||
size_t i;
|
||||
for (i = 0; i < urls_cnt; i++) {
|
||||
ctx->initiator.urls[index].utf8_urls[i][0] = 0;
|
||||
strncpy(
|
||||
(char *)&ctx->initiator.urls[index].utf8_urls[i][0], urls[i],
|
||||
sizeof(ctx->initiator.urls[index].utf8_urls[i]) - 1);
|
||||
snprintf(
|
||||
(char *)&ctx->initiator.urls[index].utf8_urls[i][0],
|
||||
sizeof(ctx->initiator.urls[index].utf8_urls[i]), "%s", urls[i]);
|
||||
}
|
||||
ctx->initiator.urls[index].urls_cnt = urls_cnt;
|
||||
}
|
||||
|
||||
@@ -64,9 +64,10 @@ void bsc_copy_uuid(BACNET_SC_UUID *dst, BACNET_SC_UUID *src)
|
||||
char *bsc_vmac_to_string(BACNET_SC_VMAC_ADDRESS *vmac)
|
||||
{
|
||||
static char buf[128];
|
||||
sprintf(
|
||||
buf, "%02x%02x%02x%02x%02x%02x", vmac->address[0], vmac->address[1],
|
||||
vmac->address[2], vmac->address[3], vmac->address[4], vmac->address[5]);
|
||||
snprintf(
|
||||
buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x", vmac->address[0],
|
||||
vmac->address[1], vmac->address[2], vmac->address[3], vmac->address[4],
|
||||
vmac->address[5]);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -78,8 +79,8 @@ char *bsc_vmac_to_string(BACNET_SC_VMAC_ADDRESS *vmac)
|
||||
char *bsc_uuid_to_string(BACNET_SC_UUID *uuid)
|
||||
{
|
||||
static char buf[128];
|
||||
sprintf(
|
||||
buf,
|
||||
snprintf(
|
||||
buf, sizeof(buf),
|
||||
"%02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x-%02x%02x%02x%02x",
|
||||
uuid->uuid[0], uuid->uuid[1], uuid->uuid[2], uuid->uuid[3],
|
||||
uuid->uuid[4], uuid->uuid[5], uuid->uuid[6], uuid->uuid[7],
|
||||
|
||||
@@ -9995,12 +9995,12 @@ static void test_sc_parameters(void)
|
||||
memset(&hubf_uuid, 0x1, sizeof(hubf_uuid));
|
||||
memset(&hubf_vmac, 0x2, sizeof(hubf_vmac));
|
||||
|
||||
sprintf(
|
||||
primary_url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT);
|
||||
sprintf(
|
||||
secondary_url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
snprintf(
|
||||
primary_url, sizeof(primary_url), "wss://%s:%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT);
|
||||
snprintf(
|
||||
secondary_url, sizeof(secondary_url), "wss://%s:%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
|
||||
// prepare
|
||||
bacfile_init();
|
||||
@@ -10132,15 +10132,26 @@ static void test_sc_datalink(void)
|
||||
memset(&uuid3, 0x35, sizeof(uuid3));
|
||||
memset(&vmac3, 0x36, sizeof(vmac3));
|
||||
|
||||
sprintf(primary_url3, "wss://%s:%d", BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
secondary_url3, "wss://%s:%d", BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
sprintf(primary_url2, "wss://%s:%d", BACNET_LOCALHOST, BACNET_HUB_PORT);
|
||||
sprintf(secondary_url2, "wss://%s:%d", BACNET_LOCALHOST, BACNET_HUB_PORT);
|
||||
sprintf(primary_url1, "wss://%s:%d", BACNET_LOCALHOST, BACNET_HUB_PORT);
|
||||
sprintf(secondary_url1, "wss://%s:%d", BACNET_LOCALHOST, BACNET_HUB_PORT);
|
||||
sprintf(
|
||||
direct_url, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
snprintf(
|
||||
primary_url3, sizeof(primary_url3), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
secondary_url3, sizeof(secondary_url3), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
primary_url2, sizeof(primary_url2), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_HUB_PORT);
|
||||
snprintf(
|
||||
secondary_url2, sizeof(secondary_url2), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_HUB_PORT);
|
||||
snprintf(
|
||||
primary_url1, sizeof(primary_url1), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_HUB_PORT);
|
||||
snprintf(
|
||||
secondary_url1, sizeof(secondary_url1), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_HUB_PORT);
|
||||
snprintf(
|
||||
direct_url, sizeof(direct_url), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
SC_NETPORT_DIRECT_SERVER_PORT);
|
||||
|
||||
bacfile_init();
|
||||
@@ -10383,26 +10394,26 @@ static void test_sc_datalink_properties(void)
|
||||
memset(&uuid4, 0x7, sizeof(uuid4));
|
||||
memset(&vmac4, 0x8, sizeof(vmac4));
|
||||
|
||||
sprintf(
|
||||
primary_url3, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
snprintf(
|
||||
primary_url3, sizeof(primary_url3), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
SC_NETPORT_HUB_SERVER_PORT);
|
||||
sprintf(
|
||||
secondary_url3, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
snprintf(
|
||||
secondary_url3, sizeof(secondary_url3), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
SC_NETPORT_HUB_SERVER_PORT);
|
||||
sprintf(
|
||||
primary_url2, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
snprintf(
|
||||
primary_url2, sizeof(primary_url2), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
SC_NETPORT_HUB_SERVER_PORT);
|
||||
sprintf(
|
||||
secondary_url2, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
snprintf(
|
||||
secondary_url2, sizeof(secondary_url2), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
SC_NETPORT_HUB_SERVER_PORT);
|
||||
sprintf(
|
||||
primary_url1, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
snprintf(
|
||||
primary_url1, sizeof(primary_url1), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
SC_NETPORT_HUB_SERVER_PORT);
|
||||
sprintf(
|
||||
secondary_url1, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
snprintf(
|
||||
secondary_url1, sizeof(secondary_url1), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
SC_NETPORT_HUB_SERVER_PORT);
|
||||
sprintf(
|
||||
direct_url, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
snprintf(
|
||||
direct_url, sizeof(direct_url), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
SC_NETPORT_DIRECT_SERVER_PORT);
|
||||
|
||||
bacfile_init();
|
||||
@@ -10709,9 +10720,11 @@ static void test_sc_datalink_failed_requests(void)
|
||||
memset(&uuid2, 0x43, sizeof(uuid2));
|
||||
memset(&vmac2, 0x42, sizeof(vmac2));
|
||||
|
||||
sprintf(primary_url2, "wss://%s:%d", BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
secondary_url2, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
snprintf(
|
||||
primary_url2, sizeof(primary_url2), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
secondary_url2, sizeof(secondary_url2), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
SC_NETPORT_HUB_SERVER_PORT);
|
||||
|
||||
bacfile_init();
|
||||
|
||||
@@ -11268,8 +11268,12 @@ static void test_node_start_stop(void)
|
||||
char primary_url[128] = { 0 };
|
||||
char secondary_url[128] = { 0 };
|
||||
|
||||
sprintf(primary_url, "wss://%s:%d", BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
sprintf(secondary_url, "wss://%s:%d", BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
primary_url, sizeof(primary_url), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
secondary_url, sizeof(secondary_url), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
|
||||
conf.ca_cert_chain = ca_cert;
|
||||
conf.ca_cert_chain_size = sizeof(ca_cert);
|
||||
@@ -11375,18 +11379,18 @@ static void test_node_duplicated_vmac(void)
|
||||
memset(&node_uuid2, 0x3, sizeof(node_uuid2));
|
||||
memset(&node_vmac2, 0x2, sizeof(node_vmac2));
|
||||
|
||||
sprintf(
|
||||
node_primary_url, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_HUB_PORT2);
|
||||
sprintf(
|
||||
node_secondary_url, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_HUB_PORT2);
|
||||
sprintf(
|
||||
node_primary_url2, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_HUB_PORT);
|
||||
sprintf(
|
||||
node_secondary_url2, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
snprintf(
|
||||
node_primary_url, sizeof(node_primary_url), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_NODE_LOCAL_HUB_PORT2);
|
||||
snprintf(
|
||||
node_secondary_url, sizeof(node_secondary_url), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_NODE_LOCAL_HUB_PORT2);
|
||||
snprintf(
|
||||
node_primary_url2, sizeof(node_primary_url2), BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_HUB_PORT);
|
||||
snprintf(
|
||||
node_secondary_url2, sizeof(node_secondary_url2), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_NODE_LOCAL_HUB_PORT);
|
||||
|
||||
conf.ca_cert_chain = ca_cert;
|
||||
conf.ca_cert_chain_size = sizeof(ca_cert);
|
||||
@@ -11476,10 +11480,12 @@ static void test_node_duplicated_vmac(void)
|
||||
memset(&node_uuid2, 0x3, sizeof(node_uuid2));
|
||||
memset(&node_vmac2, 0x2, sizeof(node_vmac2));
|
||||
|
||||
sprintf(
|
||||
url1, "wss://%s:%d", BACNET_LOCALHOST, BACNET_NODE_LOCAL_DIRECT_PORT);
|
||||
sprintf(
|
||||
url2, "wss://%s:%d", BACNET_LOCALHOST, BACNET_NODE_LOCAL_DIRECT_PORT);
|
||||
snprintf(
|
||||
url1, sizeof(url1), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_DIRECT_PORT);
|
||||
snprintf(
|
||||
url2, sizeof(url2), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_DIRECT_PORT);
|
||||
|
||||
conf.primaryURL = NULL;
|
||||
conf.failoverURL = NULL;
|
||||
@@ -11560,18 +11566,18 @@ static void test_node_send(void)
|
||||
memset(&node_uuid3, 0x5, sizeof(node_uuid3));
|
||||
memset(&node_vmac3, 0x6, sizeof(node_vmac3));
|
||||
|
||||
sprintf(
|
||||
node_primary_url, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_HUB_PORT);
|
||||
sprintf(
|
||||
node_secondary_url, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_HUB_PORT2);
|
||||
sprintf(
|
||||
node_primary_url2, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_HUB_PORT);
|
||||
sprintf(
|
||||
node_secondary_url2, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_HUB_PORT2);
|
||||
snprintf(
|
||||
node_primary_url, sizeof(node_primary_url), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_NODE_LOCAL_HUB_PORT);
|
||||
snprintf(
|
||||
node_secondary_url, sizeof(node_secondary_url), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_NODE_LOCAL_HUB_PORT2);
|
||||
snprintf(
|
||||
node_primary_url2, sizeof(node_primary_url2), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_NODE_LOCAL_HUB_PORT);
|
||||
snprintf(
|
||||
node_secondary_url2, sizeof(node_secondary_url2), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_NODE_LOCAL_HUB_PORT2);
|
||||
|
||||
conf.ca_cert_chain = ca_cert;
|
||||
conf.ca_cert_chain_size = sizeof(ca_cert);
|
||||
@@ -11805,12 +11811,12 @@ static void test_node_local_hub_function(void)
|
||||
memset(&node_vmac3, 0x6, sizeof(node_vmac3));
|
||||
memset(&broadcast.address[0], 0xff, sizeof(broadcast.address));
|
||||
|
||||
sprintf(
|
||||
node_primary_url, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_HUB_PORT);
|
||||
sprintf(
|
||||
node_secondary_url, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_HUB_PORT);
|
||||
snprintf(
|
||||
node_primary_url, sizeof(node_primary_url), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_NODE_LOCAL_HUB_PORT);
|
||||
snprintf(
|
||||
node_secondary_url, sizeof(node_secondary_url), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_NODE_LOCAL_HUB_PORT);
|
||||
|
||||
conf.ca_cert_chain = ca_cert;
|
||||
conf.ca_cert_chain_size = sizeof(ca_cert);
|
||||
@@ -12007,23 +12013,24 @@ static void test_node_direct_connection(void)
|
||||
memset(&node_vmac3, 0x6, sizeof(node_vmac2));
|
||||
memset(&broadcast.address[0], 0xff, sizeof(broadcast.address));
|
||||
|
||||
sprintf(
|
||||
node_primary_url, "wss://%s:%d", BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
node_secondary_url, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
node_primary_url2, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_HUB_PORT);
|
||||
sprintf(
|
||||
node_secondary_url2, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
node_primary_url3, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_HUB_PORT);
|
||||
sprintf(
|
||||
node_secondary_url3, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_primary_url, sizeof(node_primary_url), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_secondary_url, sizeof(node_secondary_url), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_primary_url2, sizeof(node_primary_url2), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_NODE_LOCAL_HUB_PORT);
|
||||
snprintf(
|
||||
node_secondary_url2, sizeof(node_secondary_url2), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_primary_url3, sizeof(node_primary_url3), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_NODE_LOCAL_HUB_PORT);
|
||||
snprintf(
|
||||
node_secondary_url3, sizeof(node_secondary_url3), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
|
||||
conf.ca_cert_chain = ca_cert;
|
||||
conf.ca_cert_chain_size = sizeof(ca_cert);
|
||||
@@ -12054,8 +12061,8 @@ static void test_node_direct_connection(void)
|
||||
conf.direct_connection_accept_uris_len = 0;
|
||||
conf.event_func = node_event;
|
||||
|
||||
sprintf(
|
||||
uris, "wss://%s:%d wss://%s:%d", BACNET_LOCALHOST,
|
||||
snprintf(
|
||||
uris, sizeof(uris), "wss://%s:%d wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_DIRECT_PORT2, BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_DIRECT_PORT2);
|
||||
conf2.ca_cert_chain = ca_cert;
|
||||
@@ -12262,9 +12269,12 @@ static void test_node_direct_connection(void)
|
||||
wait_for_connection_to_hub(&node_ev3, node3);
|
||||
wait_for_connection_to_hub(&node_ev2, node2);
|
||||
|
||||
sprintf(url1, "wss://%s:%d", BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
url2, "wss://%s:%d", BACNET_LOCALHOST, BACNET_NODE_LOCAL_DIRECT_PORT2);
|
||||
snprintf(
|
||||
url1, sizeof(url1), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
url2, sizeof(url2), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_DIRECT_PORT2);
|
||||
ret = bsc_node_connect_direct(node3, NULL, urls, 2);
|
||||
zassert_equal(ret == BSC_SC_SUCCESS, true, 0);
|
||||
zassert_equal(
|
||||
@@ -12421,11 +12431,12 @@ static void test_node_direct_connection(void)
|
||||
wait_specific_node_ev(&node_ev2, BSC_NODE_EVENT_STOPPED, node2);
|
||||
|
||||
// bad case test (when one url in bsc_node_connect_direct() is incorrect)
|
||||
sprintf(
|
||||
url1, "w3sdfsdfsdfss://%s:%d", BACNET_LOCALHOST,
|
||||
snprintf(
|
||||
url1, sizeof(url1), "w3sdfsdfsdfss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_DIRECT_PORT2);
|
||||
snprintf(
|
||||
url2, sizeof(url2), "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_DIRECT_PORT2);
|
||||
sprintf(
|
||||
url2, "wss://%s:%d", BACNET_LOCALHOST, BACNET_NODE_LOCAL_DIRECT_PORT2);
|
||||
ret = bsc_node_start(node);
|
||||
zassert_equal(ret == BSC_SC_SUCCESS, true, 0);
|
||||
zassert_equal(
|
||||
@@ -12474,11 +12485,11 @@ static void test_node_direct_connection(void)
|
||||
|
||||
// bad URLs test
|
||||
|
||||
sprintf(
|
||||
url1, "w3sdfsdfsdfss://%s:%d", BACNET_LOCALHOST,
|
||||
snprintf(
|
||||
url1, sizeof(url1), "w3sdfsdfsdfss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_DIRECT_PORT2);
|
||||
sprintf(
|
||||
url2, "wssdfsdfsdfs://%s:%d", BACNET_LOCALHOST,
|
||||
snprintf(
|
||||
url2, sizeof(url2), "wssdfsdfsdfs://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_DIRECT_PORT2);
|
||||
ret = bsc_node_init(&conf, &node);
|
||||
zassert_equal(ret == BSC_SC_SUCCESS, true, 0);
|
||||
@@ -12514,21 +12525,24 @@ static void test_node_direct_connection(void)
|
||||
ret = bsc_node_deinit(node3);
|
||||
zassert_equal(ret == BSC_SC_SUCCESS, true, 0);
|
||||
|
||||
sprintf(
|
||||
node_primary_url, "wss://%s:%d", BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
node_secondary_url, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
node_primary_url2, "wss://%s:%d", BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
node_secondary_url2, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
node_primary_url3, "wss://%s:%d", BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
node_secondary_url3, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_primary_url, sizeof(node_primary_url), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_secondary_url, sizeof(node_secondary_url), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_primary_url2, sizeof(node_primary_url2), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_secondary_url2, sizeof(node_secondary_url2), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_primary_url3, sizeof(node_primary_url3), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_secondary_url3, sizeof(node_secondary_url3), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
|
||||
ret = bsc_node_init(&conf, &node);
|
||||
zassert_equal(ret == BSC_SC_SUCCESS, true, 0);
|
||||
@@ -12566,23 +12580,24 @@ static void test_node_direct_connection(void)
|
||||
conf.address_resolution_freshness_timeout_s = 1;
|
||||
conf2.address_resolution_freshness_timeout_s = 1;
|
||||
conf3.address_resolution_freshness_timeout_s = 1;
|
||||
sprintf(
|
||||
node_primary_url, "wss://%s:%d", BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
node_secondary_url, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
node_primary_url2, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_HUB_PORT);
|
||||
sprintf(
|
||||
node_secondary_url2, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
node_primary_url3, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_HUB_PORT);
|
||||
sprintf(
|
||||
node_secondary_url3, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_primary_url, sizeof(node_primary_url), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_secondary_url, sizeof(node_secondary_url), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_primary_url2, sizeof(node_primary_url2), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_NODE_LOCAL_HUB_PORT);
|
||||
snprintf(
|
||||
node_secondary_url2, sizeof(node_secondary_url2), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_primary_url3, sizeof(node_primary_url3), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_NODE_LOCAL_HUB_PORT);
|
||||
snprintf(
|
||||
node_secondary_url3, sizeof(node_secondary_url3), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
ret = bsc_node_init(&conf, &node);
|
||||
zassert_equal(ret == BSC_SC_SUCCESS, true, 0);
|
||||
ret = bsc_node_init(&conf2, &node2);
|
||||
@@ -12701,23 +12716,24 @@ static void test_node_direct_connection_unsupported(void)
|
||||
memset(&node_uuid3, 0x5, sizeof(node_uuid2));
|
||||
memset(&node_vmac3, 0x6, sizeof(node_vmac2));
|
||||
|
||||
sprintf(
|
||||
node_primary_url, "wss://%s:%d", BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
node_secondary_url, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
node_primary_url2, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_HUB_PORT);
|
||||
sprintf(
|
||||
node_secondary_url2, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
node_primary_url3, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_HUB_PORT);
|
||||
sprintf(
|
||||
node_secondary_url3, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_primary_url, sizeof(node_primary_url), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_secondary_url, sizeof(node_secondary_url), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_primary_url2, sizeof(node_primary_url2), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_NODE_LOCAL_HUB_PORT);
|
||||
snprintf(
|
||||
node_secondary_url2, sizeof(node_secondary_url2), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_primary_url3, sizeof(node_primary_url3), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_NODE_LOCAL_HUB_PORT);
|
||||
snprintf(
|
||||
node_secondary_url3, sizeof(node_secondary_url3), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
|
||||
conf.ca_cert_chain = ca_cert;
|
||||
conf.ca_cert_chain_size = sizeof(ca_cert);
|
||||
@@ -12748,8 +12764,8 @@ static void test_node_direct_connection_unsupported(void)
|
||||
conf.direct_connection_accept_uris_len = 0;
|
||||
conf.event_func = node_event;
|
||||
|
||||
sprintf(
|
||||
uris, "wss://%s:%d wss://%s:%d", BACNET_LOCALHOST,
|
||||
snprintf(
|
||||
uris, sizeof(uris), "wss://%s:%d wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_DIRECT_PORT2, BACNET_LOCALHOST,
|
||||
BACNET_NODE_LOCAL_DIRECT_PORT2);
|
||||
conf2.ca_cert_chain = ca_cert;
|
||||
@@ -12917,11 +12933,12 @@ static void test_node_bad_cases(void)
|
||||
memset(big_url, 0x22, sizeof(big_url) - 1);
|
||||
memset(t, 0x22, sizeof(t) - 1);
|
||||
|
||||
sprintf(
|
||||
node_primary_url, "wss://%s:%d", BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
sprintf(
|
||||
node_secondary_url, "wss://%s:%d", BACNET_LOCALHOST,
|
||||
BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_primary_url, sizeof(node_primary_url), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
snprintf(
|
||||
node_secondary_url, sizeof(node_secondary_url), "wss://%s:%d",
|
||||
BACNET_LOCALHOST, BACNET_CLOSED_PORT);
|
||||
|
||||
conf.ca_cert_chain = ca_cert;
|
||||
conf.ca_cert_chain_size = sizeof(ca_cert);
|
||||
|
||||
@@ -9942,8 +9942,8 @@ static void test_simple(void)
|
||||
memset(&server_vmac, 0x2, sizeof(server_vmac));
|
||||
memset(&client_uuid, 0x3, sizeof(server_uuid));
|
||||
memset(&client_vmac, 0x4, sizeof(server_vmac));
|
||||
sprintf(
|
||||
url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
snprintf(
|
||||
url, sizeof(url), "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT);
|
||||
|
||||
bsc_init_ctx_cfg(
|
||||
@@ -10073,8 +10073,8 @@ static void test_duplicated_vmac_on_server(void)
|
||||
memset(&client_uuid2, 0x4, sizeof(server_uuid));
|
||||
memset(&client_vmac2, 0x5, sizeof(server_vmac));
|
||||
|
||||
sprintf(
|
||||
url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
snprintf(
|
||||
url, sizeof(url), "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT);
|
||||
|
||||
bsc_init_ctx_cfg(
|
||||
@@ -10177,8 +10177,8 @@ static void test_duplicated_vmac_on_server2(void)
|
||||
memset(&client_uuid, 0x3, sizeof(server_uuid));
|
||||
memset(&client_vmac, 0x2, sizeof(server_vmac));
|
||||
|
||||
sprintf(
|
||||
url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
snprintf(
|
||||
url, sizeof(url), "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT);
|
||||
|
||||
bsc_init_ctx_cfg(
|
||||
@@ -10274,8 +10274,8 @@ static void test_duplicated_uuid_on_server(void)
|
||||
memset(&client_uuid2, 0x3, sizeof(server_uuid));
|
||||
memset(&client_vmac2, 0x5, sizeof(server_vmac));
|
||||
|
||||
sprintf(
|
||||
url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
snprintf(
|
||||
url, sizeof(url), "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT);
|
||||
|
||||
bsc_init_ctx_cfg(
|
||||
@@ -10372,8 +10372,8 @@ static void test_bad_params(void)
|
||||
memset(&server_vmac, 0x2, sizeof(server_vmac));
|
||||
memset(&client_uuid, 0x3, sizeof(server_uuid));
|
||||
memset(&client_vmac, 0x4, sizeof(server_vmac));
|
||||
sprintf(
|
||||
url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
snprintf(
|
||||
url, sizeof(url), "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT);
|
||||
|
||||
init_sock_ev(&srv_ev);
|
||||
@@ -10528,8 +10528,8 @@ static void test_error_case1(void)
|
||||
memset(&server_vmac, 0x2, sizeof(server_vmac));
|
||||
memset(&client_uuid, 0x3, sizeof(server_uuid));
|
||||
memset(&client_vmac, 0x4, sizeof(server_vmac));
|
||||
sprintf(
|
||||
url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
snprintf(
|
||||
url, sizeof(url), "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT);
|
||||
|
||||
bsc_init_ctx_cfg(
|
||||
|
||||
@@ -2770,7 +2770,9 @@ static void test_ADDRESS_RESOLUTION_ACK(void)
|
||||
const char *err_desc = NULL;
|
||||
|
||||
web_socket_uris[0] = 0;
|
||||
sprintf(web_socket_uris, "%s %s", "web_socket_uri1", "web_socket_uri2");
|
||||
snprintf(
|
||||
web_socket_uris, sizeof(web_socket_uris), "%s %s", "web_socket_uri1",
|
||||
"web_socket_uri2");
|
||||
memset(&origin.address, 0x91, BVLC_SC_VMAC_SIZE);
|
||||
memset(&dest.address, 0xef, BVLC_SC_VMAC_SIZE);
|
||||
|
||||
|
||||
@@ -1540,19 +1540,19 @@ static void test_hub_connector_url(bool primary)
|
||||
memset(npdu, 0x11, sizeof(npdu));
|
||||
|
||||
if (primary) {
|
||||
sprintf(
|
||||
primary_url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT);
|
||||
sprintf(
|
||||
secondary_url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
snprintf(
|
||||
primary_url, sizeof(primary_url), "wss://%s:%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT);
|
||||
snprintf(
|
||||
secondary_url, sizeof(secondary_url), "wss://%s:%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
} else {
|
||||
sprintf(
|
||||
primary_url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
sprintf(
|
||||
secondary_url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT);
|
||||
snprintf(
|
||||
primary_url, sizeof(primary_url), "wss://%s:%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
snprintf(
|
||||
secondary_url, sizeof(secondary_url), "wss://%s:%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT);
|
||||
}
|
||||
|
||||
init_hubc_ev(&hubc);
|
||||
@@ -1701,12 +1701,12 @@ static void test_hub_connector_bad_primary_url(void)
|
||||
memset(&hubc_uuid, 0x3, sizeof(hubc_uuid));
|
||||
memset(&hubc_vmac, 0x4, sizeof(hubc_vmac));
|
||||
|
||||
sprintf(
|
||||
primary_url, "wsssdsdfsdf://sdsdf%s:sdfsdf%d",
|
||||
snprintf(
|
||||
primary_url, sizeof(primary_url), "wsssdsdfsdf://sdsdf%s:sdfsdf%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT);
|
||||
snprintf(
|
||||
secondary_url, sizeof(secondary_url), "wss://%s:%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT);
|
||||
sprintf(
|
||||
secondary_url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT);
|
||||
|
||||
init_hubc_ev(&hubc);
|
||||
init_hubf_ev(&hubf);
|
||||
@@ -1780,12 +1780,12 @@ static void test_hub_bad_params(void)
|
||||
memset(&hubc_vmac, 0x4, sizeof(hubc_vmac));
|
||||
memset(&hubc_uuid2, 0x5, sizeof(hubc_uuid));
|
||||
memset(&hubc_vmac2, 0x6, sizeof(hubc_vmac));
|
||||
sprintf(
|
||||
primary_url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT);
|
||||
sprintf(
|
||||
secondary_url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
snprintf(
|
||||
primary_url, sizeof(primary_url), "wss://%s:%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT);
|
||||
snprintf(
|
||||
secondary_url, sizeof(secondary_url), "wss://%s:%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
|
||||
init_hubc_ev(&hubc);
|
||||
|
||||
@@ -1824,12 +1824,13 @@ static void test_hub_bad_params(void)
|
||||
hub_connector_event, &hubc_uuid, &hubc_h);
|
||||
zassert_equal(ret, BSC_SC_BAD_PARAM, 0);
|
||||
|
||||
sprintf(
|
||||
primary_url, "wsssdsdfsdf://sdsdf%s:sdfsdf%d",
|
||||
snprintf(
|
||||
primary_url, sizeof(primary_url), "wsssdsdfsdf://sdsdf%s:sdfsdf%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT);
|
||||
sprintf(
|
||||
secondary_url, "wss23413r234://sdfsdfsdf%s:r234%2d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
snprintf(
|
||||
secondary_url, sizeof(secondary_url),
|
||||
"wss23413r234://sdfsdfsdf%s:r234%2d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
ret = bsc_hub_connector_start(
|
||||
ca_cert, sizeof(ca_cert), client_cert, sizeof(client_cert), CLIENT_KEY,
|
||||
sizeof(CLIENT_KEY), &hubc_uuid, &hubc_vmac, MAX_BVLC_LEN, MAX_NDPU_LEN,
|
||||
@@ -1841,13 +1842,13 @@ static void test_hub_bad_params(void)
|
||||
hub_connector_event, &hubc_uuid, &hubc_h);
|
||||
zassert_equal(ret, BSC_SC_BAD_PARAM, 0);
|
||||
|
||||
sprintf(
|
||||
primary_url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT);
|
||||
snprintf(
|
||||
primary_url, sizeof(primary_url), "wss://%s:%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT);
|
||||
|
||||
sprintf(
|
||||
secondary_url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
snprintf(
|
||||
secondary_url, sizeof(secondary_url), "wss://%s:%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
|
||||
ret = bsc_hub_connector_start(
|
||||
ca_cert, sizeof(ca_cert), client_cert, sizeof(client_cert), CLIENT_KEY,
|
||||
@@ -1941,12 +1942,12 @@ static void test_hub_connector_reconnect(void)
|
||||
memset(&hubc_uuid, 0x5, sizeof(hubc_uuid));
|
||||
memset(&hubc_vmac, 0x6, sizeof(hubc_vmac));
|
||||
|
||||
sprintf(
|
||||
primary_url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT);
|
||||
sprintf(
|
||||
secondary_url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
snprintf(
|
||||
primary_url, sizeof(primary_url), "wss://%s:%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT);
|
||||
snprintf(
|
||||
secondary_url, sizeof(secondary_url), "wss://%s:%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
|
||||
init_hubc_ev(&hubc);
|
||||
init_hubf_ev(&hubf);
|
||||
@@ -2093,12 +2094,12 @@ static void test_hub_connector_duplicated_vmac(void)
|
||||
memset(&hubc_uuid, 0x3, sizeof(hubc_uuid));
|
||||
memset(&hubc_vmac, 0x2, sizeof(hubc_vmac));
|
||||
|
||||
sprintf(
|
||||
primary_url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT);
|
||||
sprintf(
|
||||
secondary_url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
snprintf(
|
||||
primary_url, sizeof(primary_url), "wss://%s:%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT);
|
||||
snprintf(
|
||||
secondary_url, sizeof(secondary_url), "wss://%s:%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
|
||||
init_hubc_ev(&hubc);
|
||||
init_hubf_ev(&hubf);
|
||||
@@ -2248,12 +2249,12 @@ static void test_hub_function_duplicated_uuid(void)
|
||||
memset(&hubc_uuid2, 0x3, sizeof(hubc_uuid2));
|
||||
memset(&hubc_vmac2, 0x6, sizeof(hubc_vmac2));
|
||||
|
||||
sprintf(
|
||||
primary_url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT);
|
||||
sprintf(
|
||||
secondary_url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
snprintf(
|
||||
primary_url, sizeof(primary_url), "wss://%s:%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT);
|
||||
snprintf(
|
||||
secondary_url, sizeof(secondary_url), "wss://%s:%d",
|
||||
BACNET_WEBSOCKET_SERVER_ADDR, BACNET_WEBSOCKET_SERVER_PORT2);
|
||||
|
||||
init_hubc_ev(&hubc);
|
||||
init_hubf_ev(&hubf);
|
||||
|
||||
@@ -8143,8 +8143,8 @@ static void test_simple(void)
|
||||
memset(&srv_ctx, 0, sizeof(srv_ctx));
|
||||
srv_ctx.ev = -1;
|
||||
srv_ctx.h = BSC_WEBSOCKET_INVALID_HANDLE;
|
||||
sprintf(
|
||||
url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
snprintf(
|
||||
url, sizeof(url), "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT);
|
||||
|
||||
ret = bws_srv_start(
|
||||
@@ -8211,10 +8211,9 @@ static void test_onoff(void)
|
||||
memset(&srv_ctx, 0, sizeof(srv_ctx));
|
||||
srv_ctx.ev = -1;
|
||||
srv_ctx.h = BSC_WEBSOCKET_INVALID_HANDLE;
|
||||
sprintf(
|
||||
url, "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
snprintf(
|
||||
url, sizeof(url), "wss://%s:%d", BACNET_WEBSOCKET_SERVER_ADDR,
|
||||
BACNET_WEBSOCKET_SERVER_PORT);
|
||||
|
||||
ret = bws_srv_start(
|
||||
BSC_WEBSOCKET_HUB_PROTOCOL, BACNET_WEBSOCKET_SERVER_PORT, NULL, ca_cert,
|
||||
sizeof(ca_cert), server_cert, sizeof(server_cert), server_key,
|
||||
|
||||
Reference in New Issue
Block a user