summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-05-18 01:20:49 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-05-18 01:20:49 +0000
commit0d7088b035a7230f440a77a94f9a9f656961e137 (patch)
tree4c7c5e08ce10d425f5480c1372c728f116b51cb5
parent715ea59f6afe197fac80665471b4b6bda447ed21 (diff)
allow mask == NULL in netname6.
-rw-r--r--usr.bin/netstat/route.c111
1 files changed, 57 insertions, 54 deletions
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index 756f5e51ff5..7c1a7b783c3 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.35 2000/02/05 18:46:50 itojun Exp $ */
+/* $OpenBSD: route.c,v 1.36 2000/05/18 01:20:48 itojun Exp $ */
/* $NetBSD: route.c,v 1.15 1996/05/07 02:55:06 thorpej Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "from: @(#)route.c 8.3 (Berkeley) 3/9/94";
#else
-static char *rcsid = "$OpenBSD: route.c,v 1.35 2000/02/05 18:46:50 itojun Exp $";
+static char *rcsid = "$OpenBSD: route.c,v 1.36 2000/05/18 01:20:48 itojun Exp $";
#endif
#endif /* not lint */
@@ -433,7 +433,7 @@ p_sockaddr(sa, mask, flags, width)
register char *cp = workbuf;
size_t n;
- switch(sa->sa_family) {
+ switch (sa->sa_family) {
case AF_INET:
{
register struct sockaddr_in *sin = (struct sockaddr_in *)sa;
@@ -725,59 +725,62 @@ netname6(sa6, mask)
masklen = 0;
lim = (u_char *)(mask + 1);
i = 0;
- for (p = (u_char *)mask; p < lim; p++) {
- if (final && *p) {
- illegal++;
- sin6.sin6_addr.s6_addr[i++] = 0x00;
- continue;
- }
+ if (mask) {
+ for (p = (u_char *)mask; p < lim; p++) {
+ if (final && *p) {
+ illegal++;
+ sin6.sin6_addr.s6_addr[i++] = 0x00;
+ continue;
+ }
- switch (*p & 0xff) {
- case 0xff:
- masklen += 8;
- break;
- case 0xfe:
- masklen += 7;
- final++;
- break;
- case 0xfc:
- masklen += 6;
- final++;
- break;
- case 0xf8:
- masklen += 5;
- final++;
- break;
- case 0xf0:
- masklen += 4;
- final++;
- break;
- case 0xe0:
- masklen += 3;
- final++;
- break;
- case 0xc0:
- masklen += 2;
- final++;
- break;
- case 0x80:
- masklen += 1;
- final++;
- break;
- case 0x00:
- final++;
- break;
- default:
- final++;
- illegal++;
- break;
- }
+ switch (*p & 0xff) {
+ case 0xff:
+ masklen += 8;
+ break;
+ case 0xfe:
+ masklen += 7;
+ final++;
+ break;
+ case 0xfc:
+ masklen += 6;
+ final++;
+ break;
+ case 0xf8:
+ masklen += 5;
+ final++;
+ break;
+ case 0xf0:
+ masklen += 4;
+ final++;
+ break;
+ case 0xe0:
+ masklen += 3;
+ final++;
+ break;
+ case 0xc0:
+ masklen += 2;
+ final++;
+ break;
+ case 0x80:
+ masklen += 1;
+ final++;
+ break;
+ case 0x00:
+ final++;
+ break;
+ default:
+ final++;
+ illegal++;
+ break;
+ }
- if (!illegal)
- sin6.sin6_addr.s6_addr[i++] &= *p;
- else
- sin6.sin6_addr.s6_addr[i++] = 0x00;
- }
+ if (!illegal)
+ sin6.sin6_addr.s6_addr[i++] &= *p;
+ else
+ sin6.sin6_addr.s6_addr[i++] = 0x00;
+ }
+ } else
+ masklen = 128;
if (masklen == 0 && IN6_IS_ADDR_UNSPECIFIED(&sin6.sin6_addr))
return("default");