mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-28 20:03:22 +00:00
Add basic structure for netlink route socket
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
2c41055470
commit
ac42e83387
35
kernel/src/net/socket/netlink/route/unbound.rs
Normal file
35
kernel/src/net/socket/netlink/route/unbound.rs
Normal 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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user