From 46c3e3ef02627e5ab48952b348a765be5719f03c Mon Sep 17 00:00:00 2001 From: Peter Moody Date: Wed, 12 Jan 2011 22:56:36 +0000 Subject: + 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 --- ipaddr.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'ipaddr.py') diff --git a/ipaddr.py b/ipaddr.py index e0c847a..0e35858 100644 --- a/ipaddr.py +++ b/ipaddr.py @@ -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. -- cgit v1.2.1