diff options
author | Peter Moody <pmoody@google.com> | 2011-01-12 22:56:36 +0000 |
---|---|---|
committer | Peter Moody <pmoody@google.com> | 2011-01-12 22:56:36 +0000 |
commit | 46c3e3ef02627e5ab48952b348a765be5719f03c (patch) | |
tree | a46718805d46a78ff859ca7ad74896457b745300 /ipaddr.py | |
parent | bfa3f94bb35e7634e7b8125192f16727b9a7b6a2 (diff) | |
download | ipaddr-py-46c3e3ef02627e5ab48952b348a765be5719f03c.tar.gz |
+ fix for i71
add support for pulling the teredo client and server addresses out
of an ipv6 address.
git-svn-id: https://ipaddr-py.googlecode.com/svn/trunk@199 09200d28-7f98-11dd-ad27-0f66e57d2035
Diffstat (limited to 'ipaddr.py')
-rw-r--r-- | ipaddr.py | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -29,6 +29,7 @@ import struct IPV4LENGTH = 32 IPV6LENGTH = 128 + class AddressValueError(ValueError): """A Value Error related to the address.""" @@ -1748,6 +1749,20 @@ class _BaseV6(object): except AddressValueError: return None + def teredo(self): + """Tuple of embedded teredo IPs. + + Returns: + Tuple of the (server, client) IPs. + + Note: + This doesn't try to verify that the address is a teredo address + """ + server_bits = self._explode_shorthand_ip_string().split(':')[2:4] + client_bits = self._explode_shorthand_ip_string().split(':')[6:] + return (IPv4Address(int(''.join(server_bits), 16)), + IPv4Address(int(''.join(client_bits), 16) ^ 0xFFFFFFFF)) + class IPv6Address(_BaseV6, _BaseIP): @@ -1898,7 +1913,6 @@ class IPv6Network(_BaseV6, _BaseNet): raise ValueError('%s has host bits set' % self.ip) - def _is_valid_netmask(self, prefixlen): """Verify that the netmask/prefixlen is valid. |