return CidrV6(address, netlen)
return CidrV4(address, netlen)
+def valid_cidr(address):
+ """Returns the converted Cidr object if 'address' is valid CIDR
+ notation, False if not. For the purposes of this module, valid
+ CIDR notation consists of a IPv4 or IPv6 address with an optional
+ trailing "/netlen"."""
+
+ if isinstance(address, Cidr): return address
+ try:
+ c = new(address)
+ return c
+ except (ValueError, socket.error):
+ return False
+
+
class Cidr:
"""A class representing a generic CIDRized network value."""
return self._base_mask(CidrV6.base_mask << (128 - len))
-def valid_cidr(address):
- """Returns the converted Cidr object if 'address' is valid CIDR
- notation, False if not. For the purposes of this module, valid
- CIDR notation consists of a IPv4 or IPv6 address with an optional
- trailing "/netlen"."""
-
- if isinstance(address, Cidr): return address
- try:
- c = new(address)
- return c
- except (ValueError, socket.error):
- return False
-
def netblock_to_cidr(start, end):
"""Convert an arbitrary network block expressed as a start and end
address (inclusive) into a series of valid CIDR blocks."""