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`  w{Zc@s[dZddlZddlZddlmZmZmZm Z m Z m Z m Z m Z mZmZddlmZmZddlmZmZmZmZmZejdZejdZejdZd efd YZ d e fd YZ!d efdYZ"e#ddZ$de e"fdYZ%de e"fdYZ&dZ'dZ(dZ)dZ*dZ+ddZ,dZ-dZ.dZ/dZ0e%d Z1e%d!e%d"e%d#e%d$e%d%e%d&e&d'd(fZ2e%d)Z3e%d*Z4e%d+Z5e%d,e%d-e%d.e%d/e%d0e%d1e&d2d3e&d4d5fe1e5fZ6e!d6Z7e%d7e%d8fZ8e%d9Z9e%d:Z:e%d;e%d<e%d=e%d>e%d?e%d@e%dAe%dBe%dCe%dDe%dEe%dFe%dGe%dHe%dIe%dJfZ;dS(Ks9Routines for IPv4 and IPv6 addresses, subnets and ranges.iN( tAddrFormatErrortAddrConversionErrortnum_bitst DictDotLookuptNOHOSTtNt INET_PTONtPtZEROFILLtZ(tipv4tipv6(t _sys_maxintt _iter_ranget_is_strt _int_typet _str_types^([01]+)0 \1[1]$s^([01]+) \1[10]+$s^[01]+$tBaseIPcBseZdZdZdZdZededdZdZd Z d Z d Z d Z d Z dZdZdZdZdZdZdZdZdZdZdZedZedZRS(si An abstract base class for common operations shared between various IP related subclasses. t_valuet_modulecCsd|_d|_dS(s Constructor.N(tNoneRR(tself((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__init__"s cCspt|ts(tdt|nd|koE|jjknsctd|jjn||_dS(Nsint argument expected, not %sis&value out of bounds for an %s address!( t isinstanceRt TypeErrorttypeRtmax_intRt family_nameR(Rtvalue((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt _set_value's "cCs|jS(N(R(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt/stdocs?a positive integer representing the value of IP address/subnet.cCstS(sP @return: a key tuple that uniquely identifies this IP address. (tNotImplemented(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytkey2scCstS(sh @return: A key tuple used to compare and sort this L{IPAddress} correctly. (R (R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytsort_key8scCst|jS(sM @return: A hash value uniquely indentifying this IP object. (thashR!(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__hash__?scCs3y|j|jkSWntk r.tSXdS(s @param other: an L{IPAddress} or L{IPNetwork} object. @return: C{True} if this L{IPAddress} or L{IPNetwork} object is equivalent to C{other}, C{False} otherwise. N(R!tAttributeErrorR (Rtother((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__eq__Es cCs3y|j|jkSWntk r.tSXdS(s @param other: an L{IPAddress} or L{IPNetwork} object. @return: C{True} if this L{IPAddress} or L{IPNetwork} object is not equivalent to C{other}, C{False} otherwise. N(R!R%R (RR&((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__ne__Qs cCs3y|j|jkSWntk r.tSXdS(s @param other: an L{IPAddress} or L{IPNetwork} object. @return: C{True} if this L{IPAddress} or L{IPNetwork} object is less than C{other}, C{False} otherwise. N(R"R%R (RR&((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__lt__]s cCs3y|j|jkSWntk r.tSXdS(s @param other: an L{IPAddress} or L{IPNetwork} object. @return: C{True} if this L{IPAddress} or L{IPNetwork} object is less than or equal to C{other}, C{False} otherwise. N(R"R%R (RR&((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__le__is cCs3y|j|jkSWntk r.tSXdS(s @param other: an L{IPAddress} or L{IPNetwork} object. @return: C{True} if this L{IPAddress} or L{IPNetwork} object is greater than C{other}, C{False} otherwise. N(R"R%R (RR&((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__gt__us cCs3y|j|jkSWntk r.tSXdS(s @param other: an L{IPAddress} or L{IPNetwork} object. @return: C{True} if this L{IPAddress} or L{IPNetwork} object is greater than or equal to C{other}, C{False} otherwise. N(R"R%R (RR&((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__ge__s cCs |j S(s:@return: C{True} if this IP is unicast, C{False} otherwise(t is_multicast(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt is_unicastscCs6|jtkr|tkS|jtkr2|tkSdS(s<@return: C{True} if this IP is multicast, C{False} otherwiseN(Rt_ipv4tIPV4_MULTICASTt_ipv6tIPV6_MULTICAST(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR-s cCs6|jdkr|tkS|jdkr2|tkSdS(s @return: C{True} if this IP is loopback address (not for network transmission), C{False} otherwise. References: RFC 3330 and 4291. iiN(tversiont IPV4_LOOPBACKt IPV6_LOOPBACK(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt is_loopbacks cCsz|jdkr3xTtD]}||krtSqWn3|jdkrfx!tD]}||krItSqIWn|jrvtStS(s @return: C{True} if this IP is for internal/private use only (i.e. non-public), C{False} otherwise. Reference: RFCs 1918, 3330, 4193, 3879 and 2365. ii(R3t IPV4_PRIVATEtTruet IPV6_PRIVATEt is_link_localtFalse(Rtcidr((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt is_privates       cCs6|jdkr|tkS|jdkr2|tkSdS(s @return: C{True} if this IP is link-local address C{False} otherwise. Reference: RFCs 3927 and 4291. iiN(R3tIPV4_LINK_LOCALtIPV6_LINK_LOCAL(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR:s cCsj|jdkr3xTtD]}||krtSqWn3|jdkrfx!tD]}||krItSqIWntS(s @return: C{True} if this IP is in IANA reserved range, C{False} otherwise. Reference: RFCs 3330 and 3171. ii(R3t IPV4_RESERVEDR8t IPV6_RESERVEDR;(RR<((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt is_reserveds      cCs |jdko|jd?dkS(sn @return: C{True} if this IP is IPv4-compatible IPv6 address, C{False} otherwise. ii i(R3R(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytis_ipv4_mappedscCs |jdko|jd?dkS(sj @return: C{True} if this IP is IPv4-mapped IPv6 address, C{False} otherwise. ii i(R3R(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytis_ipv4_compatscCs ddlm}t||S(s~ A record dict containing IANA registration details for this IP address if available, None otherwise. i(tquery(tnetaddr.ip.ianaRER(RRE((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytinfoscCs |jjS(s6the IP protocol version represented by this IP object.(RR3(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR3s(s_values_module(t__name__t __module__t__doc__t __slots__RRtpropertyRR!R"R$R'R(R)R*R+R,R.R-R6R=R:RBRCRDRGR3(((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRs2             t IPAddresscBspeZdZd#Zd$ddZdZdZdZdZ dZ dZ d Z e Z d Zd Zd Zd ZdZdZdZdZdZd$dZedZedZedZedZdZedZd$dZ dZ!dZ"dZ#dZ$dZ%d Z&e&Z'd!Z(d"Z)RS(%s An individual IPv4 or IPv6 address without a net mask or subnet prefix. To support these and other network based operations, see L{IPNetwork}. icCstt|jt|trj|d k rO||jjkrOtdn|j |_ |j|_nP|d k r|dkrt |_q|dkrt |_qtd|nt |d}|rd|krtd|j jn|jd krt|trydt|ko4t jknrTt||_ t |_nCt jt|kowt jknrt||_ t |_nWqtk rqXnGxDt t fD]6}y|j|||_ Wn qqX||_PqW|jd krtd |qn|rpy|jj|||_ Wqtk rltd ||jjfqXnJdt|ko|jjknrt||_ ntd |d S( s Constructor. @param addr: an IPv4 or IPv6 address which may be represented in an accepted string format, as an unsigned integer or as another IPAddress object (copy construction). @param version: (optional) optimizes version detection if specified and distinguishes between IPv4 and IPv6 for addresses with an equivalent integer value. @param flags: (optional) 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 further details. s1cannot switch IP versions using copy constructor!iis%r is an invalid IP version!tuppert/sQ%s() does not support netmasks or subnet prefixes! See documentation for details.is+failed to detect a valid IP address from %rsbase address %r is not IPv%dsbad address format: %rN(tsuperRMRRRRRR3t ValueErrorRR/R1thasattrt __class__RHRtintRt str_to_intR(RtaddrR3tflagst has_uppertmodule((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRs\      % (   (cCs|j|jjfS(s1@return: Pickled state of an C{IPAddress} object.(RRR3(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt __getstate__JscCs_|\}}||_|dkr-t|_n.|dkrEt|_ntdt|dS(sU @param state: data used to unpickle a pickled C{IPAddress} object. iis&unpickling failed for object state: %sN(RR/RR1RQtstr(RtstateRR3((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt __setstate__Ns      cCs|jd}||d@dkS(sT @return: C{True} if this IP address host mask, C{False} otherwise. ii(R(Rtint_val((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt is_hostmask_s cCs)|j|jjAd}||d@dkS(sW @return: C{True} if this IP address network mask, C{False} otherwise. ii(RRR(RR^((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt is_netmaskfscCsL|j|}d|ko*|jjknr<||_|StddS(s Increases the numerical value of this IPAddress by num. @param num: size of IP address increment. An IndexError is raised if result exceeds maximum IP address value or is less than zero. is)result outside valid IP address boundary!N(RRRt IndexError(Rtnumt new_value((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__iadd__ms " cCsL|j|}d|ko*|jjknr<||_|StddS(s Decreases the numerical value of this IPAddress by num. @param num: size of IP address decrement. An IndexError is raised if result is less than zero or exceeds maximum IP address value. is)result outside valid IP address boundary!N(RRRRa(RRbRc((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__isub__|s " cCsR|j|}d|ko*|jjknrB|j||jStddS(s  Add the numerical value of this IP address to num and provide the result as a new IPAddress object. @param num: size of IP address increase. @return: a new IPAddress object with its numerical value increased by num. is)result outside valid IP address boundary!N(RRRRSR3Ra(RRbRc((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__add__s "cCsR|j|}d|ko*|jjknrB|j||jStddS(s Subtract the numerical value of this IP address from num providing the result as a new IPAddress object. @param num: size of IP address decrease. @return: a new IPAddress object with its numerical value decreased by num. is)result outside valid IP address boundary!N(RRRRSR3Ra(RRbRc((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__sub__s "cCsR||j}d|ko*|jjknrB|j||jStddS(s Subtract num (lvalue) from the numerical value of this IP address (rvalue) providing the result as a new IPAddress object. @param num: size of IP address decrease. @return: a new IPAddress object with its numerical value decreased by num. is)result outside valid IP address boundary!N(RRRRSR3Ra(RRbRc((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__rsub__s "cCs|j|jfS(sP @return: a key tuple that uniquely identifies this IP address. (R3R(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR!scCs|j|j|jjfS(sh @return: A key tuple used to compare and sort this L{IPAddress} correctly. (R3RRtwidth(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR"scCs|jS(s<@return: the value of this IP address as an unsigned integer(R(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__int__scCs|jS(s<@return: the value of this IP address as an unsigned integer(R(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__long__scCs|jdkrdSd|jS(s;@return: an octal string representation of this IP address.it0s0%o(R(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__oct__scCs d|jS(s@@return: a hexadecimal string representation of this IP address.s0x%x(R(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__hex__scCs|jS(sx @return: return the integer value of this IP address when called by hex(), oct() or bin(). (R(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt __index__scCs|jj|j|S(s @param word_sep: (optional) the separator to insert between words. Default: None - use default separator for address type. @return: the value of this IP address as a binary digit string.(Rt int_to_bitsR(Rtword_sep((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytbitsscCs|jj|jS(s7The value of this IP address as a packed binary string.(Rt int_to_packedR(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytpackedscCs|jj|jS(sx A list of unsigned integer words (octets for IPv4, hextets for IPv6) found in this IP address. (Rt int_to_wordsR(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytwordsscCs|jj|jS(s The value of this IP adddress in standard Python binary representational form (0bxxx). A back port of the format provided by the builtin bin() function found in Python 2.6.x and higher. (Rt int_to_binR(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytbinscCs|jj|jS(s1The reverse DNS lookup record for this IP address(Rt int_to_arpaR(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt reverse_dnsscCsd}|j}|jdkr3||jd}n|jdkrd|jko_tjknry||jd}qtj|jkodknr||jdd}qtd|n|S(s @return: A numerically equivalent version 4 L{IPAddress} object. Raises an L{AddrConversionError} if IPv6 address cannot be converted to IPv4. iiills2IPv6 address %s unsuitable for conversion to IPv4!N(RRSR3RR/RR(Rtiptklass((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR s "" cCsd}|j}|jdkrq|r\d|jko>dknr\||jdd}q||jd}nC|jdkr||jd}|s|d|jd}qn|S(s B{Please Note:} the IPv4-mapped IPv6 address format is now considered deprecated. See RFC 4291 or later for details. @param ipv4_compatible: If C{True} returns an IPv4-mapped address (::ffff:x.x.x.x), an IPv4-compatible (::x.x.x.x) address otherwise. Default: False (IPv4-mapped). @return: A numerically equivalent version 6 L{IPAddress} object. illiN(RRSR3R(Rtipv4_compatibleR{R|((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR s  cCsF|dk r-t|ds-tdq-n|jj|jd|S(s Only relevant for IPv6 addresses. Has no effect for IPv4. @param dialect: An ipv6_* dialect class. @return: an alternate string representation for this IP address. tword_fmts-custom dialects should subclass ipv6_verbose!tdialectN(RRRRRt int_to_strR(RR((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytformat:s  cCs |j|jt|B|jS(s @param other: An L{IPAddress} object (or other int-like object). @return: bitwise OR (x | y) between the integer value of this IP address and C{other}. (RSRRTR3(RR&((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__or__HscCs |j|jt|@|jS(s @param other: An L{IPAddress} object (or other int-like object). @return: bitwise AND (x & y) between the integer value of this IP address and C{other}. (RSRRTR3(RR&((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__and__QscCs |j|jt|A|jS(s @param other: An L{IPAddress} object (or other int-like object). @return: bitwise exclusive OR (x ^ y) between the integer value of this IP address and C{other}. (RSRRTR3(RR&((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__xor__ZscCs|j|j|>|jS(s @param numbits: size of bitwise shift. @return: an L{IPAddress} object based on this one with its integer value left shifted by C{numbits}. (RSRR3(Rtnumbits((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt __lshift__cscCs|j|j|?|jS(s @param numbits: size of bitwise shift. @return: an L{IPAddress} object based on this one with its integer value right shifted by C{numbits}. (RSRR3(RR((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt __rshift__lscCs t|jS(sy @return: C{True} if the numerical value of this IP address is not zero, C{False} otherwise. (tboolR(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt __nonzero__uscCs|jj|jS(s,@return: IP address in presentational format(RRR(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__str__scCsd|jj|fS(s8@return: Python statement to create an equivalent objects%s('%s')(RSRH(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__repr__s(N(*RHRIRJRKRRRZR]R_R`RdReRft__radd__RgRhR!R"RjRkRmRnRoRrRLRtRvRxRzR R;R RRRRRRRt__bool__RR(((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRMsJR                      t IPListMixincBsPeZdZdZedZdZdZdZdZ e Z RS(su A mixin class providing shared list-like functionality to classes representing groups of IP addresses. cCs7t|j|j}t|j|j}t||S(s @return: An iterator providing access to all L{IPAddress} objects within range represented by this ranged IP object. (RMtfirstR3tlastt iter_iprange(Rtstart_iptend_ip((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__iter__scCst|j|jdS(sP The total number of IP addresses within this ranged IP object. i(RTRR(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytsizescCs,|j}|tkr(tdtn|S(s @return: the number of IP addresses in this ranged IP object. Raises an C{IndexError} if size > system max int (a Python 2.x limitation). Use the .size property for subnets of any size. sZrange contains more than %d (index size max) IP addresses! Use the .size property instead.(RR Ra(RR((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt__len__s    cCsd}t|dr|jjdkr6tdn|j|j\}}}||dksm||krtt|j |jg}qt|j ||j}t|j |||j}t |||}nyt |}|j |kodknr(t|j |d|j}nKd|koF|jdknrgt|j ||j}n t dWn!tk rtd|nX|S( s @return: The IP address(es) in this L{IPNetwork} object referenced by index or slice. As slicing can produce large sequences of objects an iterator is returned instead of the more usual C{list}. tindicesisIPv6 slices are not supported!iis'index out range for address range size!sunsupported index type %r!N(RRRRR3RRRtiterRMRRRTRRaRQ(RtindextitemtstarttstoptstepRR((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt __getitem__s(!   # cCsy|j|jkrtSt|drWt|d rW|j|jkoV|j|jkS|j|jkox|j|jkS(s @param other: an L{IPAddress} or ranged IP object. @return: C{True} if other falls within the boundary of this one, C{False} otherwise. Rt _prefixlen(R3R;RRRRR(RR&((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt __contains__s "cCstS(s Ranged IP objects always represent a sequence of at least one IP address and are therefore always True in the boolean context. (R8(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRs( RHRIRJRRLRRRRRR(((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRs  % ic Cst|try|\}}Wn$tk rEtd|jnXd|ko`|jknr|}d|ko|jknr|}qtd|jqtd|jnt|tr|rt|}ny7d|kr |j dd\}}n |}d}Wn!tk r=td|nXyt ||j dt }WnZtk r|j d krtj|} t | |j dt }qtd|nX|j}yt|}Wntk r|dkrr|j}qrnwtk rqt ||j dt } | jr?|j| j}qr| jr^|j| j}qrtd |nXd|ko|jknstd |jqntd t||t@r|j|} || @}n||fS( Nsinvalid %s tuple!isinvalid prefix for %s tuple!s#invalid address value for %s tuple!ROisinvalid IPNetwork address %s!RWis!addr %r is not a valid IPNetwork!sinvalid prefix for %s address!sunexpected type %s for addr arg(RttupleRQRRRRiRtcidr_abbrev_to_verbosetsplitRRMR3RR/texpand_partial_addressRRTRR`tnetmask_to_prefixR_thostmask_to_prefixRRtprefix_to_netmask( RYRVtimplicit_prefixRWtval1tval2Rt prefixlenR{t expanded_addrtmasktnetmask((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytparse_ip_networksh               t IPNetworkcBsXeZdZd Zed!ddZdZdZdZ e de dd Z e d Z e d Z e d Ze d Ze dZe dZe dZe dZdZdZdZdZdZedZddZddZddZd!d!dZdZdZdZ RS("s` An IPv4 or IPv6 network or subnet. A combination of an IP address and a network mask. Accepts CIDR and several variants :- a) Standard CIDR:: x.x.x.x/y -> 192.0.2.0/24 x::/y -> fe80::/10 b) Hybrid CIDR format (netmask address instead of prefix):: x.x.x.x/y.y.y.y -> 192.0.2.0/255.255.255.0 x::/y:: -> fe80::/ffc0:: where 'y' address represent a valid netmask. c) ACL hybrid CIDR format (hostmask address instead of prefix):: x.x.x.x/y.y.y.y -> 192.0.2.0/0.0.0.255 x::/y:: -> fe80::/3f:ffff:ffff:ffff:ffff:ffff:ffff:ffff where 'y' address represent a valid netmask. This is like Cisco's ACL bitmasks. d) Abbreviated CIDR format (as of netaddr 0.7.x this requires the optional constructor argument C{implicit_prefix=True}):: x -> 192 x/y -> 10/8 x.x/y -> 192.168/16 x.x.x/y -> 192.168.0/24 which are equivalent to:: x.0.0.0/y -> 192.0.0.0/24 x.0.0.0/y -> 10.0.0.0/8 x.x.0.0/y -> 192.168.0.0/16 x.x.x.0/y -> 192.168.0.0/24 RicCstt|jd \}}}t|drO|j}|j}|j}nIt|dr||j}|j}|j}n|dkrt t |d|d|\}}t }n|dkrt t |d|d|\}}t }n|d k rt d|ny%t }t ||||\}}Wnit k ry%t }t ||||\}}Wnt k rtnX|d krt d|qnX||_||_||_d S( s Constructor. @param addr: an IPv4 or IPv6 address with optional CIDR prefix, netmask or hostmask. May be an IP address in presentation (string) format, an tuple containing and integer address and a network prefix, or another IPAddress/IPNetwork object (copy construction). @param implicit_prefix: (optional) if True, the constructor uses classful IPv4 rules to select a default prefix when one is not provided. If False it uses the length of the IP address version. (default: False) @param version: (optional) optimizes version detection if specified and distinguishes between IPv4 and IPv6 for addresses with an equivalent integer value. @param flags: (optional) decides which rules are applied to the interpretation of the addr value. Currently only supports the NOHOST option. See the netaddr.core docs for further details. RRiRRWis%r is an invalid IP version!sinvalid IPNetwork %sN(NNN(RPRRRRRRRRRiRR/R1RQR(RRVRR3RWRRRY((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR`sH                    cCs|j|j|jjfS(s1@return: Pickled state of an C{IPNetwork} object.(RRRR3(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRZscCs|\}}}||_|dkr0t|_n.|dkrHt|_ntdt|d|ko{|jjknr||_ntdt|dS(sU @param state: data used to unpickle a pickled C{IPNetwork} object. iis%unpickling failed for object state %siN(RR/RR1RQR[RiR(RR\RRR3((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR]s     " cCspt|ts(tdt|nd|koE|jjknsctd|jjn||_dS(Nsint argument expected, not %sis!invalid prefix for an %s address!( RRRRRRiRRR(RR((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt_set_prefixlens "cCs|jS(N(R(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRsRsCsize of the bitmask used to separate the network from the host bitscCst|j|jS(s The IP address of this L{IPNetwork} object. This is may or may not be the same as the network IP address which varies according to the value of the CIDR subnet prefix. (RMRR3(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR{scCs t|jt|j@|jS(s0The network address of this L{IPNetwork} object.(RMRRTRR3(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytnetworkscCst|j|jjB|jS(s1The broadcast address of this L{IPNetwork} object(RMRthostmaskR3(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt broadcastscCs|j|jj|jjA@S(sf The integer value of first IP address found within this L{IPNetwork} object. (RRRR(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRscCs&d|jj|j>d}|j|BS(se The integer value of last IP address found within this L{IPNetwork} object. i(RRiRR(RR((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRscCs&|jj|jjA}t||jS(s,The subnet mask of this L{IPNetwork} object.(RRRRRMR3(RR((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRscCs+d|jj|j>d}t||jS(s*The host mask of this L{IPNetwork} object.i(RRiRRMR3(RR((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRscCs?t|jt|j@|j}td||jf}|S(s The true CIDR address for this L{IPNetwork} object which omits any host bits to the right of the CIDR subnet prefix. s%s/%d(RMRRTRR3RR(RR{R<((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR<s"cCsnt|j|j|}||jd|jjkrFtdn|dkratdn||_|S(sN Increases the value of this L{IPNetwork} object by the current size multiplied by C{num}. @param num: (optional) number of L{IPNetwork} blocks to increment this IPNetwork's value by. An C{IndexError} is raised if result exceeds maximum IP address value or is less than zero. is#increment exceeds address boundary!isincrement is less than zero!(RTRRRRRaR(RRbRc((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRds   cCsnt|j|j|}|dkr5tdn||jd|jjkratdn||_|S(sN Decreases the value of this L{IPNetwork} object by the current size multiplied by C{num}. @param num: (optional) number of L{IPNetwork} blocks to decrement this IPNetwork's value by. An C{IndexError} is raised if result is less than zero or exceeds maximum IP address value. isdecrement is less than zero!is#decrement exceeds address boundary!(RTRRRaRRR(RRbRc((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRes   cCs|j|j|jfS(sS @return: A key tuple used to uniquely identify this L{IPNetwork}. (R3RR(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR!.scCs?|jjt|j}|j|j}|j|j||fS(sh @return: A key tuple used to compare and sort this L{IPNetwork} correctly. (RRiRRRRR3(Rt net_size_bitst host_bits((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR"4scCsd }|j}|jdkr=|d|j|jf}n|jdkr d|jkoitjknrtj|j}|d||jdf}q tj|jkodknrtj|jd}|d||jdf}q t d|n|S( s @return: A numerically equivalent version 4 L{IPNetwork} object. Raises an L{AddrConversionError} if IPv6 address cannot be converted to IPv4. is%s/%diii`lls2IPv6 address %s unsuitable for conversion to IPv4!N( RRSR3R{RRR/RRR(RR{R|RV((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR =s " "  cCsd}|j}|jdkr|rhd|jko>dknrh||jd|jfdd}q||j|jfdd}nc|jdkr|r||j|jdfdd}q|d|j|jdfdd}n|S(s B{Please Note:} the IPv4-mapped IPv6 address format is now considered deprecated. See RFC 4291 or later for details. @param ipv4_compatible: If C{True} returns an IPv4-mapped address (::ffff:x.x.x.x), an IPv4-compatible (::x.x.x.x) address otherwise. Default: False (IPv4-mapped). @return: A numerically equivalent version 6 L{IPNetwork} object. illR3ii`N(RRSR3RR(RR}R{R|((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR Ts   !% icCs3|jd|j|jf|j}||8}|S(s @param step: the number of IP subnets between this L{IPNetwork} object and the expected subnet. Default: 1 (the previous IP subnet). @return: The adjacent subnet preceding this L{IPNetwork} object. s%s/%d(RSRRR3(RRtip_copy((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytpreviousts  cCs3|jd|j|jf|j}||7}|S(s @param step: the number of IP subnets between this L{IPNetwork} object and the expected subnet. Default: 1 (the next IP subnet). @return: The adjacent subnet succeeding this L{IPNetwork} object. s%s/%d(RSRRR3(RRR((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytnexts  cCsd|ko|jjkns>td||jfn|j}g}x2|j|kr|jd8_|j|jqPWtt|S(sd Provides a list of supernets for this L{IPNetwork} object between the size of the current prefix and (if specified) an endpoint prefix. @param prefixlen: (optional) a CIDR prefix for the maximum supernet. Default: 0 - returns all possible supernets. @return: a tuple of supernet L{IPNetwork} objects. is"CIDR prefix /%d invalid for IPv%d!i( RRiRQR3R<Rtappendtlisttreversed(RRtsupernett supernets((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRs " c cs5d|jko |jjknsAtd||jfn|j|ksYtn|jj}d||jd||}|dkr|}nd|ko|knstdn|jj|j}xWt |D]I}|j d||f|j}|j |j |7_ ||_|VqWdS(s A generator that divides up this IPNetwork's subnet into smaller subnets based on a specified CIDR prefix. @param prefixlen: a CIDR prefix indicating size of subnets to be returned. @param count: (optional) number of consecutive IP subnets to be returned. @return: an iterator containing IPNetwork subnet objects. is"CIDR prefix /%d invalid for IPv%d!iis,count outside of current IP subnet boundary!s%s/%dN( RRRiRQR3t StopIterationRRRR RSRR( RRtcounttfmtRit max_subnetst base_subnettitsubnet((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRs$ %      cCstg}|jdkre|jdkrtt|jd|jt|jd|j}qna|jdkr|jdkrtt|jd|jt|j|j}qn t|}|S(s @return: An iterator that provides all IP addresses that can be assigned to hosts within the range of this IP object's subnet. - for IPv4, the network and broadcast addresses are always excluded. Any subnet that contains less than 4 IP addresses yields an empty list. - for IPv6, only the unspecified address '::' is excluded from any yielded IP addresses. iii(RR3RRRMRR(Rtit_hosts((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt iter_hostss " cCs&|jj|j}d||jfS(s&@return: this IPNetwork in CIDR formats%s/%s(RRRR(RRV((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRscCsd|jj|fS(s8@return: Python statement to create an equivalent objects%s('%s')(RSRH(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRs(s _prefixlenN(!RHRIRJRKR;RRRZR]RRLRR{RRRRRRR<RdReR!R"R R RRRRRRR(((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR2s:+D           (  tIPRangecBs}eZdZdZddZdZdZedZedZ d Z d Z d Z d Z d ZRS(s An arbitrary IPv4 or IPv6 address range. Formed from a lower and upper bound IP address. The upper bound IP cannot be numerically smaller than the lower bound and the IP version of both must match. t_startt_endicCsst|d||_|jj|_t||jjd||_t|jt|jkrotdndS(s Constructor. @param start: an IPv4 or IPv6 address that forms the lower boundary of this IP range. @param end: an IPv4 or IPv6 address that forms the upper boundary of this IP range. @param flags: (optional) decides which rules are applied to the interpretation of the start and end values. Supported constants are INET_PTON and ZEROFILL. See the netaddr.core docs for further details. RWs(lower bound IP greater than upper bound!N(RMRRR3RRTR(RRtendRW((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRs cCs|jj|jj|jjfS(s/@return: Pickled state of an C{IPRange} object.(RRRRR3(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRZscCsF|\}}}t|||_|jj|_t|||_dS(sS @param state: data used to unpickle a pickled C{IPRange} object. N(RMRRR(RR\RRR3((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR]scCs t|jS(s@The integer value of first IP address in this L{IPRange} object.(RTR(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR$scCs t|jS(s?The integer value of last IP address in this L{IPRange} object.(RTR(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR)scCs|j|j|jfS(sQ @return: A key tuple used to uniquely identify this L{IPRange}. (R3RR(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR!.scCs,|jjt|j}|j|j|fS(sf @return: A key tuple used to compare and sort this L{IPRange} correctly. (RRiRRR3R(Rtskey((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyR"4scCst|j|jS(sy The list of CIDR addresses found within the lower and upper bound addresses of this L{IPRange}. (tiprange_to_cidrsRR(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytcidrs<scCsd|j|jfS(s=@return: this L{IPRange} in a common representational format.s%s-%s(RR(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRCscCsd|jj|j|jfS(s8@return: Python statement to create an equivalent objects%s('%s', '%s')(RSRHRR(R((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRGs (s_starts_end(RHRIRJRKRRZR]RLRRR!R"RRR(((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRs       cgs1x*t|D]}x|D] }|VqWq WdS(s @param args: A list of IP addresses and subnets passed in as arguments. @return: A generator that flattens out IP subnets, yielding unique individual IP addresses (no duplicates). N(t cidr_merge(targsR<R{((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytiter_unique_ipsMs cCs'd}d}g}d }t|r:d|kr:|SnyHt|}t|dddg}d|dj|||fSWntk r|}g}|dkr|Sd|kr|jdd\}}n|d k r2y9d t|kod knstd |nWq2tk r.|SXnd|krP|jd}n |g}dt|kovd knrx2td t|D]}|j dqWn|S|d kry||d }Wqtk r|SXnd|dj||fSt k rnt k r"nX|S(s A function that converts abbreviated IPv4 CIDRs to their more verbose equivalent. @param 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 @return: 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. cSst|}d|ko#dkns;td|nd|koRdknr[dSd|kordknr{dSd |kod knrd Sd |kod knrdSdS(NiisInvalid octet: %r!iiiiiiiiiiii (RTRa(toctet((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytclassful_prefixss tt:Rls%s%s/%st.ROiii s.prefixlen in address %r out of range for IPv4!iN( RRRTR[tjoinRQRtlentrangeRRRa(t abbrev_cidrRRttokenstprefixRt part_addr((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRYsV    $    "   "    c Cst|d st|dr.tdnt}t}t}t}x|D]}t|}|jjddd|j!}|jdkr|dkrt }tdg}n|s |j |q qS|dkrt }tdg}n|sS|j |qSqSWd}g} d } x0|t |D]}| j | |t q9Wx0|t |D]}| j | |tqlW| S( s 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. @param ip_addrs: an iterable sequence of IP addresses and subnets. @return: a summarized list of L{IPNetwork} objects. Rtkeyss#A sequence or iterator is expected!RqRiicSsdg}|jx/t}x t|dkr(t|dkrY|j|jdnt|dkroPntjdd|d|df\}}|r||d<|jdt}qtjdd|d|df\}}|r||d<|jdt}q|j|jdqW|r3Pq|}g}q|ddgkr`dg}n|S(Nis\1s%s %siRlt1R( tsortR8RRtpoptRE_CIDR_ADJACENTtsubnR;tRE_CIDR_WITHIN(Rt new_cidrstfinishedtnew_cidrtsubs((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt_reduce_bit_cidrss: $   $     cSs|dkr8|jdkr(tddStddSntj|dkr`td|nt|}|dkrt|jd|jS|d|j |}t|j ||fd |jSdS( NRis 0.0.0.0/0s::/0is%r is an invalid bit string!iRlR3( R3RtRE_VALID_CIDR_BITStmatchRRQRRMRRit bits_to_int(RrRYR((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt _bits_to_cidrs    (RRRQtsetR;RRRrRR3R8taddRRR/R1( tip_addrstipv4_bit_cidrstipv6_bit_cidrstipv4_match_all_foundtipv6_match_all_foundR{R<RrRRR((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRs8        / c Csg}t|}t|}|j|jkr:|jgS|j|jkrV|jgS|jd}||jjkr|j}|jd|jj|}t||f}t||f}x|j|kr||kr|}|} n,||kr|}|} n|j|jPt| |f} |j| |d7}||jjkrUPn|}|d|jj|}t||f}t||f}qWn|j|S(s Removes an exclude IP address or subnet from target IP subnet. @param target: the target IP address or subnet to be divided up. @param exclude: the IP address or subnet to be removed from target. @return: list of L{IPNetwork} objects remaining after exclusion. ii( RRRR<RRRiRR( ttargettexcludeRt new_prefixlenti_lowerti_uppertlowerRNtmatchedt unmatchedR{((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt cidr_exclude8sB              cCstg|D]}t|^q }t|dksFtdn|d}|d}|j|jkr{tdn|j}x>|jdkr||kr||kr|jd8_qPqW|jS(sQ Function that accepts a sequence of IP addresses and subnets returning a single L{IPNetwork} subnet that is large enough to span the lower and upper bound IP addresses with a possible overlap on either end. @param ip_addrs: sequence of IP addresses and subnets. @return: a single spanning L{IPNetwork} subnet. is-IP sequence must contain at least 2 elements!iis.IP sequence cannot contain both IPv4 and IPv6!(tsortedRRRQR3RR<R(RR{t sorted_ipst lowest_ipt highest_ip((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyt spanning_cidrys "   iccst|}t|}|j|jkr9tdn|j}t|}|dkritdnt|}t|}t}|dkrt}n||}xKtr||7}|r||ksPqn||ksPnt||VqWdS(s 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. @param start: start IP address. @param end: end IP address. @param step: (optional) size of step between IP addresses. Default: 1 @return: an iterator of one or more L{IPAddress} objects. s(start and stop IP versions do not match!isstep argument cannot be zeroN(RMR3RRTRQR;R8(RRRR3Rt negative_stepR((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRs,              c Csg}t|}t|}|j|jg}t||g}|j|dkrt|j|dkrt|g}n|j|dkrt|}t|}|d8}t||}t}x|D]4} | j|krt}n|r|j | qqWn|j|dkr~t|}t|} |d7}t||}t} x>|D]&} |j | | j| krQPqQqQWn |j|dkr|j|dkrt|}t|}|d8}t||}t}x<|D]4} | j|krt}n|r|j | qqWt|}t|} |d7}t|j |}t} x1|D]&} |j | | j| kr^Pq^q^Wn|S(s` 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. @param start: the start IP address or subnet. @param end: the end IP address or subnet. @return: a list of one or more IP addresses and subnets. iii( RRRRRMRTRR;R8RR( RRt cidr_listtipranget cidr_spanR{t first_int_valtcidr_remaindert first_foundR<t last_int_valt last_found((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pyRsb   &            &           cCsd}t|ds(td|nt|}xRtg|D]}t|^qAD]+}||kru|}qZ|dk rZPqZqZW|S(sb Matches an IP address or subnet against a given sequence of IP addresses and subnets. @param ip: a single IP address or subnet. @param cidrs: a sequence of IP addresses and/or subnets. @return: the smallest (most specific) matching IPAddress or IPNetwork object from the provided sequence, None if there was no match. Rs,IP address/subnet sequence expected, not %r!N(RRRRRMRR(R{RRR<((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytsmallest_matching_cidrs   ,   cCs~d}t|ds(td|nt|}xCtg|D]}t|^qAD]}||krZ|}PqZqZW|S(sb Matches an IP address or subnet against a given sequence of IP addresses and subnets. @param ip: a single IP address or subnet. @param cidrs: a sequence of IP addresses and/or subnets. @return: the largest (least specific) matching IPAddress or IPNetwork object from the provided sequence, None if there was no match. Rs,IP address/subnet sequence expected, not %r!N(RRRRRMRR(R{RRR<((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytlargest_matching_cidr6s   , cCsg}t|ds(td|nt|}xStg|D]}t|^qAD],}||kr||j|qZ|rZPqZqZW|S(sW Matches an IP address or subnet against a given sequence of IP addresses and subnets. @param ip: a single IP address or subnet. @param cidrs: a sequence of IP addresses and/or subnets. @return: all matching IPAddress and/or IPNetwork objects from the provided sequence, an empty list if there was no match. Rs,IP address/subnet sequence expected, not %r!(RRRRMRRR(R{RtmatchesR<((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytall_matching_cidrsQs   , s 127.0.0.0/8s 10.0.0.0/8s 100.64.0.0/10s 172.16.0.0/12s 192.0.0.0/24s192.168.0.0/16s 198.18.0.0/15s 239.0.0.0s239.255.255.255s169.254.0.0/16s 224.0.0.0/4s192.88.99.0/24s 0.0.0.0/8s 192.0.2.0/24s 240.0.0.0/4s198.51.100.0/24s203.0.113.0/24s233.252.0.0/24s 234.0.0.0s238.255.255.255s 225.0.0.0s231.255.255.255s::1sfc00::/7s fec0::/10s fe80::/10sff00::/8s ff00::/12s::/8s0100::/8s0200::/7s0400::/6s0800::/5s1000::/4s4000::/3s6000::/3s8000::/3sA000::/3sC000::/3sE000::/4sF000::/5sF800::/6sFE00::/9(<RJtsyst_systret_ret netaddr.coreRRRRRRRRRR tnetaddr.strategyR R/R R1tnetaddr.compatR R RRRtcompileRRRtobjectRRMRR;RRRRRRRRRRR R RR4R7R>R0t IPV4_6TO4R@R5R9R?R2RA(((s7/usr/lib/python2.7/site-packages/netaddr/ip/__init__.pytsv  F(_KY g x A ! / P