HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/pyroute2/ext/__pycache__/rawsocket.cpython-37.pyc
B

��f
�@s�ddlZddlmZmZmZmZmZmZmZm	Z	ddl
mZmZm
Z
mZmZmZm
Z
ddlmZdZdZdZddddggZGd	d
�d
e�ZGdd�de�Zd
d�ZGdd�de
�ZdS)�N)�	Structure�	addressof�c_ubyte�c_uint�c_ushort�c_void_p�sizeof�	string_at)�	AF_PACKET�SOCK_RAW�
SOL_SOCKET�errno�error�htons�socket)�IPRoute����c@s(eZdZdefdefdefdefgZdS)�sock_filter�codeZjtZjf�kN)�__name__�
__module__�__qualname__rrr�_fields_�rr�G/opt/alt/python37/lib/python3.7/site-packages/pyroute2/ext/rawsocket.pyrsrc@seZdZdefdefgZdS)�
sock_fprog�len�filterN)rrrrrrrrrrr!srcCsJtt|�}|dd�|D��}tt|�t|d��}tt|�t|��|fS)NcSsg|]}t|��qSr)r)�.0�linerrr�
<listcomp>'szcompile_bpf.<locals>.<listcomp>r)rr rrr	r)rZProgramType�programZsfprrr�compile_bpf%sr&c@s0eZdZdZdZd
dd�Zddd�Zdd	�ZdS)�	RawSocketa�
    This raw socket binds to an interface and optionally installs a BPF
    filter.
    When created, the socket's buffer is cleared to remove packets that
    arrived before bind() or the BPF filter is installed.  Doing so
    requires calling recvfrom() which may raise an exception if the
    interface is down.
    In order to allow creating the socket when the interface is
    down, the ENETDOWN exception is caught and discarded.
    Nc	Cs�||_t��2}x*|��D]}|�d�|krPqWtdd��WdQRX|�d�|_|d|_t�|t	t
tt��t�
||jtf�|r�|��t|�\}|_t�|tt|�n|jdd�dS)NZIFLA_IFNAME�zLink not foundZIFLA_ADDRESS�indexT)�remove_total_filter)�ifnamerZ	get_linksZget_attr�IOErrorZl2addrZifindexr�__init__r
rr�	ETH_P_ALL�bind�clear_bufferr&�fprog�
setsockoptr�SO_ATTACH_FILTER)�selfr+Zbpf�ip�linkZfstringrrrr-:s
zRawSocket.__init__Fc
Cs�tt�\}}t�|tt|�|�d�xdy|�d�Wq(tk
r�}z2|j	dt
jkrZn|j	dt
jt
j
gkrtPn�Wdd}~XYq(Xq(W|�d�|r�t�|tt|�dS)Nr�)r&�total_filterrr2rr3�setblocking�recvfromr�argsr
ZENETDOWN�EAGAIN�EWOULDBLOCK�SO_DETACH_FILTER)r4r*Z
total_fstring�prog�errrr0Os 

zRawSocket.clear_buffercs\t��dr�d7�t�fdd�tt��d�D��}|d?|d@}||d?7}|d@S)Nr(�c	s0g|](}t�d�|d|dd��d�qS)z>Hr(r)�struct�unpack)r"�x)�datarrr$rsz"RawSocket.csum.<locals>.<listcomp>�i��)r �sum�range)r4rE�csumr)rErrIms
zRawSocket.csum)N)F)rrr�__doc__r1r-r0rIrrrrr',s



r')rB�ctypesrrrrrrrr	rr
rrr
rrZpyroute2.iproute.linuxrr.r3r>r8rrr&r'rrrr�<module>s(
$