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

Class Wildcard

source code

object --+    
         |    
 AddrRange --+
             |
            Wildcard

A block of contiguous IPv4 network addresses defined using a wildcard style syntax.

Individual octets can be represented using the following shortcuts :

  1. * - the asterisk octet (represents values 0 through 255)
  2. 'x-y' - the hyphenated octet (represents values x through y)

A few basic rules also apply :

  1. x must always be greater than y, therefore :
  2. only one hyphenated octet per wildcard is allowed
  3. only asterisks are permitted after a hyphenated octet

Example wildcards :

   '192.168.0.1'       #   a single address
   '192.168.0.0-31'    #   32 addresses
   '192.168.0.*'       #   256 addresses
   '192.168.0-1.*'     #   512 addresses
   '192.168-169.*.*'   #   131,072 addresses
   '*.*.*.*'           #   the whole IPv4 address space

Aside

Wildcard ranges are not directly equivalent to CIDR ranges as they can represent address ranges that do not fall on strict bit mask boundaries.

All CIDR ranges can always be represented as wildcard ranges but the reverse isn't true in every case.

Instance Methods
 
__init__(self, wildcard, klass=<class 'netaddr.address.IP'>)
Constructor.
source code
 
cidr(self)
Returns: A valid CIDR object for this wildcard.
source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
Returns: An executable Python statement that can recreate an object with an equivalent state.
source code

Inherited from AddrRange: __contains__, __eq__, __ge__, __getitem__, __gt__, __hash__, __iadd__, __isub__, __iter__, __le__, __len__, __lt__, __ne__, data_flavour, size

Inherited from object: __delattr__, __getattribute__, __new__, __reduce__, __reduce_ex__, __setattr__

Static Methods
 
is_valid(wildcard)
A static method that validates wildcard address ranges.
source code
Class Variables
  STRATEGIES = (netaddr.address.IPv4StrategyOpt(32, 8, '.', 4, F...
  ADDR_TYPES = (0, 4, 6)
  strategy = StrategyDescriptor(STRATEGIES)
  addr_type = AddrTypeDescriptor(ADDR_TYPES)
  klass = KlassDescriptor(IP)

Inherited from AddrRange: first, last

Properties

Inherited from object: __class__

Method Details

is_valid(wildcard)
Static Method

source code 

A static method that validates wildcard address ranges.

Parameters:
  • wildcard - an IPv4 wildcard address.
Returns:
True if wildcard address is valid, False otherwise.

__init__(self, wildcard, klass=<class 'netaddr.address.IP'>)
(Constructor)

source code 

Constructor.

Parameters:
  • wildcard - a valid IPv4 wildcard address
  • klass - (optional) class used to create each return object. Default: IP objects. See nrange() documentations for additional details on options.
Overrides: object.__init__

cidr(self)

source code 
Returns:
A valid CIDR object for this wildcard. If conversion fails an AddrConversionError is raised as not all wildcards ranges are valid CIDR ranges.

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Returns:
An executable Python statement that can recreate an object with an equivalent state.
Overrides: object.__repr__

Class Variable Details

STRATEGIES

Value:
(netaddr.address.IPv4StrategyOpt(32, 8, '.', 4, False, False),
 netaddr.address.IPv6Strategy(128, 16, ':', 6, True, False))