From 50640b654331d0f68613ee6c40a8e0200491b46b Mon Sep 17 00:00:00 2001 From: Pierre Barre Date: Sat, 11 Jan 2020 17:56:49 +0100 Subject: [PATCH] `is_subnet_of` fix was broken if the supernet was not the network address. Signed-off-by: Fredrick Brennan --- src/ipv4.rs | 2 +- src/ipv6.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ipv4.rs b/src/ipv4.rs index d9b1db2..06726ff 100644 --- a/src/ipv4.rs +++ b/src/ipv4.rs @@ -80,7 +80,7 @@ impl Ipv4Network { /// Checks if the given `Ipv4Network` is a subnet of the other. pub fn is_subnet_of(self, other: Ipv4Network) -> bool { - other.ip() <= self.ip() && other.broadcast() >= self.broadcast() + other.network() <= self.network() && other.broadcast() >= self.broadcast() } /// Checks if the given `Ipv4Network` is a supernet of the other. diff --git a/src/ipv6.rs b/src/ipv6.rs index 129edab..f3a21e7 100644 --- a/src/ipv6.rs +++ b/src/ipv6.rs @@ -122,7 +122,7 @@ impl Ipv6Network { /// Checks if the given `Ipv6Network` is a subnet of the other. pub fn is_subnet_of(self, other: Ipv6Network) -> bool { - other.ip() <= self.ip() && other.broadcast() >= self.broadcast() + other.network() <= self.network() && other.broadcast() >= self.broadcast() } /// Checks if the given `Ipv6Network` is a supernet of the other.