B [GI|@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|}|}||}|dkr>|||<q||kr||=||qWd}x4t|D]$}|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||q|j|jkr|r|dj|jkrtd||dfy||jWqtk r||j YqXq|r|dj|jkrtd||df||qWt t |}|r,x&t |D]\}}| t||qWt||S)Nz%%s and %s are not of the same version)r4r5_versionr6r@ _prefixlenr8r-AttributeErrornetwork_addressrAsetr.extendr;rE)r)ZaddrsZipsZnetsr-r+r,rrr collapse_addresses2s4     rMcCs(t|tr|St|tr$|StS)N)r4 _BaseNetwork_get_networks_keyr5_get_address_keyNotImplemented)objrrr get_mixed_type_keyhs   rSc@seZdZdZeddZeddZeddZedd Zd d Z d d Z e ddZ e ddZ e ddZe ddZe ddZe ddZddZdS)_IPAddressBasercCs|S)N)_explode_shorthand_ip_string)selfrrr explodedsz_IPAddressBase.explodedcCst|S)N)r )rVrrr compressedsz_IPAddressBase.compressedcCs|S)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}||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_netmaskcCshtj|s||y t|}Wntk r@||YnXd|krX|jksdn|||S)Nr)_BaseV4_DECIMAL_DIGITS issupersetrfintr r8)r`Z prefixlen_strrarrr _prefix_from_prefix_strings    z)_IPAddressBase._prefix_from_prefix_stringcCsy||}Wntk r,||YnXy ||Stk rLYnX||jN}y ||Stk r||YnXdS)N)_ip_int_from_stringrrfrer r9)r`ip_strrdrrr _prefix_from_ip_strings   z%_IPAddressBase._prefix_from_ip_stringcCsHt|ttfr||jfSt|ts*t|}t|dkr:|S|d|jfS)Nr%r)r4bytesrjr8tupler$r")r`rrrr _split_addr_prefixs    z!_IPAddressBase._split_addr_prefixcCs|jt|ffS)N) __class__r )rVrrr __reduce__/sz_IPAddressBase.__reduce__N)rrr __slots__propertyrWrXrZr7r^r_ classmethodrbrerfrkrnrqrsrrrr rTs        " rTc@s`eZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ dS)r5rcCs|jS)N)r()rVrrr __int__>sz_BaseAddress.__int__cCs2y|j|jko|j|jkStk r,tSXdS)N)r(rGrIrQ)rVotherrrr __eq__As   z_BaseAddress.__eq__cCsFt|tstS|j|jkr*td||f|j|jkrB|j|jkSdS)Nz%%s and %s are not of the same versionF)r4r5rQrGr6r()rVrxrrr __lt__Hs     z_BaseAddress.__lt__cCs t|tstS|t||S)N)r4rjrQrr)rVrxrrr __add__Ts z_BaseAddress.__add__cCs t|tstS|t||S)N)r4rjrQrr)rVrxrrr __sub__Ys z_BaseAddress.__sub__cCsd|jjt|fS)Nz%s(%r))rrrr )rVrrr __repr__^sz_BaseAddress.__repr__cCst||jS)N)r _string_from_ip_intr()rVrrr __str__asz_BaseAddress.__str__cCsttt|jS)N)hashhexrjr()rVrrr __hash__dsz_BaseAddress.__hash__cCs |j|fS)N)rG)rVrrr rPgsz_BaseAddress._get_address_keycCs|j|jffS)N)rrr()rVrrr rsjsz_BaseAddress.__reduce__N)rrrrtrwryrzr{r|r}rrrPrsrrrr r53s  r5c@s`eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ eddZeddZeddZeddZedd Zed!d"Zed#d$Zed%d&Zd'd(Zd)d*Zd+d,ZdGd/d0ZdHd1d2Zed3d4Zed5d6Zd7d8Zd9d:Z ed;d<Z!ed=d>Z"ed?d@Z#edAdBZ$edCdDZ%edEdFZ&d.S)IrNcCs i|_dS)N)_cache)rVrrrr __init__wsz_BaseNetwork.__init__cCsd|jjt|fS)Nz%s(%r))rrrr )rVrrr r}zsz_BaseNetwork.__repr__cCsd|j|jfS)Nz%s/%d)rJra)rVrrr r}sz_BaseNetwork.__str__ccs<t|j}t|j}x"t|d|D]}||Vq$WdS)Nr%)rjrJrCrange_address_class)rVnetwork broadcastxrrr hostss  z_BaseNetwork.hostsccs<t|j}t|j}x"t||dD]}||Vq$WdS)Nr%)rjrJrCrr)rVrrrrrr __iter__s  z_BaseNetwork.__iter__cCslt|j}t|j}|dkr>|||kr0td|||S|d7}|||krZtd|||SdS)Nrzaddress out of ranger%)rjrJrC IndexErrorr)rVnrrrrr __getitem__s    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)rVrxrrr rzs       z_BaseNetwork.__lt__cCsFy,|j|jko,|j|jko,t|jt|jkStk r@tSXdS)N)rGrJrjrrIrQ)rVrxrrr rys   z_BaseNetwork.__eq__cCstt|jt|jAS)N)rrjrJr)rVrrr rsz_BaseNetwork.__hash__cCsL|j|jkrdSt|trdSt|jt|jkoBt|jkSSdS)NF)rGr4rNrjrJr(rC)rVrxrrr __contains__s   z_BaseNetwork.__contains__cCs(|j|kp&|j|kp&|j|kp&|j|kS)N)rJrC)rVrxrrr overlapss   z_BaseNetwork.overlapscCs<|jd}|dkr8|t|jt|jB}||jd<|S)NrC)rr?rrjrJhostmask)rVrrrr rCs    z_BaseNetwork.broadcast_addresscCs8|jd}|dkr4|t|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.prefixlenccs|j|jkstd||ft|ts2td|||sLtd||f||krXdS|d|j|jf}| \}}xb||kr||kr||r|V| \}}q|||r|V| \}}q|t d|||fq|W||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) rGr6r4rN subnet_ofr rrrJrarDAssertionError)rVrxs1s2rrr address_excludes6$          z_BaseNetwork.address_excludecCs`|j|jkrtd||f|j|jkr,dS|j|jkr 0z0prefix length diff %d is invalid for netblock %s) rHr8r rjrJrCrrrr) rVprefixlen_diff new_prefix new_prefixlenstartendstepZnew_addrZcurrentrrr rD}s,       z_BaseNetwork.subnetscCs|jdkr|S|dk rB||jkr(td|dkr8td|j|}|j|}|dkrftd|j|f|t|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 rarrrjrJr)rVrrrrrr r>s     z_BaseNetwork.supernetcCs|jjo|jjS)N)rJ is_multicastrC)rVrrr rs z_BaseNetwork.is_multicastcCsfy8|j|jkr"t|d|d|j|jko8|j|jkStk r`td|d|YnXdS)Nz and z are not of the same versionz*Unable to test subnet containment between )rGr6rJrCrI)abrrr _is_subnet_ofs   z_BaseNetwork._is_subnet_ofcCs |||S)N)r)rVrxrrr rsz_BaseNetwork.subnet_ofcCs |||S)N)r)rVrxrrr supernet_ofsz_BaseNetwork.supernet_ofcCs|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 r)s z_BaseNetwork.is_unspecifiedcCs|jjo|jjS)N)rJ is_loopbackrC)rVrrr r5s z_BaseNetwork.is_loopback)r%N)r%N)'rrrrr}rrrrrzryrrrrurCrrrrrrrarrrOrDr>r staticmethodrrrrrrrrrrrrr rNnsD            K0 5 )  rNc @seZdZdZdZdedZedZedddd d d d d dh Z eZ iZ ddZ e ddZe ddZe ddZe ddZddZddZddZedd Zed!d"Zd#S)$rgrrrr% 0123456789rrcCst|S)N)r )rVrrr rUYsz$_BaseV4._explode_shorthand_ip_stringcCs||jkrt|tr<|}d|kr.|jksjn||n.y||}Wntk rh||}YnXt| |}||f|j|<|j|S)Nr) _netmask_cacher4rjr8rfrkr rnr rb)r`argrarrrr _make_netmask\s   z_BaseV4._make_netmaskc Cs||s td|d}t|dkr.td|ytt|j|dStk rv}ztd||fdWdd}~XYnXdS)NzAddress cannot be empty.rzExpected 4 octets in %rrz%s in %r)rr!r"rj from_bytesmap _parse_octetr )r`rmZoctetsexcrrr rlvs   z_BaseV4._ip_int_from_stringcCs|s td|j|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 rs       z_BaseV4._parse_octetcCsdtt|ddS)Nrrr)joinrr r)r`rdrrr r~s z_BaseV4._string_from_ip_intcCs|d}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_netmaskcsh|d}yfddtt|D}Wntk r:dSXt|t|krPdS|d|dkrddSdS)Nrcsg|]}|jkr|qSr)r).0r)rVrr sz(_BaseV4._is_hostmask..FrrFT)r!rrjr r")rVrmr1partsr)rVr _is_hostmasks z_BaseV4._is_hostmaskcCs&t|dddd}d|dS)NrrFz .in-addr.arpa)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)rrrrtrG IPV4LENGTHr9 frozensetrhrr8rrUrvrrlrr~rrrYrurr7rrrr rgBs"     %  rgc@seZdZdZddZeddZeddZee dd Z ee d d Z ed d Z eddZ eddZeddZdS)r )r( __weakref__cCsrt|tr||||_dSt|trF||dt|d|_dSt|}d|krbtd|| ||_dS)NrrrzUnexpected '/' in %r) r4rjr^r(ror_rr rrl)rVraddr_strrrr rs     zIPv4Address.__init__cCs t|jS)N)rr()rVrrr packed1szIPv4Address.packedcCs ||jjkS)N) _constants_reserved_network)rVrrr r6s zIPv4Address.is_reservedcstfddjjDS)Nc3s|]}|kVqdS)Nr)rr:)rVrr Ksz)IPv4Address.is_private..)anyr_private_networks)rVr)rVr rAs zIPv4Address.is_privatecCs||jjko|j S)N)r_public_networkr)rVrrr rMszIPv4Address.is_globalcCs ||jjkS)N)r_multicast_network)rVrrr rRs zIPv4Address.is_multicastcCs ||jjkS)N)r_unspecified_address)rVrrr r]s zIPv4Address.is_unspecifiedcCs ||jjkS)N)r_loopback_network)rVrrr rhszIPv4Address.is_loopbackcCs ||jjkS)N)r_linklocal_network)rVrrr rrszIPv4Address.is_link_localN)rrrrtrrurr functools lru_cacherrrrrrrrrr r s#    r c@sjeZdZddZddZddZddZd d Zej Z e d d Z e d dZ e ddZ e ddZdS)rcCsN||\}}t||t||fdd|_|jj|_|jj|_|jj|_dS)NF)r)rqr rrrrrrH)rVrr#rrrr rs    zIPv4Interface.__init__cCsd||j|jjfS)Nz%s/%d)r~r(rra)rVrrr rs zIPv4Interface.__str__cCsBt||}|r|tkr|Sy |j|jkStk r<dSXdS)NF)r ryrQrrI)rVrx address_equalrrr rys   zIPv4Interface.__eq__cCsNt||}|tkrtSy|j|jkp4|j|jko4|Stk rHdSXdS)NF)r rzrQrrI)rVrx address_lessrrr rzs  zIPv4Interface.__lt__cCst|j|jt|jjfS)N)rr(rHrjrrJ)rVrrr rszIPv4Interface.__hash__cCs t|jS)N)r r()rVrrr r-szIPv4Interface.ipcCsd||j|jfS)Nz%s/%s)r~r(rH)rVrrr rs zIPv4Interface.with_prefixlencCsd||j|jfS)Nz%s/%s)r~r(r)rVrrr rs zIPv4Interface.with_netmaskcCsd||j|jfS)Nz%s/%s)r~r(r)rVrrr rs zIPv4Interface.with_hostmaskN)rrrrrryrzrrTrsrur-rrrrrrr r}s      rc@s.eZdZeZdddZeeddZ dS)rTcCst||||\}}t||_||\|_|_t|j}|t|j@|krx|rdt d|nt|t|j@|_|j|j dkr|j |_ dS)Nz%s has host bits setr%) rNrrqr rJrrrHrjr r8rr)rVrrr#rrrrr rs$   zIPv4Network.__init__cCs&|jtdko|jtdk o$|j S)Nz 100.64.0.0/10)rJrrCr)rVrrr rs zIPv4Network.is_globalN)T) rrrr rrrurrrrrrr rs  4rc@seZdZedZedZedZedZededededededed ed ed ed ed edededgZedZ 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/29z192.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/32z0.0.0.0N) rrrrrrrrrrr rrrrr rs( rc@seZdZdZdZdedZdZedZ eZ iZ e ddZ e d d Ze d d Ze d dZe dddZddZddZeddZeddZdS)_BaseV6rr3rr%rcZ0123456789ABCDEFabcdefcCsl||jkrbt|tr<|}d|kr.|jksFn||n ||}t||}||f|j|<|j|S)Nr)rr4rjr8rfrkr rb)r`rrarrrr rEs    z_BaseV6._make_netmaskc Cs|s td|d}d}t||kr:d||f}t|d|dkryt|j}Wn4tk r}ztd||fdWdd}~XYnX|d|d ?d @|d|d @|jd }t||krd |d |f}t|d}x@td t|d D]*} || s|dk r"d |}t|| }qW|dk r|} t||d } |dsp| d 8} | rpd}t|||ds| d 8} | rd}t|||j| | } | d kr6d}t||jd |fnjt||jkrd}t||j|f|ds d}t|||ds&d}t||t|} d} d} ytd} x,t| D] } | d K} | | || O} qFW| d | K} x0t| dD] } | d K} | | || O} qW| St k r}ztd||fdWdd}~XYnXdS)NzAddress cannot be empty:rz At least %d parts expected in %rrrFz%s in %rz%xrir%z!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 %r) rr!r"r r=r(r@ _HEXTET_COUNTr _parse_hextetr )r`rmrZ _min_partsr]Zipv4_intrZ _max_partsZ skip_indexiZparts_hiZparts_loZ parts_skippedrdrrr rlYs    $              z_BaseV6._ip_int_from_stringcCs>|j|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)NrFrrr%)rr") r`hextetsZbest_doublecolon_startZbest_doublecolon_lenZdoublecolon_startZdoublecolon_lenindexZhextetZbest_doublecolon_endrrr _compress_hextetss.   z_BaseV6._compress_hextetsNcsZ|dkrt|j}||jkr$tdd|fddtdddD}||}d|S) NzIPv6 address is too largez%032xcs&g|]}dt||ddqS)z%xrr)rj)rr)hex_strrr r sz/_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|}||}d|fddtdddD}t|ttfrdd ||j fSd |S) Nz%032xcsg|]}||dqS)rr)rr)rrr r8sz8_BaseV6._explode_shorthand_ip_string..rrrz%s/%dr) r4rr rJrr-rlrrNrrH)rVrmrdrr)rr rU%s     z$_BaseV6._explode_shorthand_ip_stringcCs&|jddddd}d|dS)NrFrrrz .ip6.arpa)rWreplacer)rVZ reverse_charsrrr rY=sz_BaseV6._reverse_pointercCs|jS)N)r8)rVrrr rFsz_BaseV6.max_prefixlencCs|jS)N)rG)rVrrr r7Jsz_BaseV6.version)N)rrrrtrG IPV6LENGTHr9rrrr8rrvrrlrrr~rUrYrurr7rrrr r1s"    h  0  rc@seZdZdZddZeddZeddZedd Zed d Z ed d Z ee ddZ eddZeddZeddZeddZeddZeddZdS)r )r(rcCsrt|tr||||_dSt|trF||dt|d|_dSt|}d|krbtd|| ||_dS)NrrrzUnexpected '/' in %r) r4rjr^r(ror_rr rrl)rVrrrrr rUs     zIPv6Address.__init__cCs t|jS)N)rr()rVrrr ryszIPv6Address.packedcCs ||jjkS)N)rr)rVrrr r~s 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_localcstfddjjDS)Nc3s|]}|kVqdS)Nr)rr:)rVrr rsz)IPv6Address.is_private..)rrr)rVr)rVr rs zIPv6Address.is_privatecCs|j S)N)r)rVrrr rs zIPv6Address.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 ipv4_mappeds zIPv6Address.ipv4_mappedcCs4|jd?dkrdSt|jd?d@t|jd@fS)N`i @l)r(r )rVrrr teredos zIPv6Address.teredocCs$|jd?dkrdSt|jd?d@S)Npi Pl)r(r )rVrrr sixtofours zIPv6Address.sixtofourN)rrrrtrrurrrrrrrrrrrrrrrrrr r Os$   r c@seZdZddZddZddZddZd d Zej Z e d d Z e d dZ e ddZ e ddZe ddZe ddZdS)rcCsN||\}}t||t||fdd|_|jj|_|jj|_|jj|_dS)NF)r)rqr rrrrrrH)rVrr#rrrr rs    zIPv6Interface.__init__cCsd||j|jjfS)Nz%s/%d)r~r(rra)rVrrr rs zIPv6Interface.__str__cCsBt||}|r|tkr|Sy |j|jkStk r<dSXdS)NF)r ryrQrrI)rVrxrrrr rys   zIPv6Interface.__eq__cCsNt||}|tkrtSy|j|jkp4|j|jko4|Stk rHdSXdS)NF)r rzrQrrI)rVrxrrrr rzs  zIPv6Interface.__lt__cCst|j|jt|jjfS)N)rr(rHrjrrJ)rVrrr r*szIPv6Interface.__hash__cCs t|jS)N)r r()rVrrr r-/szIPv6Interface.ipcCsd||j|jfS)Nz%s/%s)r~r(rH)rVrrr r3s zIPv6Interface.with_prefixlencCsd||j|jfS)Nz%s/%s)r~r(r)rVrrr r8s zIPv6Interface.with_netmaskcCsd||j|jfS)Nz%s/%s)r~r(r)rVrrr r=s zIPv6Interface.with_hostmaskcCs|jdko|jjS)Nr)r(rr)rVrrr rBszIPv6Interface.is_unspecifiedcCs|jdko|jjS)Nr%)r(rr)rVrrr rFszIPv6Interface.is_loopbackN)rrrrrryrzrrTrsrur-rrrrrrrrr rs        rc@s.eZdZeZd ddZddZeddZdS) rTcCst||||\}}t||_||\|_|_t|j}|t|j@|krx|rdt d|nt|t|j@|_|j|j dkr|j |_ dS)Nz%s has host bits setr%) rNrrqr rJrrrHrjr r8rr)rVrrr#rrrrr r[s   zIPv6Network.__init__ccs@t|j}t|j}x&t|d|dD]}||Vq(WdS)Nr%)rjrJrCrr)rVrrrrrr rs  zIPv6Network.hostscCs|jjo|jjS)N)rJrrC)rVrrr rs zIPv6Network.is_site_localN)T) rrrr rrrrurrrrr rKs / rc@seZdZedZedZededededededed ed ed edg Zed ed edededededededededededededgZedZdS)_IPv6Constantsz fe80::/10zff00::/8z::1/128z::/128z ::ffff:0:0/96z100::/64z 2001::/23z 2001:2::/48z 2001:db8::/32z 2001:10::/28zfc00::/7z::/8z100::/8z200::/7z400::/6z800::/5z1000::/4z4000::/3z6000::/3z8000::/3zA000::/3zC000::/3zE000::/4zF000::/5zF800::/6zFE00::/9z fec0::/10N) rrrrrrrrrrrrr rs*         r)T)" __version__rrrr rr rrrrrr$r.r2r;rErMrSrTtotal_orderingr5rNrgr rrrrrr rrrrrrr  sT #7163:VGu@R 5H[!