diff --git a/bacnet-stack/ports/linux/bip-init.c b/bacnet-stack/ports/linux/bip-init.c index 8ccd2d5f..2aad427c 100644 --- a/bacnet-stack/ports/linux/bip-init.c +++ b/bacnet-stack/ports/linux/bip-init.c @@ -180,3 +180,18 @@ bool bip_init( return true; } + +/** Get the netmask of the BACnet/IP's interface via an ioctl() call. + * @param netmask [out] The netmask, in host order. + * @return 0 on success, else the error from the ioctl() call. + */ +int bip_get_local_netmask( + struct in_addr *netmask ) +{ + int rv; + char *ifname = getenv("BACNET_IFACE"); /* will probably be null */ + if ( ifname == NULL ) + ifname = "eth0"; + rv = get_local_address_ioctl(ifname, netmask, SIOCGIFNETMASK); + return rv; +} diff --git a/bacnet-stack/ports/linux/net.h b/bacnet-stack/ports/linux/net.h index e4cf610a..99b04f85 100644 --- a/bacnet-stack/ports/linux/net.h +++ b/bacnet-stack/ports/linux/net.h @@ -94,6 +94,12 @@ #include #include +/** @file linux/net.h Includes Linux network headers. */ + +/* Local helper functions for this port */ +extern int bip_get_local_netmask( + struct in_addr *netmask ); + + #endif -/** @file linux/net.h Includes Linux network headers. */ diff --git a/bacnet-stack/ports/linux/timer.h b/bacnet-stack/ports/linux/timer.h index 8cee552d..153bb1c4 100644 --- a/bacnet-stack/ports/linux/timer.h +++ b/bacnet-stack/ports/linux/timer.h @@ -26,7 +26,7 @@ #include #include -#include // for timeval +#include /* for timeval */ /* Timer Module */ #ifndef MAX_MILLISECOND_TIMERS