Package netaddr :: Module address
[frames] | no frames]

Module address

source code

network address classes (IP, EUI) and associated aggregate classes (CIDR, Wilcard, etc).

Classes
  AddrTypeDescriptor
A descriptor that checks addr_type property assignments for validity and also keeps the strategy property in sync with any changes made.
  AddrValueDescriptor
A descriptor that checks assignments to the named parameter passed to the constructor.
  StrategyDescriptor
A descriptor that checks strategy property assignments for validity and also keeps the addr_type property in sync with any changes made.
  PrefixLenDescriptor
A descriptor that checks prefixlen property assignments for validity based on address type.
  KlassDescriptor
A descriptor that checks klass (data flavour) property assignments for validity.
  Addr
The base class containing common functionality for all subclasses representing various network address types.
  EUI
EUI objects represent IEEE Extended Unique Identifiers.
  IP
A class whose objects represent Internet Protocol network addresses.
  AddrRange
A block of contiguous network addresses bounded by an arbitrary start and stop address.
  CIDR
A block of contiguous IPv4 or IPv6 network addresses defined by a base network address and a bitmask prefix or subnet mask address indicating the size/extent of the subnet.
  Wildcard
A block of contiguous IPv4 network addresses defined using a wildcard style syntax.
Functions
 
nrange(start, stop, step=1, klass=None)
A generator producing sequences of network addresses based on start and stop values, in intervals of step.
source code
Variables
  AT_STRATEGIES = {0: None, 4: netaddr.address.IPv4StrategyOpt(3...
Address type to strategy object lookup dict.
Function Details

nrange(start, stop, step=1, klass=None)

source code 

A generator producing sequences of network addresses based on start and stop values, in intervals of step.

Parameters:
  • start - first network address as string or instance of Addr (sub)class.
  • stop - last network address as string or instance of Addr (sub)class.
  • step - (optional) size of step between addresses in range. Default is 1.
  • klass - (optional) the class used to create objects returned. Default: Addr class.
    • str returns string representation of network address
    • int, long and hex return expected values
    • Addr (sub)class or duck type* return objects of that class. If you use your own duck class, make sure you handle both arguments (addr_value, addr_type) passed to the constructor.

Variables Details

AT_STRATEGIES

Address type to strategy object lookup dict.

Value:
{0: None,
 4: netaddr.address.IPv4StrategyOpt(32, 8, '.', 4, False, False),
 6: netaddr.address.IPv6Strategy(128, 16, ':', 6, True, False),
 48: netaddr.address.EUI48Strategy(48, 8, '-', 48, True, True),
 64: netaddr.address.AddrStrategy(64, 8, '-', 64, True, True)}