����JFIF��`�`�����Viewing File: /lib/python3.9/site-packages/netaddr/eui/__pycache__/__init__.cpython-39.pyc
a

��g�d�@s�dZddlmZmZmZddlmZmZ	ddl
mZddlm
Z
ddlmZddlmZmZmZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�de�ZdS)z]
Classes and functions for dealing with MAC addresses, EUI-48, EUI-64, OUI, IAB
identifiers.
�)�NotRegisteredError�AddrFormatError�
DictDotLookup)�eui48�eui64)�	mac_eui48)�
eui64_base)�	IPAddress)�_open_binary�_is_int�_is_strc@sDeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�BaseIdentifierz$Base class for all IEEE identifiers.)�_value�__weakref__cCs
d|_dS�N�r��self�r�8/usr/lib/python3.9/site-packages/netaddr/eui/__init__.py�__init__szBaseIdentifier.__init__cCs|jS�z):return: integer value of this identifierrrrrr�__int__szBaseIdentifier.__int__cCs|jSrrrrrr�__long__szBaseIdentifier.__long__cCs|jdkrdSd|jS)z8:return: octal string representation of this identifier.r�0z0%orrrrr�__oct__"s
zBaseIdentifier.__oct__cCs
d|jS)z>:return: hexadecimal string representation of this identifier.z0x%xrrrrr�__hex__)szBaseIdentifier.__hex__cCs|jS)zx
        :return: return the integer value of this identifier when passed to
            hex(), oct() or bin().
        rrrrr�	__index__.szBaseIdentifier.__index__N)�__name__�
__module__�__qualname__�__doc__�	__slots__rrrrrrrrrrr
sr
cszeZdZdZdZ�fdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zedd��Z
ddd�Zdd�Zdd�Z�ZS)�OUIz�
    An individual IEEE OUI (Organisationally Unique Identifier).

    For online details see - http://standards.ieee.org/regauth/oui/

    )�recordscs�tt|���ddlm}g|_t|t�r@t|�	dd�d�|_
nFt|�rxd|kr\dkrhnn||_
q�td|f��nt
d|f��|j
|jvr�ttd	�}|j|j
D]0\}}|�|�|�|��d
�}|�|||�q�|��ntd|f��dS)
z�
        Constructor

        :param oui: an OUI string ``XX-XX-XX`` or an unsigned integer.             Also accepts and parses full MAC/EUI-48 address strings (but not             MAC/EUI-48 integers)!
        r��ieee�-����z"OUI int outside expected range: %rzunexpected OUI format: %rzoui.txt�UTF-8zOUI %r not registered!N)�superr#r�netaddr.euir&r$�
isinstance�str�int�replacerr�
ValueError�	TypeErrorZ	OUI_INDEXr
�__package__�seek�read�decode�_parse_data�closer)r�ouir&�fh�offset�size�data��	__class__rrr@s$



zOUI.__init__cCs
t|j�Sr)�hashrrrrr�__hash__gszOUI.__hash__cCs<t|t�s0z|�|�}Wnty.tYS0|j|jkSr�r.r#r@�	Exception�NotImplementedr�r�otherrrr�__eq__js

z
OUI.__eq__cCs<t|t�s0z|�|�}Wnty.tYS0|j|jkSrrCrFrrr�__ne__rs

z
OUI.__ne__cCs|j|jfS)z+:returns: Pickled state of an `OUI` object.�rr$rrrr�__getstate__zszOUI.__getstate__cCs|\|_|_dS)z;:param state: data used to unpickle a pickled `OUI` object.NrJ�r�staterrr�__setstate__~szOUI.__setstate__cCs�dddg||d�}|�d�D]`}|��}|s.qd|vrb|j|d<|�dd�d|d	<t|�|d
<qd|vrnqq|d�|�q|j�|�dS)
z.Returns a dict record from raw OUI record datarr()�idxr:�org�addressr<r=�
�(hex)rON�rPr:�	(base 16)rQ)�split�striprr/�appendr$)rr>r<r=�record�linerrrr8�s&�	
zOUI._parse_datacCs
t|j�S)z0Number of registered organisations with this OUI)�lenr$rrrr�	reg_count�sz
OUI.reg_countrcCst|j|�S)a
        The IEEE registration details for this OUI.

        :param index: the index of record (may contain multiple registrations)
            (Default: 0 - first registration)

        :return: Objectified Python data structure containing registration
            details.
        )rr$)r�indexrrr�registration�s
zOUI.registrationcCs(|j}d|d?d@|d?d@|d@fS)z*:return: string representation of this OUI�%02X-%02X-%02Xr)��r�r�int_valrrr�__str__�s

�zOUI.__str__cCsd|S)�@:return: executable Python string to recreate equivalent object.z	OUI('%s')rrrrr�__repr__�szOUI.__repr__)r)rrr r!r"rrBrHrIrKrNr8�propertyr\r^rdrf�
__classcell__rrr?rr#7s'

r#csteZdZdZdZeddd��Zd�fdd�	Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Z�ZS)�IAB)i�PiU�@)rYFcCsz|d?|jvr|dfSd}d|A}|d?}||B|}|d?|jvrb|rr|dkrrtdt|���ntdt|���||fS)z�
        :param eui_int: a MAC IAB as an unsigned integer.

        :param strict: If True, raises a ValueError if the last 12 bits of
            IAB MAC/EUI-48 address are non-zero, ignores them otherwise.
            (Default: False)
        �ri�����z%r is not a strict IAB!z%r is not an IAB address!)�IAB_EUI_VALUESr2�hex)�clsZeui_int�strictZ	user_maskZiab_maskZiab_bitsZ	user_bitsrrr�
split_iab_mac�s	zIAB.split_iab_maccstt|���ddlm}dddgddd�|_t|t�rdt|�	dd�d�}|j
||d�\}}||_n0t|�r�|j
||d�\}}||_nt
d|f��|j|jv�rttd	�}|j|jd\}}	||jd
<|	|jd<|�|�|�|	��d�}
|�|
||	�|��ntd
|f��dS)a�
        Constructor

        :param iab: an IAB string ``00-50-C2-XX-X0-00`` or an unsigned             integer. This address looks like an EUI-48 but it should not             have any non-zero bits in the last 3 bytes.

        :param strict: If True, raises a ValueError if the last 12 bits             of IAB MAC/EUI-48 address are non-zero, ignores them otherwise.             (Default: False)
        rr%r()rO�iabrPrQr<r=r'r))rozunexpected IAB format: %r!ziab.txtr<r=r+zIAB %r not unregistered!N)r,rirr-r&rYr.r/r0r1rprrr3Z	IAB_INDEXr
r4r5r6r7r8r9r)rrqror&rcZiab_intZuser_intr;r<r=r>r?rrr�s6�	





zIAB.__init__cCs<t|t�s0z|�|�}Wnty.tYS0|j|jkSr�r.rir@rDrErrFrrrrHs

z
IAB.__eq__cCs<t|t�s0z|�|�}Wnty.tYS0|j|jkSrrrrFrrrrIs

z
IAB.__ne__cCs|j|jfS)z+:returns: Pickled state of an `IAB` object.�rrYrrrrrK#szIAB.__getstate__cCs|\|_|_dS)z;:param state: data used to unpickle a pickled `IAB` object.NrsrLrrrrN'szIAB.__setstate__cCsx|�d�D]h}|��}|sq
d|vrV|j|jd<|�dd�d|jd<t|�|jd<q
d|vrbq
q
|jd	�|�q
dS)
z.Returns a dict record from raw IAB record datarRrSrONrTrPrqrUrQ)rVrWrrYr/rX)rr>r<r=rZrrrr8+szIAB._parse_datacCs
t|j�S)z*The IEEE registration details for this IAB)rrYrrrrr^;szIAB.registrationcCs@|jd>}d|d?d@|d?d@|d?d@|d?d@|d@fS)z*:return: string representation of this IAB�z%02X-%02X-%02X-%02X-%02X-00� r`�r)rarrbrrrrd?s




�zIAB.__str__cCsd|S)rez	IAB('%s')rrrrrrfJszIAB.__repr__)F)F)rrr rlr"�classmethodrprrHrIrKrNr8r^rdrfrhrrr?rri�s4ricsneZdZdZdZdJ�fdd�	Zdd�Zdd	�Zd
d�Zdd
�Z	e
ee	dd�Zdd�Zdd�Z
dd�Ze
eedd�Ze
dd��Ze
dd��Zdd�Ze
dd��Ze
dd��Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�ZdKd2d3�Ze
d4d5��Ze
d6d7��Z e
d8d9��Z!d:d;�Z"d<d=�Z#d>d?�Z$d@dA�Z%e
dBdC��Z&dLdDdE�Z'dFdG�Z(dHdI�Z)�Z*S)M�EUIz�
    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.

    )�_module�_dialectNcs�tt|���d|_t|t�rV|dur:||jjkr:td��|j|_|j|_|j|_dS|dur�|dkrnt	|_q�|dkr~t
|_q�td|��nFt|�r�d|kr�dkr�nnt	|_nd|kr�dkr�nnt
|_||_||_dS)	aJ
        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 explicit EUI address version, either             48 or 64. Mainly used to distinguish EUI-48 and EUI-64 identifiers             specified as integers which may be numerically equivalent.

        :param dialect: (optional) one of the :ref:`mac_formatting_dialects` to
            be used to configure the formatting of EUI-48 (MAC) addresses.
        Nz2cannot switch EUI versions using copy constructor!�0�@zunsupported EUI version %rrrkl����)
r,rxrryr.�versionr2r�dialect�_eui48�_eui64r�value)r�addrr}r~r?rrr[s,
zEUI.__init__cCs|j|jj|jfS)z+:returns: Pickled state of an `EUI` object.)rryr}r~rrrrrK�szEUI.__getstate__cCsH|\}}}||_|dkr t|_n|dkr0t|_ntd|f��||_dS)zN
        :param state: data used to unpickle a pickled `EUI` object.

        r{r|z&unpickling failed for object state: %sN)rrryr�r2r~)rrMr�r}r~rrrrN�s
�zEUI.__setstate__cCs|jSrrrrrr�
_get_value�szEUI._get_valuecCs6|jdur�ttfD]�}z|�|�|_||_Wq�Wqty�z:dt|�kr\|jkrxnnt|�|_||_WYq�Wnty�Yn0Yq0q|jdur�td|f��n�t	|�r�z|j�|�|_Wn&ty�td||jj
f��Yn0n>dt|�k�r|jjk�r$nnt|�|_ntd|f��dS)Nrz failed to detect EUI version: %rzaddress %r is not an EUIv%dzbad address format: %r)ryrr�Z
str_to_intrrr0Zmax_intr2rr})rr��modulerrr�
_set_value�s8



�
�$zEUI._set_valuezAa positive integer representing the value of this EUI identifier.cCs|jSr)rzrrrr�_get_dialect�szEUI._get_dialectcCs@|dur|jturtStSn t|d�r4t|d�r4|Std��dS)N�	word_sizeZword_fmtz*custom dialects should subclass mac_eui48!)ryr�rr�hasattrr3�rr�rrr�_validate_dialect�s
zEUI._validate_dialectcCs|�|�|_dSr)r�rzr�rrr�_set_dialect�szEUI._set_dialectzXa Python class providing support for the interpretation of various MAC
 address formats.cCs4|jtkrt|jd?�S|jtkr0t|jd?�SdS)z:The OUI (Organisationally Unique Identifier) for this EUI.rv�(N)ryrr#r�r�rrrrr:�s

zEUI.ouicCs@|jtkrdt|dd��S|jtkr<dt|dd��SdS)z*The EI (Extension Identifier) for this EUIr_��z%02X-%02X-%02X-%02X-%02XraN)ryr�tupler�rrrr�ei�s

zEUI.eicCs|jd?tjvS)z<:return: True if this EUI is an IAB address, False otherwiserv)rrirlrrrr�is_iab�sz
EUI.is_iabcCs|��rt|jd?�SdS)zr
        If is_iab() is True, the IAB (Individual Address Block) is returned,
        ``None`` otherwise.
        rjN)r�rirrrrrrq�szEUI.iabcCs|jjS)z/The EUI version represented by this EUI object.)ryr}rrrrr}�szEUI.versioncs�t|�rJ|jj}||kr*|dks4ntd��|j�|j|j�|St|t�r�|j�|j|j���fdd�t	|�
t����D�Std|f��dS)z�
        :return: The integer value of the word referenced by index (both             positive and negative). Raises ``IndexError`` if index is out             of bounds. Also supports Python list slices for accessing             word groups.
        �z!index out range for address type!csg|]}�|�qSrr)�.0�i��wordsrr�
<listcomp>�z#EUI.__getitem__.<locals>.<listcomp>zunsupported type %r!N)
rrz�	num_words�
IndexErrorry�int_to_wordsrr.�slice�range�indicesr[r3)rrOr�rr�r�__getitem__s
 zEUI.__getitem__cCs�t|t�rtd��t|�s"td��d|kr>|jjdksNntd|f��t|�s^td��d|krv|jjks�ntd||jj	f��t
|j�|j
|j��}|||<|j�|�|_
dS)	z=Set the value of the word referenced by index in this addressz"settable slices are not supported!zindex not an integer!rr�z'index %d outside address type boundary!zvalue not an integer!z.value %d outside word size maximum of %d bits!N)r.r��NotImplementedErrorrr3rzr�r�Zmax_wordr��listryr�rZwords_to_int)rrOr�r�rrr�__setitem__s

�zEUI.__setitem__cCst|j|jf�S)zA:return: hash of this EUI object suitable for dict keys, sets etc)rAr}rrrrrrB.szEUI.__hash__cCsHt|t�s0z|�|�}Wnty.tYS0|j|jf|j|jfkS�zy
        :return: ``True`` if this EUI object is numerically the same as other,             ``False`` otherwise.
        �r.rxr@rDrEr}rrFrrrrH2s

z
EUI.__eq__cCsHt|t�s0z|�|�}Wnty.tYS0|j|jf|j|jfkSr�r�rFrrrrI>s

z
EUI.__ne__cCsHt|t�s0z|�|�}Wnty.tYS0|j|jf|j|jfkS)z�
        :return: ``True`` if this EUI object is numerically lower in value than             other, ``False`` otherwise.
        r�rFrrr�__lt__Js

z
EUI.__lt__cCsHt|t�s0z|�|�}Wnty.tYS0|j|jf|j|jfkS)z�
        :return: ``True`` if this EUI object is numerically lower or equal in             value to other, ``False`` otherwise.
        r�rFrrr�__le__Vs

z
EUI.__le__cCsHt|t�s0z|�|�}Wnty.tYS0|j|jf|j|jfkS)z�
        :return: ``True`` if this EUI object is numerically greater in value             than other, ``False`` otherwise.
        r�rFrrr�__gt__bs

z
EUI.__gt__cCsHt|t�s0z|�|�}Wnty.tYS0|j|jf|j|jfkS)z�
        :return: ``True`` if this EUI object is numerically greater or equal             in value to other, ``False`` otherwise.
        r�rFrrr�__ge__ns

z
EUI.__ge__cCs|j�|j|�S)z�
        :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.
        )ryZint_to_bitsr)rZword_seprrr�bitszszEUI.bitscCs|j�|j�S)z8The value of this EUI address as a packed binary string.)ryZ
int_to_packedrrrrr�packed�sz
EUI.packedcCs|j�|j�S)z<A list of unsigned integer octets found in this EUI address.)ryr�rrrrrr��sz	EUI.wordscCs|j�|j�S)z�
        The value of this EUI address 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.
        )ryZ
int_to_binrrrrr�bin�szEUI.bincCsD|jdkr0|jd?}|jd@}|d>dB|B}n|j}|j|dd�S)a2
        - If this object represents an EUI-48 it is converted to EUI-64             as per the standard.
        - If this object is already an EUI-64, a new, numerically             equivalent object is returned instead.

        :return: The value of this EUI object as a new 64-bit EUI object.
        r{rvr*r�l|�r|�r})r}rr@)rZfirst_threeZ
last_threeZ	new_valuerrrr�s	


z	EUI.eui64cCs|��}|jdN_|S)z�
        - create a new EUI object with a modified EUI-64 as described in RFC 4291 section 2.5.1

        :return: a new and modified 64-bit EUI object.
        l)rr)rrrrr�modified_eui64�szEUI.modified_eui64cCs t|�t|���}t|dd�S)a5
        .. note:: This poses security risks in certain scenarios.             Please read RFC 4941 for details. Reference: RFCs 4291 and 4941.

        :param prefix: ipv6 prefix

        :return: new IPv6 `IPAddress` object based on this `EUI`             using the technique described in RFC 4291.
        r�r�)r0r�r	)r�prefixrcrrr�ipv6�s
zEUI.ipv6cCs
|�d�S)a
        .. note:: This poses security risks in certain scenarios.             Please read RFC 4941 for details. Reference: RFCs 4291 and 4941.

        :return: new link local IPv6 `IPAddress` object based on this `EUI`             using the technique described in RFC 4291.
        l	@�)r�rrrr�ipv6_link_local�szEUI.ipv6_link_localcCs,d|j��i}|��r$|j��|d<t|�S)z�
        A record dict containing IEEE registration details for this EUI
        (MAC-48) if available, None otherwise.
        r#ri)r:r^r�rqr)rr>rrr�info�szEUI.infocCs|�|�}|j�|j|�S)a:
        Format the EUI into the representational format according to the given
        dialect

        :param dialect: one of the :ref:`mac_formatting_dialects` defining the
            formatting of EUI-48 (MAC) addresses.

        :return: EUI in representational format according to the given dialect
        )r�ry�
int_to_strr)rr~Zvalidated_dialectrrr�format�s

z
EUI.formatcCs|j�|j|j�S)z':return: EUI in representational format)ryr�rrzrrrrrd�szEUI.__str__cCsd|S)rez	EUI('%s')rrrrrrf�szEUI.__repr__)NN)N)N)+rrr r!r"rrKrNr�r�rgr�r�r�r�r~r:r�r�rqr}r�r�rBrHrIr�r�r�r�r�r�r�r�rr�r�r�r�r�rdrfrhrrr?rrxOsd	2"��




	







rxN)r!Znetaddr.corerrrZnetaddr.strategyrrrr�Znetaddr.strategy.eui48rZnetaddr.strategy.eui64rZ
netaddr.ipr	Znetaddr.compatr
rr�objectr
r#rirxrrrr�<module>s$
Back to Directory �������}�!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz�������������������������������������������������������������������������������� ������w�!1AQaq"2�B���� #3R�br� $4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz������������������������������������������������������������������������ ��?��_��+��?��(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(�����