Module ipaddr :: Class IPv6
[show private | hide private]
[frames | no frames]

Type IPv6

object --+    
         |    
    BaseIP --+
             |
            IPv6


This class respresents and manipulates 128-bit IPv6 addresses.

Attributes: [examples for IPv6('2001:658:22A:CAFE:200::1/64')]
    .ip: 42540616829182469433547762482097946625L
    .ip_ext: '2001:658:22a:cafe:200::1'
    .ip_ext_full: '2001:0658:022a:cafe:0200:0000:0000:0001'
    .network: 42540616829182469433403647294022090752L
    .network_ext: '2001:658:22a:cafe::'
    .hostmask: 18446744073709551615L
    .hostmask_ext: '::ffff:ffff:ffff:ffff'
    .broadcast: 42540616829182469451850391367731642367L
    .broadcast_ext: '2001:658:22a:cafe:ffff:ffff:ffff:ffff'
    .netmask: 340282366920938463444927863358058659840L
    .netmask_ext: 64
    .prefixlen: 64

Method Summary
  __init__(self, ipaddr)
Instantiate a new IPv6 object.
  SetPrefix(self, prefixlen)
Change the prefix length.
  Subnet(self, prefixlen_diff)
The subnets which join to make the current subnet.
  Supernet(self, prefixlen_diff)
The supernet containing the current network.
  _CompressHextets(self, hextets)
Compresses a list of hextets.
  _ExplodeShortHandIpStr(self, ip_str)
Expand a shortened IPv6 address.
  _IpIntFromStr(self, ip_str)
Turn an IPv6 address into an integer.
  _IsShortHandIp(self, ip_str)
Determine if the address is shortened.
  _IsValidIp(self, ip_str)
Ensure we have a valid IPv6 address.
  _IsValidNetmask(self, prefixlen)
Verify that the netmask/prefixlen is valid.
  _StrFromIpInt(self, ip_int)
Turns a 128-bit integer into hexadecimal notation.
    Inherited from BaseIP
  __cmp__(self, other)
  __contains__(self, other)
Return True if other is contained by self.
  __eq__(self, other)
  __getitem__(self, n)
  __hash__(self)
  __hex__(self)
  __int__(self)
  __ne__(self, other)
  __repr__(self)
  __str__(self)
  AddressExclude(self, other)
Remove an address from a larger block.
  CompareNetworks(self, other)
Compare two IP objects.
  Contains(self, other)
Return True if other is contained by self.
  _IpIntFromPrefixlen(self, prefixlen)
Turn the prefix length netmask into a int for comparison.
  _IpStrFromPrefixlen(self, prefixlen)
Turn a prefix length into a dotted decimal string.
  _PrefixlenFromIpInt(self, ip_int, mask)
Return prefix length from the decimal netmask.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value

Property Summary
  ip_ext_full
  netmask_ext
  version
    Inherited from BaseIP
  broadcast
  broadcast_ext
  hostmask
  hostmask_ext
  ip_ext
  network
  network_ext
  numhosts

Class Variable Summary
long _ALL_ONES = 340282366920938463463374607431768211455L

Method Details

__init__(self, ipaddr)
(Constructor)

Instantiate a new IPv6 object.

Args:
    ipaddr: A string or integer representing the IP or the IP
      and prefix/netmask.
      '2001:4860::/128'
      '2001:4860:0000:0000:0000:0000:0000:0000/128'
      '2001:4860::'
      are all functionally the same in IPv6.  That is to say,
      failing to provide a subnetmask will create an object with
      a mask of /128.

      Additionally, an integer can be passed, so
      IPv6('2001:4860::') ==
      IPv6(42541956101370907050197289607612071936L).
      or, more generally
      IPv6(IPv6('2001:4860::').ip) == IPv6('2001:4860::')

Raises:
    IPv6IpValidationError: If ipaddr isn't a valid IPv6 address.
    IPv6NetmaskValidationError: If the netmask isn't valid for
      an IPv6 address.
Overrides:
__builtin__.object.__init__

SetPrefix(self, prefixlen)

Change the prefix length.

Args:
    prefixlen: An integer, the new prefix length.

Raises:
    IPv6NetmaskValidationError: If prefixlen is out of bounds.

Subnet(self, prefixlen_diff=1)

The subnets which join to make the current subnet.

In the case that self contains only one IP
(self.prefixlen == 128), return a list with just ourself.

Args:
    prefixlen_diff: An integer, the amount the prefix length
      should be increased by.

Returns:
    A list of IPv6 objects.

Raises:
    PrefixlenDiffInvalidError: The prefixlen_diff is too small
      or too large.

Supernet(self, prefixlen_diff=1)

The supernet containing the current network.

Args:
    prefixlen_diff: An integer, the amount the prefix length of the
      network should be decreased by.  For example, given a /96
      network and a prefixlen_diff of 3, a supernet with a /93
      netmask is returned.

Returns:
    An IPv6 object.

Raises:
    PrefixlenDiffInvalidError: If
      self.prefixlen - prefixlen_diff < 0. I.e., you have a
      negative prefix length.

_CompressHextets(self, hextets)

Compresses a list of hextets.

Compresses a list of strings, replacing the longest continuous
sequence of "0" in the list with "" and adding empty strings at
the beginning or at the end of the string such that subsequently
calling ":".join(hextets) will produce the compressed version of
the IPv6 address.

Args:
    hextets: A list of strings, the hextets to compress.

Returns:
    A list of strings.

_ExplodeShortHandIpStr(self, ip_str)

Expand a shortened IPv6 address.

Args:
    ip_str: A string, the IPv6 address.

Returns:
    A string, the expanded IPv6 address.

_IpIntFromStr(self, ip_str=None)

Turn an IPv6 address into an integer.

Args:
    ip_str: A string, the IPv6 address.

Returns:
    A long, the IPv6 address.

_IsShortHandIp(self, ip_str=None)

Determine if the address is shortened.

Args:
    ip_str: A string, the IPv6 address.

Returns:
    A boolean, True if the address is shortened.

_IsValidIp(self, ip_str=None)

Ensure we have a valid IPv6 address.

Probably not as exhaustive as it should be.

Args:
    ip_str: A string, the IPv6 address.

Returns:
    A boolean, True if this is a valid IPv6 address.

_IsValidNetmask(self, prefixlen)

Verify that the netmask/prefixlen is valid.

Args:
    prefixlen: A string, the netmask in prefix length format.

Returns:
    A boolean, True if the prefix represents a valid IPv6
    netmask.

_StrFromIpInt(self, ip_int=None)

Turns a 128-bit integer into hexadecimal notation.

Args:
    ip_int: An integer, the IP address.

Returns:
    A string, the hexadecimal representation of the address.

Raises:
    ValueError: The address is bigger than 128 bits of all ones.

Property Details

ip_ext_full

Get Method:
ip_ext_full(...)

netmask_ext

Get Method:
netmask_ext(...)

version

Get Method:
version(...)

Class Variable Details

_ALL_ONES

Type:
long
Value:
340282366920938463463374607431768211455L                               

Generated by Epydoc 2.1 on Tue Feb 3 11:02:37 2009 http://epydoc.sf.net