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

# Class IPv6Strategy

source code

      object --+
               |
    AddrStrategy --+
                   |
                  IPv6Strategy

Implements the operations that can be performed on an Internet Protocol version 6 network address in accordance with RFC 4291.

NB - This class would benefit greatly from access to inet_pton/inet_ntop() function calls in Python's socket module. Sadly, they aren't available so we'll have to put up with the pure-Python implementation here (for now at least).

Instance Methods
__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 network byte order 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 network byte order integer value provided. | 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 `AddrStrategy`: `__repr__`, `bits_to_int`, `int_to_bin`, `int_to_bits`, `int_to_packed`, `int_to_words`, `packed_to_int`, `valid_bits`, `valid_int`, `valid_words`, `words_to_int` Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__str__`

Class Variables
Inherited from `AddrStrategy`: `STRUCT_FORMATS`

Properties
Inherited from `object`: `__class__`

Method Details

### __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) `uppercase` - uppercase address. (Default: False) 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 network byte order 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` - A network byte order 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. Returns: The IPv6 string form equal to the network byte order integer value provided. Overrides: AddrStrategy.int_to_str

### int_to_arpa(self, int_val) | source code
Parameters: `int_val` - A network byte order integer. Returns: The reverse DNS lookup for an IPv6 address in network byte order integer form.