aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-09-05 19:32:00 +0000
committerEric Andersen <andersen@codepoet.org>2001-09-05 19:32:00 +0000
commitb9408504f5bc74a71435162e1c86ce7b60b9530b (patch)
tree04985614a1bdd024a152cb6227d6e5a3fbd72ccd
parent3b1525e444b2fb51bfc3e2fa91bf7b8614e22f0c (diff)
downloadbusybox-w32-b9408504f5bc74a71435162e1c86ce7b60b9530b.tar.gz
busybox-w32-b9408504f5bc74a71435162e1c86ce7b60b9530b.tar.bz2
busybox-w32-b9408504f5bc74a71435162e1c86ce7b60b9530b.zip
Another fix from vodz
-rw-r--r--networking/route.c92
-rw-r--r--route.c92
2 files changed, 94 insertions, 90 deletions
diff --git a/networking/route.c b/networking/route.c
index bb88307a8..ee3533100 100644
--- a/networking/route.c
+++ b/networking/route.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * Bjorn Wesen, Axis Communications AB 6 * Bjorn Wesen, Axis Communications AB
7 * 7 *
8 * Author of the original route: 8 * Author of the original route:
9 * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> 9 * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
10 * (derived from FvK's 'route.c 1.70 01/04/94') 10 * (derived from FvK's 'route.c 1.70 01/04/94')
11 * 11 *
@@ -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.12 2001/08/27 17:57:27 andersen Exp $ 18 * $Id: route.c,v 1.13 2001/09/05 19:32:00 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 * adjustments by Larry Doolittle <LRDoolittle@lbl.gov> 21 * adjustments by Larry Doolittle <LRDoolittle@lbl.gov>
@@ -61,7 +61,7 @@ static int
61INET_resolve(char *name, struct sockaddr *sa) 61INET_resolve(char *name, struct sockaddr *sa)
62{ 62{
63 struct sockaddr_in *s_in = (struct sockaddr_in *)sa; 63 struct sockaddr_in *s_in = (struct sockaddr_in *)sa;
64 64
65 s_in->sin_family = AF_INET; 65 s_in->sin_family = AF_INET;
66 s_in->sin_port = 0; 66 s_in->sin_port = 0;
67 67
@@ -132,15 +132,15 @@ INET_setroute(int action, int options, char **args)
132 case 1: 132 case 1:
133 isnet = 1; 133 isnet = 1;
134 break; 134 break;
135 135
136 case 2: 136 case 2:
137 isnet = 0; 137 isnet = 0;
138 break; 138 break;
139 139
140 default: 140 default:
141 break; 141 break;
142 } 142 }
143 143
144 /* Fill in the other fields. */ 144 /* Fill in the other fields. */
145 rt.rt_flags = (RTF_UP | RTF_HOST); 145 rt.rt_flags = (RTF_UP | RTF_HOST);
146 if (isnet) 146 if (isnet)
@@ -149,7 +149,7 @@ INET_setroute(int action, int options, char **args)
149 while (*args) { 149 while (*args) {
150 if (strcmp(*args, "metric")==0) { 150 if (strcmp(*args, "metric")==0) {
151 int metric; 151 int metric;
152 152
153 args++; 153 args++;
154 if (!*args || !isdigit(**args)) 154 if (!*args || !isdigit(**args))
155 show_usage(); 155 show_usage();
@@ -165,7 +165,7 @@ INET_setroute(int action, int options, char **args)
165 165
166 if (strcmp(*args, "netmask")==0) { 166 if (strcmp(*args, "netmask")==0) {
167 struct sockaddr mask; 167 struct sockaddr mask;
168 168
169 args++; 169 args++;
170 if (!*args || mask_in_addr(rt)) 170 if (!*args || mask_in_addr(rt))
171 show_usage(); 171 show_usage();
@@ -237,8 +237,8 @@ INET_setroute(int action, int options, char **args)
237#if HAVE_RTF_IRTT 237#if HAVE_RTF_IRTT
238 rt.rt_flags |= RTF_IRTT; 238 rt.rt_flags |= RTF_IRTT;
239 rt.rt_irtt = atoi(*(args - 1)); 239 rt.rt_irtt = atoi(*(args - 1));
240 rt.rt_irtt *= (HZ / 100); /* FIXME */ 240 rt.rt_irtt *= (HZ / 100); /* FIXME */
241#if 0 /* FIXME: do we need to check anything of this? */ 241#if 0 /* FIXME: do we need to check anything of this? */
242 if (rt.rt_irtt < 1 || rt.rt_irtt > (120 * HZ)) { 242 if (rt.rt_irtt < 1 || rt.rt_irtt > (120 * HZ)) {
243 error_msg(_("Invalid initial rtt.")); 243 error_msg(_("Invalid initial rtt."));
244 return E_OPTERR; 244 return E_OPTERR;
@@ -285,7 +285,7 @@ INET_setroute(int action, int options, char **args)
285 if (!rt.rt_dev) { 285 if (!rt.rt_dev) {
286 rt.rt_dev = *args++; 286 rt.rt_dev = *args++;
287 if (*args) 287 if (*args)
288 show_usage(); /* must be last to catch typos */ 288 show_usage(); /* must be last to catch typos */
289 } else { 289 } else {
290 show_usage(); 290 show_usage();
291 } 291 }
@@ -339,7 +339,7 @@ INET_setroute(int action, int options, char **args)
339 return E_SOCK; 339 return E_SOCK;
340 } 340 }
341 } 341 }
342 342
343 /* Close the socket. */ 343 /* Close the socket. */
344 (void) close(skfd); 344 (void) close(skfd);
345 return EXIT_SUCCESS; 345 return EXIT_SUCCESS;
@@ -370,7 +370,7 @@ static void displayroutes(void)
370 struct in_addr gw; 370 struct in_addr gw;
371 struct in_addr mask; 371 struct in_addr mask;
372 int flgs, ref, use, metric; 372 int flgs, ref, use, metric;
373 char flags[4]; 373 char flags[64];
374 unsigned long int d,g,m; 374 unsigned long int d,g,m;
375 375
376 char sdest[16], sgw[16]; 376 char sdest[16], sgw[16];
@@ -384,44 +384,46 @@ static void displayroutes(void)
384 while(buff[ifl]!=' ' && buff[ifl]!='\t' && buff[ifl]!='\0') 384 while(buff[ifl]!=' ' && buff[ifl]!='\t' && buff[ifl]!='\0')
385 ifl++; 385 ifl++;
386 buff[ifl]=0; /* interface */ 386 buff[ifl]=0; /* interface */
387 if(sscanf(buff+ifl+1, "%lx%lx%d%d%d%d%lx", 387 if(sscanf(buff+ifl+1, "%lx%lx%X%d%d%d%lx",
388 &d, &g, &flgs, &ref, &use, &metric, &m)!=7) { 388 &d, &g, &flgs, &ref, &use, &metric, &m)!=7) {
389 error_msg_and_die( "Unsuported kernel route format\n"); 389 error_msg_and_die( "Unsuported kernel route format\n");
390 } 390 }
391 if(nl==1) 391 if(nl==1)
392 printf("Kernel IP routing table\n" 392 printf("Kernel IP routing table\n"
393"Destination Gateway Genmask Flags Metric Ref Use Iface\n"); 393 "Destination Gateway Genmask Flags Metric Ref Use Iface\n");
394 394
395 ifl = 0; /* parse flags */ 395 ifl = 0; /* parse flags */
396 if(flgs&RTF_UP) 396 if(flgs&RTF_UP) {
397 flags[ifl++]='U'; 397 if(flgs&RTF_REJECT)
398 if(flgs&RTF_GATEWAY) 398 flags[ifl++]='!';
399 flags[ifl++]='G'; 399 else
400 if(flgs&RTF_HOST) 400 flags[ifl++]='U';
401 flags[ifl++]='H'; 401 if(flgs&RTF_GATEWAY)
402 if(flgs&RTF_REINSTATE) 402 flags[ifl++]='G';
403 flags[ifl++]='R'; 403 if(flgs&RTF_HOST)
404 if(flgs&RTF_DYNAMIC) 404 flags[ifl++]='H';
405 flags[ifl++]='D'; 405 if(flgs&RTF_REINSTATE)
406 if(flgs&RTF_MODIFIED) 406 flags[ifl++]='R';
407 flags[ifl++]='H'; 407 if(flgs&RTF_DYNAMIC)
408 if(flgs&RTF_REJECT) 408 flags[ifl++]='D';
409 flags[ifl++]='!'; 409 if(flgs&RTF_MODIFIED)
410 flags[ifl]=0; 410 flags[ifl++]='M';
411 dest.s_addr = d; 411 flags[ifl]=0;
412 gw.s_addr = g; 412 dest.s_addr = d;
413 mask.s_addr = m; 413 gw.s_addr = g;
414 strcpy(sdest, (dest.s_addr==0 ? "default" : 414 mask.s_addr = m;
415 inet_ntoa(dest))); 415 strcpy(sdest, (dest.s_addr==0 ? "default" :
416 strcpy(sgw, (gw.s_addr==0 ? "*" : 416 inet_ntoa(dest)));
417 inet_ntoa(gw))); 417 strcpy(sgw, (gw.s_addr==0 ? "*" :
418 printf("%-16s%-16s%-16s%-6s%-6d %-2d %7d %s\n", 418 inet_ntoa(gw)));
419 sdest, sgw, 419 printf("%-16s%-16s%-16s%-6s%-6d %-2d %7d %s\n",
420 inet_ntoa(mask), 420 sdest, sgw,
421 flags, metric, ref, use, buff); 421 inet_ntoa(mask),
422 } 422 flags, metric, ref, use, buff);
423 nl++; 423 }
424 } 424 }
425 nl++;
426 }
425} 427}
426 428
427int route_main(int argc, char **argv) 429int route_main(int argc, char **argv)
diff --git a/route.c b/route.c
index bb88307a8..ee3533100 100644
--- a/route.c
+++ b/route.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * Bjorn Wesen, Axis Communications AB 6 * Bjorn Wesen, Axis Communications AB
7 * 7 *
8 * Author of the original route: 8 * Author of the original route:
9 * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> 9 * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
10 * (derived from FvK's 'route.c 1.70 01/04/94') 10 * (derived from FvK's 'route.c 1.70 01/04/94')
11 * 11 *
@@ -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.12 2001/08/27 17:57:27 andersen Exp $ 18 * $Id: route.c,v 1.13 2001/09/05 19:32:00 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 * adjustments by Larry Doolittle <LRDoolittle@lbl.gov> 21 * adjustments by Larry Doolittle <LRDoolittle@lbl.gov>
@@ -61,7 +61,7 @@ static int
61INET_resolve(char *name, struct sockaddr *sa) 61INET_resolve(char *name, struct sockaddr *sa)
62{ 62{
63 struct sockaddr_in *s_in = (struct sockaddr_in *)sa; 63 struct sockaddr_in *s_in = (struct sockaddr_in *)sa;
64 64
65 s_in->sin_family = AF_INET; 65 s_in->sin_family = AF_INET;
66 s_in->sin_port = 0; 66 s_in->sin_port = 0;
67 67
@@ -132,15 +132,15 @@ INET_setroute(int action, int options, char **args)
132 case 1: 132 case 1:
133 isnet = 1; 133 isnet = 1;
134 break; 134 break;
135 135
136 case 2: 136 case 2:
137 isnet = 0; 137 isnet = 0;
138 break; 138 break;
139 139
140 default: 140 default:
141 break; 141 break;
142 } 142 }
143 143
144 /* Fill in the other fields. */ 144 /* Fill in the other fields. */
145 rt.rt_flags = (RTF_UP | RTF_HOST); 145 rt.rt_flags = (RTF_UP | RTF_HOST);
146 if (isnet) 146 if (isnet)
@@ -149,7 +149,7 @@ INET_setroute(int action, int options, char **args)
149 while (*args) { 149 while (*args) {
150 if (strcmp(*args, "metric")==0) { 150 if (strcmp(*args, "metric")==0) {
151 int metric; 151 int metric;
152 152
153 args++; 153 args++;
154 if (!*args || !isdigit(**args)) 154 if (!*args || !isdigit(**args))
155 show_usage(); 155 show_usage();
@@ -165,7 +165,7 @@ INET_setroute(int action, int options, char **args)
165 165
166 if (strcmp(*args, "netmask")==0) { 166 if (strcmp(*args, "netmask")==0) {
167 struct sockaddr mask; 167 struct sockaddr mask;
168 168
169 args++; 169 args++;
170 if (!*args || mask_in_addr(rt)) 170 if (!*args || mask_in_addr(rt))
171 show_usage(); 171 show_usage();
@@ -237,8 +237,8 @@ INET_setroute(int action, int options, char **args)
237#if HAVE_RTF_IRTT 237#if HAVE_RTF_IRTT
238 rt.rt_flags |= RTF_IRTT; 238 rt.rt_flags |= RTF_IRTT;
239 rt.rt_irtt = atoi(*(args - 1)); 239 rt.rt_irtt = atoi(*(args - 1));
240 rt.rt_irtt *= (HZ / 100); /* FIXME */ 240 rt.rt_irtt *= (HZ / 100); /* FIXME */
241#if 0 /* FIXME: do we need to check anything of this? */ 241#if 0 /* FIXME: do we need to check anything of this? */
242 if (rt.rt_irtt < 1 || rt.rt_irtt > (120 * HZ)) { 242 if (rt.rt_irtt < 1 || rt.rt_irtt > (120 * HZ)) {
243 error_msg(_("Invalid initial rtt.")); 243 error_msg(_("Invalid initial rtt."));
244 return E_OPTERR; 244 return E_OPTERR;
@@ -285,7 +285,7 @@ INET_setroute(int action, int options, char **args)
285 if (!rt.rt_dev) { 285 if (!rt.rt_dev) {
286 rt.rt_dev = *args++; 286 rt.rt_dev = *args++;
287 if (*args) 287 if (*args)
288 show_usage(); /* must be last to catch typos */ 288 show_usage(); /* must be last to catch typos */
289 } else { 289 } else {
290 show_usage(); 290 show_usage();
291 } 291 }
@@ -339,7 +339,7 @@ INET_setroute(int action, int options, char **args)
339 return E_SOCK; 339 return E_SOCK;
340 } 340 }
341 } 341 }
342 342
343 /* Close the socket. */ 343 /* Close the socket. */
344 (void) close(skfd); 344 (void) close(skfd);
345 return EXIT_SUCCESS; 345 return EXIT_SUCCESS;
@@ -370,7 +370,7 @@ static void displayroutes(void)
370 struct in_addr gw; 370 struct in_addr gw;
371 struct in_addr mask; 371 struct in_addr mask;
372 int flgs, ref, use, metric; 372 int flgs, ref, use, metric;
373 char flags[4]; 373 char flags[64];
374 unsigned long int d,g,m; 374 unsigned long int d,g,m;
375 375
376 char sdest[16], sgw[16]; 376 char sdest[16], sgw[16];
@@ -384,44 +384,46 @@ static void displayroutes(void)
384 while(buff[ifl]!=' ' && buff[ifl]!='\t' && buff[ifl]!='\0') 384 while(buff[ifl]!=' ' && buff[ifl]!='\t' && buff[ifl]!='\0')
385 ifl++; 385 ifl++;
386 buff[ifl]=0; /* interface */ 386 buff[ifl]=0; /* interface */
387 if(sscanf(buff+ifl+1, "%lx%lx%d%d%d%d%lx", 387 if(sscanf(buff+ifl+1, "%lx%lx%X%d%d%d%lx",
388 &d, &g, &flgs, &ref, &use, &metric, &m)!=7) { 388 &d, &g, &flgs, &ref, &use, &metric, &m)!=7) {
389 error_msg_and_die( "Unsuported kernel route format\n"); 389 error_msg_and_die( "Unsuported kernel route format\n");
390 } 390 }
391 if(nl==1) 391 if(nl==1)
392 printf("Kernel IP routing table\n" 392 printf("Kernel IP routing table\n"
393"Destination Gateway Genmask Flags Metric Ref Use Iface\n"); 393 "Destination Gateway Genmask Flags Metric Ref Use Iface\n");
394 394
395 ifl = 0; /* parse flags */ 395 ifl = 0; /* parse flags */
396 if(flgs&RTF_UP) 396 if(flgs&RTF_UP) {
397 flags[ifl++]='U'; 397 if(flgs&RTF_REJECT)
398 if(flgs&RTF_GATEWAY) 398 flags[ifl++]='!';
399 flags[ifl++]='G'; 399 else
400 if(flgs&RTF_HOST) 400 flags[ifl++]='U';
401 flags[ifl++]='H'; 401 if(flgs&RTF_GATEWAY)
402 if(flgs&RTF_REINSTATE) 402 flags[ifl++]='G';
403 flags[ifl++]='R'; 403 if(flgs&RTF_HOST)
404 if(flgs&RTF_DYNAMIC) 404 flags[ifl++]='H';
405 flags[ifl++]='D'; 405 if(flgs&RTF_REINSTATE)
406 if(flgs&RTF_MODIFIED) 406 flags[ifl++]='R';
407 flags[ifl++]='H'; 407 if(flgs&RTF_DYNAMIC)
408 if(flgs&RTF_REJECT) 408 flags[ifl++]='D';
409 flags[ifl++]='!'; 409 if(flgs&RTF_MODIFIED)
410 flags[ifl]=0; 410 flags[ifl++]='M';
411 dest.s_addr = d; 411 flags[ifl]=0;
412 gw.s_addr = g; 412 dest.s_addr = d;
413 mask.s_addr = m; 413 gw.s_addr = g;
414 strcpy(sdest, (dest.s_addr==0 ? "default" : 414 mask.s_addr = m;
415 inet_ntoa(dest))); 415 strcpy(sdest, (dest.s_addr==0 ? "default" :
416 strcpy(sgw, (gw.s_addr==0 ? "*" : 416 inet_ntoa(dest)));
417 inet_ntoa(gw))); 417 strcpy(sgw, (gw.s_addr==0 ? "*" :
418 printf("%-16s%-16s%-16s%-6s%-6d %-2d %7d %s\n", 418 inet_ntoa(gw)));
419 sdest, sgw, 419 printf("%-16s%-16s%-16s%-6s%-6d %-2d %7d %s\n",
420 inet_ntoa(mask), 420 sdest, sgw,
421 flags, metric, ref, use, buff); 421 inet_ntoa(mask),
422 } 422 flags, metric, ref, use, buff);
423 nl++; 423 }
424 } 424 }
425 nl++;
426 }
425} 427}
426 428
427int route_main(int argc, char **argv) 429int route_main(int argc, char **argv)