fix BACnet/IP on OS to bind broadcast to specific port (#489)

* Fixes #346 by binding the broadcast socket to the port specific broadcast address rather than INADDR_ANY or INADDR_BROADCAST. Added additional compile and environment options for those who might need them. 

* Changed the define USE_CLASSADDR to BACNET_IP_BROADCAST_USE_CLASSADDR to help manage namespaces.

* Added BACNET_IP_BROADCAST_BIND_ADDR environment variable to override the default broadcast binding address.

---------

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2023-09-10 10:24:18 -05:00
committed by GitHub
parent 0001f85f29
commit 55b8b3d93c
18 changed files with 231 additions and 58 deletions
+5 -1
View File
@@ -39,7 +39,7 @@
#endif
#include <windows.h>
#if (!defined(USE_CLASSADDR) || (USE_CLASSADDR == 0))
#ifndef BACNET_IP_BROADCAST_USE_CLASSADDR
#include <iphlpapi.h>
#if defined(_MSC_VER)
#pragma comment(lib, "IPHLPAPI.lib")
@@ -81,6 +81,10 @@ and globals in favor of more secure versions. */
#define snprintf _snprintf
#endif
BACNET_STACK_EXPORT
extern int bip_get_local_netmask(
struct in_addr *netmask);
#define BACNET_OBJECT_TABLE(table_name, _type, _init, _count, \
_index_to_instance, _valid_instance, _object_name, \
_read_property, _write_property, _RPM_list, \