diff options
author | Brian Raaen <github@brianraaen.com> | 2015-07-22 12:03:41 -0400 |
---|---|---|
committer | Brian Raaen <github@brianraaen.com> | 2015-07-22 12:03:41 -0400 |
commit | 71f1bf27e9fea7f9ec4cbee80aafc35b5b779b26 (patch) | |
tree | 99e7b169bd5b0d33de408c8496b9d78099a226bb | |
parent | e32317cf85c063d0c769cfb74e377886b820662f (diff) | |
parent | c494d606820b2502f161b761cbfcd428cedb3031 (diff) | |
download | netaddr-71f1bf27e9fea7f9ec4cbee80aafc35b5b779b26.tar.gz |
Merge pull request #2 from drkjam/rel-0.7.x
Pull updates from main code body
-rw-r--r-- | CHANGELOG | 19 | ||||
-rw-r--r-- | netaddr/ip/__init__.py | 2 | ||||
-rw-r--r-- | test/ip/test_ip_v4.py | 8 |
3 files changed, 26 insertions, 3 deletions
@@ -1,4 +1,23 @@ --------------- +Release: 0.7.16 +--------------- +Date: ?????? 2015 + +^^^^^^^^^^^^^^^^^^^^ +Changes since 0.7.15 +^^^^^^^^^^^^^^^^^^^^ + +* IPv4 networks with /31 and /32 netmasks are now treated according to + RFC 3021. Thanks to kalombos and braaen. + +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Specific bug fixes addressed in this release +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +FIXED Issue 96: https://github.com/drkjam/netaddr/issues/96 + - Wrong hosts and broadcasts for /31 and /32 networks. + +--------------- Release: 0.7.15 --------------- Date: 29 Jun 2015 diff --git a/netaddr/ip/__init__.py b/netaddr/ip/__init__.py index f675e23..d8f001e 100644 --- a/netaddr/ip/__init__.py +++ b/netaddr/ip/__init__.py @@ -991,7 +991,7 @@ class IPNetwork(BaseIP, IPListMixin): @property def broadcast(self): """The broadcast address of this `IPNetwork` object""" - if (self._module.width - self._prefixlen) <= 1: + if self._module.version == 4 and (self._module.width - self._prefixlen) <= 1: return None else: return IPAddress(self._value | self._hostmask_int, self._module.version) diff --git a/test/ip/test_ip_v4.py b/test/ip/test_ip_v4.py index 0b1fc4f..85fcf6a 100644 --- a/test/ip/test_ip_v4.py +++ b/test/ip/test_ip_v4.py @@ -492,10 +492,14 @@ def test_ipnetwork_incrementing_by_int(): def test_rfc3021_subnets(): # Tests for /31 subnet assert IPNetwork('192.0.2.0/31').network == IPAddress('192.0.2.0') - assert IPNetwork('192.0.2.0/31').broadcast == None + assert IPNetwork('192.0.2.0/31').broadcast is None assert list(IPNetwork('192.0.2.0/31').iter_hosts()) == [IPAddress('192.0.2.0'), IPAddress('192.0.2.1')] # Tests for /32 subnet assert IPNetwork('192.0.2.0/32').network == IPAddress('192.0.2.0') - assert IPNetwork('192.0.2.0/32').broadcast == None + assert IPNetwork('192.0.2.0/32').broadcast is None assert list(IPNetwork('192.0.2.0/32').iter_hosts()) == [IPAddress('192.0.2.0')] + + # IPv6 must not be affected + assert IPNetwork('abcd::/127').broadcast is not None + assert IPNetwork('abcd::/128').broadcast is not None |