%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/share/hplip/base/__pycache__/
Upload File :
Create Path :
Current File : //usr/share/hplip/base/__pycache__/mdns.cpython-312.pyc

�

=	f1(���ddlZddlZddlZddlZddlZddlZddlZddl�ddlm	Z	ddl
mZmZm
Z
mZdZdZdZdZd	Zd
ZdZd�Zd�Zd
�Zd�Zd�Zd�Zdd�Zd�Zdd�Zy)�N�)�*)�utils)�BytesIO�
to_bytes_utf8�to_bytes_latin�to_string_latin���!��c��||z||||zfS�N���offset�data�ls   �/usr/share/hplip/base/mdns.py�	read_utf8r1����!�8�T�&����*�*�*�c��||z||||zfSrrrs   r�	read_datar4rrc
��tj|�}||ztj|t||||z��fSr)�struct�calcsize�unpackr)rr�fmtrs    r�read_data_unpackr!7s:�������A��!�8�V�]�]�3��t�F�6�!�8�7L�(M�N�N�Nrc��d}|}d}|}	t|||dz�}|dz
}|dk(rn�|dz}|dk(r%t|||�\}}dj||dg�}nc|dk(rE|dkr|dz}|dzdzt|||dz�z}||k\rtj	d	|z�n|}ntj	d
|z�n��|dk\r|}||fS|}||fS)N����rr��.�?�z$Bad domain name (circular) at 0x%04xzBad domain name at 0x%04x)�ordr�join�log�error)	rr�result�off�next�firstr�t�utf8s	         r�	read_namer3;s��
�F�
�C�
�D��E�
���S��Q��� ���q�����6��
��H����9�!�#�t�Q�/�I�C���W�W�f�d�C�0�1�F�
�$�Y��a�x��Q�w����H��?�c�$�s�3�q�5�/�&:�:�C��e�|��	�	�@�3�F�G���E�
�I�I�1�C�7�8��7�:�q�y���
�6�>�����6�>�rc	���|jd�D]R}|jd�}|jtjdt|���|j|��Ty)Nr&zutf-8�!B)�split�encode�writer�pack�len)�packet�name�p�utf8_strings    r�
write_namer?gsO��
�Z�Z��_�"���h�h�w�'�����V�[�[��s�;�'7�8�9����[�!�"rc���d}d}d}g}t�}t�}	|jd�|j�t|||tz�}|dk(r|dk(r	|Sd}t|�|z
tkrd}|jt
jdd|||dd��|r_t|d�|jt
jdd��|jt
jdtt��d}	|||tzD�]�}
|jd�|j�|s6|	r4d	}	t|d�|jt
jdd��n%|jt
jd
d��|jt
jdtt��|jt
jdd
��|j�}|jt
jd
d��t||
�|jt
jd
d��|j�|z
dz
}|j|�|jt
jd
|��|jd�|j|j�����|j|j��|dz
}|rd}d	}���)NrrTi�!HHHHHHz_pdl-datastream._tcp.localr5�!HHFz!Hi�z!Ii����)r�seek�truncater:�MAX_ANSWERS_PER_PACKETr8rr9r?�	QTYPE_PTR�	QCLASS_IN�tell�read�append�getvalue)
�answers�index�
num_questions�first_packet�packetsr;�
answer_record�num_answers�flags�first_record�d�rdlength_pos�rdlengths
             r�create_outgoing_packetsrZns���
�E��M��L��G�
�Y�F��I�M�
����A�������'�%��.D�(D�E�F���!��
�� 2��x�N�u���w�<�%��#9�9��E�	���V�[�[��F�E�=�+�W]�_e�f�g���v�;�<��L�L����T�4�0�1�
�L�L����U�I�y�A�B�����u�%;�;�<� 	/�A����q�!��"�"�$� �L�$���=�*F�G��#�#�F�K�K��d�$;�<��#�#�F�K�K��f�$=�>�
������E�9�i� H�I�
������D�&� 9�:�(�-�-�/�L�
������D�&� 9�:�
�}�a�(�������D�&� 9�:�%�)�)�+�l�:�Q�>�H����|�,�������D�(� ;�<����q�!��L�L��+�+�-�.�A 	/�D	���v���(�)�
������M� �L�Crc��d}	tjtjtjtj�}tjtjtj�}|j	d�|j�d}|j
�|jd�tjd|�}	|jtjtjd�|jtjtjd�	|jtj"tj$|�|jtj"tj&tj(|�tj(d�z�|jtj"tj*d�|S#tj$r*tjd�|r|j
�YywxYw#t tjf$rY��wxYw#t,$r4}tjd|z�|r|j
�Yd}~yd}~wwxYw)N)z1.2.3.4�8r�Bz
Network errorrz0.0.0.0z-Unable to setup multicast socket for mDNS: %s)�socket�AF_INET�
SOCK_DGRAM�IPPROTO_UDP�connect�getsockname�close�setblockingrr9r,r+�
setsockopt�
SOL_SOCKET�SO_REUSEADDR�SO_REUSEPORT�AttributeError�SOL_IP�IP_MULTICAST_TTL�IP_MULTICAST_IF�	inet_aton�IP_MULTICAST_LOOP�	Exception)�ttl�s�x�intf�es     r�createSocketsWithsetOptionrv�s���
�A�
��M�M�&�.�.�&�*;�*;�V�=O�=O�P���M�M�&�.�.�&�*;�*;�<��	�	�	�/�"��}�}��q�!��	���	�	�
�
�a���k�k�#�s�#��
�	���V�&�&��(;�(;�Q�?�	���V�&�&��(;�(;�Q�?��	���V�]�]�F�$;�$;�S�A�	���V�]�]�F�$:�$:�F�<L�<L�T�<R�U[�Ue�Ue�fo�Up�<p�q�	���V�]�]�F�$<�$<�a�@�
�H��+�<�<���	�	�/�"��
�G�G�I��	��
�F�L�L�)�
��
�����	�	�A�A�E�F��
�G�G�I���	�s>�CG*�AH*�2B6I
�*:H'�&H'�*I�I�
	J�*J�Jc��t�ddddddddd�}tjdt|�z�tj	|d��d}t||d	�\}\}}}}}}	tjd
||||||	fz�t
|�D]I}
t�t||�\}}t||d�\}\}}
tjd|||
fz��Kd
}t
||z|	z�D�]Z}t�t||�\}}t||d
�\}}|dtk(r_t||d�\}}dj|D�cgc]}tt|����c}�}tjd|z�||d<��|dtk(rNt||�\}}tjd|z�||d<|j|jdd����|dt k(r�t|||d�\}}id}}|t|�krLt|||dz�}|dz
}||||z}	|j#d�\}}|||<||z
}|t|�kr�Ltjdt'|�z�	d|dz|d<	d|dz|d<d|vs���|d|d<���|dt*k(r:t||d�\}\}}}t||�\}}|jd d�|d!<���|dt,k(r3t||d�\}}tjd"t'|�z���=tj/d#|dz�||fS||fScc}w#t$$rY��wxYw#t($r%tjdt'|�z�Y��wxYw#t($r%tjdt'|�z�Y��-wxYw)$Nrr#r�0)�num_devices�	num_ports�
product_id�mac�status_code�device2�device3�notezIncoming: (%d)r��widthrAz3Response: ID=%d FLAGS=0x%x Q=%d A=%d AUTH=%d ADD=%drBzQ: %s TYPE=%d CLASS=%dz!HHiH�r&zA: %s�ipzPTR: %s�mdnsz._pdl-datastream._tcp.local.��=zTXT: %sz'MFG:Hewlett-Packard;MDL:%s;CLS:PRINTER;�ty�device1zNO ty Key in txt: %s�usb_MDLzNO usb_MDL Key in txt: %sr�z!HHHz.local.�hnzAAAA: %szUnknown DNS record type (%d).)�update_spinnerr+�debugr:�log_datar!�ranger3�QTYPE_Arr*�strr)rHrL�replace�	QTYPE_TXTr6�
ValueError�repr�KeyError�	QTYPE_SRV�
QTYPE_AAAAr,)rrN�yr�idrUrPrT�num_authorities�num_additionals�questionr<�typ�clsr �record�infor-rsr��txtr.r�key�value�priority�weight�port�servers                             r�updateReceivedDatar��s�������2�b��c�c�2�	G�A��I�I���T��*�+��L�L��R�L� �
�F����y�1�V�F�U�R��
�{�O�_��I�I�C�	�U�M�;���Q�R�S��-�(�?���� ���.����-�f�d�E�B���
��c��	�	�*�d�C��-=�=�>�	?��C���o�5��G�H�=���� ���.����'���g�>������7�g��&�v�t�Q�7�N�F�F�����7�1�3�s�1�v�;�7�8�B��I�I�g��l�#��A�d�G�
�!�W�	�
!�$�V�T�2�L�F�D��I�I�i�$�&�'��A�f�I��N�N�4�<�<�(F��K�L�
�!�W�	�
!�$�V�T�4��7�;�L�F�D��1��C���D�	�/���S��Q���(���q����c�#�a�%����!'���c�!2�J�C��$�C��H��q�����D�	�/�
�I�I�i�$�s�)�+�,�
>�H�3�t�9�T��)��
C�H�3�y�>�Y��)��
��}���K��&�	�
�!�W�	�
!�/?���f�/U�,�F�,�X�v�t�&�v�t�4�N�F�F��n�n�Y��3�A�d�G�
�!�W�
�
"�&�v�t�R�8�N�F�F��I�I�j�4��<�/�0�
�I�I�5��Q��?�@���g�:��}=�|
�g�:���o8��,"������
>��	�	�0�4��9�<�=�
>���
C��	�	�5��S�	�A�B�
C�s<�M
�1M�M&�N�	M#�"M#�&*N�N�*O�Oc�4�d\}}i}g}t|�}|siStj�}|}||z}	d}
	tj�}||	kDrn�||k\ri	t|�D]O}tj	dt|�z�tj
|d��|j|d||f��Q	||
z
}|
dz}
t�tj|gg|gd	�\}
}}|
s��|jd
�\}}t|�}|r#t||�\}}|||jd�<��tj	dt|�z�|j!�|S#tj$r"}tjd|z�Yd}~��d}~wwxYw)
N)z224.0.0.251i�rzOutgoing: (%d)rr�rz'Unable to send broadcast DNS packet: %srCg�?i@r�zFound %d devices)rv�timerZr+r�r:r��sendtor^r,r��select�recvfromr	r��getrd)rq�timeout�
mcast_addr�
mcast_port�
found_devicesrNrr�nowr/�last�delayr=ru�r�wr�addrr�s                  r�detectNetworkDevicesr�4s���/��J�
��M��G�"�3�'�A���	�
�)�)�+�C��D���=�D�
�E�
��i�i�k����:���$�;�
I�0��9�=�A��I�I�.��Q��7�8��L�L��"�L�-��H�H�Q��J�
�#;�<�=�
�E�M�D��Q�J�E����-�-���R�!��c�2���1�a����Z�Z��&�
��d��t�$���+�D�'�:�J�A�w�)*�M�!�%�%��+�&�=�@�I�I� �3�}�#5�5�6��G�G�I����+�<�<�
I��	�	�C�a�G�H�H��
I�s�AE"�"F�5F�F)r�)r��
)�sysr�r^r�r�random�re�gr#r�sixextrrrr	rGr�r�r�r�rHrIrrr!r3r?rZrvr�r�rrr�<module>r�s���2��
�
�
�
�	���K�K���
���	��	�
�
��	�
�	�+�+�O�)�X"�K�Z 
�DT�n0r

Zerion Mini Shell 1.0