diff options
author | pdw <> | 2003-06-08 18:43:55 +0000 |
---|---|---|
committer | pdw <> | 2003-06-08 18:43:55 +0000 |
commit | a410f232957a7480a54d0e2b034106d5d8ce707e (patch) | |
tree | ba52df787f64f1ecb2f796df711be9c3a7dbb69f /addrs_dlpi.c | |
parent | 136a3b30baf0b88632415dfdd3959b0b7b91eb79 (diff) | |
download | iftop-a410f232957a7480a54d0e2b034106d5d8ce707e.zip |
Made dlpi code fail non-fatally. Patch by Jonathan Abbey
Diffstat (limited to 'addrs_dlpi.c')
-rw-r--r-- | addrs_dlpi.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/addrs_dlpi.c b/addrs_dlpi.c index 99e4301..88138b7 100644 --- a/addrs_dlpi.c +++ b/addrs_dlpi.c @@ -102,7 +102,7 @@ get_addrs_dlpi(char *interface, char if_hw_addr[], struct in_addr *if_ip_addr) if (cp == NULL) { free(devname2); - return -1; + goto get_ip_address; } else { *cp = '\0'; /* null terminate devname2 right before numeric extension */ } @@ -114,12 +114,12 @@ get_addrs_dlpi(char *interface, char if_hw_addr[], struct in_addr *if_ip_addr) if (errno != ENOENT) { fprintf(stderr, "Couldn't open %s\n", devname2); free(devname2); - return -1; + goto get_ip_address; } else { if ((fd = open(fulldevpath, O_RDWR)) < 0) { fprintf(stderr, "Couldn't open %s\n", fulldevpath); free(devname2); - return -1; + goto get_ip_address; } } } @@ -167,12 +167,12 @@ get_addrs_dlpi(char *interface, char if_hw_addr[], struct in_addr *if_ip_addr) fprintf(stderr, "Error, bad length for hardware interface %s -- %d\n", interface, dlp->info_ack.dl_addr_length); - close(fd); - return -1; } close(fd); + get_ip_address: + /* Get the IP address of the interface */ #ifdef SIOCGIFADDR @@ -186,10 +186,7 @@ get_addrs_dlpi(char *interface, char if_hw_addr[], struct in_addr *if_ip_addr) if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) { fprintf(stderr, "Error getting IP address for interface: %s\n", "ge0"); perror("ioctl(SIOCGIFADDR)"); - close(fd); - return -1; - } - else { + } else { memcpy(if_ip_addr, &((*(struct sockaddr_in *) &ifr.ifr_addr).sin_addr), sizeof(struct in_addr)); got_ip_addr = 2; } |