Add basic structure for netlink route socket

This commit is contained in:
jiangjianfeng
2025-04-11 07:31:21 +00:00
committed by Tate, Hongliang Tian
parent 2c41055470
commit ac42e83387
18 changed files with 1001 additions and 44 deletions

View File

@ -0,0 +1,35 @@
// SPDX-License-Identifier: MPL-2.0
use super::bound::BoundNetlinkRoute;
use crate::{
events::IoEvents,
net::socket::netlink::{
table::NETLINK_SOCKET_TABLE, NetlinkSocketAddr, StandardNetlinkProtocol,
},
prelude::*,
};
pub(super) struct UnboundNetlinkRoute {
_private: (),
}
impl UnboundNetlinkRoute {
pub(super) const fn new() -> Self {
Self { _private: () }
}
pub(super) fn bind(
self,
addr: &NetlinkSocketAddr,
) -> core::result::Result<BoundNetlinkRoute, (Error, Self)> {
let bound_handle = NETLINK_SOCKET_TABLE
.bind(StandardNetlinkProtocol::ROUTE as _, addr)
.map_err(|err| (err, self))?;
Ok(BoundNetlinkRoute::new(bound_handle))
}
pub(super) fn check_io_events(&self) -> IoEvents {
IoEvents::OUT
}
}