summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mrouted/inet.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-01-06 21:10:30 +0000
committerpeter <peter@FreeBSD.org>1996-01-06 21:10:30 +0000
commitd4c03f31b99ac4bd269582b4d2fee704364a2c1e (patch)
treef1d0a40a2a6e33e9f309cdfe59bfbb0d9a7d4628 /usr.sbin/mrouted/inet.c
parenta8e9d6a2eaa9df5881201d40c5c05c6154333fef (diff)
downloadFreeBSD-src-d4c03f31b99ac4bd269582b4d2fee704364a2c1e.zip
FreeBSD-src-d4c03f31b99ac4bd269582b4d2fee704364a2c1e.tar.gz
Resync our mainline to mrouted release 3.8.
This will make FreeBSD boxes better behaved 'MBONE Citizens', based on a couple of the comments about the severity of fixes.. Agreed to by: wollman, fenner@parc.xerox.com
Diffstat (limited to 'usr.sbin/mrouted/inet.c')
-rw-r--r--usr.sbin/mrouted/inet.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/usr.sbin/mrouted/inet.c b/usr.sbin/mrouted/inet.c
index e8d5ab6..b60e385 100644
--- a/usr.sbin/mrouted/inet.c
+++ b/usr.sbin/mrouted/inet.c
@@ -7,7 +7,7 @@
* Leland Stanford Junior University.
*
*
- * $Id: inet.c,v 3.6 1995/06/25 18:54:45 fenner Exp $
+ * $Id: inet.c,v 3.8 1995/11/29 22:36:57 fenner Rel $
*/
@@ -41,6 +41,22 @@ inet_valid_host(naddr)
(addr & 0xff000000) == 0));
}
+/*
+ * Verify that a given netmask is plausible;
+ * make sure that it is a series of 1's followed by
+ * a series of 0's with no discontiguous 1's.
+ */
+int
+inet_valid_mask(mask)
+ u_int32 mask;
+{
+ if (~(((mask & -mask) - 1) | mask) != 0) {
+ /* Mask is not contiguous */
+ return (FALSE);
+ }
+
+ return (TRUE);
+}
/*
* Verify that a given subnet number and mask pair are credible.
@@ -62,21 +78,26 @@ inet_valid_subnet(nsubnet, nmask)
if ((subnet & mask) != subnet) return (FALSE);
- if (subnet == 0 && mask == 0)
- return (TRUE);
+ if (subnet == 0)
+ return (mask == 0);
if (IN_CLASSA(subnet)) {
if (mask < 0xff000000 ||
- (subnet & 0xff000000) == 0x7f000000) return (FALSE);
+ (subnet & 0xff000000) == 0x7f000000 ||
+ (subnet & 0xff000000) == 0x00000000) return (FALSE);
}
else if (IN_CLASSD(subnet) || IN_BADCLASS(subnet)) {
/* Above Class C address space */
return (FALSE);
}
- else if (subnet & ~mask) {
+ if (subnet & ~mask) {
/* Host bits are set in the subnet */
return (FALSE);
}
+ if (!inet_valid_mask(mask)) {
+ /* Netmask is not contiguous */
+ return (FALSE);
+ }
return (TRUE);
}
OpenPOWER on IntegriCloud