^ dZddlZddlZddlmZddlmZ m Z m Z mZmZmZmZmZmZdZdZeZdZdZdezdz ZGd d e Z!Gd d e!Z"Gd de"Z#Gdde!Z$Gdde!Z%e!Z&ddjOdgdzzdzddjOdgdzzdzddjOdgdzzdzddjOdgdzzdzddjOdgdzzdzddjOdgdzzd zfZ(e(Dcgc]}ejR|ejT!c}Z(d!Z+d"Z,d#Z-d0d$Z.d%Z/d&Z0d0d'Zd0d(Z d0d)Z d0d*Zd0d+Zd0d,Zd0d-Zd.Zd/Zycc}w)1z6 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:eZdZdZdZeezZdezdz ZdZdZ dZ y) eui64_basez%A standard IEEE EUI-64 dialect class.rr-z%.2XN) __name__ __module__ __qualname____doc__ word_sizewidth num_wordsmax_wordword_sepword_fmt word_base8/usr/lib/python3/dist-packages/netaddr/strategy/eui64.pyrr+s;/I"II~!HHHIr!rc*eZdZdZdZeezZdZdZdZ y) eui64_unixz'A UNIX-style MAC address dialect class.r:z%xrN rrrrrrrrrrr r!r"r$r$@s#1I"IHHIr!r$ceZdZdZdZy)eui64_unix_expandedz;A UNIX-style MAC address dialect class with leading zeroes.%.2xN)rrrrrr r!r"r(r(Is EHr!r(c*eZdZdZdZeezZdZdZdZ y) eui64_ciscoz2A Cisco 'triple hextet' MAC address dialect class.r.%.4xNr&r r!r"r+r+Ns#<I"IHHIr!r+c*eZdZdZdZeezZdZdZdZ y) eui64_barez1A bare (no delimiters) MAC address dialect class.r z%.16XrNr&r r!r"r/r/Ws#;I"IHHIr!r/^r%z([0-9A-F]{1,2})r$rz([0-9A-F]{1,4})z\.z^(r0z[0-9A-F]rz)$cF|D]}|j|}|s|dcSy)Nr)findall)addressformatsregexpmatchs r"_get_match_resultr:xs+w' 8Or!cH t|try y#t$rYywxYw)z :param addr: An IEEE EUI-64 indentifier in string form. :return: ``True`` if EUI-64 indentifier is valid, ``False`` otherwise. TF)r:RE_EUI64_FORMATS TypeError)addrs r" valid_strr?s6  T#3 4 5     s  !!c :g} t|t}|st t |t rn|f}t |dk(r8tdj|Dcgc]}dt|dzc}d}|St |dk(r8tdj|Dcgc]}dt|dzc}d}|St |d k(rtd t|d dzd}|Std |z#t$rtd|dwxYwcc}wcc}w) 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: !rr0r)rr3r-rz%016xrz)bad word count for EUI-64 identifier: %r!) r:r<r=r isinstancetuplelenintjoin)r>wordswint_vals r" str_to_intrJs0 EO!$(89O %  5zQbggEBqvAr 2BCRH N UqbggEBqvAr 2BCRH N UqgE!Hb 1126 N 7$ >@ @% OtMNNOCCsC7D D 7Dc|t}t||}|Dcgc]}|j|z}}|jj |}|Scc}w)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. )rrrrrF)rIdialectrGitokensr>s r" int_to_strrOsX ' *E,1 2qg" 2F 2     (D K3sAcDt|}tjdg|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_structpack)rIrGs r" int_to_packedrTs"  !E << & &&r!cttjd|}d}tt |D]\}}|}|d|zz}||z}|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)listrRunpack enumeratereversed) packed_intrGrIrMnumwords r" packed_to_intr]s\ z2 3EGHUO,!3q1u}D.! Nr!cT|t}t||j|jSN)DEFAULT_EUI64_DIALECT _valid_wordsrrrGrLs r"rrs'' w00'2C2C DDr!cT|t}t||j|jSr_)r` _int_to_wordsrrrIrLs r"rrs'' '"3"3W5F5F GGr!cT|t}t||j|jSr_)r` _words_to_intrrrbs r"rrs''  1 173D3D EEr!cH|t}t|t|jSr_)r` _valid_bitsrrbitsrLs r"rrs!' tUG$4$4 55r!cH|t}t|t|jSr_)r` _bits_to_intrrrjs r"rrs!' eW%5%5 66r!cj|t}t||j|j|jSr_)r` _int_to_bitsrrrres r"r r s6' ""G$5$5w7G7G IIr!c2|t}t|tSr_)r` _valid_binr)bin_valrLs r"r r s' gu %%r!c"t|tSr_) _int_to_binr)rIs r"r r  w &&r!c"t|tSr_) _bin_to_intr)rrs r"r r rur!r_)1rstructrRre_re netaddr.corernetaddr.strategyrrarrdrrgrrirrmr ror rqr rtr rwAF_EUI64rfamily family_nameversionmax_intobjectrr$r(r+r/r`rFr<compile IGNORECASEr:r?rJrOrTr])_s0r"rs (      u*q. ** *# #((%&* ++c1#((%&* ++c1#((%&* ++c1#((%&* ++c1%**'(1, --3 277J<"$ %%, =MMqKCKK3>>2M "J  '&E H F 6 7 I& ''wNs$E1