Package netaddr :: Module strategy :: Class IPv6Strategy
[hide private]
[frames] | no frames]

Class IPv6Strategy

source code

  object --+    
           |    
AddrStrategy --+
               |
              IPv6Strategy

An AddrStrategy for IPv6 address processing.

Implements the operations that can be performed on an IPv6 network address in accordance with RFC 4291.

Instance Methods [hide private]
 
__init__(self)
Constructor.
source code
 
valid_str(self, addr)
Returns: True if IPv6 network address string is valid, False otherwise.
source code
 
str_to_int(self, addr)
Returns: The equivalent unsigned integer for a given IPv6 address.
source code
 
int_to_str(self, int_val, compact=True, word_fmt=None)
Returns: The IPv6 string form equal to the unsigned integer provided.
source code
 
int_to_packed(self, int_val)
Returns: a packed string that is equivalent to value represented by an unsigned integer (in network byte order).
source code
 
packed_to_int(self, packed_int)
Returns: An unsigned integer that is equivalent to value of network address represented by packed binary string.
source code
 
int_to_arpa(self, int_val)
Returns: The reverse DNS lookup for an IPv6 address in network byte order integer form.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

    Inherited from AddrStrategy
 
__repr__(self)
Returns: executable Python string to recreate equivalent object
source code
 
bits_to_int(self, bits)
Returns: An unsigned integer that is equivalent to value represented by network address in readable binary form.
source code
 
int_to_bin(self, int_val)
Returns: A network address in standard binary representation format that is equivalent to integer address value.
source code
 
int_to_bits(self, int_val, word_sep=None)
Returns: A network address in readable binary form that is equivalent to value represented by an unsigned integer.
source code
 
int_to_words(self, int_val, num_words=None, word_size=None) source code
 
valid_bits(self, bits)
Returns: True if network address is valid for this address type, False otherwise.
source code
 
valid_int(self, int_val)
Returns: True if integer falls within the boundaries of this address type, False otherwise.
source code
 
valid_words(self, words)
Returns: True if word sequence is valid for this address type, False otherwise.
source code
 
words_to_int(self, words)
Returns: An unsigned integer that is equivalent to value represented by word sequence.
source code
Class Variables [hide private]
    Inherited from AddrStrategy
  STRUCT_FORMATS = {8: 'B', 16: 'H', 32: 'I'}
Lookup table for struct module format strings.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

Constructor.

Parameters:
  • width - size of address in bits. (e.g. 32 - IPv4, 48 - MAC, 128 - IPv6)
  • word_size - size of each word. (e.g. 8 - octets, 16 - hextets)
  • word_sep - separator between each word. (e.g. '.' - IPv4, ':' - IPv6, '-' - EUI-48)
  • word_fmt - format string for each word. (Default: '%x')
  • addr_type - address type. (Default: AT_UNSPEC)
  • word_base - number base used to convert each word using int(). (Default: 16)
Overrides: object.__init__

valid_str(self, addr)

source code 
Parameters:
  • addr - An IPv6 address in string form.
Returns:
True if IPv6 network address string is valid, False otherwise.
Overrides: AddrStrategy.valid_str

str_to_int(self, addr)

source code 
Parameters:
  • addr - An IPv6 address in string form.
Returns:
The equivalent unsigned integer for a given IPv6 address.
Overrides: AddrStrategy.str_to_int

int_to_str(self, int_val, compact=True, word_fmt=None)

source code 
Parameters:
  • int_val - An unsigned integer.
  • compact - (optional) A boolean flag indicating if compact formatting should be used. If True, this method uses the '::' string to represent the first adjacent group of words with a value of zero. Default: True
  • word_fmt - (optional) The Python format string used to override formatting for each word. Only applies when compact is False.
Returns:
The IPv6 string form equal to the unsigned integer provided.
Overrides: AddrStrategy.int_to_str

int_to_packed(self, int_val)

source code 
Parameters:
  • int_val - the integer to be packed.
Returns:
a packed string that is equivalent to value represented by an unsigned integer (in network byte order).
Overrides: AddrStrategy.int_to_packed

packed_to_int(self, packed_int)

source code 
Parameters:
  • packed_int - a packed string containing an unsigned integer. It is assumed that string is packed in network byte order.
Returns:
An unsigned integer that is equivalent to value of network address represented by packed binary string.
Overrides: AddrStrategy.packed_to_int

int_to_arpa(self, int_val)

source code 
Parameters:
  • int_val - An unsigned integer.
Returns:
The reverse DNS lookup for an IPv6 address in network byte order integer form.