Run through indent, fix comment
This commit is contained in:
parent
baf55a85fc
commit
7c58e9be69
@ -15,7 +15,7 @@
|
||||
* Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* $Id: route.c,v 1.17 2002/07/03 11:46:34 andersen Exp $
|
||||
* $Id: route.c,v 1.18 2002/08/22 18:24:43 bug1 Exp $
|
||||
*
|
||||
* displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru>
|
||||
* adjustments by Larry Doolittle <LRDoolittle@lbl.gov>
|
||||
@ -28,7 +28,7 @@
|
||||
#include "inet_common.h"
|
||||
#include <net/route.h>
|
||||
#include <net/if.h>
|
||||
#include <linux/param.h> // HZ
|
||||
#include <linux/param.h> /* HZ */
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
@ -78,8 +78,7 @@
|
||||
|
||||
/* add or delete a route depending on action */
|
||||
|
||||
static int
|
||||
INET_setroute(int action, int options, char **args)
|
||||
static int INET_setroute(int action, int options, char **args)
|
||||
{
|
||||
struct rtentry rt;
|
||||
char target[128], gateway[128] = "NONE";
|
||||
@ -106,7 +105,9 @@ INET_setroute(int action, int options, char **args)
|
||||
memset((char *) &rt, 0, sizeof(struct rtentry));
|
||||
|
||||
|
||||
if ((isnet = INET_resolve(target, (struct sockaddr_in *)&rt.rt_dst, xflag!=1)) < 0) {
|
||||
if ((isnet =
|
||||
INET_resolve(target, (struct sockaddr_in *) &rt.rt_dst,
|
||||
xflag != 1)) < 0) {
|
||||
error_msg(_("can't resolve %s"), target);
|
||||
return EXIT_FAILURE; /* XXX change to E_something */
|
||||
}
|
||||
@ -153,7 +154,9 @@ INET_setroute(int action, int options, char **args)
|
||||
if (!*args || mask_in_addr(rt))
|
||||
show_usage();
|
||||
netmask = *args;
|
||||
if ((isnet = INET_resolve(netmask, (struct sockaddr_in *)&mask, 0)) < 0) {
|
||||
if ((isnet =
|
||||
INET_resolve(netmask, (struct sockaddr_in *) &mask,
|
||||
0)) < 0) {
|
||||
error_msg(_("can't resolve netmask %s"), netmask);
|
||||
return E_LOOKUP;
|
||||
}
|
||||
@ -169,14 +172,14 @@ INET_setroute(int action, int options, char **args)
|
||||
if (rt.rt_flags & RTF_GATEWAY)
|
||||
show_usage();
|
||||
safe_strncpy(gateway, *args, (sizeof gateway));
|
||||
if ((isnet = INET_resolve(gateway, (struct sockaddr_in *)&rt.rt_gateway, 1)) < 0) {
|
||||
if ((isnet =
|
||||
INET_resolve(gateway, (struct sockaddr_in *) &rt.rt_gateway,
|
||||
1)) < 0) {
|
||||
error_msg(_("can't resolve gw %s"), gateway);
|
||||
return E_LOOKUP;
|
||||
}
|
||||
if (isnet) {
|
||||
error_msg(
|
||||
_("%s: cannot use a NETWORK as gateway!"),
|
||||
gateway);
|
||||
error_msg(_("%s: cannot use a NETWORK as gateway!"), gateway);
|
||||
return E_OPTERR;
|
||||
}
|
||||
rt.rt_flags |= RTF_GATEWAY;
|
||||
@ -282,10 +285,10 @@ INET_setroute(int action, int options, char **args)
|
||||
/* sanity checks.. */
|
||||
if (mask_in_addr(rt)) {
|
||||
unsigned long mask = mask_in_addr(rt);
|
||||
|
||||
mask = ~ntohl(mask);
|
||||
if ((rt.rt_flags & RTF_HOST) && mask != 0xffffffff) {
|
||||
error_msg(
|
||||
_("netmask %.8x doesn't make sense with host route"),
|
||||
error_msg(_("netmask %.8x doesn't make sense with host route"),
|
||||
(unsigned int) mask);
|
||||
return E_OPTERR;
|
||||
}
|
||||
@ -506,12 +509,14 @@ void displayroutes(int noresolve, int netstatfmt)
|
||||
ifl++;
|
||||
buff[ifl] = 0; /* interface */
|
||||
if (sscanf(buff + ifl + 1, "%lx%lx%X%d%d%d%lx%d%d%d",
|
||||
&d, &g, &flgs, &ref, &use, &metric, &m, &mtu, &win, &ir )!=10) {
|
||||
&d, &g, &flgs, &ref, &use, &metric, &m, &mtu, &win,
|
||||
&ir) != 10) {
|
||||
error_msg_and_die("Unsuported kernel route format\n");
|
||||
}
|
||||
if (nl == 1) {
|
||||
printf("Kernel IP routing table\n");
|
||||
printf("Destination Gateway Genmask Flags %s Iface\n",
|
||||
printf
|
||||
("Destination Gateway Genmask Flags %s Iface\n",
|
||||
netstatfmt ? " MSS Window irtt" : "Metric Ref Use");
|
||||
}
|
||||
ifl = 0; /* parse flags */
|
||||
@ -543,7 +548,8 @@ void displayroutes(int noresolve, int netstatfmt)
|
||||
s_addr.sin_addr = gw;
|
||||
INET_rresolve(sgw, sizeof(sgw), &s_addr, numeric, m);
|
||||
|
||||
printf("%-16s%-16s%-16s%-6s", sdest, sgw, inet_ntoa(mask), flags);
|
||||
printf("%-16s%-16s%-16s%-6s", sdest, sgw, inet_ntoa(mask),
|
||||
flags);
|
||||
if (netstatfmt)
|
||||
printf("%5d %-5d %6d %s\n", mtu, win, ir, buff);
|
||||
else
|
||||
@ -567,6 +573,7 @@ static void INET6_displayroutes(int noresolve)
|
||||
char addr6p[8][5], saddr6p[8][5], naddr6p[8][5];
|
||||
|
||||
FILE *fp = xfopen("/proc/net/ipv6_route", "r");
|
||||
|
||||
flags[0] = 'U';
|
||||
|
||||
if (noresolve)
|
||||
@ -618,7 +625,8 @@ static void INET6_displayroutes(int noresolve)
|
||||
inet_pton(AF_INET6, addr6, (struct sockaddr *) &saddr6.sin6_addr);
|
||||
saddr6.sin6_family = AF_INET6;
|
||||
|
||||
INET6_rresolve(addr6, sizeof(addr6), (struct sockaddr_in6 *) &saddr6, numeric);
|
||||
INET6_rresolve(addr6, sizeof(addr6), (struct sockaddr_in6 *) &saddr6,
|
||||
numeric);
|
||||
snprintf(addr6, sizeof(addr6), "%s/%d", addr6, prefix_len);
|
||||
|
||||
/* Fetch and resolve the nexthop address. */
|
||||
@ -628,7 +636,8 @@ static void INET6_displayroutes(int noresolve)
|
||||
inet_pton(AF_INET6, naddr6, (struct sockaddr *) &snaddr6.sin6_addr);
|
||||
snaddr6.sin6_family = AF_INET6;
|
||||
|
||||
INET6_rresolve(naddr6, sizeof(naddr6), (struct sockaddr_in6 *) &snaddr6, numeric);
|
||||
INET6_rresolve(naddr6, sizeof(naddr6),
|
||||
(struct sockaddr_in6 *) &snaddr6, numeric);
|
||||
|
||||
/* Print the info. */
|
||||
printf("%-43s %-39s %-5s %-6d %-2d %7d %-8s\n",
|
||||
@ -641,6 +650,7 @@ int route_main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
int what = 0;
|
||||
|
||||
#if CONFIG_FEATURE_IPV6
|
||||
int af = AF_INET;
|
||||
#endif
|
||||
@ -680,7 +690,8 @@ int route_main(int argc, char **argv)
|
||||
/* check verb */
|
||||
if (strcmp(argv[1], "add") == 0)
|
||||
what = RTACTION_ADD;
|
||||
else if (strcmp( argv [1], "del")==0 || strcmp( argv [1], "delete")==0)
|
||||
else if (strcmp(argv[1], "del") == 0
|
||||
|| strcmp(argv[1], "delete") == 0)
|
||||
what = RTACTION_DEL;
|
||||
else if (strcmp(argv[1], "flush") == 0)
|
||||
what = RTACTION_FLUSH;
|
||||
|
Loading…
x
Reference in New Issue
Block a user