Ñò î¡ßNc@s'dZddkZddkZddkiZddkZ ddk Z ddk Z ddklZlZlZlZlZlZddklZlZddklZddklZddklZl Z de!fd „ƒYZ"d e"fd „ƒYZ#d e"fd „ƒYZ$de"fd„ƒYZ%dS(s] Classes and functions for dealing with MAC addresses, EUI-48, EUI-64, OUI, IAB identifiers. iÿÿÿÿN(tNotRegisteredErrortAddrFormatErrortAddrConversionErrort Subscribert Publishert DictDotLookup(teui48teui64(t mac_eui48(t IPAddress(t_is_intt_is_strtBaseIdentifiercBsJeZdZdZd„Zd„Zd„Zd„Zd„Zd„Z RS( s$Base class for all IEEE identifiers.t_valuecCs d|_dS(N(tNoneR (tself((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt__init__ scCs|iS(s)@return: integer value of this identifier(R (R((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt__int__#scCs|iS(s)@return: integer value of this identifier(R (R((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt__long__'scCs |idjodSd|iS(s8@return: octal string representation of this identifier.it0s0%o(R (R((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt__oct__+scCs d|iS(s>@return: hexadecimal string representation of this identifier.s0x%x(R (R((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt__hex__2scCs|iS(sx @return: return the integer value of this identifier when passed to hex(), oct() or bin(). (R (R((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt __index__7s(s_value( t__name__t __module__t__doc__t __slots__RRRRRR(((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyR s     tOUIcBsSeZdZd Zd„Zd„Zed„ƒZdd„Zd„Z d„Z RS( s An individual IEEE OUI (Organisationally Unique Identifier). For online details see - U{http://standards.ieee.org/regauth/oui/} trecordscCsNtt|ƒiƒddkl}g|_t|tƒo"t|i ddƒdƒ|_ n]t |ƒo?d|jo djno ||_ qºt d|ƒ‚nt d |ƒ‚|i |ijomt|iƒ}xM|i|i D];\}}|i|ƒ|i|ƒ}|i|||ƒqíW|iƒntd |ƒ‚d S( sÓ Constructor @param oui: an OUI string C{XX-XX-XX} or an unsigned integer. Also accepts and parses full MAC/EUI-48 address strings (but not MAC/EUI-48 integers)! iÿÿÿÿ(tieeet-tiiiÿÿÿs"OUI int outside expected range: %rsunexpected OUI format: %rsOUI %r not registered!N(tsuperRRt netaddr.euiRRt isinstancetstrtinttreplaceR R t ValueErrort TypeErrort OUI_INDEXtopent OUI_REGISTRYtseektreadt _parse_datatcloseR(RtouiRtfhtoffsettsizetdata((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyRIs& "    cCsèhdd6dd6dd6gd6|d6|d6}x¡|id ƒD]}|iƒ}|pq@nd |jo>|i|d}g}x9tdƒD]+}|d@}|id|ƒ|dL}q Wdit|ƒƒiƒS(s*@return: string representation of this IABi iiÿs%02xiR(R RBR;R:RCRD(RRERFRGRH((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyRIs   cCsd|S(s@@return: executable Python string to recreate equivalent object.s IAB('%s')((R((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyRJs(srecord( RRRRt staticmethodtFalseRTRR-RARIRJ(((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyRL«s 4   tEUIcBsseZdZd!Zd"d"d„Zd„Zd„Zeeed"dƒZ d„Z d„Z ee e d"d ƒZ ed „ƒZ ed „ƒZd „Zed „ƒZed„ƒZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd"d„Zed„ƒZed„ƒZed„ƒZd„Zd„Z ed„ƒZ!d„Z"d „Z#RS(#s× An IEEE EUI (Extended Unique Identifier). Both EUI-48 (used for layer 2 MAC addresses) and EUI-64 are supported. Input parsing for EUI-48 addresses is flexible, supporting many MAC variants. t_modulet_dialectcCsWtt|ƒiƒd|_t|tƒoY|dj o#||iijotdƒ‚n|i|_|i|_|i |_ dS|dj oH|djo t |_qA|djo t |_qAtd|ƒ‚nht |ƒoZd|jo djno t |_qAd|jo djno t |_qAn||_ ||_ dS( s Constructor. @param addr: an EUI-48 (MAC) or EUI-64 address in string format or an unsigned integer. May also be another EUI object (copy construction). @param version: (optional) the explict EUI address version. Mainly used to distinguish between EUI-48 and EUI-64 identifiers specified as integers which may be numerically equivalent. @param dialect: (optional) the mac_* dialect to be used to configure the formatting of EUI-48 (MAC) addresses. s2cannot switch EUI versions using copy constructor!Ni0i@sunsupported EUI version %rilÿÿÿlÿÿÿÿ(R R\RRR]R"tversionR&R tdialectt_eui48t_eui64R tvalue(RtaddrR_R`((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyR0s,             cCs|iS(N(R (R((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt _get_valueascCs“|idjoÓx¨ttfD]š}y |i|ƒ|_||_PWqtj oeyHdt|ƒjo |ijnot|ƒ|_||_PnWq·t j oq·XqXqW|idjotd|ƒ‚qn­t |dƒoOy|ii|ƒ|_Wqtj o#td||ii fƒ‚qXnNdt|ƒjo|iijnot|ƒ|_ntd|ƒ‚dS(Nis failed to detect EUI version: %rRDsaddress %r is not an EUIv%dsbad address format: %r( R]RRaRbt str_to_intR RR$tmax_intR&thasattrR_(RRctmodule((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt _set_valueds6  '  *sBa positive integer representing the value of this EUI indentifier.cCs|iS(N(R^(R((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt _get_dialect‰scCsW|djo t|_n:t|dƒot|dƒo ||_n tdƒ‚dS(Nt word_sizetword_fmts*custom dialects should subclass mac_eui48!(RRR^RhR'(RRc((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt _set_dialectŒs     sXa Python class providing support for the interpretation of various MAC address formats.cCsH|itjot|id?ƒS|itjot|id?ƒSdS(s:The OUI (Organisationally Unique Identifier) for this EUI.ii(N(R]RaRRcRb(R((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyR/™scCs˜|itjo:dig}|dd!D]}|d|q(~ƒiƒS|itjo:dig}|dd!D]}|d|qr~ƒiƒSdS(s*The EI (Extension Identifier) for this EUIRiis%02xiN(R]RaR:RDRb(Rt_[1]tit_[2]((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pytei¡s:cCs d|id?jodjSS(s<@return: True if this EUI is an IAB address, False otherwisei i iÿ/ (R (R((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pytis_iab©scCs#|iƒot|id?ƒSdS(sq If is_iab() is True, the IAB (Individual Address Block) is returned, C{None} otherwise. i N(RsRLR (R((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyRU­s cCs |iiS(s/The EUI version represented by this EUI object.(R]R_(R((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyR_¶scCsât|ƒo]|ii}| |jo|djnptdƒ‚n|ii|i|iƒ|St|tƒoT|ii|i|iƒ}g}t |i t |ƒƒŒD]}|||qµ~St d|ƒ‚dS(sú @return: The integer value of the word referenced by index (both positive and negative). Raises C{IndexError} if index is out of bounds. Also supports Python list slices for accessing word groups. is!index out range for address type!sunsupported type %r!N( R R^t num_wordst IndexErrorR]t int_to_wordsR R"tsliceRBtindicesR>R'(RR4RtRFRoRp((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt __getitem__»s  #9cCst|tƒotdƒ‚nt|ƒptdƒ‚nd|jo|iidjnptd|ƒ‚nt|ƒptdƒ‚nd|jo|iijnp td||ii fƒ‚nt |i i |i |iƒƒ}|||<|i i|ƒ|_ dS( s>Sets the value of the word referenced by index in this addresss"settable slices are not supported!sindex not an integer!iis'index %d outside address type boundary!svalue not an integer!s.value %d outside word size maximum of %d bits!N(R"RwtNotImplementedErrorR R'R^RtRutmax_wordRltlistR]RvR t words_to_int(RR4RcRF((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt __setitem__Îs ( $! cCst|i|ifƒS(sA@return: hash of this EUI object suitable for dict keys, sets etc(thashR_R (R((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt__hash__åscCsAy&|i|if|i|ifjSWntj otSXdS(sw @return: C{True} if this EUI object is numerically the same as other, C{False} otherwise. N(R_R tAttributeErrortNotImplemented(Rtother((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt__eq__és&cCsAy&|i|if|i|ifjSWntj otSXdS(s{ @return: C{False} if this EUI object is numerically the same as the other, C{True} otherwise. N(R_R RR‚(RRƒ((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt__ne__ós&cCsAy&|i|if|i|ifjSWntj otSXdS(s @return: C{True} if this EUI object is numerically lower in value than other, C{False} otherwise. N(R_R RR‚(RRƒ((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt__lt__ýs&cCsAy&|i|if|i|ifjSWntj otSXdS(s† @return: C{True} if this EUI object is numerically lower or equal in value to other, C{False} otherwise. N(R_R RR‚(RRƒ((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt__le__s&cCsAy&|i|if|i|ifjSWntj otSXdS(s @return: C{True} if this EUI object is numerically greater in value than other, C{False} otherwise. N(R_R RR‚(RRƒ((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt__gt__s&cCsAy&|i|if|i|ifjSWntj otSXdS(sˆ @return: C{True} if this EUI object is numerically greater or equal in value to other, C{False} otherwise. N(R_R RR‚(RRƒ((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyt__ge__s&cCs|ii|i|ƒS(sÔ @param word_sep: (optional) the separator to insert between words. Default: None - use default separator for address type. @return: human-readable binary digit string of this address(R]t int_to_bitsR (Rtword_sep((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pytbits%scCs|ii|iƒS(s8The value of this EUI address as a packed binary string.(R]t int_to_packedR (R((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pytpacked-scCs|ii|iƒS(s<A list of unsigned integer octets found in this EUI address.(R]RvR (R((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyRF2scCs|ii|iƒS(sÜ The value of this EUI 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. (R]t int_to_binR (R((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pytbin7sc Cs›|idjowg}|dd!D]}|d|q"~ddgg}|dd!D]}|d|qU~}|idi|ƒƒStt|ƒƒSd S( sR @return: The value of this EUI object as a new 64-bit EUI object. - If this object represents an EUI-48 it is converted to EUI-64 as per the standard. - If this object is already and EUI-64, it just returns a new, numerically equivalent object is returned instead. i0iis%02xtfftfeiRN(R_t __class__R:R\R#(RRoRpRqt eui64_words((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pyR@s 3-c Cs°d}|idjo€g}|dd!D]}|d|q(~ddgg}|dd!D]}|d|q[~}|td i|ƒd ƒ7}n||i7}t|dƒS( s' @return: new link local IPv6 L{IPAddress} object based on this L{EUI} using the technique described in RFC 4291. B{Please Note:} this poses security risks in certain scenarios. Please read RFC 4941 for details. Reference: RFCs 4291 and 4941. l @þi0iis%02xR‘R’iRi(R_R$R:R R (RRERoRpRqt eui64_tokens((s8/usr/lib/python2.6/site-packages/netaddr/eui/__init__.pytipv6_link_localPs3-  cCsDh|iiƒd6}|iƒo|iiƒ|d s     .$ky