Another fix from vodz
This commit is contained in:
parent
3b1525e444
commit
b9408504f5
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Bjorn Wesen, Axis Communications AB
|
* Bjorn Wesen, Axis Communications AB
|
||||||
*
|
*
|
||||||
* Author of the original route:
|
* Author of the original route:
|
||||||
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
|
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
|
||||||
* (derived from FvK's 'route.c 1.70 01/04/94')
|
* (derived from FvK's 'route.c 1.70 01/04/94')
|
||||||
*
|
*
|
||||||
@ -15,7 +15,7 @@
|
|||||||
* Foundation; either version 2 of the License, or (at
|
* Foundation; either version 2 of the License, or (at
|
||||||
* your option) any later version.
|
* your option) any later version.
|
||||||
*
|
*
|
||||||
* $Id: route.c,v 1.12 2001/08/27 17:57:27 andersen Exp $
|
* $Id: route.c,v 1.13 2001/09/05 19:32:00 andersen Exp $
|
||||||
*
|
*
|
||||||
* displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru>
|
* displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru>
|
||||||
* adjustments by Larry Doolittle <LRDoolittle@lbl.gov>
|
* adjustments by Larry Doolittle <LRDoolittle@lbl.gov>
|
||||||
@ -61,7 +61,7 @@ static int
|
|||||||
INET_resolve(char *name, struct sockaddr *sa)
|
INET_resolve(char *name, struct sockaddr *sa)
|
||||||
{
|
{
|
||||||
struct sockaddr_in *s_in = (struct sockaddr_in *)sa;
|
struct sockaddr_in *s_in = (struct sockaddr_in *)sa;
|
||||||
|
|
||||||
s_in->sin_family = AF_INET;
|
s_in->sin_family = AF_INET;
|
||||||
s_in->sin_port = 0;
|
s_in->sin_port = 0;
|
||||||
|
|
||||||
@ -132,15 +132,15 @@ INET_setroute(int action, int options, char **args)
|
|||||||
case 1:
|
case 1:
|
||||||
isnet = 1;
|
isnet = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
isnet = 0;
|
isnet = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fill in the other fields. */
|
/* Fill in the other fields. */
|
||||||
rt.rt_flags = (RTF_UP | RTF_HOST);
|
rt.rt_flags = (RTF_UP | RTF_HOST);
|
||||||
if (isnet)
|
if (isnet)
|
||||||
@ -149,7 +149,7 @@ INET_setroute(int action, int options, char **args)
|
|||||||
while (*args) {
|
while (*args) {
|
||||||
if (strcmp(*args, "metric")==0) {
|
if (strcmp(*args, "metric")==0) {
|
||||||
int metric;
|
int metric;
|
||||||
|
|
||||||
args++;
|
args++;
|
||||||
if (!*args || !isdigit(**args))
|
if (!*args || !isdigit(**args))
|
||||||
show_usage();
|
show_usage();
|
||||||
@ -165,7 +165,7 @@ INET_setroute(int action, int options, char **args)
|
|||||||
|
|
||||||
if (strcmp(*args, "netmask")==0) {
|
if (strcmp(*args, "netmask")==0) {
|
||||||
struct sockaddr mask;
|
struct sockaddr mask;
|
||||||
|
|
||||||
args++;
|
args++;
|
||||||
if (!*args || mask_in_addr(rt))
|
if (!*args || mask_in_addr(rt))
|
||||||
show_usage();
|
show_usage();
|
||||||
@ -237,8 +237,8 @@ INET_setroute(int action, int options, char **args)
|
|||||||
#if HAVE_RTF_IRTT
|
#if HAVE_RTF_IRTT
|
||||||
rt.rt_flags |= RTF_IRTT;
|
rt.rt_flags |= RTF_IRTT;
|
||||||
rt.rt_irtt = atoi(*(args - 1));
|
rt.rt_irtt = atoi(*(args - 1));
|
||||||
rt.rt_irtt *= (HZ / 100); /* FIXME */
|
rt.rt_irtt *= (HZ / 100); /* FIXME */
|
||||||
#if 0 /* FIXME: do we need to check anything of this? */
|
#if 0 /* FIXME: do we need to check anything of this? */
|
||||||
if (rt.rt_irtt < 1 || rt.rt_irtt > (120 * HZ)) {
|
if (rt.rt_irtt < 1 || rt.rt_irtt > (120 * HZ)) {
|
||||||
error_msg(_("Invalid initial rtt."));
|
error_msg(_("Invalid initial rtt."));
|
||||||
return E_OPTERR;
|
return E_OPTERR;
|
||||||
@ -285,7 +285,7 @@ INET_setroute(int action, int options, char **args)
|
|||||||
if (!rt.rt_dev) {
|
if (!rt.rt_dev) {
|
||||||
rt.rt_dev = *args++;
|
rt.rt_dev = *args++;
|
||||||
if (*args)
|
if (*args)
|
||||||
show_usage(); /* must be last to catch typos */
|
show_usage(); /* must be last to catch typos */
|
||||||
} else {
|
} else {
|
||||||
show_usage();
|
show_usage();
|
||||||
}
|
}
|
||||||
@ -339,7 +339,7 @@ INET_setroute(int action, int options, char **args)
|
|||||||
return E_SOCK;
|
return E_SOCK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the socket. */
|
/* Close the socket. */
|
||||||
(void) close(skfd);
|
(void) close(skfd);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
@ -370,7 +370,7 @@ static void displayroutes(void)
|
|||||||
struct in_addr gw;
|
struct in_addr gw;
|
||||||
struct in_addr mask;
|
struct in_addr mask;
|
||||||
int flgs, ref, use, metric;
|
int flgs, ref, use, metric;
|
||||||
char flags[4];
|
char flags[64];
|
||||||
unsigned long int d,g,m;
|
unsigned long int d,g,m;
|
||||||
|
|
||||||
char sdest[16], sgw[16];
|
char sdest[16], sgw[16];
|
||||||
@ -384,44 +384,46 @@ static void displayroutes(void)
|
|||||||
while(buff[ifl]!=' ' && buff[ifl]!='\t' && buff[ifl]!='\0')
|
while(buff[ifl]!=' ' && buff[ifl]!='\t' && buff[ifl]!='\0')
|
||||||
ifl++;
|
ifl++;
|
||||||
buff[ifl]=0; /* interface */
|
buff[ifl]=0; /* interface */
|
||||||
if(sscanf(buff+ifl+1, "%lx%lx%d%d%d%d%lx",
|
if(sscanf(buff+ifl+1, "%lx%lx%X%d%d%d%lx",
|
||||||
&d, &g, &flgs, &ref, &use, &metric, &m)!=7) {
|
&d, &g, &flgs, &ref, &use, &metric, &m)!=7) {
|
||||||
error_msg_and_die( "Unsuported kernel route format\n");
|
error_msg_and_die( "Unsuported kernel route format\n");
|
||||||
}
|
}
|
||||||
if(nl==1)
|
if(nl==1)
|
||||||
printf("Kernel IP routing table\n"
|
printf("Kernel IP routing table\n"
|
||||||
"Destination Gateway Genmask Flags Metric Ref Use Iface\n");
|
"Destination Gateway Genmask Flags Metric Ref Use Iface\n");
|
||||||
|
|
||||||
ifl = 0; /* parse flags */
|
ifl = 0; /* parse flags */
|
||||||
if(flgs&RTF_UP)
|
if(flgs&RTF_UP) {
|
||||||
flags[ifl++]='U';
|
if(flgs&RTF_REJECT)
|
||||||
if(flgs&RTF_GATEWAY)
|
flags[ifl++]='!';
|
||||||
flags[ifl++]='G';
|
else
|
||||||
if(flgs&RTF_HOST)
|
flags[ifl++]='U';
|
||||||
flags[ifl++]='H';
|
if(flgs&RTF_GATEWAY)
|
||||||
if(flgs&RTF_REINSTATE)
|
flags[ifl++]='G';
|
||||||
flags[ifl++]='R';
|
if(flgs&RTF_HOST)
|
||||||
if(flgs&RTF_DYNAMIC)
|
flags[ifl++]='H';
|
||||||
flags[ifl++]='D';
|
if(flgs&RTF_REINSTATE)
|
||||||
if(flgs&RTF_MODIFIED)
|
flags[ifl++]='R';
|
||||||
flags[ifl++]='H';
|
if(flgs&RTF_DYNAMIC)
|
||||||
if(flgs&RTF_REJECT)
|
flags[ifl++]='D';
|
||||||
flags[ifl++]='!';
|
if(flgs&RTF_MODIFIED)
|
||||||
flags[ifl]=0;
|
flags[ifl++]='M';
|
||||||
dest.s_addr = d;
|
flags[ifl]=0;
|
||||||
gw.s_addr = g;
|
dest.s_addr = d;
|
||||||
mask.s_addr = m;
|
gw.s_addr = g;
|
||||||
strcpy(sdest, (dest.s_addr==0 ? "default" :
|
mask.s_addr = m;
|
||||||
inet_ntoa(dest)));
|
strcpy(sdest, (dest.s_addr==0 ? "default" :
|
||||||
strcpy(sgw, (gw.s_addr==0 ? "*" :
|
inet_ntoa(dest)));
|
||||||
inet_ntoa(gw)));
|
strcpy(sgw, (gw.s_addr==0 ? "*" :
|
||||||
printf("%-16s%-16s%-16s%-6s%-6d %-2d %7d %s\n",
|
inet_ntoa(gw)));
|
||||||
sdest, sgw,
|
printf("%-16s%-16s%-16s%-6s%-6d %-2d %7d %s\n",
|
||||||
inet_ntoa(mask),
|
sdest, sgw,
|
||||||
flags, metric, ref, use, buff);
|
inet_ntoa(mask),
|
||||||
}
|
flags, metric, ref, use, buff);
|
||||||
nl++;
|
}
|
||||||
}
|
}
|
||||||
|
nl++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int route_main(int argc, char **argv)
|
int route_main(int argc, char **argv)
|
||||||
|
92
route.c
92
route.c
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Bjorn Wesen, Axis Communications AB
|
* Bjorn Wesen, Axis Communications AB
|
||||||
*
|
*
|
||||||
* Author of the original route:
|
* Author of the original route:
|
||||||
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
|
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
|
||||||
* (derived from FvK's 'route.c 1.70 01/04/94')
|
* (derived from FvK's 'route.c 1.70 01/04/94')
|
||||||
*
|
*
|
||||||
@ -15,7 +15,7 @@
|
|||||||
* Foundation; either version 2 of the License, or (at
|
* Foundation; either version 2 of the License, or (at
|
||||||
* your option) any later version.
|
* your option) any later version.
|
||||||
*
|
*
|
||||||
* $Id: route.c,v 1.12 2001/08/27 17:57:27 andersen Exp $
|
* $Id: route.c,v 1.13 2001/09/05 19:32:00 andersen Exp $
|
||||||
*
|
*
|
||||||
* displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru>
|
* displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru>
|
||||||
* adjustments by Larry Doolittle <LRDoolittle@lbl.gov>
|
* adjustments by Larry Doolittle <LRDoolittle@lbl.gov>
|
||||||
@ -61,7 +61,7 @@ static int
|
|||||||
INET_resolve(char *name, struct sockaddr *sa)
|
INET_resolve(char *name, struct sockaddr *sa)
|
||||||
{
|
{
|
||||||
struct sockaddr_in *s_in = (struct sockaddr_in *)sa;
|
struct sockaddr_in *s_in = (struct sockaddr_in *)sa;
|
||||||
|
|
||||||
s_in->sin_family = AF_INET;
|
s_in->sin_family = AF_INET;
|
||||||
s_in->sin_port = 0;
|
s_in->sin_port = 0;
|
||||||
|
|
||||||
@ -132,15 +132,15 @@ INET_setroute(int action, int options, char **args)
|
|||||||
case 1:
|
case 1:
|
||||||
isnet = 1;
|
isnet = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
isnet = 0;
|
isnet = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fill in the other fields. */
|
/* Fill in the other fields. */
|
||||||
rt.rt_flags = (RTF_UP | RTF_HOST);
|
rt.rt_flags = (RTF_UP | RTF_HOST);
|
||||||
if (isnet)
|
if (isnet)
|
||||||
@ -149,7 +149,7 @@ INET_setroute(int action, int options, char **args)
|
|||||||
while (*args) {
|
while (*args) {
|
||||||
if (strcmp(*args, "metric")==0) {
|
if (strcmp(*args, "metric")==0) {
|
||||||
int metric;
|
int metric;
|
||||||
|
|
||||||
args++;
|
args++;
|
||||||
if (!*args || !isdigit(**args))
|
if (!*args || !isdigit(**args))
|
||||||
show_usage();
|
show_usage();
|
||||||
@ -165,7 +165,7 @@ INET_setroute(int action, int options, char **args)
|
|||||||
|
|
||||||
if (strcmp(*args, "netmask")==0) {
|
if (strcmp(*args, "netmask")==0) {
|
||||||
struct sockaddr mask;
|
struct sockaddr mask;
|
||||||
|
|
||||||
args++;
|
args++;
|
||||||
if (!*args || mask_in_addr(rt))
|
if (!*args || mask_in_addr(rt))
|
||||||
show_usage();
|
show_usage();
|
||||||
@ -237,8 +237,8 @@ INET_setroute(int action, int options, char **args)
|
|||||||
#if HAVE_RTF_IRTT
|
#if HAVE_RTF_IRTT
|
||||||
rt.rt_flags |= RTF_IRTT;
|
rt.rt_flags |= RTF_IRTT;
|
||||||
rt.rt_irtt = atoi(*(args - 1));
|
rt.rt_irtt = atoi(*(args - 1));
|
||||||
rt.rt_irtt *= (HZ / 100); /* FIXME */
|
rt.rt_irtt *= (HZ / 100); /* FIXME */
|
||||||
#if 0 /* FIXME: do we need to check anything of this? */
|
#if 0 /* FIXME: do we need to check anything of this? */
|
||||||
if (rt.rt_irtt < 1 || rt.rt_irtt > (120 * HZ)) {
|
if (rt.rt_irtt < 1 || rt.rt_irtt > (120 * HZ)) {
|
||||||
error_msg(_("Invalid initial rtt."));
|
error_msg(_("Invalid initial rtt."));
|
||||||
return E_OPTERR;
|
return E_OPTERR;
|
||||||
@ -285,7 +285,7 @@ INET_setroute(int action, int options, char **args)
|
|||||||
if (!rt.rt_dev) {
|
if (!rt.rt_dev) {
|
||||||
rt.rt_dev = *args++;
|
rt.rt_dev = *args++;
|
||||||
if (*args)
|
if (*args)
|
||||||
show_usage(); /* must be last to catch typos */
|
show_usage(); /* must be last to catch typos */
|
||||||
} else {
|
} else {
|
||||||
show_usage();
|
show_usage();
|
||||||
}
|
}
|
||||||
@ -339,7 +339,7 @@ INET_setroute(int action, int options, char **args)
|
|||||||
return E_SOCK;
|
return E_SOCK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the socket. */
|
/* Close the socket. */
|
||||||
(void) close(skfd);
|
(void) close(skfd);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
@ -370,7 +370,7 @@ static void displayroutes(void)
|
|||||||
struct in_addr gw;
|
struct in_addr gw;
|
||||||
struct in_addr mask;
|
struct in_addr mask;
|
||||||
int flgs, ref, use, metric;
|
int flgs, ref, use, metric;
|
||||||
char flags[4];
|
char flags[64];
|
||||||
unsigned long int d,g,m;
|
unsigned long int d,g,m;
|
||||||
|
|
||||||
char sdest[16], sgw[16];
|
char sdest[16], sgw[16];
|
||||||
@ -384,44 +384,46 @@ static void displayroutes(void)
|
|||||||
while(buff[ifl]!=' ' && buff[ifl]!='\t' && buff[ifl]!='\0')
|
while(buff[ifl]!=' ' && buff[ifl]!='\t' && buff[ifl]!='\0')
|
||||||
ifl++;
|
ifl++;
|
||||||
buff[ifl]=0; /* interface */
|
buff[ifl]=0; /* interface */
|
||||||
if(sscanf(buff+ifl+1, "%lx%lx%d%d%d%d%lx",
|
if(sscanf(buff+ifl+1, "%lx%lx%X%d%d%d%lx",
|
||||||
&d, &g, &flgs, &ref, &use, &metric, &m)!=7) {
|
&d, &g, &flgs, &ref, &use, &metric, &m)!=7) {
|
||||||
error_msg_and_die( "Unsuported kernel route format\n");
|
error_msg_and_die( "Unsuported kernel route format\n");
|
||||||
}
|
}
|
||||||
if(nl==1)
|
if(nl==1)
|
||||||
printf("Kernel IP routing table\n"
|
printf("Kernel IP routing table\n"
|
||||||
"Destination Gateway Genmask Flags Metric Ref Use Iface\n");
|
"Destination Gateway Genmask Flags Metric Ref Use Iface\n");
|
||||||
|
|
||||||
ifl = 0; /* parse flags */
|
ifl = 0; /* parse flags */
|
||||||
if(flgs&RTF_UP)
|
if(flgs&RTF_UP) {
|
||||||
flags[ifl++]='U';
|
if(flgs&RTF_REJECT)
|
||||||
if(flgs&RTF_GATEWAY)
|
flags[ifl++]='!';
|
||||||
flags[ifl++]='G';
|
else
|
||||||
if(flgs&RTF_HOST)
|
flags[ifl++]='U';
|
||||||
flags[ifl++]='H';
|
if(flgs&RTF_GATEWAY)
|
||||||
if(flgs&RTF_REINSTATE)
|
flags[ifl++]='G';
|
||||||
flags[ifl++]='R';
|
if(flgs&RTF_HOST)
|
||||||
if(flgs&RTF_DYNAMIC)
|
flags[ifl++]='H';
|
||||||
flags[ifl++]='D';
|
if(flgs&RTF_REINSTATE)
|
||||||
if(flgs&RTF_MODIFIED)
|
flags[ifl++]='R';
|
||||||
flags[ifl++]='H';
|
if(flgs&RTF_DYNAMIC)
|
||||||
if(flgs&RTF_REJECT)
|
flags[ifl++]='D';
|
||||||
flags[ifl++]='!';
|
if(flgs&RTF_MODIFIED)
|
||||||
flags[ifl]=0;
|
flags[ifl++]='M';
|
||||||
dest.s_addr = d;
|
flags[ifl]=0;
|
||||||
gw.s_addr = g;
|
dest.s_addr = d;
|
||||||
mask.s_addr = m;
|
gw.s_addr = g;
|
||||||
strcpy(sdest, (dest.s_addr==0 ? "default" :
|
mask.s_addr = m;
|
||||||
inet_ntoa(dest)));
|
strcpy(sdest, (dest.s_addr==0 ? "default" :
|
||||||
strcpy(sgw, (gw.s_addr==0 ? "*" :
|
inet_ntoa(dest)));
|
||||||
inet_ntoa(gw)));
|
strcpy(sgw, (gw.s_addr==0 ? "*" :
|
||||||
printf("%-16s%-16s%-16s%-6s%-6d %-2d %7d %s\n",
|
inet_ntoa(gw)));
|
||||||
sdest, sgw,
|
printf("%-16s%-16s%-16s%-6s%-6d %-2d %7d %s\n",
|
||||||
inet_ntoa(mask),
|
sdest, sgw,
|
||||||
flags, metric, ref, use, buff);
|
inet_ntoa(mask),
|
||||||
}
|
flags, metric, ref, use, buff);
|
||||||
nl++;
|
}
|
||||||
}
|
}
|
||||||
|
nl++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int route_main(int argc, char **argv)
|
int route_main(int argc, char **argv)
|
||||||
|
Loading…
Reference in New Issue
Block a user