o i¾nhã @sâdZddlZddlZddlmZddlmZ m Z m Z mZmZmZmZmZmZdZdZeZdZdZdedZGd d „d e ƒZ!Gd d „d e!ƒZ"Gd d„de"ƒZ#Gdd„de!ƒZ$Gdd„de!ƒZ%e!Z&dd 'dgd¡ddd 'dgd¡ddd 'dgd¡ddd 'dgd¡ddd 'dgd¡ddd 'dgd¡d fZ(d!d"„e(DƒZ(d#d$„Z)d%d&„Z*d'd(„Z+dAd)d*„Z,d+d,„Z-d-d.„Z.dAd/d0„ZdAd1d2„Z dAd3d4„Z dAd5d6„ZdAd7d8„ZdAd9d:„ZdAd;d<„Zd=d>„Zd?d@„ZdS)Bz5 IEEE 64-bit EUI (Extended Unique Identifier) logic. éN)ÚAddrFormatError) Ú valid_wordsÚ int_to_wordsÚ words_to_intÚ valid_bitsÚ bits_to_intÚ int_to_bitsÚ valid_binÚ int_to_binÚ bin_to_inté@zEUI-64ééc@s4eZdZdZdZeeZdedZdZdZ dZ dS) Ú eui64_basez%A standard IEEE EUI-64 dialect class.ér rú-z%.2XéN) Ú__name__Ú __module__Ú __qualname__Ú__doc__Ú word_sizeÚwidthÚ num_wordsÚmax_wordÚword_sepÚword_fmtÚ word_base©rrúA/usr/local/lib/python3.10/dist-packages/netaddr/strategy/eui64.pyr+s rc@ó(eZdZdZdZeeZdZdZdZ dS)Ú eui64_unixz'A UNIX-style MAC address dialect class.rú:z%xrN© rrrrrrrrrrrrrrr!@ór!c@seZdZdZdZdS)Úeui64_unix_expandedz;A UNIX-style MAC address dialect class with leading zeroes.ú%.2xN)rrrrrrrrrr%Isr%c@s(eZdZdZdZeeZdZdZdZ dS)Ú eui64_ciscoz2A Cisco 'triple hextet' MAC address dialect class.rÚ.ú%.4xNr#rrrrr'Nr$r'c@r )Ú eui64_barez1A bare (no delimiters) MAC address dialect class.r Úz%.16XrNr#rrrrr*Wr$r*ú^r"z([0-9A-F]{1,2})rú$rz([0-9A-F]{1,4})éz\.z^(r+z[0-9A-F]rz)$cCsg|] }t |tj¡‘qSr)Ú_reÚcompileÚ IGNORECASE)Ú.0Ú_rrrÚ uór4cCs(|D]}| |¡}|r|dSqdS)Nr)Úfindall)ÚaddressÚformatsÚregexpÚmatchrrrÚ_get_match_resultxs   ÿþr;cCs,z t|tƒr WdSWdStyYdSw)z‹ :param addr: An IEEE EUI-64 identifier in string form. :return: ``True`` if EUI-64 identifier is valid, ``False`` otherwise. TF)r;ÚRE_EUI64_FORMATSÚ TypeError)ÚaddrrrrÚ valid_strs ÿ ýýr?cCsÒg}z t|tƒ}|s t‚Wntytd|fƒ‚wt|tƒr"n|f}t|ƒdkr:td dd„|Dƒ¡dƒ}|St|ƒdkrOtd dd„|Dƒ¡dƒ}|St|ƒd krctd t|d dƒdƒ}|Std |ƒ‚) zÎ :param addr: An IEEE EUI-64 identifier in string form. :return: An unsigned integer that is equivalent to value represented by EUI-64 string address formatted according to the dialect z#invalid IEEE EUI-64 identifier: %r!rr+cSóg|] }dt|dƒ‘qS)r&r©Úint©r2Úwrrrr4¥r5zstr_to_int..rr.cSr@)r)rrArCrrrr4¨r5rz%016xrz)bad word count for EUI-64 identifier: %r!) r;r<r=rÚ isinstanceÚtupleÚlenrBÚjoin)r>ÚwordsÚint_valrrrÚ str_to_intŽs0 ÿ ÿ   ö ùýÿrKcs8ˆdurt‰t|ˆƒ}‡fdd„|Dƒ}ˆj |¡}|S)zÉ :param int_val: An unsigned integer. :param dialect: (optional) a Python class defining formatting options :return: An IEEE EUI-64 identifier that is equivalent to unsigned integer. Ncsg|]}ˆj|‘qSr)r)r2Úi©Údialectrrr4¾szint_to_str..)rrrrH)rJrNrIÚtokensr>rrMrÚ int_to_str³s   rPcCst|ƒ}tjdg|¢RŽS)z• :param int_val: the integer to be packed. :return: a packed string that is equivalent to value represented by an unsigned integer. ú>8B)rÚ_structÚpack)rJrIrrrÚ int_to_packedÃsrTcCsFtt d|¡ƒ}d}tt|ƒƒD]\}}|}|d|>}||B}q|S)a :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. rQrr)ÚlistrRÚunpackÚ enumerateÚreversed)Ú packed_intrIrJrLÚnumÚwordrrrÚ packed_to_intÎs  r\cCó|durt}t||j|jƒS©N)ÚDEFAULT_EUI64_DIALECTÚ _valid_wordsrr©rIrNrrrráórcCr]r^)r_Ú _int_to_wordsrr©rJrNrrrrçrbrcCr]r^)r_Ú _words_to_intrrrarrrrírbrcCó|durt}t|t|jƒSr^)r_Ú _valid_bitsrr©ÚbitsrNrrrróórcCrfr^)r_Ú _bits_to_intrrrhrrrrùrjrcCs |durt}t||j|j|jƒSr^)r_Ú _int_to_bitsrrrrdrrrrÿs ÿrcCs|durt}t|tƒSr^)r_Ú _valid_binr)Úbin_valrNrrrr s r cCó t|tƒSr^)Ú _int_to_binr)rJrrrr ó r cCror^)Ú _bin_to_intr)rnrrrr rqr r^)/rÚstructrRÚrer/Ú netaddr.corerÚnetaddr.strategyrr`rrcrrerrgrrkrrlr rmr rpr rrÚAF_EUI64rÚfamilyÚ family_nameÚversionÚmax_intÚobjectrr!r%r'r*r_rHr<r;r?rKrPrTr\rrrrÚsP ,     õ %