%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/netaddr/eui/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/netaddr/eui/__pycache__/ieee.cpython-312.pyc

�

���^W$����dZddlmZddlZddlmZmZddl	m
Z
mZiZiZ
Gd�de
�ZGd�de�ZGd	�d
e�Zd�Zd�Zd
�Zd�Zedk(re�ye�y)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�_importlib_resources)�
Subscriber�	Publisherc��eZdZdZd�Zd�Zy)�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.
    c��t|d�rt|d�r||_nt|d�|_tj|jd��|_y)z�
        Constructor.

        :param index_file: a file-like object or name of index file where
            index records will be written.
        �readline�tell�w�
)�lineterminatorN)�hasattr�fh�open�_csv�writer)�self�
index_files  �2/usr/lib/python3/dist-packages/netaddr/eui/ieee.py�__init__zFileIndexer.__init__6sB���:�z�*�w�z�6�/J� �D�G��:�s�+�D�G��k�k�$�'�'�$�?���c�:�|jj|�y)z�
        Receives and writes index data to a CSV data file.

        :param data: record containing offset record information.
        N)r�writerow)r�datas  r�updatezFileIndexer.updateDs��	
�����T�"rN)�__name__�
__module__�__qualname__�__doc__rr�rrrr1s���@�#rrc�(��eZdZdZ�fd�Zd�Z�xZS)�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
    c���tt|��t|d�rt|d�r||_yt|d�|_y)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.
        r
r�rbN)�superr#rrrr�r�	ieee_file�	__class__s  �rrzOUIIndexParser.__init__b�:���	�n�d�,�.��9�j�)�g�i��.H��D�G��9�d�+�D�Grc� �d}d}d}td�}td�}td�}	|jj�}|sn�|r||vrd}|r�)||vr�|�"|j|�|j	|�t|�}|jj
�t|�z
}|j�d}	t|	j||�d�}
|
|g}n|t|�z
}��|j|�|j	|�y)	z�
        Starts the parsing process which detects records and notifies
        registered subscribers as it finds each OUI record.
        TNr�(hex)�-�F�)
rrr
�append�notify�lenr�split�int�replace)r�skip_header�record�size�marker�hyphen�empty_string�line�offset�oui�indexs           r�parsezOUIIndexParser.parseqs��
�������W�%���S�!��"�2�����7�7�#�#�%�D����v��~�#������~��%��M�M�$�'��K�K��'��4�y���'�'�,�,�.�3�t�9�4���j�j�l�1�o���C�K�K���=�r�B��������D�	�!��7�<	�
�
�d�����F�r�rrrr rr@�
__classcell__�r)s@rr#r#Ms����(
,�,rr#c�(��eZdZdZ�fd�Zd�Z�xZS)�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
    c���tt|��t|d�rt|d�r||_yt|d�|_y)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.
        r
rr%N)r&rErrrrr's  �rrzIABIndexParser.__init__�r*rc���d}d}d}td�}td�}td�}td�}	|jj�}|sn�|r||vrd}|r�)||vro|�"|j|�|j	|�|jj�t
|�z
}	|j�d}
|
}||	g}t
|�}nr||vr`|t
|�z
}|dj||�}|j�d}
|
j|�d}
t||
zd	�d
z	|d<n|t
|�z
}��|j|�|j	|�y)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/�)
rrr
r0r1rr2r3r5r4)rr6r7r8�
hex_marker�
base16_markerr:r;r<r=�
iab_prefixr?�prefix�suffixs              rr@zIABIndexParser.parse�sf��
������ ��)�
�#�K�0�
��S�!��"�2�����7�7�#�#�%�D����z�T�1�#�����T�!��%��M�M�$�'��K�K��'��'�'�,�,�.�3�t�9�4��!�Z�Z�\�!�_�
�"�������4�y���$�&���D�	�!�����*�*�6�<�@������a������f�-�a�0�� ��&��"�5�"�<��q�	���D�	�!��C�H	�
�
�d�����F�rrArCs@rrErE�s����(
,�3rrEc�h�||�}|jt|��|j�y)z4Generate an index files from the IEEE registry file.N)�attachrr@)�registry_fh�
index_path�parser�
oui_parsers    r�create_index_from_registryrT�s+����$�J����k�*�-�.����rc��ttjtjt�d�tjtjt�d�t
�ttjtjt�d�tjtjt�d�t�y)z1Create indices for OUI and IAB file based lookupszoui.txt�oui.idxziab.txt�iab.idxN)rT�_path�join�dirname�__file__r#rEr!rr�create_indicesr\sv���
�
�
�5�=�=��*�I�6�
�
�
�5�=�=��*�I�6���
�
�
�
�5�=�=��*�I�6�
�
�
�5�=�=��*�I�6��rc�^�	tj|D�cgc]}|jd���c}�D]G}|D�cgc]
}t|���c}\}}}|j	|g�||j||f��I	|j
�ycc}wcc}w#|j
�wxYw)z/Load index from file into index data structure.zUTF-8N)r�reader�decoder4�
setdefaultr0�close)r?�fp�x�row�_�keyr=r8s        r�
load_indexrgs�����;�;�2�>�a����� 1�>�?�	.�C�36�"7�a�3�q�6�"7��S�&�$����S�"�%��#�J���v�t�n�-�	.�
	���
�� ?��"7��	���
�s&�B�B�B�B�
1B�
B�B,c��tttjtd��tt
tjtd��y)z+Load OUI and IAB lookup indices into memoryrVrWN)rg�	OUI_INDEXr�open_binary�__package__�	IAB_INDEXr!rr�load_indicesrms2���y�.�:�:�;�	�R�S��y�.�:�:�;�	�R�Sr�__main__)r �os.path�pathrX�csvr�netaddr.compatrr�netaddr.corerrrirlrr#rErTr\rgrmrr!rr�<module>rts|��4���<�.�
�	�
�	�#�*�#�8P�Y�P�fW�Y�W�t���T��z�����Nr

Zerion Mini Shell 1.0