diff options
author | Peter Moody <python@hda3.com> | 2014-03-11 09:55:46 -0700 |
---|---|---|
committer | Peter Moody <python@hda3.com> | 2014-03-11 09:55:46 -0700 |
commit | 79a65d968b079e185b4b1f1c56c497e247711e5c (patch) | |
tree | 421472a56b83b6c40e659e6d947982aa40ce8204 /Lib/ipaddress.py | |
parent | 4dfd512d3f6874108312d6c4b76ce4696da2d73e (diff) | |
download | cpython-79a65d968b079e185b4b1f1c56c497e247711e5c.tar.gz |
Issue #19157: Include the broadcast address in the usuable hosts for IPv6
in ipaddress.
Diffstat (limited to 'Lib/ipaddress.py')
-rw-r--r-- | Lib/ipaddress.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index dd71347fa9..54df39ae56 100644 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -2155,6 +2155,18 @@ class IPv6Network(_BaseV6, _BaseNetwork): if self._prefixlen == (self._max_prefixlen - 1): self.hosts = self.__iter__ + def hosts(self): + """Generate Iterator over usable hosts in a network. + + This is like __iter__ except it doesn't return the + Subnet-Router anycast address. + + """ + network = int(self.network_address) + broadcast = int(self.broadcast_address) + for x in range(network + 1, broadcast + 1): + yield self._address_class(x) + @property def is_site_local(self): """Test if the address is reserved for site-local. |