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

# Class IPv4StrategyStd

source code

      object --+
               |
    AddrStrategy --+
                   |
                  IPv4StrategyStd

Known Subclasses:
  - IPv4StrategyOpt

A 'safe' AddrStrategy for IPv4 addresses. Unlike IPv4StrategyOpt.

It contains all methods related to IPv4 addresses that the optimised version has, without the reliance on the socket or struct modules. There are several cases where the use of this class are preferable when either the modules mentioned do not exist on certain Python implementations or contain bugs like the infamous inet_aton('255.255.255.254') bug.

All methods shared between the optimised class and this one should be defined here.

Instance Methods
__init__(self) Constructor. | source code
int_to_arpa(self, int_val) Returns: The reverse DNS lookup for an IPv4 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_str`, `int_to_words`, `packed_to_int`, `str_to_int`, `valid_bits`, `valid_int`, `valid_str`, `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__

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