diff options
author | Peter Moody <pmoody@google.com> | 2011-01-12 22:56:45 +0000 |
---|---|---|
committer | Peter Moody <pmoody@google.com> | 2011-01-12 22:56:45 +0000 |
commit | 2c2d0f01693aeefd8b0a1c5fa0a2d10494c4883e (patch) | |
tree | 8c81113fda3931788fe510c11c251ccf316cd09e /ipaddr.py | |
parent | 381d0c46710032afd8acfb3284c88e143b21d5ac (diff) | |
download | ipaddr-py-2c2d0f01693aeefd8b0a1c5fa0a2d10494c4883e.tar.gz |
+ add 6to4 to the ipv6 tunnel decoding.
git-svn-id: https://ipaddr-py.googlecode.com/svn/trunk@201 09200d28-7f98-11dd-ad27-0f66e57d2035
Diffstat (limited to 'ipaddr.py')
-rw-r--r-- | ipaddr.py | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -1753,15 +1753,30 @@ class _BaseV6(object): """Tuple of embedded teredo IPs. Returns: - Tuple of the (server, client) IPs. + Tuple of the (server, client) IPs or False if the address + doesn't appear to be a teredo address (doesn't start with + 2001) - Note: - This doesn't try to verify that the address is a teredo address """ bits = self._explode_shorthand_ip_string().split(':') + if not bits[0] == '2001': + return False return (IPv4Address(int(''.join(bits[2:4]), 16)), IPv4Address(int(''.join(bits[6:]), 16) ^ 0xFFFFFFFF)) + def sixtofour(self): + """Return the IPv4 6to4 embedded address. + + Returns: + The IPv4 6to4-embedded address if present or False if the + address doesn't appear to contain a 6to4 embedded address. + + """ + bits = self._explode_shorthand_ip_string().split(':') + if not bits[0] == '2002': + return False + return IPv4Address(int(''.join(bits[1:3]), 16)) + class IPv6Address(_BaseV6, _BaseIP): |