U _ @sdZddlZddlZddlmZddlmZ m Z m Z mZmZmZmZmZmZdZdZeZdZdZdedZGd d d e Z!Gd d d e!Z"Gd dde"Z#Gddde!Z$Gddde!Z%e!Z&dd'dgdddd'dgdddd'dgdddd'dgdddd'dgdddd'dgdd fZ(d!d"e(DZ(d#d$Z)d%d&Z*d'd(Z+dAd)d*Z,d+d,Z-d-d.Z.dBd/d0ZdCd1d2Z dDd3d4Z dEd5d6ZdFd7d8ZdGd9d:ZdHd;d<Zd=d>Zd?d@ZdS)Iz6 IEEE 64-bit EUI (Extended Unique Indentifier) 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-64c@s4eZdZdZdZeeZdedZdZdZ dZ dS) eui64_basez%A standard IEEE EUI-64 dialect class.r r-z%.2XN) __name__ __module__ __qualname____doc__ word_sizewidth num_wordsZmax_wordword_sepword_fmt word_baserrn/private/var/folders/y3/n__7lzs1191bf6ypqtmfbcr1rfn98y/T/pip-unpacked-wheel-_tyv3h66/netaddr/strategy/eui64.pyr+s rc@s(eZdZdZdZeeZdZdZdZ dS) eui64_unixz'A UNIX-style MAC address dialect class.r:z%xrN rrrrrrrrrrrrrrr@s rc@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$Ns r$c@s(eZdZdZdZeeZdZdZdZ dS) eui64_barez1A bare (no delimiters) MAC address dialect class.r z%.16XrNr!rrrrr'Ws 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|tjqSr)_recompile IGNORECASE).0_rrr usr1cCs(|D]}||}|r|dSqdS)Nr)findall)addressformatsregexpmatchrrr_get_match_resultxs r7cCs.zt|trWdSWntk r(YnXdS)z :param addr: An IEEE EUI-64 indentifier in string form. :return: ``True`` if EUI-64 indentifier is valid, ``False`` otherwise. TF)r7RE_EUI64_FORMATS TypeError)addrrrr valid_strs   r;cCsg}zt|t}|stWn"tk r<td|fYnXt|trJn|f}t|dkrxtddd|Dd}nZt|dkrtddd|Dd}n2t|d krtd t|d dd}n td ||S) z :param addr: An IEEE EUI-64 indentifier 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(cSsg|]}dt|dqS)r#rintr/wrrrr1szstr_to_int..rr+cSsg|]}dt|dqS)r&rr<r>rrrr1srz%016xrz)bad word count for EUI-64 identifier: %r!) r7r8r9r isinstancetuplelenr=join)r:wordsint_valrrr str_to_ints(     rFcs8dkr tt|}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)r/idialectrrr1szint_to_str..)rrrrC)rErIrDtokensr:rrHr int_to_strs   rKcCst|}tjd|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)rL)r_structpack)rErDrrr int_to_packedsrOcCsFttd|}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. rLrr)listrMunpack enumeratereversed)Z packed_intrDrErGnumwordrrr packed_to_ints  rVcCs|dkr t}t||j|jSN)DEFAULT_EUI64_DIALECT _valid_wordsrrrDrIrrrrsrcCs|dkr t}t||j|jSrW)rX _int_to_wordsrrrErIrrrrsrcCs|dkr t}t||j|jSrW)rX _words_to_intrrrZrrrrsrcCs|dkr t}t|t|jSrW)rX _valid_bitsrrbitsrIrrrrsrcCs|dkr t}t|t|jSrW)rX _bits_to_intrrr_rrrrsrcCs |dkr t}t||j|j|jSrW)rX _int_to_bitsrrrr\rrrrsrcCs|dkr t}t|tSrW)rX _valid_binr)bin_valrIrrrr sr cCs t|tSrW) _int_to_binr)rErrrr sr cCs t|tSrW) _bin_to_intr)rdrrrr sr )N)N)N)N)N)N)N)N)/rstructrMrer,Z netaddr.corerZnetaddr.strategyrrYrr[rr]rr^rrarrbr rcr rer rfZAF_EUI64rfamilyZ family_nameversionZmax_intobjectrrr"r$r'rXrCr8r7r;rFrKrOrVrrrrsN ,     %