Package netaddr
[frames] | no frames]

Package netaddr

source code

network address manipulation, done Pythonically


Version: 0.5.2

Submodules
  • netaddr.address: network address classes (IP, EUI) and associated aggregate classes (CIDR, Wilcard, etc).
  • netaddr.strategy: network address type logic, constants used to identify them and shared strategy objects.

Classes
  AddrFormatError
Network address format not recognised.
  AddrConversionError
Conversion between address types or notations failed.
  Addr
The base class containing common functionality for all subclasses representing various network address types.
  AddrRange
A block of contiguous network addresses bounded by an arbitrary start and stop address.
  IP
A class whose objects represent Internet Protocol network addresses.
  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.
  EUI
EUI objects represent IEEE Extended Unique Identifiers.
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_INET = 4
IPv4 address type constant.
  AT_INET6 = 6
IPv6 address type constant.
  AT_LINK = 48
MAC/EUI-48 address type constant.
  AT_EUI64 = 64
EUI-64 address type constant.
  ST_IPV4 = netaddr.address.IPv4StrategyOpt(32, 8, '.', 4, False...
  ST_IPV6 = netaddr.address.IPv6Strategy(128, 16, ':', 6, True, ...
  ST_EUI48 = netaddr.address.EUI48Strategy(48, 8, '-', 48, True,...
  ST_EUI64 = netaddr.address.AddrStrategy(64, 8, '-', 64, True, ...
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

ST_IPV4

Value:
netaddr.address.IPv4StrategyOpt(32, 8, '.', 4, False, False)

ST_IPV6

Value:
netaddr.address.IPv6Strategy(128, 16, ':', 6, True, False)

ST_EUI48

Value:
netaddr.address.EUI48Strategy(48, 8, '-', 48, True, True)

ST_EUI64

Value:
netaddr.address.AddrStrategy(64, 8, '-', 64, True, True)