Fix malformed build-depends. Update list of bugs to close
[oweals/busybox.git] / route.c
diff --git a/route.c b/route.c
index fe8fd915e48779bdeff518875a28fe10b05d4e3f..9be0027920cec4b2bd35b3caf0ec38fa69cd650f 100644 (file)
--- a/route.c
+++ b/route.c
  * Foundation;  either  version 2 of the License, or  (at
  * your option) any later version.
  *
- * $Id: route.c,v 1.4 2001/02/15 23:00:48 markw Exp $
+ * $Id: route.c,v 1.7 2001/02/20 06:14:08 andersen Exp $
  *
  * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru>
  * busybox style adjustments by Larry Doolittle  <LRDoolittle@lbl.gov>
  * displayroute() format now matches net-tools-1.57/lib/inet_gr.c line 173.
  */
 
-#include "busybox.h"
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
@@ -38,6 +37,7 @@
 #include <getopt.h>
 #include <unistd.h>
 #include <ctype.h>
+#include "busybox.h"
 
 #define _(x) x
 
@@ -361,11 +361,8 @@ void displayroutes(void)
        char sdest[16], sgw[16];
 
 
-       FILE *fp = fopen("/proc/net/route", "r");
+       FILE *fp = xfopen("/proc/net/route", "r");
 
-       if(fp==0) {
-               perror_msg_and_die("/proc/net/route");
-       }
        while( fgets(buff, sizeof(buff), fp) != NULL ) {
                if(nl) {
                        int ifl = 0;
@@ -376,12 +373,11 @@ void displayroutes(void)
                           &d, &g, &flgs, &ref, &use, &metric, &m)!=7) {
                                error_msg_and_die( "Unsuported kernel route format\n");
                        }
-                       dest.s_addr = d;
-                       gw.s_addr   = g;
-                       mask.s_addr = m;
-                       if(nl==1)
-                               printf("Kernel IP routing table\n\
-Destination\tGateway\t\tGenmask\t\tFlags Metric Ref    Use Iface\n");
+                       if(nl==1) {
+                printf("Kernel IP routing table\n"
+"Destination     Gateway         Genmask         Flags Metric Ref    Use Iface\n");
+                       }
+
 
                        ifl = 0;        /* parse flags */
                        if(flgs&1)
@@ -391,6 +387,9 @@ Destination\tGateway\t\tGenmask\t\tFlags Metric Ref    Use Iface\n");
                        if(flgs&4)
                                flags[ifl++]='H';
                        flags[ifl]=0;
+                       dest.s_addr = d;
+                       gw.s_addr   = g;
+                       mask.s_addr = m;
                        strcpy(sdest,  (dest.s_addr==0 ? "default" :
                                        inet_ntoa(dest)));
                        strcpy(sgw,    (gw.s_addr==0   ? "*"       :