Made dlpi code fail non-fatally. Patch by Jonathan Abbey

This commit is contained in:
pdw
2003-06-08 18:43:55 +00:00
parent 136a3b30ba
commit a410f23295

View File

@@ -102,7 +102,7 @@ get_addrs_dlpi(char *interface, char if_hw_addr[], struct in_addr *if_ip_addr)
if (cp == NULL) { if (cp == NULL) {
free(devname2); free(devname2);
return -1; goto get_ip_address;
} else { } else {
*cp = '\0'; /* null terminate devname2 right before numeric extension */ *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) { if (errno != ENOENT) {
fprintf(stderr, "Couldn't open %s\n", devname2); fprintf(stderr, "Couldn't open %s\n", devname2);
free(devname2); free(devname2);
return -1; goto get_ip_address;
} else { } else {
if ((fd = open(fulldevpath, O_RDWR)) < 0) { if ((fd = open(fulldevpath, O_RDWR)) < 0) {
fprintf(stderr, "Couldn't open %s\n", fulldevpath); fprintf(stderr, "Couldn't open %s\n", fulldevpath);
free(devname2); 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", fprintf(stderr, "Error, bad length for hardware interface %s -- %d\n",
interface, interface,
dlp->info_ack.dl_addr_length); dlp->info_ack.dl_addr_length);
close(fd);
return -1;
} }
close(fd); close(fd);
get_ip_address:
/* Get the IP address of the interface */ /* Get the IP address of the interface */
#ifdef SIOCGIFADDR #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) { if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) {
fprintf(stderr, "Error getting IP address for interface: %s\n", "ge0"); fprintf(stderr, "Error getting IP address for interface: %s\n", "ge0");
perror("ioctl(SIOCGIFADDR)"); perror("ioctl(SIOCGIFADDR)");
close(fd); } else {
return -1;
}
else {
memcpy(if_ip_addr, &((*(struct sockaddr_in *) &ifr.ifr_addr).sin_addr), sizeof(struct in_addr)); memcpy(if_ip_addr, &((*(struct sockaddr_in *) &ifr.ifr_addr).sin_addr), sizeof(struct in_addr));
got_ip_addr = 2; got_ip_addr = 2;
} }