Bugfix/router mstp builds (#630)
* Fixed example app router-ipv6 to build under ports/win32 * Fixed example app router-mstp to build under ports/win32 with MinGW * Added win32 builds of router-ipv6 and router-mstp to the Github pipeline
This commit is contained in:
@@ -38,6 +38,15 @@ endif
|
||||
ifeq (${BACDL},none)
|
||||
BACDL_DEFINE=-DBACDL_NONE=1
|
||||
endif
|
||||
ifeq (${BACDL},bip-mstp)
|
||||
BACDL_DEFINE=-DBACDL_ROUTER=1
|
||||
endif
|
||||
ifeq (${BACDL},bip-bip6)
|
||||
BACDL_DEFINE=-DBACDL_ROUTER=1
|
||||
endif
|
||||
ifeq (${BACDL},all)
|
||||
BACDL_DEFINE=-DBACDL_ALL=1
|
||||
endif
|
||||
ifeq (${BACDL},)
|
||||
BACDL_DEFINE ?= -DBACDL_BIP=1
|
||||
BBMD_DEFINE ?= -DBBMD_ENABLED=1 -DBBMD_CLIENT_ENABLED
|
||||
@@ -418,10 +427,18 @@ router:
|
||||
router-ipv6: $(BACNET_LIB_TARGET)
|
||||
$(MAKE) -B -C $@
|
||||
|
||||
.PHONY: router-ipv6-clean
|
||||
router-ipv6-clean:
|
||||
$(MAKE) -C router-ipv6 clean
|
||||
|
||||
.PHONY: router-mstp
|
||||
router-mstp: $(BACNET_LIB_TARGET)
|
||||
$(MAKE) -B -C $@
|
||||
|
||||
.PHONY: router-mstp-clean
|
||||
router-mstp-clean:
|
||||
$(MAKE) -C router-mstp clean
|
||||
|
||||
.PHONY: fuzz-libfuzzer
|
||||
fuzz-libfuzzer: $(BACNET_LIB_TARGET)
|
||||
$(MAKE) -B -C $@
|
||||
|
||||
+14
-6
@@ -23,6 +23,9 @@ INCLUDES = -I$(BACNET_SRC_DIR)
|
||||
CFLAGS += $(WARNINGS) $(DEBUGGING) $(OPTIMIZATION) $(BACNET_DEFINES) $(INCLUDES)
|
||||
CFLAGS += -ffunction-sections -fdata-sections
|
||||
|
||||
APPS_ENVIRONMENT_SRC = \
|
||||
$(BACNET_SRC_DIR)/bacnet/datalink/dlenv.c
|
||||
|
||||
PORT_ARCNET_SRC = \
|
||||
$(BACNET_PORT_DIR)/arcnet.c
|
||||
|
||||
@@ -60,19 +63,19 @@ PORT_NONE_SRC = \
|
||||
$(BACNET_SRC_DIR)/bacnet/datalink/datalink.c
|
||||
|
||||
ifeq (${BACDL_DEFINE},-DBACDL_BIP=1)
|
||||
BACNET_PORT_SRC = ${PORT_BIP_SRC}
|
||||
BACNET_PORT_SRC = ${PORT_BIP_SRC} ${APPS_ENVIRONMENT_SRC}
|
||||
endif
|
||||
ifeq (${BACDL_DEFINE},-DBACDL_BIP6=1)
|
||||
BACNET_PORT_SRC = ${PORT_BIP6_SRC}
|
||||
BACNET_PORT_SRC = ${PORT_BIP6_SRC} ${APPS_ENVIRONMENT_SRC}
|
||||
endif
|
||||
ifeq (${BACDL_DEFINE},-DBACDL_MSTP=1)
|
||||
BACNET_PORT_SRC = ${PORT_MSTP_SRC}
|
||||
BACNET_PORT_SRC = ${PORT_MSTP_SRC} ${APPS_ENVIRONMENT_SRC}
|
||||
endif
|
||||
ifeq (${BACDL_DEFINE},-DBACDL_ARCNET=1)
|
||||
BACNET_PORT_SRC = ${PORT_ARCNET_SRC}
|
||||
BACNET_PORT_SRC = ${PORT_ARCNET_SRC} ${APPS_ENVIRONMENT_SRC}
|
||||
endif
|
||||
ifeq (${BACDL_DEFINE},-DBACDL_ETHERNET=1)
|
||||
BACNET_PORT_SRC = ${PORT_ETHERNET_SRC}
|
||||
BACNET_PORT_SRC = ${PORT_ETHERNET_SRC} ${APPS_ENVIRONMENT_SRC}
|
||||
endif
|
||||
ifeq (${BACDL_DEFINE},-DBACDL_NONE=1)
|
||||
BACNET_PORT_SRC = ${PORT_NONE_SRC}
|
||||
@@ -80,12 +83,17 @@ endif
|
||||
ifeq (${BACDL_DEFINE},-DBACDL_ALL=1)
|
||||
BACNET_PORT_SRC = ${PORT_ALL_SRC}
|
||||
endif
|
||||
ifeq (${BACDL},bip-mstp)
|
||||
BACNET_PORT_SRC = ${PORT_BIP_SRC} ${PORT_MSTP_SRC}
|
||||
endif
|
||||
ifeq (${BACDL},bip-bip6)
|
||||
BACNET_PORT_SRC = ${PORT_BIP_SRC} ${PORT_BIP6_SRC}
|
||||
endif
|
||||
ifneq (${BACDL_DEFINE},)
|
||||
CFLAGS += ${BACDL_DEFINE}
|
||||
endif
|
||||
|
||||
BACNET_PORT_SRC += \
|
||||
$(BACNET_SRC_DIR)/bacnet/datalink/dlenv.c \
|
||||
$(BACNET_PORT_DIR)/mstimer-init.c \
|
||||
$(BACNET_PORT_DIR)/datetime-init.c
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# CC = gcc
|
||||
|
||||
# Executable file name
|
||||
TARGET = bacroute
|
||||
TARGET = router-ipv6
|
||||
|
||||
TARGET_BIN = ${TARGET}$(TARGET_EXT)
|
||||
|
||||
@@ -13,49 +13,17 @@ TARGET_BIN = ${TARGET}$(TARGET_EXT)
|
||||
# BACNET_SRC_DIR is defined in common apps Makefile
|
||||
BACNET_OBJECT_DIR = $(BACNET_SRC_DIR)/bacnet/basic/object
|
||||
SRC = main.c \
|
||||
$(BACNET_OBJECT_DIR)/netport.c \
|
||||
$(BACNET_OBJECT_DIR)/client/device-client.c
|
||||
|
||||
PORT_BIP6_SRC = \
|
||||
$(BACNET_PORT_DIR)/bip6.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/datalink/bvlc6.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/basic/bbmd6/h_bbmd6.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/basic/bbmd6/vmac.c
|
||||
|
||||
PORT_BIP_SRC = \
|
||||
$(BACNET_PORT_DIR)/bip-init.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/datalink/bvlc.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/basic/bbmd/h_bbmd.c
|
||||
$(BACNET_SRC_DIR)/bacnet/basic/npdu/s_router.c
|
||||
|
||||
# WARNINGS, DEBUGGING, OPTIMIZATION are defined in common apps Makefile
|
||||
# BACNET_DEFINES is defined in common apps Makefile
|
||||
# put all the flags together
|
||||
INCLUDES = -I$(BACNET_SRC_DIR) -I$(BACNET_PORT_DIR)
|
||||
CFLAGS += $(WARNINGS) $(DEBUGGING) $(OPTIMIZATION) $(BACNET_DEFINES) $(INCLUDES)
|
||||
LFLAGS += -Wl,$(SYSTEM_LIB)
|
||||
ifneq (${BACNET_LIB},)
|
||||
LFLAGS += -Wl,$(BACNET_LIB)
|
||||
endif
|
||||
# GCC dead code removal
|
||||
CFLAGS += -ffunction-sections -fdata-sections
|
||||
LFLAGS += -Wl,--gc-sections
|
||||
|
||||
BACNET_SRC = \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/*.c) \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/*.c) \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/binding/*.c) \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/service/*.c) \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/sys/*.c) \
|
||||
$(BACNET_SRC_DIR)/bacnet/basic/npdu/h_routed_npdu.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/basic/npdu/s_router.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/basic/tsm/tsm.c
|
||||
|
||||
SRCS = ${SRC} ${BACNET_SRC} ${PORT_BIP6_SRC} ${PORT_BIP_SRC}
|
||||
|
||||
SRCS = ${SRC}
|
||||
OBJS += ${SRCS:.c=.o}
|
||||
|
||||
.PHONY: all
|
||||
all: Makefile ${TARGET_BIN}
|
||||
all: ${BACNET_LIB_TARGET} Makefile ${TARGET_BIN}
|
||||
|
||||
${TARGET_BIN}: ${OBJS}
|
||||
${CC} ${PFLAGS} ${OBJS} ${LFLAGS} -o $@
|
||||
|
||||
+26
-3
@@ -62,6 +62,7 @@
|
||||
|
||||
/* current version of the BACnet stack */
|
||||
static const char *BACnet_Version = BACNET_VERSION_TEXT;
|
||||
static uint32_t Device_Instance_Number = BACNET_MAX_INSTANCE;
|
||||
|
||||
/**
|
||||
* 6.6.1 Routing Tables
|
||||
@@ -602,6 +603,8 @@ static void who_is_router_to_network_handler(uint16_t snet,
|
||||
uint16_t network = 0;
|
||||
uint16_t len = 0;
|
||||
|
||||
(void)src;
|
||||
(void)npdu_data;
|
||||
if (npdu) {
|
||||
if (npdu_len >= 2) {
|
||||
len += decode_unsigned16(&npdu[len], &network);
|
||||
@@ -948,12 +951,16 @@ static void my_routing_npdu_handler(
|
||||
uint16_t snet, BACNET_ADDRESS *src, uint8_t *pdu, uint16_t pdu_len)
|
||||
{
|
||||
int apdu_offset = 0;
|
||||
unsigned protocol_version = 0;
|
||||
BACNET_ADDRESS dest = { 0 };
|
||||
BACNET_NPDU_DATA npdu_data = { 0 };
|
||||
|
||||
if (!pdu) {
|
||||
/* no packet */
|
||||
} else if (pdu[0] == BACNET_PROTOCOL_VERSION) {
|
||||
} else {
|
||||
protocol_version = pdu[0];
|
||||
}
|
||||
if (protocol_version == BACNET_PROTOCOL_VERSION) {
|
||||
apdu_offset = bacnet_npdu_decode(pdu, pdu_len, &dest, src, &npdu_data);
|
||||
if (apdu_offset <= 0) {
|
||||
fprintf(stderr, "NPDU: Decoding failed; Discarded!\n");
|
||||
@@ -994,7 +1001,9 @@ static void my_routing_npdu_handler(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* unsupported protocol version */
|
||||
fprintf(
|
||||
stderr, "NPDU: unsupported protocol version %u. Discarded!\n",
|
||||
protocol_version);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -1126,6 +1135,17 @@ static void control_c_hooks(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get the Device object instance number
|
||||
* @return The Device object instance number
|
||||
* @note This is a proxy function to satisfy the BACnet Stack IPv6 port layer
|
||||
* requirements since this application omits a Device object.
|
||||
*/
|
||||
uint32_t Device_Object_Instance_Number(void)
|
||||
{
|
||||
return Device_Instance_Number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Main function of simple router demo.
|
||||
*
|
||||
@@ -1141,8 +1161,11 @@ int main(int argc, char *argv[])
|
||||
time_t current_seconds = 0;
|
||||
uint32_t elapsed_seconds = 0;
|
||||
|
||||
printf("BACnet Simple IP Router Demo\n");
|
||||
printf("BACnet Simple IP to IPv6 Router Demo\n");
|
||||
printf("BACnet Stack Version %s\n", BACnet_Version);
|
||||
if (argc > 1) {
|
||||
Device_Instance_Number = strtol(argv[1], NULL, 0);
|
||||
}
|
||||
datalink_init();
|
||||
atexit(cleanup);
|
||||
control_c_hooks();
|
||||
|
||||
@@ -12,52 +12,17 @@ TARGET_BIN = ${TARGET}$(TARGET_EXT)
|
||||
# BACNET_PORT, BACNET_PORT_DIR, BACNET_PORT_SRC are defined in common Makefile
|
||||
# BACNET_SRC_DIR is defined in common apps Makefile
|
||||
BACNET_OBJECT_DIR = $(BACNET_SRC_DIR)/bacnet/basic/object
|
||||
SRC = main.c \
|
||||
$(BACNET_OBJECT_DIR)/netport.c \
|
||||
$(BACNET_OBJECT_DIR)/client/device-client.c
|
||||
|
||||
PORT_MSTP_SRC = \
|
||||
$(BACNET_PORT_DIR)/rs485.c \
|
||||
$(BACNET_PORT_DIR)/dlmstp.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/datalink/cobs.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/datalink/mstp.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/datalink/mstptext.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/datalink/crc.c
|
||||
|
||||
PORT_BIP_SRC = \
|
||||
$(BACNET_PORT_DIR)/bip-init.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/datalink/bvlc.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/basic/bbmd/h_bbmd.c
|
||||
SRC = main.c
|
||||
|
||||
# WARNINGS, DEBUGGING, OPTIMIZATION are defined in common apps Makefile
|
||||
# BACNET_DEFINES is defined in common apps Makefile
|
||||
# put all the flags together
|
||||
INCLUDES = -I$(BACNET_SRC_DIR) -I$(BACNET_PORT_DIR)
|
||||
CFLAGS += $(WARNINGS) $(DEBUGGING) $(OPTIMIZATION) $(BACNET_DEFINES) $(INCLUDES)
|
||||
LFLAGS += -Wl,$(SYSTEM_LIB)
|
||||
ifneq (${BACNET_LIB},)
|
||||
LFLAGS += -Wl,$(BACNET_LIB)
|
||||
endif
|
||||
# GCC dead code removal
|
||||
CFLAGS += -ffunction-sections -fdata-sections
|
||||
LFLAGS += -Wl,--gc-sections
|
||||
|
||||
BACNET_SRC = \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/*.c) \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/*.c) \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/binding/*.c) \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/service/*.c) \
|
||||
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/sys/*.c) \
|
||||
$(BACNET_SRC_DIR)/bacnet/basic/npdu/h_routed_npdu.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/basic/npdu/s_router.c \
|
||||
$(BACNET_SRC_DIR)/bacnet/basic/tsm/tsm.c
|
||||
|
||||
SRCS = ${SRC} ${BACNET_SRC} ${PORT_MSTP_SRC} ${PORT_BIP_SRC}
|
||||
|
||||
SRCS = ${SRC}
|
||||
OBJS += ${SRCS:.c=.o}
|
||||
|
||||
.PHONY: all
|
||||
all: Makefile ${TARGET_BIN}
|
||||
all: ${BACNET_LIB_TARGET} Makefile ${TARGET_BIN}
|
||||
|
||||
${TARGET_BIN}: ${OBJS}
|
||||
${CC} ${PFLAGS} ${OBJS} ${LFLAGS} -o $@
|
||||
|
||||
Reference in New Issue
Block a user