File: //opt/alt/python311/lib/python3.11/site-packages/pyroute2/iproute/__pycache__/bsd.cpython-311.pyc
�
�;f%) � � � d Z ddlZddlZddlZddlZddlZddlmZ ddlm Z ddl
mZ ddlm
Z
mZmZ ddlmZmZ ddlmZmZmZmZ dd lmZ dd
lmZmZmZmZmZm Z m!Z!m"Z" ddl#m$Z$ ddl%m&Z&m'Z' dd
l(m)Z) ddl*m+Z+ ddl,m-Z- ddl.Z.n# e/$ r ddl0Z.Y nw xY w G d� de1� � Z2 G d� de2� � Z3 G d� d� � Z4dS )a�
The library provides very basic RTNL API for BSD systems
via protocol emulation. Only getters are supported yet, no
setters.
BSD employs PF_ROUTE sockets to send notifications about
network object changes, but the protocol doesn not allow
changing links/addresses/etc like Netlink.
To change network setting one have to rely on system calls
or external tools. Thus IPRoute on BSD systems is not as
effective as on Linux, where all the changes are done via
Netlink.
The monitoring started with `bind()` is implemented as an
implicit thread, started by the `bind()` call. This is done
to have only one notification FD, used both for normal calls
and notifications. This allows to use IPRoute objects in
poll/select calls.
On Linux systems RTNL API is provided by the netlink protocol,
so no implicit threads are started by default to monitor the
system updates. `IPRoute.bind(...)` may start the async cache
thread, but only when asked explicitly::
#
# Normal monitoring. Always starts monitoring thread on
# FreeBSD / OpenBSD, no threads on Linux.
#
with IPRoute() as ipr:
ipr.bind()
...
#
# Monitoring with async cache. Always starts cache thread
# on Linux, ignored on FreeBSD / OpenBSD.
#
with IPRoute() as ipr:
ipr.bind(async_cache=True)
...
On all the supported platforms, be it Linux or BSD, the
`IPRoute.recv(...)` method returns valid netlink RTNL raw binary
payload and `IPRoute.get(...)` returns parsed RTNL messages.
� N)�config)�
IFF_VALUES)� RTMSocket)�ARP�Ifconfig�Route)�AddrPool� Namespace)�
NLM_F_DUMP�NLM_F_MULTI�
NLM_F_REQUEST�
NLMSG_DONE)�NetlinkProxy)�RTM_GETADDR�RTM_GETLINK�RTM_GETNEIGH�RTM_GETROUTE�RTM_NEWADDR�RTM_NEWLINK�RTM_NEWNEIGH�RTM_NEWROUTE)� ifaddrmsg)� IFF_NAMES�ifinfmsg)�MarshalRtnl)�ndmsg)�rtmsgc � � e Zd Zd� Zd� Zd� Zd� Zej fd�Z d� Z
d� Zd� Zd � Z
dd�Zd� Zd
� Zdd�Zd� Zd� Zd� Zd� Zd
S )�IPRoutec �\ � d|v rd|� d� � g| _ ng | _ |� d� � }t | j ddgz �� � | _ t | j ddgz �� � | _ t | j dd gz �� � | _ t � � | _
|� d
� � pd| _ t | t dd
� � dd�� � }t d|�� � | _ d | _ d | _ d | _ t'