HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/linux_ip.cpython-310.pyc
o

�N�g�@szdZddlZddlZddlZddlZdZdd�Zddd�Zdd	�Z	d
d�Z
ddd
�Zddd�Zdd�Z
dd�Zdd�ZdS)z4
The networking module for Non-RH/Deb Linux distros
�N�ipcCsftjj��rdStddkrdStddkrdStddkr dStdd	kr(d
Stjj�d�s1dStS)
z9
    Confine this module to Non-RH/Deb Linux distros
    )Fz3Module linux_ip: Windows systems are not supported.Z	os_familyZRedHat)Fz2Module linux_ip: RedHat systems are not supported.ZSuse)Fz0Module linux_ip: SUSE systems are not supported.ZDebian)Fz2Module linux_ip: Debian systems are not supported.Z	NILinuxRT)Fz5Module linux_ip: NILinuxRT systems are not supported.r)FzQThe linux_ip execution module cannot be loaded: the ip binary is not in the path.)�salt�utils�platformZ
is_windowsZ
__grains__�path�which�__virtualname__�r	r	�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/linux_ip.py�__virtual__
srcC� |dvrtdd|�d��SdS)zq
    Shutdown a network interface

    CLI Example:

    .. code-block:: bash

        salt '*' ip.down eth0
    �Zslave�cmd.run�ip link set z downN��__salt__��ifaceZ
iface_typer	r	r
�down$�rcCst�}|�|�S)z�
    Return the contents of an interface script

    CLI Example:

    .. code-block:: bash

        salt '*' ip.get_interface eth0
    )�
_ip_ifaces�get)rZifacesr	r	r
�
get_interface4s

rcCs�i}i}d}d}tdd�}|��D]�}|�d�sM|�d�}|d��}|d����}|�d��d	��d
��d�}t|�}	|t	t
t|	|	���d�||<q|���d
�rjt|�����}t	t
t||���||d<q|���d�r�|����}|d}t|�ddkr�|��}
|dd|
��7<t|�}t	t
t||���|||<q|����}t|�}|||�
t	t
t||����q|S)z"
    Parse output from 'ip a'
    Nrzip a� �:��r�<�>�,)�flags�options�linkZ
link_layerZinet���)r�
splitlines�
startswith�split�strip�pop�lstrip�rstrip�iter�dict�list�zip�len�update)�tmp�retZif_Zat_�out�line�compsZ
opts_compsr Z	opts_iter�lastZifir	r	r
rBs<

�"rcCr)zo
    Start up a network interface

    CLI Example:

    .. code-block:: bash

        salt '*' ip.up eth0
    r
rrz upNrrr	r	r
�upirr7cCst�}|dur|�|�S|S)z�
    Return the current routing table

    CLI Examples:

    .. code-block:: bash

        salt '*' ip.get_routes
        salt '*' ip.get_routes eth0
    N)�
_parse_routesr)rZroutesr	r	r
�
get_routesys
r9cCs<tjj�dd��}tjj�|���}Wd�n1swYi}|��D]t}i}|��s0q'|�	d�r6q'|�
�}|d|d<t|d�|d<t|d	�|d
<tt
|d��|d<|d
|d<|d|d<|d|d<t|d�|d<|d|d<|d|d<|d|d<|d|vr�g||d<||d�|�q'|S)z3
    Parse the contents of ``/proc/net/route``
    z/proc/net/route�rNZIfacerrrZdestinationrZgateway�r �Zrefcnt�Zuse�Zmetric��mask�Zmtu�	Zwindow�
Zirtt)rr�filesZfopenZstringutilsZ
to_unicode�readr$r'r%r&�_hex_to_octets�_route_flags�int�append)Zfp_r3r2r4r1r5r	r	r
r8�s4�
r8c	CsHd�t|dd�d�t|dd�d�t|dd�d�t|dd�d��S)z<
    Convert hex fields from /proc/net/route to octects
    z{}:{}:{}:{}r>rA�r<rr)�formatrH)�addrr	r	r
rF�s�rFc
Cs>d}dddddddd	d
d�	}|D]}||@r|||7}q|S)z�
    https://github.com/torvalds/linux/blob/master/include/uapi/linux/route.h
    https://github.com/torvalds/linux/blob/master/include/uapi/linux/ipv6_route.h
    ��U�G�H�R�D�M�A�C�!)	rrr<rArJ� iiir	)Zrflagsr Zfmap�itemr	r	r
rG�s ��rG)N)�__doc__Zsalt.utils.filesrZsalt.utils.pathZsalt.utils.platformZsalt.utils.stringutilsrrrrrr7r9r8rFrGr	r	r	r
�<module>s

'