Ñò î¡ßNc@s?dZddkZddkZddkZeid&jo0ddklZ l Z ddk l ZlZn`y3eidƒddklZ l Z l ZlZWn)ddk lZ l Z l ZlZnXdd klZlZlZdd klZlZlZlZlZlZ l!Z"dd k#l$Z$d Z%d Z&dZ'dZ(eZ)dZ*dZ+dZ,de%dZ-e%e&Z.de&dZ/e0gZ1e2de%dƒD]#Z3e1e3e-de%e3dAfqš[1ƒZ4e0gZ5e2de%dƒD]#Z3e5e-de%e3dAe3fqä[5ƒZ6e0gZ7e2de%dƒD]Z3e7e3de%e3dfq.[7ƒZ8e0gZ9e2de%dƒD]Z3e9de%e3de3fqt[9ƒZ:dd„Z;dd„Z<dd„Z>d„Z?d„Z@d„ZAd„Zd„ZBd„ZCd„Zd „Zdd!„Zd"„Zd#„Zd$„Z!d%„ZDdS('sIPv4 address logic.iÿÿÿÿNtwin32tcygwin(t inet_atont inet_ntoa(t inet_ptontAF_INETs255.255.255.255(RRRR(tAddrFormatErrortZEROFILLt INET_PTON(t valid_wordst valid_bitst bits_to_intt int_to_bitst valid_bint int_to_bint bin_to_int(t _str_typei is%dt.tIPv4ii iiicCs­|djotdƒ‚nt}|t@oAdig}|idƒD]}|dt|ƒqH~ƒ}ny*|t@ott|ƒn t |ƒWn t }nX|S(sN @param addr: An IPv4 address in presentation (string) format. @param 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. @return: C{True} if IPv4 address is valid, C{False} otherwise. ts Empty strings are not supported!Rs%d( RtTrueRtjointsplittintRt _inet_ptonRt _inet_atontFalse(taddrtflagstvalidityt_[1]ti((s9/usr/lib/python2.6/site-packages/netaddr/strategy/ipv4.pyt valid_str^s  A  c Cs±|t@oAdig}|idƒD]}|dt|ƒq%~ƒ}nyG|t@otidtt|ƒƒdStidt |ƒƒdSWnt d|ƒ‚nXdS(sP @param addr: An IPv4 dotted decimal address in string form. @param 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. @return: The equivalent unsigned integer for a given IPv4 address. Rs%ds>Iis&%r is not a valid IPv4 address string!N( RRRRRt_structtunpackRRRR(RRRR((s9/usr/lib/python2.6/site-packages/netaddr/strategy/ipv4.pyt str_to_int{s A cCs_d|jo tjno-d|d?|d?d@|d?d@|d@fStd|ƒ‚dS( sÝ @param int_val: An unsigned integer. @param dialect: (unused) Any value passed in is ignored. @return: The IPv4 presentation (string) format address equivalent to the unsigned integer provided. is %d.%d.%d.%diiiÿis*%r is not a valid 32-bit unsigned integer!N(tmax_intt ValueError(tint_valtdialect((s9/usr/lib/python2.6/site-packages/netaddr/strategy/ipv4.pyt int_to_str‘s    cCsXg}t|ƒD]}|d|q~}|iƒ|idddgƒdi|ƒS(s“ @param int_val: An unsigned integer. @return: The reverse DNS lookup for an IPv4 address in network byte order integer form. s%dsin-addrtarpaRR(t int_to_wordstreversetextendR(R&RRtwords((s9/usr/lib/python2.6/site-packages/netaddr/strategy/ipv4.pyt int_to_arpa¥s+ cCstid|ƒS(s• @param int_val: the integer to be packed. @return: a packed string that is equivalent to value represented by an unsigned integer. s>I(R!tpack(R&((s9/usr/lib/python2.6/site-packages/netaddr/strategy/ipv4.pyt int_to_packed²scCstid|ƒdS(s @param packed_int: a packed string containing an unsigned integer. It is assumed that string is packed in network byte order. @return: An unsigned integer equivalent to value of network address represented by packed binary string. s>Ii(R!R"(t packed_int((s9/usr/lib/python2.6/site-packages/netaddr/strategy/ipv4.pyt packed_to_int¼scCst|ttƒS(N(t _valid_wordst word_sizet num_words(R-((s9/usr/lib/python2.6/site-packages/netaddr/strategy/ipv4.pyR ÇscCsZd|jo tjnptd|ƒ‚n|d?|d?d@|d?d@|d@fS(s¥ @param int_val: An unsigned integer. @return: An integer word (octet) sequence that is equivalent to value represented by an unsigned integer. is?%r is not a valid integer value supported by this address type!iiiÿi(R$R%(R&((s9/usr/lib/python2.6/site-packages/netaddr/strategy/ipv4.pyR*Ës  cCsAt|ƒptd|ƒ‚ntidtid|ŒƒdS(s® @param words: A list or tuple containing integer octets. @return: An unsigned integer that is equivalent to value represented by word (octet) sequence. s1%r is not a valid octet list for an IPv4 address!s>It4Bi(R R%R!R"R/(R-((s9/usr/lib/python2.6/site-packages/netaddr/strategy/ipv4.pyt words_to_intÛs cCst|ttƒS(N(t _valid_bitstwidthtword_sep(tbits((s9/usr/lib/python2.6/site-packages/netaddr/strategy/ipv4.pyR èscCst|ttƒS(N(t _bits_to_intR9R:(R;((s9/usr/lib/python2.6/site-packages/netaddr/strategy/ipv4.pyR ìscCs1|djotƒd}nt|tt|ƒS(NR:(tNonetglobalst _int_to_bitsR4R5(R&R:((s9/usr/lib/python2.6/site-packages/netaddr/strategy/ipv4.pyR ðs cCs t|tƒS(N(t _valid_binR9(tbin_val((s9/usr/lib/python2.6/site-packages/netaddr/strategy/ipv4.pyR öscCs t|tƒS(N(t _int_to_binR9(R&((s9/usr/lib/python2.6/site-packages/netaddr/strategy/ipv4.pyRúscCs t|tƒS(N(t _bin_to_intR9(RA((s9/usr/lib/python2.6/site-packages/netaddr/strategy/ipv4.pyRþscCs4g}td|ƒ}t|tƒoïd|jo |‚nd|jo8g}|idƒD]}|dt|ƒq^~}n4ydt|ƒg}Wntj o |‚nXdt|ƒjo djno2x5tdt|ƒƒD]}|idƒqðWq|‚n|p |‚ndt |ƒS( sÅ Expands a partial IPv4 address into a full 4-octet version. @param addr: an partial or abbreviated IPv4 address @return: an expanded IP address in presentation format (x.x.x.x) s!invalid partial IPv4 address: %r!t:Rs%diit0s %s.%s.%s.%s( Rt isinstanceRRRR%tlentrangetappendttuple(RttokensterrorRtoR((s9/usr/lib/python2.6/site-packages/netaddr/strategy/ipv4.pytexpand_partial_addresss&    8 $  (swin32R(Et__doc__tsyst_syststructR!tsockett_sockettplatformRRRt _inet_ntoatnetaddr.fbsocketRRRt netaddr.coreRRRtnetaddr.strategyR R3R R8R R<R R?R R@RRBRRCtnetaddr.compatRR9R4tword_fmtR:tfamilyt family_nametversiont word_baseR$R5tmax_wordtdictRRHRtprefix_to_netmaskt_[2]tnetmask_to_prefixt_[3]tprefix_to_hostmaskt_[4]thostmask_to_prefixR R#R=R(R.R0R2R*R7RN(((s9/usr/lib/python2.6/site-packages/netaddr/strategy/ipv4.pytsb    &&4 GGCC