Netlink client for asyncio
Project description
aiortnetlink
Pure-python asyncio rtnetlink client.
Getting started
Install from PyPI:
pip install aiortnetlink
Or, adding to your uv project:
uv add aiortnetlink
Example:
from aiortnetlink import NetlinkClient
async with NetlinkClient() as nl:
async for link in nl.get_links():
print(f"{link.index}: {link.name}")
The module ships with a CLI, for example if running from the repository root:
uv run aiortnetlink addr show
Supported features
Links
get_links: List all links.get_link: Lookup link by index or name.
Addresses
get_links: List all addresses.add_addr: Add IP address to link.del_addr: Remove IP address from link.
Routes
get_routes: List all routes.get_route: Get route for the given address.
Rules
get_rules: List all rules.
Notifications
recv_notification: Receive netlink notification. Notification subscription is done by passing the revelant rtnetlink groups to the netlink client.
Tun/Tap
create_tuntap: Create tun or tap device.delete_tuntap: Delete tun or tap device.
Network namespaces
All network operations can be performed in a network namesapce by passing the netns_name argument to the NetlinkClient.
Development
This project uses uv for project management and poe the poet to run development tasks. Linting and code formatting is done using ruff, type checking using mypy and tests using pytest.
For example to run all checks locally:
uvx --from poethepoet poe lint
To format code using ruff:
uvx --from poethepoet poe fmt
Constants generator
Linux user API constants are exposed to C programs as symbols. In order to extract their values for use in a pure-Python module without violating the license we need to write a C program that will import the appropriate linux uapi headers and print their values.
To facilitate development of this library we generate a C program and use its output to generate python source code representing the various constants. The constants are grouped into types using IntEnum.
This is handled by the constants generator. The files in the constants directory and generated in this way and should not be edited manually.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiortnetlink-0.2.3.tar.gz.
File metadata
- Download URL: aiortnetlink-0.2.3.tar.gz
- Upload date:
- Size: 47.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19fcad6516d30134aa2fd4ae0cdf462ffe5f977877297c8d114c221cae4cc387
|
|
| MD5 |
40a9b3724eab032ecc97a22dc8f8418a
|
|
| BLAKE2b-256 |
a6e65af960004082c453640184f74346e6ccf5733d7787697c5431617c4432ed
|
File details
Details for the file aiortnetlink-0.2.3-py3-none-any.whl.
File metadata
- Download URL: aiortnetlink-0.2.3-py3-none-any.whl
- Upload date:
- Size: 39.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58b84940fff637f022f5cc8013e112e56133557ebcfd95a9e3283fb159808c76
|
|
| MD5 |
452cf2c2bbada043777779b66092cc21
|
|
| BLAKE2b-256 |
d333c1947a6db4d7888bf1934eeb39a3ee9af2611f8a5b58026ef6a5d6a3cf3a
|