summaryrefslogtreecommitdiff
path: root/util/idiscover.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/idiscover.c')
-rw-r--r--util/idiscover.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/util/idiscover.c b/util/idiscover.c
index 6dd0225..567cf05 100644
--- a/util/idiscover.c
+++ b/util/idiscover.c
@@ -17,6 +17,7 @@
* 09/20/07 Andy Cress - fixed send/receive thread order
* 07/15/08 Andy Cress - added -r for ping repeats
* 11/21/08 Andy Cress - detect eth intf and broadcast ip addr
+ * 01/04/16 Andy Cress - v1.11, allow 0 if fBroadcastOk (-a)
*/
/*M*
Copyright (c) 2006, Intel Corporation
@@ -157,7 +158,7 @@ int GetFirstIP(uchar *ipaddr, uchar *macadr, char *ipname, char fdb); /*ilan.c*/
/*
* Global variables
*/
-static char * progver = "1.10";
+static char * progver = "1.11";
static char * progname = "idiscover";
static char fdebug = 0;
static char fping = 1;
@@ -504,7 +505,7 @@ int sock_init( char *_interface, char *_startIP, char *_endIP)
strcpy(ifr.ifr_name, devname);
ifr.ifr_addr.sa_family = AF_INET;
if (ioctl(g_sockfd, SIOCGIFADDR, &ifr) >= 0) {
- /* valid IP address, so active interface, use it */
+ /* valid IP address, so active interface, use it */
temp_sockaddr = *((struct sockaddr_in *)&ifr.ifr_addr);
memcpy(&_srcaddr.sin_addr.s_addr, &temp_sockaddr.sin_addr.s_addr,
sizeof(_srcaddr.sin_addr.s_addr));
@@ -575,14 +576,15 @@ int sock_init( char *_interface, char *_startIP, char *_endIP)
if (rv ) {
_startAddr.s_addr = ntohl(_startAddr.s_addr);
if (fdebug) show_ip(_startAddr.s_addr);
- pb = (unsigned char*)&_startAddr.s_addr;
- if (pb[0] < 1)
+ pb = (unsigned char*)&_startAddr.s_addr;
+ if (!fBroadcastOk && (pb[0] < 1) )
printerr("Malformed begin IP: %s\n", _startIP);
else if (!fBroadcastOk && (pb[0] >254) )
printerr("Malformed begin IP: %s\n", _startIP);
else if (fBroadcastOk) {
- val = pb[0] & 0x0f;
- if (val == 0x0f) rv = 0;
+ val = pb[0] & 0x0f;
+ if (val == 0x0f) rv = 0;
+ else if (val == 0x00) rv = 0;
else printerr("Malformed begin broadcast IP: %s\n", _startIP);
} else rv = 0;
} else {
@@ -594,8 +596,8 @@ int sock_init( char *_interface, char *_startIP, char *_endIP)
if (rv ) {
_endAddr.s_addr = ntohl(_endAddr.s_addr);
if (fdebug) show_ip(_endAddr.s_addr);
- pb = (unsigned char*)&_endAddr.s_addr;
- if (pb[0] < 1)
+ pb = (unsigned char*)&_endAddr.s_addr;
+ if (!fBroadcastOk && (pb[0] < 1) )
printerr("Malformed end IP: %s\n", _endIP);
else if (!fBroadcastOk && (pb[0] >254) )
printerr("Malformed end IP: %s\n", _endIP);