diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-02-18 20:12:25 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-02-18 20:12:25 +0000 |
commit | f1bbb22dca4d39aa227246f4c2ee90acd7e512a4 (patch) | |
tree | 0a87d7c1639e01870970c55688ab1fd8dd13f1a2 | |
parent | f57a83206398c3d47b8465f05a3c576b2d41187c (diff) | |
download | busybox-w32-f1bbb22dca4d39aa227246f4c2ee90acd7e512a4.tar.gz busybox-w32-f1bbb22dca4d39aa227246f4c2ee90acd7e512a4.tar.bz2 busybox-w32-f1bbb22dca4d39aa227246f4c2ee90acd7e512a4.zip |
A small cleanup by Vladimir
-rw-r--r-- | networking/route.c | 13 | ||||
-rw-r--r-- | route.c | 13 |
2 files changed, 10 insertions, 16 deletions
diff --git a/networking/route.c b/networking/route.c index 9bd4e91d2..d98d9a0b6 100644 --- a/networking/route.c +++ b/networking/route.c | |||
@@ -15,7 +15,7 @@ | |||
15 | * Foundation; either version 2 of the License, or (at | 15 | * Foundation; either version 2 of the License, or (at |
16 | * your option) any later version. | 16 | * your option) any later version. |
17 | * | 17 | * |
18 | * $Id: route.c,v 1.5 2001/02/15 23:31:40 markw Exp $ | 18 | * $Id: route.c,v 1.6 2001/02/18 20:12:25 andersen Exp $ |
19 | * | 19 | * |
20 | * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru> | 20 | * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru> |
21 | * busybox style adjustments by Larry Doolittle <LRDoolittle@lbl.gov> | 21 | * busybox style adjustments by Larry Doolittle <LRDoolittle@lbl.gov> |
@@ -361,11 +361,8 @@ void displayroutes(void) | |||
361 | char sdest[16], sgw[16]; | 361 | char sdest[16], sgw[16]; |
362 | 362 | ||
363 | 363 | ||
364 | FILE *fp = fopen("/proc/net/route", "r"); | 364 | FILE *fp = xfopen("/proc/net/route", "r"); |
365 | 365 | ||
366 | if(fp==0) { | ||
367 | perror_msg_and_die("/proc/net/route"); | ||
368 | } | ||
369 | while( fgets(buff, sizeof(buff), fp) != NULL ) { | 366 | while( fgets(buff, sizeof(buff), fp) != NULL ) { |
370 | if(nl) { | 367 | if(nl) { |
371 | int ifl = 0; | 368 | int ifl = 0; |
@@ -376,9 +373,6 @@ void displayroutes(void) | |||
376 | &d, &g, &flgs, &ref, &use, &metric, &m)!=7) { | 373 | &d, &g, &flgs, &ref, &use, &metric, &m)!=7) { |
377 | error_msg_and_die( "Unsuported kernel route format\n"); | 374 | error_msg_and_die( "Unsuported kernel route format\n"); |
378 | } | 375 | } |
379 | dest.s_addr = d; | ||
380 | gw.s_addr = g; | ||
381 | mask.s_addr = m; | ||
382 | if(nl==1) { | 376 | if(nl==1) { |
383 | printf("Kernel IP routing table\n" | 377 | printf("Kernel IP routing table\n" |
384 | "Destination Gateway Genmask Flags Metric Ref Use Iface\n"); | 378 | "Destination Gateway Genmask Flags Metric Ref Use Iface\n"); |
@@ -393,6 +387,9 @@ void displayroutes(void) | |||
393 | if(flgs&4) | 387 | if(flgs&4) |
394 | flags[ifl++]='H'; | 388 | flags[ifl++]='H'; |
395 | flags[ifl]=0; | 389 | flags[ifl]=0; |
390 | dest.s_addr = d; | ||
391 | gw.s_addr = g; | ||
392 | mask.s_addr = m; | ||
396 | strcpy(sdest, (dest.s_addr==0 ? "default" : | 393 | strcpy(sdest, (dest.s_addr==0 ? "default" : |
397 | inet_ntoa(dest))); | 394 | inet_ntoa(dest))); |
398 | strcpy(sgw, (gw.s_addr==0 ? "*" : | 395 | strcpy(sgw, (gw.s_addr==0 ? "*" : |
@@ -15,7 +15,7 @@ | |||
15 | * Foundation; either version 2 of the License, or (at | 15 | * Foundation; either version 2 of the License, or (at |
16 | * your option) any later version. | 16 | * your option) any later version. |
17 | * | 17 | * |
18 | * $Id: route.c,v 1.5 2001/02/15 23:31:40 markw Exp $ | 18 | * $Id: route.c,v 1.6 2001/02/18 20:12:25 andersen Exp $ |
19 | * | 19 | * |
20 | * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru> | 20 | * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru> |
21 | * busybox style adjustments by Larry Doolittle <LRDoolittle@lbl.gov> | 21 | * busybox style adjustments by Larry Doolittle <LRDoolittle@lbl.gov> |
@@ -361,11 +361,8 @@ void displayroutes(void) | |||
361 | char sdest[16], sgw[16]; | 361 | char sdest[16], sgw[16]; |
362 | 362 | ||
363 | 363 | ||
364 | FILE *fp = fopen("/proc/net/route", "r"); | 364 | FILE *fp = xfopen("/proc/net/route", "r"); |
365 | 365 | ||
366 | if(fp==0) { | ||
367 | perror_msg_and_die("/proc/net/route"); | ||
368 | } | ||
369 | while( fgets(buff, sizeof(buff), fp) != NULL ) { | 366 | while( fgets(buff, sizeof(buff), fp) != NULL ) { |
370 | if(nl) { | 367 | if(nl) { |
371 | int ifl = 0; | 368 | int ifl = 0; |
@@ -376,9 +373,6 @@ void displayroutes(void) | |||
376 | &d, &g, &flgs, &ref, &use, &metric, &m)!=7) { | 373 | &d, &g, &flgs, &ref, &use, &metric, &m)!=7) { |
377 | error_msg_and_die( "Unsuported kernel route format\n"); | 374 | error_msg_and_die( "Unsuported kernel route format\n"); |
378 | } | 375 | } |
379 | dest.s_addr = d; | ||
380 | gw.s_addr = g; | ||
381 | mask.s_addr = m; | ||
382 | if(nl==1) { | 376 | if(nl==1) { |
383 | printf("Kernel IP routing table\n" | 377 | printf("Kernel IP routing table\n" |
384 | "Destination Gateway Genmask Flags Metric Ref Use Iface\n"); | 378 | "Destination Gateway Genmask Flags Metric Ref Use Iface\n"); |
@@ -393,6 +387,9 @@ void displayroutes(void) | |||
393 | if(flgs&4) | 387 | if(flgs&4) |
394 | flags[ifl++]='H'; | 388 | flags[ifl++]='H'; |
395 | flags[ifl]=0; | 389 | flags[ifl]=0; |
390 | dest.s_addr = d; | ||
391 | gw.s_addr = g; | ||
392 | mask.s_addr = m; | ||
396 | strcpy(sdest, (dest.s_addr==0 ? "default" : | 393 | strcpy(sdest, (dest.s_addr==0 ? "default" : |
397 | inet_ntoa(dest))); | 394 | inet_ntoa(dest))); |
398 | strcpy(sgw, (gw.s_addr==0 ? "*" : | 395 | strcpy(sgw, (gw.s_addr==0 ? "*" : |