HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/internet/test/__pycache__/_posixifaces.cpython-38.pyc
U


W[Q�@s�dZddlmZmZddlZddlZddlmZmZmZddl	m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZddlmZddlmZmZer�dd	�Ze
ed
��Zej�d�s�ejdkr�d
efdefgZn
defgZGdd�de�Z Gdd�de�Z!Gdd�de�Z"Gdd�de�Z#Gdd�de�Z$Gdd�de�Z%ee%�Z&de&fde
fdefdee"�fdee"�fd ee"�fd!efge%_'ej(Z(ee&�ge(_)ee(_*ej+Z+e&ge+_)d"d#�Z,d$d%�Z-d&d'�Z.dS)(z>
POSIX implementation of local network interface enumeration.
�)�division�absolute_importN)�AF_INET�AF_INET6�	inet_ntop)�CDLL�POINTER�	Structure�c_char_p�c_ushort�c_int�c_uint32�c_uint8�c_void_p�c_ubyte�pointer�cast)�find_library)�_PY3�nativeStringcCs
t|g�S)zs
        Python 3 implementation of Python 2 chr(), i.e. convert an integer to
        corresponding byte.
        )�bytes)�i�r�D/usr/lib/python3/dist-packages/twisted/internet/test/_posixifaces.py�chrsr�c�freebsd�darwinZsin_len�
sin_familyc@seZdZdedfgZdS)�in_addr�N��__name__�
__module__�__qualname__r�_fields_rrrrr-s
�rc@seZdZdedfgZdS)�in6_addrr�Nr!rrrrr&4s
�r&c@seZdZedefgZdS)�sockaddr�sin_portN)r"r#r$�_sockaddrCommonrr%rrrrr(;s�r(c@s eZdZedefdefgZdS)�sockaddr_inr)�sin_addrN)r"r#r$r*rrr%rrrrr+Bs�r+c@s&eZdZedefdefdefgZdS)�sockaddr_in6r)Zsin_flowinfor,N)r"r#r$r*rr
r&r%rrrrr-Js
�r-c@seZdZdS)�ifaddrsN)r"r#r$rrrrr.Ssr.�ifa_next�ifa_nameZ	ifa_flags�ifa_addrZifa_netmaskZifa_dstaddrZifa_datacCs<tj�d�r8|dd�dkr8|dd�d|dd�S|S)a�
    On FreeBSD, kill the embedded interface indices in link-local scoped
    addresses.

    @param family: The address family of the packed address - one of the
        I{socket.AF_*} constants.

    @param packed: The packed representation of the address (ie, the bytes of a
        I{in_addr} field).
    @type packed: L{bytes}

    @return: The packed address with any FreeBSD-specific extra bits cleared.
    @rtype: L{bytes}

    @see: U{https://twistedmatrix.com/trac/ticket/6843}
    @see: U{http://www.freebsd.org/doc/en/books/developers-handbook/ipv6.html#ipv6-scope-index}

    @note: Indications are that the need for this will be gone in FreeBSD >=10.
    rN�s��sr )�sys�platform�
startswith)�family�packedrrr�_maybeCleanupScopeIndexisr8cCs�t�}tt|��dkrt��g}z�|r�|djr�|djdj}|tkr^t|djt	t
��}n"|tkr|t|djt	t��}nd}|r�d�
tt|djjdd���}t||�}|�|dj|t||�f�|dj}q"W5t|�X|S)z�
    Call C{getifaddrs(3)} and return a list of tuples of interface name, address
    family, and human-readable address representing its results.
    rN�)�	ifaddrs_p�
getifaddrsr�OSError�freeifaddrsr1rrrrr+rr-�join�maprr,rr8�appendr0rr/)r.Zresultsr6Zaddrr7rrr�_interfaces�s0
 
�
rAcCsPg}t�D]@\}}}t|�}t|�}|tjkr
|�d�r
|�d||f�q
|S)z�
    Return a list of strings in colon-hex format representing all the link local
    IPv6 addresses available on the system, as reported by I{getifaddrs(3)}.
    zfe80:z%s%%%s)rAr�socketrr5r@)ZretListZ	interfacer6Zaddressrrr�posixGetLinkLocalIPv6Addresses�srC)/�__doc__Z
__future__rrr3rBrrrZctypesrrr	r
rrr
rrrrrZctypes.utilrZtwisted.python.compatrrrZlibcr4r5r*rr&r(r+r-r.r:r%r;ZargtypesZrestyper=r8rArCrrrr�<module>sL8��	


�	#