Merge "Patch ifconfig from toolbox"
diff --git a/ifconfig.c b/ifconfig.c
index 80c0e5c..b524647 100644
--- a/ifconfig.c
+++ b/ifconfig.c
@@ -61,7 +61,7 @@
 {
     struct ifreq ifr;
     int s;
-    unsigned int addr, mask, flags;
+    unsigned int flags;
     char astring[20];
     char mstring[20];
     char *updown, *brdcst, *loopbk, *ppp, *running, *multi;
@@ -82,16 +82,23 @@
 
     if (argc == 0) {
         if (ioctl(s, SIOCGIFADDR, &ifr) < 0) {
-            perror(ifr.ifr_name);
-            return -1;
-        } else
-            addr = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
+            if (errno == EADDRNOTAVAIL || errno == EAFNOSUPPORT) {
+                bzero((char *)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
+            } else {
+                perror(ifr.ifr_name);
+                return -1;
+            }
+        }
+        sprintf(astring, "%s",
+                inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr));
 
         if (ioctl(s, SIOCGIFNETMASK, &ifr) < 0) {
-            perror(ifr.ifr_name);
-            return -1;
-        } else
-            mask = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
+            if (errno != EADDRNOTAVAIL)
+                perror(ifr.ifr_name);
+            bzero((char *)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
+        }
+        sprintf(mstring, "%s",
+                inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr));
 
         if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0) {
             perror(ifr.ifr_name);
@@ -99,16 +106,6 @@
         } else
             flags = ifr.ifr_flags;
 
-        sprintf(astring, "%d.%d.%d.%d",
-                addr & 0xff,
-                ((addr >> 8) & 0xff),
-                ((addr >> 16) & 0xff),
-                ((addr >> 24) & 0xff));
-        sprintf(mstring, "%d.%d.%d.%d",
-                mask & 0xff,
-                ((mask >> 8) & 0xff),
-                ((mask >> 16) & 0xff),
-                ((mask >> 24) & 0xff));
         printf("%s: ip %s mask %s flags [", ifr.ifr_name,
                astring,
                mstring