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

Module address

source code

network address classes (IP, EUI) and associated aggregate classes (CIDR, Wildcard and IPRange).

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.
  FormatDescriptor
A descriptor that checks formatter property assignments for validity.
  Addr
The base class containing common functionality for all subclasses representing various network address types.
  EUI
Represents an IEEE EUI (Extended Unique Identifier) indentifier.
  IP
Represents individual IPv4 and IPv6 addresses.
  IPRange
Represents arbitrary contiguous blocks of IPv4 and IPv6 addresses using only a lower and upper bound IP address.
  CIDR
Represents blocks of IPv4 and IPv6 addresses using CIDR (Classless Inter-Domain Routing) notation.
  Wildcard
Represents blocks of IPv4 addresses using a wildcard or glob style syntax.
  IPRangeSet
*EXPERIMENTAL* A customised Python set class that deals with collections of IPRange class and subclass instances.
Functions
 
nrange(start, stop, step=1, fmt=None)
An xrange work alike generator that produces sequences of IP addresses based on start and stop addresses, in intervals of step size.
source code
Variables
  AT_STRATEGIES = {0: None, 4: IPv4StrategyOpt(32, 8, '.', 4, 10...
Address type to strategy object lookup dict.
Function Details

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

source code 

An xrange work alike generator that produces sequences of IP addresses based on start and stop addresses, in intervals of step size.

Parameters:
  • start - first IP address string or IP object in range.
  • stop - last IP address string or IP object in range
  • step - (optional) size of step between address in range. (Default: 1)
  • fmt - (optional) callable used on addresses returned. (Default: None - IP objects). Supported options :-
    • str - IP address strings
    • int, long - IP address integer (network byte order)
    • hex - IP address as a hexadecimal number
    • IP class/subclass or callable that accepts addr_value and addr_type arguments.

Variables Details

AT_STRATEGIES

Address type to strategy object lookup dict.

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