HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //proc/thread-self/root/usr/lib/python3.9/site-packages/netaddr/eui/__pycache__/ieee.cpython-39.pyc
a

��g$�@s�dZddlmZddlZddlmZmZddl	m
Z
mZiZiZ
Gdd�de
�ZGdd�de�ZGd	d
�d
e�Zdd�Zd
d�Zdd�Zdd�Zedkr�e�ne�dS)z�
Provides access to public OUI and IAB registration data published by the IEEE.

More details can be found at the following URLs :-

    - IEEE Home Page - http://www.ieee.org/
    - Registration Authority Home Page - http://standards.ieee.org/regauth/
�N)�_bytes_type�_open_binary)�
Subscriber�	Publisherc@s eZdZdZdd�Zdd�ZdS)�FileIndexerz�
    A concrete Subscriber that receives OUI record offset information that is
    written to an index data file as a set of comma separated records.
    cCs>t|d�rt|d�r||_nt|d�|_tj|jdd�|_dS)z�
        Constructor.

        :param index_file: a file-like object or name of index file where
            index records will be written.
        �readline�tell�w�
)ZlineterminatorN)�hasattr�fh�open�_csv�writer)�selfZ
index_file�r�4/usr/lib/python3.9/site-packages/netaddr/eui/ieee.py�__init__5szFileIndexer.__init__cCs|j�|�dS)z�
        Receives and writes index data to a CSV data file.

        :param data: record containing offset record information.
        N)rZwriterow)r�datarrr�updateCszFileIndexer.updateN)�__name__�
__module__�__qualname__�__doc__rrrrrrr0srcs(eZdZdZ�fdd�Zdd�Z�ZS)�OUIIndexParsera�
    A concrete Publisher that parses OUI (Organisationally Unique Identifier)
    records from IEEE text-based registration files

    It notifies registered Subscribers as each record is encountered, passing
    on the record's position relative to the start of the file (offset) and
    the size of the record (in bytes).

    The file processed by this parser is available online from this URL :-

        - http://standards.ieee.org/regauth/oui/oui.txt

    This is a sample of the record structure expected::

        00-CA-FE   (hex)        ACME CORPORATION
        00CAFE     (base 16)        ACME CORPORATION
                        1 MAIN STREET
                        SPRINGFIELD
                        UNITED STATES
    cs:tt|���t|d�r*t|d�r*||_nt|d�|_dS)z�
        Constructor.

        :param ieee_file: a file-like object or name of file containing OUI
            records. When using a file-like object always open it in binary
            mode otherwise offsets will probably misbehave.
        rr�rbN)�superrrrrr
�rZ	ieee_file��	__class__rrraszOUIIndexParser.__init__cCs�d}d}d}td�}td�}td�}|j��}|s4q�|rD||vrDd}|rJq$||vr�|durn|�|�|�|�t|�}|j��t|�}|��d}	t|	�	||�d�}
|
|g}q$|t|�7}q$|�|�|�|�dS)	z�
        Starts the parsing process which detects records and notifies
        registered subscribers as it finds each OUI record.
        TNr�(hex)�-�F�)
rrr�append�notify�lenr�split�int�replace)r�skip_header�record�sizeZmarker�hyphen�empty_string�line�offsetZoui�indexrrr�parseps2




zOUIIndexParser.parse�rrrrrr2�
__classcell__rrrrrLsrcs(eZdZdZ�fdd�Zdd�Z�ZS)�IABIndexParsera�
    A concrete Publisher that parses IAB (Individual Address Block) records
    from IEEE text-based registration files

    It notifies registered Subscribers as each record is encountered, passing
    on the record's position relative to the start of the file (offset) and
    the size of the record (in bytes).

    The file processed by this parser is available online from this URL :-

        - http://standards.ieee.org/regauth/oui/iab.txt

    This is a sample of the record structure expected::

        00-50-C2   (hex)        ACME CORPORATION
        ABC000-ABCFFF     (base 16)        ACME CORPORATION
                        1 MAIN STREET
                        SPRINGFIELD
                        UNITED STATES
    cs:tt|���t|d�r*t|d�r*||_nt|d�|_dS)z�
        Constructor.

        :param ieee_file: a file-like object or name of file containing IAB
            records. When using a file-like object always open it in binary
            mode otherwise offsets will probably misbehave.
        rrrN)rr5rrrr
rrrrr�szIABIndexParser.__init__cCs*d}d}d}td�}td�}td�}td�}|j��}|s>�q|rN||vrNd}|rTq,||vr�|durx|�|�|�|�|j��t|�}	|��d}
|
}||	g}t|�}q,||v�r|t|�7}|d�||�}|��d}
|
�|�d}
t	||
d	�d
?|d<q,|t|�7}q,|�|�|�|�dS)z�
        Starts the parsing process which detects records and notifies
        registered subscribers as it finds each IAB record.
        TNrr z	(base 16)r!r"Fr#�)
rrrr$r%rr&r'r)r()rr*r+r,Z
hex_markerZ
base16_markerr-r.r/r0Z
iab_prefixr1�prefix�suffixrrrr2�s@





zIABIndexParser.parser3rrrrr5�sr5cCs"||�}|�t|��|��dS)z4Generate an index files from the IEEE registry file.N)Zattachrr2)Zregistry_fhZ
index_path�parserZ
oui_parserrrr�create_index_from_registry�sr:cCsTtt�t�t�d�t�t�t�d�t�tt�t�t�d�t�t�t�d�t�dS)z1Create indices for OUI and IAB file based lookupszoui.txt�oui.idxziab.txt�iab.idxN)r:�_path�join�dirname�__file__rr5rrrr�create_indicess��rAcCshzXt�dd�|D��D]6}dd�|D�\}}}|�|g�||�||f�qW|��n
|��0dS)z/Load index from file into index data structure.cSsg|]}|�d��qS)zUTF-8)�decode)�.0�xrrr�
<listcomp>�zload_index.<locals>.<listcomp>cSsg|]}t|��qSr)r()rC�_rrrrErFN)r�reader�
setdefaultr$�close)r1�fp�row�keyr0r,rrr�
load_indexsrNcCs$ttttd��ttttd��dS)z+Load OUI and IAB lookup indices into memoryr;r<N)rN�	OUI_INDEXr�__package__�	IAB_INDEXrrrr�load_indicessrR�__main__)rZos.path�pathr=ZcsvrZnetaddr.compatrrZnetaddr.corerrrOrQrrr5r:rArNrRrrrrr�<module>s 	SZ