From 722b183f9834fdd685bc70d2997cf373c431e8ce Mon Sep 17 00:00:00 2001 From: skarg Date: Sat, 11 Aug 2007 17:16:22 +0000 Subject: [PATCH] Updated handling of port without IP address. --- bacnet-stack/ports/linux/bip-init.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bacnet-stack/ports/linux/bip-init.c b/bacnet-stack/ports/linux/bip-init.c index d672ca5a..e03ebf40 100644 --- a/bacnet-stack/ports/linux/bip-init.c +++ b/bacnet-stack/ports/linux/bip-init.c @@ -71,22 +71,29 @@ static int get_local_address_ioctl(char *ifname, return rv; } - /* on Linux, ifname is eth0, ath0, arc0, and others. */ static void bip_set_interface(char *ifname) { struct in_addr local_address; struct in_addr broadcast_address; + int rv = 0; /* setup local address */ - get_local_address_ioctl(ifname, &local_address, SIOCGIFADDR); + rv = get_local_address_ioctl(ifname, &local_address, SIOCGIFADDR); + if (rv < 0) { + local_address.s_addr = 0; + } bip_set_addr(local_address.s_addr); #ifdef BIP_DEBUG fprintf(stderr, "Interface: %s\n", ifname); fprintf(stderr, "IP Address: %s\n", inet_ntoa(local_address)); #endif /* setup local broadcast address */ - get_local_address_ioctl(ifname, &broadcast_address, SIOCGIFBRDADDR); + rv = get_local_address_ioctl(ifname, &broadcast_address, + SIOCGIFBRDADDR); + if (rv < 0) { + broadcast_address.s_addr = ~0; + } bip_set_broadcast_addr(broadcast_address.s_addr); #ifdef BIP_DEBUG fprintf(stderr, "IP Broadcast Address: %s\n",