3 f/@sdZddlZdZdZGdddeZGdddeZd d Zd7}|d|j krPqWdS)Nz1first and last must be IP addresses, not networksz%%s and %s are not of the same versionz*last IP address must be greater than firstrzunknown IP versionr%) isinstance _BaseAddress TypeErrorversionr rr_max_prefixlenr(r/r2r0 _ALL_ONES)r+r,r-Zip_bitsZ first_intZlast_intZnbitsnetrrr summarize_address_ranges0         r;ccst|}i}xL|rX|j}|j}|j|}|dkr>|||<q||kr||=|j|qWd}x4t|jD]$}|dk r|j|jkrql|V|}qlWdS)N)listpopsupernetgetappendsortedvaluesbroadcast_address)r)Zto_mergesubnetsr:r>Zexistingr,rrr _collapse_addresses_internals$   rEc Cs8g}g}g}x|D]}t|trT|rH|dj|jkrHtd||df|j|q|j|jkr|r|dj|jkrtd||dfy|j|jWqtk r|j|j YqXq|r|dj|jkrtd||df|j|qWt t |}|r,x&t |D]\}}|j t||qWt||S) Nr%z%%s and %s are not of the same versionrFrFrFrFrF)r4r5_versionr6r@ _prefixlenr8r-AttributeErrornetwork_addressrAsetr.extendr;rE)r)ZaddrsZipsZnetsr-r+r,rrr collapse_addresses2s4     rMcCs(t|tr|jSt|tr$|jStS)N)r4 _BaseNetwork_get_networks_keyr5_get_address_keyNotImplemented)objrrr get_mixed_type_keyhs   rSc@seZdZfZeddZeddZeddZeddZd d Z d d Z e d dZ e ddZ e ddZe ddZe ddZddZdS)_IPAddressBasecCs|jS)N)_explode_shorthand_ip_string)selfrrr explodedsz_IPAddressBase.explodedcCst|S)N)r )rVrrr compressedsz_IPAddressBase.compressedcCs|jS)N)_reverse_pointer)rVrrr reverse_pointers z_IPAddressBase.reverse_pointercCsdt|f}t|dS)Nz%200s has no version specified)typeNotImplementedError)rVmsgrrr r7sz_IPAddressBase.versioncCsF|dkrd}t|||jf||jkrBd}t|||j|jfdS)Nrz-%d (< 0) is not permitted as an IPv%d addressz2%d (>= 2**%d) is not permitted as an IPv%d address)rrGr9r8)rVrr]rrr _check_int_addresss  z!_IPAddressBase._check_int_addresscCs.t|}||kr*d}t|||||jfdS)Nz6%r (len %d != %d) is not permitted as an IPv%d address)r"rrG)rVrZ expected_lenZ address_lenr]rrr _check_packed_addresss z$_IPAddressBase._check_packed_addresscCs|j|j|?AS)N)r9)cls prefixlenrrr _ip_int_from_prefixs z"_IPAddressBase._ip_int_from_prefixc Cs\t||j}|j|}||?}d|>d}||krX|jd}|j|d}d}t|||S)Nr%rz&Netmask pattern %r mixes zeroes & ones)r2r8rr ) r`ip_intZtrailing_zeroesraZ leading_onesZall_onesZbyteslenZdetailsr]rrr _prefix_from_ip_ints      z"_IPAddressBase._prefix_from_ip_intcCsd|}t|ddS)Nz%r is not a valid netmask)r )r`Z netmask_strr]rrr _report_invalid_netmasksz&_IPAddressBase._report_invalid_netmaskc Csjtjj|s|j|y t|}Wntk r@|j|YnXd|koV|jknsf|j||S)Nr)_BaseV4_DECIMAL_DIGITS issupersetrfintr r8)r`Z prefixlen_strrarrr _prefix_from_prefix_strings    z)_IPAddressBase._prefix_from_prefix_stringcCsy|j|}Wntk r,|j|YnXy |j|Stk rLYnX||jN}y |j|Stk r|j|YnXdS)N)_ip_int_from_stringrrfrer r9)r`ip_strrdrrr _prefix_from_ip_strings   z%_IPAddressBase._prefix_from_ip_stringcCs|jt|ffS)N) __class__r )rVrrr __reduce__sz_IPAddressBase.__reduce__N)rrr __slots__propertyrWrXrZr7r^r_ classmethodrbrerfrkrnrprrrr rTs        "rTc@s`eZdZfZddZddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ dS)r5cCs|jS)N)r()rVrrr __int__&sz_BaseAddress.__int__c Cs2y|j|jko|j|jkStk r,tSXdS)N)r(rGrIrQ)rVotherrrr __eq__)s   z_BaseAddress.__eq__cCsFt|tstS|j|jkr*td||f|j|jkrB|j|jkSdS)Nz%%s and %s are not of the same versionF)r4r5rQrGr6r()rVrurrr __lt__0s     z_BaseAddress.__lt__cCs t|tstS|jt||S)N)r4rjrQro)rVrurrr __add__<s z_BaseAddress.__add__cCs t|tstS|jt||S)N)r4rjrQro)rVrurrr __sub__As z_BaseAddress.__sub__cCsd|jjt|fS)Nz%s(%r))rorr )rVrrr __repr__Fsz_BaseAddress.__repr__cCst|j|jS)N)r _string_from_ip_intr()rVrrr __str__Isz_BaseAddress.__str__cCsttt|jS)N)hashhexrjr()rVrrr __hash__Lsz_BaseAddress.__hash__cCs |j|fS)N)rG)rVrrr rPOsz_BaseAddress._get_address_keycCs|j|jffS)N)ror()rVrrr rpRsz_BaseAddress.__reduce__N)rrrrqrtrvrwrxryrzr|rrPrprrrr r5s  r5c@sDeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ eddZeddZeddZeddZedd Zed!d"Zed#d$Zed%d&Zd'd(Zd)d*Zd+d,ZdAd/d0ZdBd1d2Zed3d4Zed5d6Zed7d8Zed9d:Zed;d<Z ed=d>Z!ed?d@Z"d.S)CrNcCs i|_dS)N)_cache)rVrrrr __init___sz_BaseNetwork.__init__cCsd|jjt|fS)Nz%s(%r))rorr )rVrrr rzbsz_BaseNetwork.__repr__cCsd|j|jfS)Nz%s/%d)rJra)rVrrr r|esz_BaseNetwork.__str__ccs<t|j}t|j}x"t|d|D]}|j|Vq$WdS)Nr%)rjrJrCrange_address_class)rVnetwork broadcastxrrr hostshs  z_BaseNetwork.hostsccs<t|j}t|j}x"t||dD]}|j|Vq$WdS)Nr%)rjrJrCrr)rVrrrrrr __iter__ts  z_BaseNetwork.__iter__cCslt|j}t|j}|dkr>|||kr0td|j||S|d7}|||krZtd|j||SdS)Nrzaddress out of ranger%)rjrJrC IndexErrorr)rVnrrrrr __getitem__zs    z_BaseNetwork.__getitem__cCs^t|tstS|j|jkr*td||f|j|jkrB|j|jkS|j|jkrZ|j|jkSdS)Nz%%s and %s are not of the same versionF)r4rNrQrGr6rJnetmask)rVrurrr rws       z_BaseNetwork.__lt__c CsFy,|j|jko,|j|jko,t|jt|jkStk r@tSXdS)N)rGrJrjrrIrQ)rVrurrr rvs   z_BaseNetwork.__eq__cCstt|jt|jAS)N)r}rjrJr)rVrrr rsz_BaseNetwork.__hash__cCsL|j|jkrdSt|trdSt|jt|jkoBt|jkSSdS)NF)rGr4rNrjrJr(rC)rVrurrr __contains__s   z_BaseNetwork.__contains__cCs(|j|kp&|j|kp&|j|kp&|j|kS)N)rJrC)rVrurrr overlapss   z_BaseNetwork.overlapscCs<|jjd}|dkr8|jt|jt|jB}||jd<|S)NrC)rr?rrjrJhostmask)rVrrrr rCs    z_BaseNetwork.broadcast_addresscCs8|jjd}|dkr4|jt|j|jA}||jd<|S)Nr)rr?rrjrr9)rVrrrr rs   z_BaseNetwork.hostmaskcCsd|j|jfS)Nz%s/%d)rJrH)rVrrr with_prefixlensz_BaseNetwork.with_prefixlencCsd|j|jfS)Nz%s/%s)rJr)rVrrr with_netmasksz_BaseNetwork.with_netmaskcCsd|j|jfS)Nz%s/%s)rJr)rVrrr with_hostmasksz_BaseNetwork.with_hostmaskcCst|jt|jdS)Nr%)rjrCrJ)rVrrr num_addressessz_BaseNetwork.num_addressescCsdt|f}t|dS)Nz%%200s has no associated address class)r[r\)rVr]rrr rsz_BaseNetwork._address_classcCs|jS)N)rH)rVrrr rasz_BaseNetwork.prefixlenccsD|j|jkstd||ft|ts2td||j|jkoH|j|jksZtd||f||krfdS|jd|j|jf}|j \}}x||ko||kr|j|jkr|j|jkr|V|j \}}q|j|jkr|j|jkr|V|j \}}qt d|||fqW||kr|Vn$||kr.|Vnt d|||fdS)Nz%%s and %s are not of the same versionz%s is not a network objectz%s not contained in %sz%s/%sz3Error performing exclusion: s1: %s s2: %s other: %s) rGr6r4rNrJrCr rorarDAssertionError)rVrus1s2rrr address_excludes<$               z_BaseNetwork.address_excludecCs`|j|jkrtd||f|j|jkr,dS|j|jkr 0z0prefix length diff %d is invalid for netblock %s) rHr8r rjrJrCrrro) rVprefixlen_diff new_prefix new_prefixlenstartendstepZnew_addrZcurrentrrr rDhs,       z_BaseNetwork.subnetscCs|jdkr|S|dk rB||jkr(td|dkr8td|j|}|j|}|dkrftd|j|f|jt|jt|j|>@|fS)Nrznew prefix must be shorterr%z(cannot set prefixlen_diff and new_prefixz;current prefixlen is %d, cannot have a prefixlen_diff of %d)rHr rarorjrJr)rVrrrrrr r>s     z_BaseNetwork.supernetcCs|jjo|jjS)N)rJ is_multicastrC)rVrrr rs z_BaseNetwork.is_multicastcCs|jjo|jjS)N)rJ is_reservedrC)rVrrr rs z_BaseNetwork.is_reservedcCs|jjo|jjS)N)rJ is_link_localrC)rVrrr rsz_BaseNetwork.is_link_localcCs|jjo|jjS)N)rJ is_privaterC)rVrrr rs z_BaseNetwork.is_privatecCs|j S)N)r)rVrrr is_globals z_BaseNetwork.is_globalcCs|jjo|jjS)N)rJis_unspecifiedrC)rVrrr rs z_BaseNetwork.is_unspecifiedcCs|jjo|jjS)N)rJ is_loopbackrC)rVrrr r s z_BaseNetwork.is_loopback)r%N)r%N)#rrrrrzr|rrrrwrvrrrrrrCrrrrrrrarrrOrDr>rrrrrrrrrrr rNVs>            N0 5 ) rNc @seZdZfZdZdedZedZeddddd d d d d h Z eZ iZ ddZ e ddZe ddZe ddZe ddZddZddZddZeddZed d!Zd"S)#rgrrr% 0123456789rrcCst|S)N)r )rVrrr rU0sz$_BaseV4._explode_shorthand_ip_stringc Csn||jkrdt|tr|}n.y|j|}Wntk rF|j|}YnXt|j|}||f|j|<|j|S)N)_netmask_cacher4rjrkr rnr rb)r`argrarrrr _make_netmask3s  z_BaseV4._make_netmaskcCs||s td|jd}t|dkr.td|ytjt|j|dStk rv}ztd||fdWYdd}~XnXdS)NzAddress cannot be empty.rzExpected 4 octets in %rrz%s in %r)rr!r"rj from_bytesmap _parse_octetr )r`rmZoctetsexcrrr rlKs   z_BaseV4._ip_int_from_stringcCs|s td|jj|s(d}t||t|dkrDd}t||t|d}|dkrr|ddkrrd }t|||d krtd ||S) NzEmpty octet not permittedz#Only decimal digits permitted in %rz$At most 3 characters permitted in %r r0z3Ambiguous (octal/decimal) value in %r not permittedrzOctet %d (> 255) not permitted)r rhrir"rj)r`Z octet_strr]Z octet_intrrr res       z_BaseV4._parse_octetcCsdjtt|jddS)Nrrr)joinrr r)r`rdrrr r{s z_BaseV4._string_from_ip_intcCs|jd}t|dkry$x|D]}t||jkrdSqWWntk rNdSXx0t|D]$\}}|dkrZ|||dkrZdSqZWdSy t|}Wntk rdSXd|ko|jkSS)NrrFrr%T)r!r"rj_valid_mask_octetsr enumerater8)rVrmaskridxyrrr _is_valid_netmasks"     z_BaseV4._is_valid_netmaskc sh|jd}yfddtt|D}Wntk r:dSXt|t|krPdS|d|dkrddSdS) Nrcsg|]}|jkr|qSr)r).0r)rVrr sz(_BaseV4._is_hostmask..Frr%TrF)r!rrjr r")rVrmr1partsr)rVr _is_hostmasks z_BaseV4._is_hostmaskcCs&t|jdddd}dj|dS)Nrr%z .in-addr.arparF)r r!r)rVZreverse_octetsrrr rYsz_BaseV4._reverse_pointercCs|jS)N)r8)rVrrr max_prefixlensz_BaseV4.max_prefixlencCs|jS)N)rG)rVrrr r7sz_BaseV4.versionN)rrrrqrG IPV4LENGTHr9 frozensetrhrr8rrUrsrrlrr{rrrYrrrr7rrrr rgs"     %  rgc@seZdZdZddZeddZeddZeej d d Z eej d d Z ed dZ eddZ eddZeddZdS)r r( __weakref__cCsrt|tr|j|||_dSt|trF|j|dtj|d|_dSt|}d|krbtd||j ||_dS)NrrrzUnexpected '/' in %r) r4rjr^r(bytesr_rr rrl)rVraddr_strrrr rs     zIPv4Address.__init__cCs t|jS)N)rr()rVrrr packedszIPv4Address.packedcCs ||jjkS)N) _constants_reserved_network)rVrrr r s zIPv4Address.is_reservedcs4tfddjjDo2tfddjjDS)Nc3s|]}|kVqdS)Nr)rr:)rVrr (sz)IPv4Address.is_private..c3s|]}|kVqdS)Nr)rr:)rVrr r)s)anyr_private_networksall_private_networks_exceptions)rVr)rVr rszIPv4Address.is_privatecCs||jjko|j S)N)r_public_networkr)rVrrr r,szIPv4Address.is_globalcCs ||jjkS)N)r_multicast_network)rVrrr r>s zIPv4Address.is_multicastcCs ||jjkS)N)r_unspecified_address)rVrrr rIs zIPv4Address.is_unspecifiedcCs ||jjkS)N)r_loopback_network)rVrrr rTszIPv4Address.is_loopbackcCs ||jjkS)N)r_linklocal_network)rVrrr r^szIPv4Address.is_link_localN)r(r)rrrrqrrrrr functools lru_cacherrrrrrrrrr r s#   r c@sjeZdZddZddZddZddZd d Zej Z e d d Z e d dZ e ddZ e ddZdS)rcCst|ttfr2tj||t|j|_|j|_ dSt|t rtj||dt |dkrht|d|_ n|j|_ t|dd|_|jj |_ |jj |_ dSt|}tj||dt|dd|_|jj |_ |jj |_ |jj |_ dS)Nrr%F)r)r4rrjr rrr(rr8rHtupler"rrr$)rVrr#rrr rks(        zIPv4Interface.__init__cCsd|j|j|jjfS)Nz%s/%d)r{r(rra)rVrrr r|s zIPv4Interface.__str__c CsDtj||}| s|tkr|Sy |j|jkStk r>dSXdS)NF)r rvrQrrI)rVru address_equalrrr rvs  zIPv4Interface.__eq__c CsNtj||}|tkrtSy|j|jkp4|j|jko4|Stk rHdSXdS)NF)r rwrQrrI)rVru address_lessrrr rws  zIPv4Interface.__lt__cCst|j|jt|jjfS)N)r}r(rHrjrrJ)rVrrr rszIPv4Interface.__hash__cCs t|jS)N)r r()rVrrr r-szIPv4Interface.ipcCsd|j|j|jfS)Nz%s/%s)r{r(rH)rVrrr rs zIPv4Interface.with_prefixlencCsd|j|j|jfS)Nz%s/%s)r{r(r)rVrrr rs zIPv4Interface.with_netmaskcCsd|j|j|jfS)Nz%s/%s)r{r(r)rVrrr rs zIPv4Interface.with_hostmaskN)rrrrr|rvrwrrTrprrr-rrrrrrr ris     rc@s.eZdZeZdddZeejddZ dS)rTcCstj||t|ttfr&|}|j}n^t|trT|d}t|dkrL|dn|j}n0t|}|j |d}t|dkr~|dn|j}t ||_ |j |\|_ |_t|j }|t|j @|kr|rtd|nt |t|j @|_ |j|jdkr|j|_dS)Nrr%rz%s has host bits set)rNrr4rjrr8rr"r$rlr rJrrrHr rr)rVrrr#rargsrrrr rs(%    zIPv4Network.__init__cCs&|jtdko|jtdk o$|j S)Nz 100.64.0.0/10)rJrrCr)rVrrr rs zIPv4Network.is_globalN)T) rrrr rrrrrrrrrrr rs  Crc@seZdZedZedZedZedZededededededed ed ed ed ed edededgZededgZ edZ e dZ dS)_IPv4Constantsz169.254.0.0/16z 127.0.0.0/8z 224.0.0.0/4z 100.64.0.0/10z 0.0.0.0/8z 10.0.0.0/8z 172.16.0.0/12z 192.0.0.0/24z192.0.0.170/31z 192.0.2.0/24z192.168.0.0/16z 198.18.0.0/15z198.51.100.0/24z203.0.113.0/24z 240.0.0.0/4z255.255.255.255/32z 192.0.0.9/32z 192.0.0.10/32z0.0.0.0N) rrrrrrrrrrrr rrrrr rs,  rc@seZdZfZdZdedZdZedZ eZ iZ e ddZ e dd Ze d d Ze d d Ze dddZddZddZeddZeddZdS)_BaseV6r3rr%rcZ0123456789ABCDEFabcdefcCsJ||jkr@t|tr|}n |j|}t|j|}||f|j|<|j|S)N)rr4rjrkr rb)r`rrarrrr rZs   z_BaseV6._make_netmaskcCs|s td|jd}d}t||kr:d||f}t|d|dkryt|jj}Wn4tk r}ztd||fdWYdd}~XnX|jd|d ?d @|jd|d @|jd}t||krd |d|f}t|d}xDtdt|dD].} || s|dk r$d |}t|| }qW|dk r|} t||d} |d st| d8} | rtd}t|||ds| d8} | rd}t|||j| | } | dkr:d}t||jd|fnjt||jkrd}t||j|f|d sd}t|||ds*d}t||t|} d } d } ytd } x,t| D] } | d K} | |j || O} qJW| d | K} x0t| d D] } | d K} | |j || O} qW| St k r}ztd||fdWYdd}~XnXdS)NzAddress cannot be empty:rz At least %d parts expected in %rrr%z%s in %rz%xriz!At most %d colons permitted in %rz At most one '::' permitted in %rrz0Leading ':' only permitted as part of '::' in %rz1Trailing ':' only permitted as part of '::' in %rz/Expected at most %d other parts with '::' in %rz,Exactly %d parts expected without '::' in %rrFrFrF) rr!r"r r=r(r@ _HEXTET_COUNTr _parse_hextetr )r`rmrZ _min_partsr]Zipv4_intrZ _max_partsZ skip_indexiZparts_hiZparts_loZ parts_skippedrdrrr rlls    $                z_BaseV6._ip_int_from_stringcCs>|jj|std|t|dkr4d}t||t|dS)NzOnly hex digits permitted in %rrz$At most 4 characters permitted in %rr) _HEX_DIGITSrir r"rj)r`Z hextet_strr]rrr rs     z_BaseV6._parse_hextetc Csd}d}d}d}xJt|D]>\}}|dkrP|d7}|dkr>|}||krX|}|}qd}d}qW|dkr||}|t|kr|dg7}dg|||<|dkrdg|}|S) Nr%rrrFrFrFrF)rr") r`hextetsZbest_doublecolon_startZbest_doublecolon_lenZdoublecolon_startZdoublecolon_lenindexZhextetZbest_doublecolon_endrrr _compress_hextetss.   z_BaseV6._compress_hextetsNcsZ|dkrt|j}||jkr$tdd|fddtdddD}|j|}dj|S) NzIPv6 address is too largez%032xcs&g|]}dt||ddqS)z%xrr)rj)rr)hex_strrr r3sz/_BaseV6._string_from_ip_int..rrrr)rjr(r9r rrr)r`rdrr)rr r{s   z_BaseV6._string_from_ip_intcst|trt|j}nt|tr,t|j}nt|}|j|}d|fddtdddD}t|ttfrddj ||j fSdj |S) Nz%032xcsg|]}||dqS)rr)rr)rrr rKsz8_BaseV6._explode_shorthand_ip_string..rrrz%s/%dr) r4rr rJrr-rlrrNrrH)rVrmrdrr)rr rU8s     z$_BaseV6._explode_shorthand_ip_stringcCs&|jdddjdd}dj|dS)Nr%rrrz .ip6.arparF)rWreplacer)rVZ reverse_charsrrr rYPsz_BaseV6._reverse_pointercCs|jS)N)r8)rVrrr rYsz_BaseV6.max_prefixlencCs|jS)N)rG)rVrrr r7]sz_BaseV6.version)N)rrrrqrG IPV6LENGTHr9rrrr8rrsrrlrrr{rUrYrrrr7rrrr rFs"    h  0  rc@seZdZdZddZeddZeddZed d Zed d Z ed dZ ee j ddZ eddZeddZeddZeddZeddZeddZdS)r r(rcCsrt|tr|j|||_dSt|trF|j|dtj|d|_dSt|}d|krbtd||j ||_dS)NrrrzUnexpected '/' in %r) r4rjr^r(rr_rr rrl)rVrrrrr rhs     zIPv6Address.__init__cCs t|jS)N)rr()rVrrr rszIPv6Address.packedcCs ||jjkS)N)rr)rVrrr rs zIPv6Address.is_multicastcstfddjjDS)Nc3s|]}|kVqdS)Nr)rr)rVrr rsz*IPv6Address.is_reserved..)rr_reserved_networks)rVr)rVr rs zIPv6Address.is_reservedcCs ||jjkS)N)rr)rVrrr rszIPv6Address.is_link_localcCs ||jjkS)N)r_sitelocal_network)rVrrr is_site_locals zIPv6Address.is_site_localcsHj}|dk r|jStfddjjDoFtfddjjDS)Nc3s|]}|kVqdS)Nr)rr:)rVrr rsz)IPv6Address.is_private..c3s|]}|kVqdS)Nr)rr:)rVrr rs) ipv4_mappedrrrrrr)rVrr)rVr rs zIPv6Address.is_privatecCs|j S)N)r)rVrrr rszIPv6Address.is_globalcCs |jdkS)Nr)r()rVrrr rs zIPv6Address.is_unspecifiedcCs |jdkS)Nr%)r()rVrrr rs zIPv6Address.is_loopbackcCs |jd?dkrdSt|jd@S)Nril)r(r )rVrrr rs zIPv6Address.ipv4_mappedcCs4|jd?dkrdSt|jd?d@t|jd@fS)N`i @l)r(r )rVrrr teredo s zIPv6Address.teredocCs$|jd?dkrdSt|jd?d@S)Npi Pl)r(r )rVrrr sixtofours zIPv6Address.sixtofourN)r(r)rrrrqrrrrrrrrrrrrrrrrrrrrr r bs$    r c@seZdZddZddZddZddZd d Zej Z e d d Z e d dZ e ddZ e ddZe ddZe ddZdS)rcCst|ttfr2tj||t|j|_|j|_ dSt|t rtj||dt |dkrht|d|_ n|j|_ t|dd|_|jj |_ |jj |_ dSt|}tj||dt|dd|_|jj |_ |jj |_ |jj |_ dS)Nrr%F)r)r4rrjr rrr(rr8rHrr"rrr$)rVrr#rrr r+s(        zIPv6Interface.__init__cCsd|j|j|jjfS)Nz%s/%d)r{r(rra)rVrrr r|Cs zIPv6Interface.__str__c CsDtj||}| s|tkr|Sy |j|jkStk r>dSXdS)NF)r rvrQrrI)rVrurrrr rvGs  zIPv6Interface.__eq__c CsNtj||}|tkrtSy|j|jkp4|j|jko4|Stk rHdSXdS)NF)r rwrQrrI)rVrurrrr rwSs  zIPv6Interface.__lt__cCst|j|jt|jjfS)N)r}r(rHrjrrJ)rVrrr r_szIPv6Interface.__hash__cCs t|jS)N)r r()rVrrr r-dszIPv6Interface.ipcCsd|j|j|jfS)Nz%s/%s)r{r(rH)rVrrr rhs zIPv6Interface.with_prefixlencCsd|j|j|jfS)Nz%s/%s)r{r(r)rVrrr rms zIPv6Interface.with_netmaskcCsd|j|j|jfS)Nz%s/%s)r{r(r)rVrrr rrs zIPv6Interface.with_hostmaskcCs|jdko|jjS)Nr)r(rr)rVrrr rwszIPv6Interface.is_unspecifiedcCs|jdko|jjS)Nr%)r(rr)rVrrr r{szIPv6Interface.is_loopbackN)rrrrr|rvrwrrTrprrr-rrrrrrrrr r)s       rc@s.eZdZeZd ddZddZeddZdS) rTcCstj||t|ttfr&|}|j}n^t|trT|d}t|dkrL|dn|j}n0t|}|j |d}t|dkr~|dn|j}t ||_ |j |\|_ |_t|j }|t|j @|kr|rtd|nt |t|j @|_ |j|jdkr|j|_dS)Nrr%rz%s has host bits set)rNrr4rjrr8rr"r$rlr rJrrrHr rr)rVrrr#rrrrrr rs(    zIPv6Network.__init__ccs@t|j}t|j}x&t|d|dD]}|j|Vq(WdS)Nr%)rjrJrCrr)rVrrrrrr rs  zIPv6Network.hostscCs|jjo|jjS)N)rJrrC)rVrrr rs zIPv6Network.is_site_localN)T) rrrr rrrrrrrrrr rs > rc@seZdZedZedZededededededed ed ed edg Zed ed ededededgZededededededededededededededed gZed!Z d"S)#_IPv6Constantsz fe80::/10zff00::/8z::1/128z::/128z ::ffff:0:0/96z64:ff9b:1::/48z100::/64z 2001::/23z 2001:db8::/32z 2002::/16zfc00::/7z 2001:1::1/128z 2001:1::2/128z 2001:3::/32z2001:4:112::/48z 2001:20::/28z 2001:30::/28z::/8z100::/8z200::/7z400::/6z800::/5z1000::/4z4000::/3z6000::/3z8000::/3zA000::/3zC000::/3zE000::/4zF000::/5zF800::/6zFE00::/9z fec0::/10N) rrrrrrrrrrrrrr rs6          r)T)" __version__rrrr rr rrrrrr$r.r2r;rErMrSrTtotal_orderingr5rNrgr rrrrrr rrrrrrr  sV #716:EE Sa&HWj-