summaryrefslogtreecommitdiff
path: root/ipaddr.py
diff options
context:
space:
mode:
authorPeter Moody <pmoody@google.com>2010-05-10 05:54:16 +0000
committerPeter Moody <pmoody@google.com>2010-05-10 05:54:16 +0000
commitd9c3704814986df2a7783ec641882d35d7025852 (patch)
tree073f23452d894abc6a1cddf927fd7dfab864f9c3 /ipaddr.py
parentb002fb292645ea2b08a5baf822c44a578473ef3b (diff)
downloadipaddr-py-d9c3704814986df2a7783ec641882d35d7025852.tar.gz
+ add masked() to _BaseNet to automatically mask out
the host bits of a network object. issue58. Reported by Robert Thomson. git-svn-id: https://ipaddr-py.googlecode.com/svn/trunk@166 09200d28-7f98-11dd-ad27-0f66e57d2035
Diffstat (limited to 'ipaddr.py')
-rw-r--r--ipaddr.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/ipaddr.py b/ipaddr.py
index f7c7d2c..5f3a15b 100644
--- a/ipaddr.py
+++ b/ipaddr.py
@@ -903,6 +903,11 @@ class _BaseNet(_IPAddrBase):
yield current
+ def masked(self):
+ """Return the network object with the host bits masked out."""
+ return IPNetwork('%s/%d' % (self.network, self._prefixlen),
+ version=self._version)
+
def subnet(self, prefixlen_diff=1, new_prefix=None):
"""Return a list of subnets, rather than an interator."""
return list(self.iter_subnets(prefixlen_diff, new_prefix))