HEX
Server: LiteSpeed
System: Linux premium71.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User: consovgw (933)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //proc/self/root/usr/lib/python3.6/site-packages/netaddr/eui/__pycache__/__init__.cpython-36.pyc
3

��]�a�@s�dZddlmZmZmZddlmZmZ	ddl
mZddlm
Z
ddlmZddlmZmZGdd	�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)�_is_int�_is_strc@sDeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�BaseIdentifierz$Base class for all IEEE identifiers.�_valuecCs
d|_dS)N)r
)�self�r�/usr/lib/python3.6/__init__.py�__init__szBaseIdentifier.__init__cCs|jS)z):return: integer value of this identifier)r
)rrrr�__int__szBaseIdentifier.__int__cCs|jS)z):return: integer value of this identifier)r
)rrrr�__long__szBaseIdentifier.__long__cCs|jdkrdSd|jS)z8:return: octal string representation of this identifier.r�0z0%o)r
)rrrr�__oct__"s
zBaseIdentifier.__oct__cCs
d|jS)z>:return: hexadecimal string representation of this identifier.z0x%x)r
)rrrr�__hex__)szBaseIdentifier.__hex__cCs|jS)zx
        :return: return the integer value of this identifier when passed to
            hex(), oct() or bin().
        )r
)rrrr�	__index__.szBaseIdentifier.__index__N)r
)�__name__�
__module__�__qualname__�__doc__�	__slots__rrrrrrrrrrrsrcsreZdZdZdZ�fdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
edd��Zddd�Z
dd�Zdd�Z�ZS)�OUIz�
    An individual IEEE OUI (Organisationally Unique Identifier).

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

    �recordscs�tt|�j�ddlm}g|_t|t�r@t|j	dd�d�|_
nBt|�rvd|koZdknrh||_
q�td|��nt
d|��|j
|jkr�t|jd	�}x@|j|j
D]0\}}|j|�|j|�jd
�}|j|||�q�W|j�ntd|��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�-��i���z"OUI int outside expected range: %rzunexpected OUI format: %r�rbzUTF-8zOUI %r not registered!N)�superrr�netaddr.euirr�
isinstance�str�int�replacer
r
�
ValueError�	TypeErrorZ	OUI_INDEX�openZOUI_REGISTRY_PATH�seek�read�decode�_parse_data�closer)r�ouir�fh�offset�size�data)�	__class__rrr@s$


zOUI.__init__cCs:t|t�s.y|j|�}Wntk
r,tSX|j|jkS)N)r&rr7�	Exception�NotImplementedr
)r�otherrrr�__eq__gs
z
OUI.__eq__cCs:t|t�s.y|j|�}Wntk
r,tSX|j|jkS)N)r&rr7r8r9r
)rr:rrr�__ne__os
z
OUI.__ne__cCs|j|jfS)z+:returns: Pickled state of an `OUI` object.)r
r)rrrr�__getstate__wszOUI.__getstate__cCs|\|_|_dS)z;:param state: data used to unpickle a pickled `OUI` object.N)r
r)r�staterrr�__setstate__{szOUI.__setstate__cCs�dddg||d�}xn|jd�D]`}|j�}|s0qd|krd|j|d<|jdd�d|d	<t|�|d
<qd|krpqq|dj|�qW|jj|�dS)
z.Returns a dict record from raw OUI record datarr!)�idxr2�org�addressr4r5�
z(hex)r@N�rAr2z	(base 16)rB)�split�stripr
r'�appendr)rr6r4r5�record�linerrrr0s$
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 OUIz%02X-%02X-%02Xr"��)r
)r�int_valrrr�__str__�s


zOUI.__str__cCsd|S)z@:return: executable Python string to recreate equivalent object.z	OUI('%s')r)rrrr�__repr__�szOUI.__repr__)r)r)rrrrrrr;r<r=r?r0�propertyrKrMrQrR�
__classcell__rr)r7rr7s'
rcsteZdZdZdZeddd��Zd�fdd�	Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Z�ZS)�IABz�
    An individual IEEE IAB (Individual Address Block) identifier.

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

    rHFcCs�d|kodknr |dfSd}d
|A}|d?}||B|}d|koRdknrv|r�|dkr�tdt|���ntd	t|���||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)
        i i�/rrD���0z%r is not a strict IAB!z%r is not an IAB address!ii�ll���)r*�hex)Zeui_int�strictZ	user_maskZiab_maskZiab_bitsZ	user_bitsrrr�
split_iab_mac�s	zIAB.split_iab_maccstt|�j�ddlm}dddgddd�|_t|t�rdt|j	dd�d�}|j
||d�\}}||_n.t|�r�|j
||d�\}}||_nt
d|��|j|jk�rt|jd	�}|j|jd\}}	||jd
<|	|jd<|j|�|j|	�jd�}
|j|
||	�|j�ntd
|��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)
        r)rr!)r@�iabrArBr4r5r r")rZzunexpected IAB format: %r!r#r4r5zUTF-8zIAB %r not unregistered!N)r$rUrr%rrHr&r'r(r)r[r
r
r+Z	IAB_INDEXr,ZIAB_REGISTRY_PATHr-r.r/r0r1r)rr\rZrrPZiab_intZuser_intr3r4r5r6)r7rrr�s4





zIAB.__init__cCs:t|t�s.y|j|�}Wntk
r,tSX|j|jkS)N)r&rUr7r8r9r
)rr:rrrr;s
z
IAB.__eq__cCs:t|t�s.y|j|�}Wntk
r,tSX|j|jkS)N)r&rUr7r8r9r
)rr:rrrr<s
z
IAB.__ne__cCs|j|jfS)z+:returns: Pickled state of an `IAB` object.)r
rH)rrrrr=szIAB.__getstate__cCs|\|_|_dS)z;:param state: data used to unpickle a pickled `IAB` object.N)r
rH)rr>rrrr?"szIAB.__setstate__cCs|xv|jd�D]h}|j�}|sqd|krX|j|jd<|jdd�d|jd<t|�|jd<qd|krdqq|jd	j|�qWdS)
z.Returns a dict record from raw IAB record datarCz(hex)r@NrDrAr\z	(base 16)rB)rErFr
rHr'rG)rr6r4r5rIrrrr0&szIAB._parse_datacCs
t|j�S)z*The IEEE registration details for this IAB)rrH)rrrrrM6szIAB.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� rN�r"rO)r
)rrPrrrrQ:s




zIAB.__str__cCsd|S)z@:return: executable Python string to recreate equivalent object.z	IAB('%s')r)rrrrrREszIAB.__repr__)rH)F)F)rrrrr�staticmethodr[rr;r<r=r?r0rMrQrRrTrr)r7rrU�s4rUcs\eZdZdZdGZdH�fdd�	Zdd�Zd	d
�Zdd�Zd
d�Z	e
ee	dd�Zdd�Zdd�Z
e
ee
dd�Ze
dd��Ze
dd��Zdd�Ze
dd��Ze
dd��Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�ZdId1d2�Ze
d3d4��Ze
d5d6��Ze
d7d8��Z d9d:�Z!d;d<�Z"d=d>�Z#d?d@�Z$e
dAdB��Z%dCdD�Z&dEdF�Z'�Z(S)J�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|�j�d|_t|t�rV|dk	r:||jjkr:td��|j|_|j|_|j|_dS|dk	r�|dkrnt	|_q�|dkr~t
|_q�td|��nFt|�r�d|ko�dknr�t	|_nd|ko�dknr�t
|_||_||_dS)	a2
        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) the mac_* dialect to be used to configure             the formatting of EUI-48 (MAC) addresses.
        Nz2cannot switch EUI versions using copy constructor!rX�@zunsupported EUI version %rrl���l����)
r$rarrbr&�versionr*r
�dialect�_eui48�_eui64r
�value)rZaddrrerf)r7rrrVs,
zEUI.__init__cCs|j|jj|jfS)z+:returns: Pickled state of an `EUI` object.)r
rbrerf)rrrrr=�szEUI.__getstate__cCsJ|\}}}||_|dkr t|_n |dkr0t|_ntdt|���||_dS)zN
        :param state: data used to unpickle a pickled `EUI` object.

        rXrdz&unpickling failed for object state: %sN)r
rgrbrhr*r'rf)rr>rirerfrrrr?�s
zEUI.__setstate__cCs|jS)N)r
)rrrr�
_get_value�szEUI._get_valuecCs2|jdkr�x�ttfD]|}y|j|�|_||_PWqtk
r�y4dt|�koZ|jknrrt|�|_||_PWntk
r�YnXYqXqW|jdkr�td|��n�t	|�r�y|jj|�|_Wn(tk
r�td||jj
f��YnXn<dt|�k�o|jjkn�r"t|�|_ntd|��dS)Nrz failed to detect EUI version: %rzaddress %r is not an EUIv%dzbad address format: %r)rbrgrhZ
str_to_intr
rr(Zmax_intr*rre)rri�modulerrr�
_set_value�s4



$zEUI._set_valuezBa positive integer representing the value of this EUI indentifier.cCs|jS)N)rc)rrrr�_get_dialect�szEUI._get_dialectcCsJ|dkr"|jtkrt|_qFt|_n$t|d�r>t|d�r>||_ntd��dS)N�	word_sizeZword_fmtz*custom dialects should subclass mac_eui48!)rbrhrrcr�hasattrr+)rrirrr�_set_dialect�s
zEUI._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.r_�(N)rbrgrrirh)rrrrr2�s

zEUI.ouicCs@|jtkrdt|dd��S|jtkr<dt|dd��SdS)z*The EI (Extension Identifier) for this EUIz%02X-%02X-%02X��z%02X-%02X-%02X-%02X-%02XrON)rbrg�tuplerh)rrrr�ei�s

zEUI.eicCsd|jd?kodkSS)z<:return: True if this EUI is an IAB address, False otherwisei rVi�/)r
)rrrr�is_iab�sz
EUI.is_iabcCs|j�rt|jd?�SdS)zr
        If is_iab() is True, the IAB (Individual Address Block) is returned,
        ``None`` otherwise.
        rVN)rvrUr
)rrrrr\�szEUI.iabcCs|jjS)z/The EUI version represented by this EUI object.)rbre)rrrrre�szEUI.versioncs�t|�rL|jj}||ko(|dkns6td��|jj|j|j�|St|t�r�|jj|j|j���fdd�t	|j
t����D�Std|��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.
        rWz!index out range for address type!csg|]}�|�qSrr)�.0�i)�wordsrr�
<listcomp>sz#EUI.__getitem__.<locals>.<listcomp>zunsupported type %r!N)
r
rc�	num_words�
IndexErrorrb�int_to_wordsr
r&�slice�range�indicesrJr+)rr@r{r)ryr�__getitem__�s
 zEUI.__getitem__cCs�t|t�rtd��t|�s"td��d|ko<|jjdknsNtd|��t|�s^td��d|kot|jjkns�td||jj	f��t
|jj|j
|j��}|||<|jj|�|_
dS)	z=Set the value of the word referenced by index in this addressz"settable slices are not supported!zindex not an integer!rrWz'index %d outside address type boundary!zvalue not an integer!z.value %d outside word size maximum of %d bits!N)r&r~�NotImplementedErrorr
r+rcr{r|Zmax_wordrn�listrbr}r
Zwords_to_int)rr@riryrrr�__setitem__s
 zEUI.__setitem__cCst|j|jf�S)zA:return: hash of this EUI object suitable for dict keys, sets etc)�hashrer
)rrrr�__hash__&szEUI.__hash__cCsFt|t�s.y|j|�}Wntk
r,tSX|j|jf|j|jfkS)zy
        :return: ``True`` if this EUI object is numerically the same as other,             ``False`` otherwise.
        )r&rar7r8r9rer
)rr:rrrr;*s
z
EUI.__eq__cCsFt|t�s.y|j|�}Wntk
r,tSX|j|jf|j|jfkS)zy
        :return: ``True`` if this EUI object is numerically the same as other,             ``False`` otherwise.
        )r&rar7r8r9rer
)rr:rrrr<6s
z
EUI.__ne__cCsFt|t�s.y|j|�}Wntk
r,tSX|j|jf|j|jfkS)z�
        :return: ``True`` if this EUI object is numerically lower in value than             other, ``False`` otherwise.
        )r&rar7r8r9rer
)rr:rrr�__lt__Bs
z
EUI.__lt__cCsFt|t�s.y|j|�}Wntk
r,tSX|j|jf|j|jfkS)z�
        :return: ``True`` if this EUI object is numerically lower or equal in             value to other, ``False`` otherwise.
        )r&rar7r8r9rer
)rr:rrr�__le__Ns
z
EUI.__le__cCsFt|t�s.y|j|�}Wntk
r,tSX|j|jf|j|jfkS)z�
        :return: ``True`` if this EUI object is numerically greater in value             than other, ``False`` otherwise.
        )r&rar7r8r9rer
)rr:rrr�__gt__Zs
z
EUI.__gt__cCsFt|t�s.y|j|�}Wntk
r,tSX|j|jf|j|jfkS)z�
        :return: ``True`` if this EUI object is numerically greater or equal             in value to other, ``False`` otherwise.
        )r&rar7r8r9rer
)rr:rrr�__ge__fs
z
EUI.__ge__cCs|jj|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.
        )rbZint_to_bitsr
)rZword_seprrr�bitsrszEUI.bitscCs|jj|j�S)z8The value of this EUI address as a packed binary string.)rbZ
int_to_packedr
)rrrr�packed{sz
EUI.packedcCs|jj|j�S)z<A list of unsigned integer octets found in this EUI address.)rbr}r
)rrrrry�sz	EUI.wordscCs|jj|j�S)z�
        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.
        )rbZ
int_to_binr
)rrrr�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.
        rXr_i���rql|�rd)re)rer
r7)rZfirst_threeZ
last_threeZ	new_valuerrrr�s	


z	EUI.eui64cCs|j�}|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|j��}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.
        rs)re)r(r�r	)r�prefixrPrrr�ipv6�s
zEUI.ipv6cCs
|jd�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|jj�i}|j�r$|jj�|d<t|�S)z�
        A record dict containing IEEE registration details for this EUI
        (MAC-48) if available, None otherwise.
        rrU)r2rMrvr\r)rr6rrr�info�szEUI.infocCs|jj|j|j�S)z':return: EUI in representational format)rbZ
int_to_strr
rc)rrrrrQ�szEUI.__str__cCsd|S)z@:return: executable Python string to recreate equivalent object.z	EUI('%s')r)rrrrrR�szEUI.__repr__)rbrc)NN)N))rrrrrrr=r?rjrlrSrirmrprfr2rurvr\rer�r�r�r;r<r�r�r�r�r�r�ryr�rr�r�r�r�rQrRrTrr)r7rraJsL	2"	
		

raN)rZnetaddr.corerrrZnetaddr.strategyrrgrrhZnetaddr.strategy.eui48rZnetaddr.strategy.eui64rZ
netaddr.ipr	Znetaddr.compatr
r�objectrrrUrarrrr�<module>	s$