PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB` netaddr
Package netaddr
[hide private]
[frames] | no frames]

Package netaddr

A Python library for manipulating IP and EUI network addresses.


Version: 0.7.5

Submodules [hide private]

Classes [hide private]
  AddrConversionError
An Exception indicating a failure to convert between address types or notations.
  AddrFormatError
An Exception indicating a network address is not correctly formatted.
  NotRegisteredError
An Exception indicating that an OUI or IAB was not found in the IEEE Registry.
  IPAddress
An individual IPv4 or IPv6 address without a net mask or subnet prefix.
  IPNetwork
An IPv4 or IPv6 network or subnet.
  IPRange
An arbitrary IPv4 or IPv6 address range.
  IPSet
Represents an unordered collection (set) of unique IP addresses and subnets.
  IPGlob
Represents an IP address range using a glob-style syntax (x.x.x-y.*).
  EUI
An IEEE EUI (Extended Unique Identifier).
  IAB
An individual IEEE IAB (Individual Address Block) identifier.
  OUI
An individual IEEE OUI (Organisationally Unique Identifier).
  ipv6_compact
An IPv6 dialect class - compact form.
  ipv6_full
An IPv6 dialect class - 'all zeroes' form.
  ipv6_verbose
An IPv6 dialect class - extra wide 'all zeroes' form.
  mac_eui48
A standard IEEE EUI-48 dialect class.
  mac_unix
A UNIX-style MAC address dialect class.
  mac_cisco
A Cisco 'triple hextet' MAC address dialect class.
  mac_bare
A bare (no delimiters) MAC address dialect class.
  mac_pgsql
A PostgreSQL style (2 x 24-bit words) MAC address dialect class.
Functions [hide private]
 
all_matching_cidrs(ip, cidrs)
Matches an IP address or subnet against a given sequence of IP addresses and subnets.
 
cidr_abbrev_to_verbose(abbrev_cidr)
A function that converts abbreviated IPv4 CIDRs to their more verbose equivalent.
 
cidr_exclude(target, exclude)
Removes an exclude IP address or subnet from target IP subnet.
 
cidr_merge(ip_addrs)
A function that accepts an iterable sequence of IP addresses and subnets merging them into the smallest possible list of CIDRs.
 
iprange_to_cidrs(start, end)
A function that accepts an arbitrary start and end IP address or subnet and returns a list of CIDR subnets that fit exactly between the boundaries of the two with no overlap.
 
iter_iprange(start, end, step=1)
A generator that produces IPAddress objects between an arbitrary start and stop IP address with intervals of step between them.
 
iter_unique_ips(*args)
Returns: A generator that flattens out IP subnets, yielding unique individual IP addresses (no duplicates).
 
largest_matching_cidr(ip, cidrs)
Matches an IP address or subnet against a given sequence of IP addresses and subnets.
 
smallest_matching_cidr(ip, cidrs)
Matches an IP address or subnet against a given sequence of IP addresses and subnets.
 
spanning_cidr(ip_addrs)
Function that accepts a sequence of IP addresses and subnets returning a single IPNetwork subnet that is large enough to span the lower and upper bound IP addresses with a possible overlap on either end.
 
cidr_to_glob(cidr)
A function that accepts an IP subnet in a glob-style format and returns a list of CIDR subnets that exactly matches the specified glob.
 
glob_to_cidrs(ipglob)
A function that accepts a glob-style IP range and returns a list of one or more IP CIDRs that exactly matches it.
 
glob_to_iprange(ipglob)
A function that accepts a glob-style IP range and returns the equivalent IP range.
 
glob_to_iptuple(ipglob)
A function that accepts a glob-style IP range and returns the component lower and upper bound IP address.
 
iprange_to_globs(start, end)
A function that accepts an arbitrary start and end IP address or subnet and returns one or more glob-style IP ranges.
 
valid_glob(ipglob)
Returns: True if IP range glob is valid, False otherwise.
 
valid_nmap_range(iprange)
Returns: True if IP range is valid, False otherwise.
 
iter_nmap_range(iprange)
The nmap security tool supports a custom type of IPv4 range using multiple hyphenated octets.
 
base85_to_ipv6(addr)
Convert a base 85 IPv6 address to its hexadecimal format.
 
ipv6_to_base85(addr)
Convert a regular IPv6 address to base 85.
 
valid_ipv4(addr, flags=0)
Returns: True if IPv4 address is valid, False otherwise.
 
valid_ipv6(addr, flags=0)
Returns: True if IPv6 address is valid, False otherwise.
 
valid_mac(addr)
Returns: True if MAC address string is valid, False otherwise.
Variables [hide private]
  VERSION = (0, 7, 5)
  STATUS = ''
  ZEROFILL = 2
  Z = 2
  INET_PTON = 1
  P = 1
  NOHOST = 4
  N = 4
  __package__ = 'netaddr'
Function Details [hide private]

all_matching_cidrs(ip, cidrs)

 

Matches an IP address or subnet against a given sequence of IP addresses and subnets.

Parameters:
  • ip - a single IP address or subnet.
  • cidrs - a sequence of IP addresses and/or subnets.
Returns:
all matching IPAddress and/or IPNetwork objects from the provided sequence, an empty list if there was no match.

cidr_abbrev_to_verbose(abbrev_cidr)

 

A function that converts abbreviated IPv4 CIDRs to their more verbose equivalent.

Parameters:
  • abbrev_cidr - an abbreviated CIDR.

    Uses the old-style classful IP address rules to decide on a default subnet prefix if one is not explicitly provided.

    Only supports IPv4 addresses.

    Examples :

       10                  - 10.0.0.0/8
       10/16               - 10.0.0.0/16
       128                 - 128.0.0.0/16
       128/8               - 128.0.0.0/8
       192.168             - 192.168.0.0/16
    
Returns:
A verbose CIDR from an abbreviated CIDR or old-style classful network address, The original value if it was not recognised as a supported abbreviation.

cidr_exclude(target, exclude)

 

Removes an exclude IP address or subnet from target IP subnet.

Parameters:
  • target - the target IP address or subnet to be divided up.
  • exclude - the IP address or subnet to be removed from target.
Returns:
list of IPNetwork objects remaining after exclusion.

cidr_merge(ip_addrs)

 

A function that accepts an iterable sequence of IP addresses and subnets merging them into the smallest possible list of CIDRs. It merges adjacent subnets where possible, those contained within others and also removes any duplicates.

Parameters:
  • ip_addrs - an iterable sequence of IP addresses and subnets.
Returns:
a summarized list of IPNetwork objects.

iprange_to_cidrs(start, end)

 

A function that accepts an arbitrary start and end IP address or subnet and returns a list of CIDR subnets that fit exactly between the boundaries of the two with no overlap.

Parameters:
  • start - the start IP address or subnet.
  • end - the end IP address or subnet.
Returns:
a list of one or more IP addresses and subnets.

iter_iprange(start, end, step=1)

 

A generator that produces IPAddress objects between an arbitrary start and stop IP address with intervals of step between them. Sequences produce are inclusive of boundary IPs.

Parameters:
  • start - start IP address.
  • end - end IP address.
  • step - (optional) size of step between IP addresses. Default: 1
Returns:
an iterator of one or more IPAddress objects.

iter_unique_ips(*args)

 
Parameters:
  • args - A list of IP addresses and subnets passed in as arguments.
Returns:
A generator that flattens out IP subnets, yielding unique individual IP addresses (no duplicates).

largest_matching_cidr(ip, cidrs)

 

Matches an IP address or subnet against a given sequence of IP addresses and subnets.

Parameters:
  • ip - a single IP address or subnet.
  • cidrs - a sequence of IP addresses and/or subnets.
Returns:
the largest (least specific) matching IPAddress or IPNetwork object from the provided sequence, None if there was no match.

smallest_matching_cidr(ip, cidrs)

 

Matches an IP address or subnet against a given sequence of IP addresses and subnets.

Parameters:
  • ip - a single IP address or subnet.
  • cidrs - a sequence of IP addresses and/or subnets.
Returns:
the smallest (most specific) matching IPAddress or IPNetwork object from the provided sequence, None if there was no match.

spanning_cidr(ip_addrs)

 

Function that accepts a sequence of IP addresses and subnets returning a single IPNetwork subnet that is large enough to span the lower and upper bound IP addresses with a possible overlap on either end.

Parameters:
  • ip_addrs - sequence of IP addresses and subnets.
Returns:
a single spanning IPNetwork subnet.

cidr_to_glob(cidr)

 

A function that accepts an IP subnet in a glob-style format and returns a list of CIDR subnets that exactly matches the specified glob.

Parameters:
  • cidr - an IP object CIDR subnet.
Returns:
a list of one or more IP addresses and subnets.

glob_to_cidrs(ipglob)

 

A function that accepts a glob-style IP range and returns a list of one or more IP CIDRs that exactly matches it.

Parameters:
  • ipglob - an IP address range in a glob-style format.
Returns:
a list of one or more IP objects.

glob_to_iprange(ipglob)

 

A function that accepts a glob-style IP range and returns the equivalent IP range.

Parameters:
  • ipglob - an IP address range in a glob-style format.
Returns:
an IPRange object.

glob_to_iptuple(ipglob)

 

A function that accepts a glob-style IP range and returns the component lower and upper bound IP address.

Parameters:
  • ipglob - an IP address range in a glob-style format.
Returns:
a tuple contain lower and upper bound IP objects.

iprange_to_globs(start, end)

 

A function that accepts an arbitrary start and end IP address or subnet and returns one or more glob-style IP ranges.

Parameters:
  • start - the start IP address or subnet.
  • end - the end IP address or subnet.
Returns:
a list containing one or more IP globs.

valid_glob(ipglob)

 
Parameters:
  • ipglob - An IP address range in a glob-style format.
Returns:
True if IP range glob is valid, False otherwise.

valid_nmap_range(iprange)

 
Parameters:
  • iprange - an nmap-style IP address range.
Returns:
True if IP range is valid, False otherwise.

iter_nmap_range(iprange)

 

The nmap security tool supports a custom type of IPv4 range using multiple hyphenated octets. This generator provides iterators yielding IP addresses according to this rule set.

Parameters:
  • iprange - an nmap-style IP address range.
Returns:
an iterator producing IPAddress objects for each IP in the range.

valid_ipv4(addr, flags=0)

 
Parameters:
  • addr - An IPv4 address in presentation (string) format.
  • flags - decides which rules are applied to the interpretation of the addr value. Supported constants are INET_PTON and ZEROFILL. See the netaddr.core docs for details.
Returns:
True if IPv4 address is valid, False otherwise.

valid_ipv6(addr, flags=0)

 
Parameters:
  • addr - An IPv6 address in presentation (string) format.
  • flags - decides which rules are applied to the interpretation of the addr value. Future use - currently has no effect.
Returns:
True if IPv6 address is valid, False otherwise.

valid_mac(addr)

 
Parameters:
  • addr - An IEEE EUI-48 (MAC) address in string form.
Returns:
True if MAC address string is valid, False otherwise.