summaryrefslogtreecommitdiff
path: root/sbin/route
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2000-09-24 01:02:25 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2000-09-24 01:02:25 +0000
commit457a4fc6915bb4ce3568b76708d6793ef520b2cb (patch)
tree311a6b8234f9c0539a06a861be4213a15c72a87a /sbin/route
parent92c8d0a90d0c7f44770290f84163349177cd04b6 (diff)
If the route add/delete fails exit w/ 1 instead of 0
Remove register decls and make return foo vs. return (foo) consistent.
Diffstat (limited to 'sbin/route')
-rw-r--r--sbin/route/ccitt_addr.c12
-rw-r--r--sbin/route/route.c102
-rw-r--r--sbin/route/show.c26
3 files changed, 70 insertions, 70 deletions
diff --git a/sbin/route/ccitt_addr.c b/sbin/route/ccitt_addr.c
index 5105b09ca53..5f4a1d4db98 100644
--- a/sbin/route/ccitt_addr.c
+++ b/sbin/route/ccitt_addr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ccitt_addr.c,v 1.4 1997/06/24 04:05:37 millert Exp $ */
+/* $OpenBSD: ccitt_addr.c,v 1.5 2000/09/24 01:02:23 millert Exp $ */
/* $NetBSD: ccitt_addr.c,v 1.8 1995/04/23 10:33:41 cgd Exp $ */
/*
@@ -64,9 +64,9 @@ static char *copychar __P((char *, char *));
int
ccitt_addr (addr, xp)
char *addr;
-register struct sockaddr_x25 *xp;
+struct sockaddr_x25 *xp;
{
- register char *p, *ap, *limit;
+ char *p, *ap, *limit;
int havenet = 0;
memset(xp, 0, sizeof (*xp));
@@ -158,9 +158,9 @@ register struct sockaddr_x25 *xp;
static char *
copychar (from, to)
-register char *from, *to;
+char *from, *to;
{
- register int n;
+ int n;
if (*from != '\\' || from[1] < '0' || from[1] > '7') {
*to = *from++;
@@ -169,7 +169,7 @@ register char *from, *to;
n = *++from - '0';
from++;
if (*from >= '0' && *from <= '7') {
- register int n1;
+ int n1;
n = n*8 + *from++ - '0';
if (*from >= '0' && *from <= '7' && (n1 = n*8 + *from-'0') < 256) {
diff --git a/sbin/route/route.c b/sbin/route/route.c
index a41c61e8aa9..5c9731ed1f4 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.39 2000/08/03 07:01:32 angelos Exp $ */
+/* $OpenBSD: route.c,v 1.40 2000/09/24 01:02:24 millert Exp $ */
/* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)route.c 8.3 (Berkeley) 3/19/94";
#else
-static char rcsid[] = "$OpenBSD: route.c,v 1.39 2000/08/03 07:01:32 angelos Exp $";
+static char rcsid[] = "$OpenBSD: route.c,v 1.40 2000/09/24 01:02:24 millert Exp $";
#endif
#endif /* not lint */
@@ -102,7 +102,7 @@ uid_t uid;
char *routename __P((struct sockaddr *));
char *netname __P((struct sockaddr *));
void flushroutes __P((int, char **));
-void newroute __P((int, char **));
+int newroute __P((int, char **));
void monitor __P((void));
#ifdef INET6
static int prefixlen __P((char *));
@@ -159,9 +159,10 @@ main(argc, argv)
char **argv;
{
int ch;
+ int rval = 0;
if (argc < 2)
- usage((char *)NULL);
+ usage(NULL);
while ((ch = getopt(argc, argv, "nqdtv")) != -1)
switch(ch) {
@@ -181,7 +182,7 @@ main(argc, argv)
debugonly = 1;
break;
default:
- usage((char *)NULL);
+ usage(NULL);
}
argc -= optind;
argv += optind;
@@ -203,7 +204,7 @@ main(argc, argv)
case K_CHANGE:
case K_ADD:
case K_DELETE:
- newroute(argc, argv);
+ rval = newroute(argc, argv);
break;
case K_SHOW:
uid = 0;
@@ -218,9 +219,8 @@ main(argc, argv)
no_cmd:
default:
usage(*argv);
- return 1;
}
- return 0;
+ exit(rval);
}
/*
@@ -235,7 +235,7 @@ flushroutes(argc, argv)
size_t needed;
int mib[6], rlen, seqno;
char *buf = NULL, *next, *lim;
- register struct rt_msghdr *rtm;
+ struct rt_msghdr *rtm;
struct sockaddr *sa;
if (uid) {
@@ -367,12 +367,11 @@ char *
routename(sa)
struct sockaddr *sa;
{
- register char *cp = NULL;
+ char *cp = NULL;
static char line[MAXHOSTNAMELEN];
struct hostent *hp;
static char domain[MAXHOSTNAMELEN];
static int first = 1;
- struct in_addr ina;
char *ns_print();
char *ipx_print();
@@ -607,13 +606,13 @@ set_metric(value, key)
*valp = atoi(value);
}
-void
+int
newroute(argc, argv)
int argc;
- register char **argv;
+ char **argv;
{
char *cmd, *dest = "", *gateway = "", *err;
- int ishost = 0, ret, attempts, oerrno, flags = RTF_STATIC;
+ int ishost = 0, ret = 0, attempts, oerrno, flags = RTF_STATIC;
int key;
struct hostent *hp = 0;
@@ -771,18 +770,18 @@ newroute(argc, argv)
gateway = *argv;
(void) getaddr(RTA_GATEWAY, *argv, &hp);
} else {
- int ret = atoi(*argv);
+ int hops = atoi(*argv);
- if (ret == 0) {
+ if (hops == 0) {
if (!qflag && strcmp(*argv, "0") == 0)
printf("%s,%s",
"old usage of trailing 0",
"assuming route to if\n");
else
- usage((char *)NULL);
+ usage(NULL);
iflag = 1;
continue;
- } else if (ret > 0 && ret < 10) {
+ } else if (hops > 0 && hops < 10) {
if (!qflag) {
printf("old usage of trailing digit, ");
printf("assuming route via gateway\n");
@@ -846,16 +845,17 @@ newroute(argc, argv)
}
(void) printf(": %s\n", err);
}
+ return (ret != 0);
}
void
inet_makenetandmask(net, sin, bits)
u_int32_t net;
- register struct sockaddr_in *sin;
+ struct sockaddr_in *sin;
int bits;
{
u_int32_t addr, mask = 0;
- register char *cp;
+ char *cp;
rtm_addrs |= RTA_NETMASK;
if (net == 0)
@@ -934,7 +934,7 @@ getaddr(which, s, hpp)
char *s;
struct hostent **hpp;
{
- register sup su;
+ sup su;
struct ns_addr ns_addr();
struct ipx_addr ipx_addr();
struct iso_addr *iso_addr();
@@ -1019,7 +1019,7 @@ getaddr(which, s, hpp)
if (which == RTA_DST)
inet6_makenetandmask(&su->sin6);
freeaddrinfo(res);
- return 0;
+ return (0);
}
#endif
@@ -1052,7 +1052,7 @@ getaddr(which, s, hpp)
case AF_OSI:
su->siso.siso_addr = *iso_addr(s);
if (which == RTA_NETMASK || which == RTA_GENMASK) {
- register char *cp = (char *)TSEL(&su->siso);
+ char *cp = (char *)TSEL(&su->siso);
su->siso.siso_nlen = 0;
do {
--cp;
@@ -1147,14 +1147,14 @@ prefixlen(s)
memset((void *)&so_mask.sin6.sin6_addr, 0xff, q);
if (r > 0)
*((u_char *)&so_mask.sin6.sin6_addr + q) = (0xff00 >> r) & 0xff;
- return(len);
+ return (len);
}
#endif
int
x25_makemask()
{
- register char *cp;
+ char *cp;
if ((rtm_addrs & RTA_NETMASK) == 0) {
rtm_addrs |= RTA_NETMASK;
@@ -1163,7 +1163,7 @@ x25_makemask()
*cp = -1;
so_mask.sx25.x25_len = (u_char)&(((sup)0)->sx25.x25_opts);
}
- return 0;
+ return (0);
}
short ns_nullh[] = {0,0,0};
@@ -1179,7 +1179,7 @@ ns_print(sns)
static char mybuf[50+MAXHOSTNAMELEN];
char cport[10], chost[25];
char *host = "";
- register u_char *q;
+ u_char *q;
work = sns->sns_addr;
port = ntohs(work.x_port);
@@ -1224,8 +1224,8 @@ ipx_print(sipx)
u_short port;
static char mybuf[50+MAXHOSTNAMELEN], cport[10], chost[25];
char *host = "";
- register char *p;
- register u_char *q;
+ char *p;
+ u_char *q;
work = sipx->sipx_addr;
port = ntohs(work.ipx_port);
@@ -1266,7 +1266,7 @@ interfaces()
size_t needed;
int mib[6];
char *buf = NULL, *lim, *next;
- register struct rt_msghdr *rtm;
+ struct rt_msghdr *rtm;
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
@@ -1321,8 +1321,8 @@ rtmsg(cmd, flags)
{
static int seq;
int rlen;
- register char *cp = m_rtmsg.m_space;
- register int l;
+ char *cp = m_rtmsg.m_space;
+ int l;
#define NEXTADDR(w, u) \
if (rtm_addrs & (w)) {\
@@ -1390,7 +1390,7 @@ void
mask_addr()
{
int olen = so_mask.sa.sa_len;
- register char *cp1 = olen + (char *)&so_mask, *cp2;
+ char *cp1 = olen + (char *)&so_mask, *cp2;
for (so_mask.sa.sa_len = 0; cp1 > (char *)&so_mask; )
if (*--cp1 != 0) {
@@ -1458,7 +1458,7 @@ char addrnames[] =
void
print_rtmsg(rtm, msglen)
- register struct rt_msghdr *rtm;
+ struct rt_msghdr *rtm;
int msglen;
{
struct if_msghdr *ifm;
@@ -1496,14 +1496,14 @@ print_rtmsg(rtm, msglen)
void
print_getmsg(rtm, msglen)
- register struct rt_msghdr *rtm;
+ struct rt_msghdr *rtm;
int msglen;
{
struct sockaddr *dst = NULL, *gate = NULL, *mask = NULL;
struct sockaddr_dl *ifp = NULL;
- register struct sockaddr *sa;
- register char *cp;
- register int i;
+ struct sockaddr *sa;
+ char *cp;
+ int i;
(void) printf(" route to: %s\n", routename(&so_dst.sa));
if (rtm->rtm_version != RTM_VERSION) {
@@ -1594,7 +1594,7 @@ print_getmsg(rtm, msglen)
void
pmsg_common(rtm)
- register struct rt_msghdr *rtm;
+ struct rt_msghdr *rtm;
{
(void) printf("\nlocks: ");
bprintf(stdout, rtm->rtm_rmx.rmx_locks, metricnames);
@@ -1608,7 +1608,7 @@ pmsg_addrs(cp, addrs)
char *cp;
int addrs;
{
- register struct sockaddr *sa;
+ struct sockaddr *sa;
int i;
if (addrs == 0)
@@ -1628,11 +1628,11 @@ pmsg_addrs(cp, addrs)
void
bprintf(fp, b, s)
- register FILE *fp;
- register int b;
- register u_char *s;
+ FILE *fp;
+ int b;
+ u_char *s;
{
- register int i;
+ int i;
int gotsome = 0;
if (b == 0)
@@ -1659,16 +1659,16 @@ int
keyword(cp)
char *cp;
{
- register struct keytab *kt = keywords;
+ struct keytab *kt = keywords;
while (kt->kt_cp && strcmp(kt->kt_cp, cp))
kt++;
- return kt->kt_i;
+ return (kt->kt_i);
}
void
sodump(su, which)
- register sup su;
+ sup su;
char *which;
{
#ifdef INET6
@@ -1718,13 +1718,13 @@ sodump(su, which)
void
sockaddr(addr, sa)
- register char *addr;
- register struct sockaddr *sa;
+ char *addr;
+ struct sockaddr *sa;
{
- register char *cp = (char *)sa;
+ char *cp = (char *)sa;
int size = sa->sa_len;
char *cplim = cp + size;
- register int byte = 0, state = VIRGIN, new = 0;
+ int byte = 0, state = VIRGIN, new = 0;
memset(cp, 0, size);
cp++;
diff --git a/sbin/route/show.c b/sbin/route/show.c
index 15b2e4548d2..df0ea4a7bea 100644
--- a/sbin/route/show.c
+++ b/sbin/route/show.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: show.c,v 1.17 2000/07/27 20:12:25 angelos Exp $ */
+/* $OpenBSD: show.c,v 1.18 2000/09/24 01:02:24 millert Exp $ */
/* $NetBSD: show.c,v 1.1 1996/11/15 18:01:41 gwr Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94";
#else
-static char *rcsid = "$OpenBSD: show.c,v 1.17 2000/07/27 20:12:25 angelos Exp $";
+static char *rcsid = "$OpenBSD: show.c,v 1.18 2000/09/24 01:02:24 millert Exp $";
#endif
#endif /* not lint */
@@ -114,7 +114,7 @@ show(argc, argv)
int argc;
char **argv;
{
- register struct rt_msghdr *rtm;
+ struct rt_msghdr *rtm;
char *buf = NULL, *next, *lim;
size_t needed;
int mib[6];
@@ -173,9 +173,9 @@ pr_rthdr()
*/
static void
p_rtentry(rtm)
- register struct rt_msghdr *rtm;
+ struct rt_msghdr *rtm;
{
- register struct sockaddr *sa = (struct sockaddr *)(rtm + 1);
+ struct sockaddr *sa = (struct sockaddr *)(rtm + 1);
#ifdef notdef
static int masks_done, banner_printed;
#endif
@@ -262,13 +262,13 @@ p_sockaddr(sa, flags, width)
int flags, width;
{
char workbuf[128], *cplim;
- register char *cp = workbuf;
+ char *cp = workbuf;
switch(sa->sa_family) {
case AF_LINK:
{
- register struct sockaddr_dl *sdl = (struct sockaddr_dl *)sa;
+ struct sockaddr_dl *sdl = (struct sockaddr_dl *)sa;
if (sdl->sdl_nlen == 0 && sdl->sdl_alen == 0 &&
sdl->sdl_slen == 0)
@@ -276,8 +276,8 @@ p_sockaddr(sa, flags, width)
else switch (sdl->sdl_type) {
case IFT_ETHER:
{
- register int i;
- register u_char *lla = (u_char *)sdl->sdl_data +
+ int i;
+ u_char *lla = (u_char *)sdl->sdl_data +
sdl->sdl_nlen;
cplim = "";
@@ -297,7 +297,7 @@ p_sockaddr(sa, flags, width)
case AF_INET:
{
- register struct sockaddr_in *sin = (struct sockaddr_in *)sa;
+ struct sockaddr_in *sin = (struct sockaddr_in *)sa;
if (sin->sin_addr.s_addr == 0)
cp = "default";
@@ -327,7 +327,7 @@ p_sockaddr(sa, flags, width)
default:
{
- register u_char *s = (u_char *)sa->sa_data, *slim;
+ u_char *s = (u_char *)sa->sa_data, *slim;
slim = sa->sa_len + (u_char *) sa;
cplim = cp + sizeof(workbuf) - 6;
@@ -352,11 +352,11 @@ p_sockaddr(sa, flags, width)
static void
p_flags(f, format)
- register int f;
+ int f;
char *format;
{
char name[33], *flags;
- register const struct bits *p = bits;
+ const struct bits *p = bits;
for (flags = name; p->b_mask && flags < &name[sizeof name-2]; p++)
if (p->b_mask & f)