Added ability to get "my" netmask from the OS-specific network code, so we could construct subnet broadcasts from source addresses.
(Haven't hooked up code to actually do that, yet.)
This commit is contained in:
@@ -180,3 +180,18 @@ bool bip_init(
|
|||||||
|
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -94,6 +94,12 @@
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
|
||||||
|
/** @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
|
#endif
|
||||||
|
|
||||||
/** @file linux/net.h Includes Linux network headers. */
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/time.h> // for timeval
|
#include <sys/time.h> /* for timeval */
|
||||||
|
|
||||||
/* Timer Module */
|
/* Timer Module */
|
||||||
#ifndef MAX_MILLISECOND_TIMERS
|
#ifndef MAX_MILLISECOND_TIMERS
|
||||||
|
|||||||
Reference in New Issue
Block a user