summaryrefslogtreecommitdiffstats
path: root/sbin/route
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2001-06-08 09:07:34 +0000
committerru <ru@FreeBSD.org>2001-06-08 09:07:34 +0000
commit50544d4e122310c27531e9ee8c78b07642f4ad80 (patch)
treefe9bbad640c0ac90e4d0b598d262cca2dfd88d73 /sbin/route
parent05d2bc21eb72cda1cbb3da5d05ccf702278302eb (diff)
downloadFreeBSD-src-50544d4e122310c27531e9ee8c78b07642f4ad80.zip
FreeBSD-src-50544d4e122310c27531e9ee8c78b07642f4ad80.tar.gz
Change the host/bits syntax introduced in route.c,v 1.24 to the
net/bits syntax, for consistency with netstat(1) in particular. OK'ed by: phk MFC after: 1 week
Diffstat (limited to 'sbin/route')
-rw-r--r--sbin/route/route.86
-rw-r--r--sbin/route/route.c11
2 files changed, 8 insertions, 9 deletions
diff --git a/sbin/route/route.8 b/sbin/route/route.8
index 5e67f44..a6d8b72 100644
--- a/sbin/route/route.8
+++ b/sbin/route/route.8
@@ -168,7 +168,7 @@ route to a host.
Optionally, the
.Ar destination
could also be specified in the
-.Ar host Ns / Ns Ar bits
+.Ar net Ns / Ns Ar bits
format.
.Pp
For example,
@@ -185,9 +185,9 @@ is interpreted as
is interpreted as
.Li 128.32.130.0;
and
-.Li 192.168.0.0/16
+.Li 192.168.64/20
is interpreted as
-.Li 192.168.0.0 Fl netmask Li 255.255.0.0 .
+.Fl net Li 192.168.64 Fl netmask Li 255.255.240.0 .
.Pp
A
.Ar destination
diff --git a/sbin/route/route.c b/sbin/route/route.c
index 77aa720..467dbe1 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -759,10 +759,7 @@ inet_makenetandmask(net, sin, bits)
register char *cp;
rtm_addrs |= RTA_NETMASK;
- if (bits) {
- addr = net;
- mask = 0xffffffff << (32 - bits);
- } else if (net == 0)
+ if (net == 0)
mask = addr = 0;
else if (net < 128) {
addr = net << IN_CLASSA_NSHIFT;
@@ -784,6 +781,8 @@ inet_makenetandmask(net, sin, bits)
else
mask = -1;
}
+ if (bits)
+ mask = 0xffffffff << (32 - bits);
sin->sin_addr.s_addr = htonl(addr);
sin = &so_mask.sin;
sin->sin_addr.s_addr = htonl(mask);
@@ -976,9 +975,9 @@ getaddr(which, s, hpp)
q = strchr(s,'/');
if (q && which == RTA_DST) {
*q = '\0';
- if ((val = inet_addr(s)) != INADDR_NONE) {
+ if ((val = inet_network(s)) != INADDR_NONE) {
inet_makenetandmask(
- ntohl(val), &su->sin, strtoul(q+1, 0, 0));
+ val, &su->sin, strtoul(q+1, 0, 0));
return (0);
}
*q = '/';
OpenPOWER on IntegriCloud