summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpmoody@google.com <pmoody@google.com@09200d28-7f98-11dd-ad27-0f66e57d2035>2010-02-05 22:54:22 +0000
committerpmoody@google.com <pmoody@google.com@09200d28-7f98-11dd-ad27-0f66e57d2035>2010-02-05 22:54:22 +0000
commit821c81fdd4749208c9731c74f55eca5930cf2a8a (patch)
tree0b2d7971f0de5a3db5c5a864eb27f2eb0f34ee83
parente1e83e4ac5232246a8badc40a9e93a4f95648418 (diff)
downloadipaddr-py-821c81fdd4749208c9731c74f55eca5930cf2a8a.tar.gz
+ add IPv4Network().is_unspecified. issue52.
(thanks to rep.dot.net for the bug report and patch). git-svn-id: https://ipaddr-py.googlecode.com/svn@137 09200d28-7f98-11dd-ad27-0f66e57d2035
-rw-r--r--trunk/ipaddr.py11
-rwxr-xr-xtrunk/ipaddr_test.py2
2 files changed, 13 insertions, 0 deletions
diff --git a/trunk/ipaddr.py b/trunk/ipaddr.py
index fdf2e4c..0f55b02 100644
--- a/trunk/ipaddr.py
+++ b/trunk/ipaddr.py
@@ -1045,6 +1045,17 @@ class _BaseV4(object):
return self in IPv4Network('224.0.0.0/4')
@property
+ def is_unspecified(self):
+ """Test if the address is unspecified.
+
+ Returns:
+ A boolean, True if this is the unspecified address as defined in
+ RFC 5735 3.
+
+ """
+ return self in IPv4Network('0.0.0.0')
+
+ @property
def is_loopback(self):
"""Test if the address is a loopback address.
diff --git a/trunk/ipaddr_test.py b/trunk/ipaddr_test.py
index b019014..4336ddf 100755
--- a/trunk/ipaddr_test.py
+++ b/trunk/ipaddr_test.py
@@ -656,6 +656,8 @@ class IpaddrUnitTest(unittest.TestCase):
self.assertEquals(True, ipaddr.IPAddress('127.42.0.0').is_loopback)
self.assertEquals(False, ipaddr.IPAddress('128.0.0.0').is_loopback)
+ self.assertEquals(True, ipaddr.IPNetwork('0.0.0.0').is_unspecified)
+
def testReservedIpv6(self):