mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-23 09:23:25 +00:00
Clean up public re-exports under net/
This commit is contained in:
committed by
Jianfeng Jiang
parent
86a7aa09eb
commit
639bc91e31
@ -1,7 +1,7 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use super::sched::PollScheduler;
|
use super::sched::PollScheduler;
|
||||||
use crate::net::socket::ip::{datagram::DatagramObserver, stream::StreamObserver};
|
use crate::net::socket::ip::{DatagramObserver, StreamObserver};
|
||||||
|
|
||||||
pub struct BigtcpExt;
|
pub struct BigtcpExt;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use aster_bigtcp::wire::{IpAddress, IpEndpoint, Ipv4Address};
|
use aster_bigtcp::wire::{IpAddress, IpEndpoint, Ipv4Address};
|
||||||
|
|
||||||
use crate::{net::socket::SocketAddr, prelude::*, return_errno_with_message};
|
use crate::{net::socket::util::SocketAddr, prelude::*, return_errno_with_message};
|
||||||
|
|
||||||
impl TryFrom<SocketAddr> for IpEndpoint {
|
impl TryFrom<SocketAddr> for IpEndpoint {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
@ -9,7 +9,7 @@ use crate::{
|
|||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
net::{
|
net::{
|
||||||
iface::{Iface, UdpSocket},
|
iface::{Iface, UdpSocket},
|
||||||
socket::util::{datagram_common, send_recv_flags::SendRecvFlags},
|
socket::util::{datagram_common, SendRecvFlags},
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
util::{MultiRead, MultiWrite},
|
util::{MultiRead, MultiWrite},
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
use core::sync::atomic::{AtomicBool, Ordering};
|
use core::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
|
||||||
use aster_bigtcp::wire::IpEndpoint;
|
use aster_bigtcp::wire::IpEndpoint;
|
||||||
use unbound::BindOptions;
|
use bound::BoundDatagram;
|
||||||
|
use unbound::{BindOptions, UnboundDatagram};
|
||||||
|
|
||||||
use self::{bound::BoundDatagram, unbound::UnboundDatagram};
|
use super::addr::UNSPECIFIED_LOCAL_ENDPOINT;
|
||||||
use super::UNSPECIFIED_LOCAL_ENDPOINT;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
match_sock_option_mut,
|
match_sock_option_mut,
|
||||||
@ -16,9 +16,7 @@ use crate::{
|
|||||||
util::{
|
util::{
|
||||||
datagram_common::{select_remote_and_bind, Bound, Inner},
|
datagram_common::{select_remote_and_bind, Bound, Inner},
|
||||||
options::{SetSocketLevelOption, SocketOptionSet},
|
options::{SetSocketLevelOption, SocketOptionSet},
|
||||||
send_recv_flags::SendRecvFlags,
|
MessageHeader, SendRecvFlags, SocketAddr,
|
||||||
socket_addr::SocketAddr,
|
|
||||||
MessageHeader,
|
|
||||||
},
|
},
|
||||||
Socket,
|
Socket,
|
||||||
},
|
},
|
||||||
@ -28,11 +26,9 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
mod bound;
|
mod bound;
|
||||||
mod observer;
|
pub(super) mod observer;
|
||||||
mod unbound;
|
mod unbound;
|
||||||
|
|
||||||
pub(in crate::net) use self::observer::DatagramObserver;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct OptionSet {
|
struct OptionSet {
|
||||||
socket: SocketOptionSet,
|
socket: SocketOptionSet,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use aster_bigtcp::{socket::UdpSocket, wire::IpEndpoint};
|
use aster_bigtcp::{socket::UdpSocket, wire::IpEndpoint};
|
||||||
|
|
||||||
use super::{bound::BoundDatagram, DatagramObserver};
|
use super::{bound::BoundDatagram, observer::DatagramObserver};
|
||||||
use crate::{
|
use crate::{
|
||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
net::socket::{
|
net::socket::{
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
mod addr;
|
mod addr;
|
||||||
mod common;
|
mod common;
|
||||||
pub mod datagram;
|
mod datagram;
|
||||||
pub mod options;
|
pub mod options;
|
||||||
pub mod stream;
|
mod stream;
|
||||||
|
|
||||||
use addr::UNSPECIFIED_LOCAL_ENDPOINT;
|
pub(in crate::net) use datagram::observer::DatagramObserver;
|
||||||
|
pub use datagram::DatagramSocket;
|
||||||
|
pub(in crate::net) use stream::observer::StreamObserver;
|
||||||
|
pub use stream::{options as stream_options, StreamSocket};
|
||||||
|
@ -6,15 +6,12 @@ use aster_bigtcp::{
|
|||||||
wire::IpEndpoint,
|
wire::IpEndpoint,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::StreamObserver;
|
use super::observer::StreamObserver;
|
||||||
use crate::{
|
use crate::{
|
||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
net::{
|
net::{
|
||||||
iface::{Iface, RawTcpSocketExt, TcpConnection},
|
iface::{Iface, RawTcpSocketExt, TcpConnection},
|
||||||
socket::{
|
socket::util::{LingerOption, SendRecvFlags, SockShutdownCmd},
|
||||||
util::{send_recv_flags::SendRecvFlags, shutdown_cmd::SockShutdownCmd},
|
|
||||||
LingerOption,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{Pollee, Poller},
|
process::signal::{Pollee, Poller},
|
||||||
|
@ -6,7 +6,7 @@ use aster_bigtcp::{
|
|||||||
wire::IpEndpoint,
|
wire::IpEndpoint,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{connected::ConnectedStream, init::InitStream, StreamObserver};
|
use super::{connected::ConnectedStream, init::InitStream, observer::StreamObserver};
|
||||||
use crate::{
|
use crate::{
|
||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
net::iface::{BoundPort, Iface, TcpConnection},
|
net::iface::{BoundPort, Iface, TcpConnection},
|
||||||
|
@ -7,14 +7,14 @@ use core::{
|
|||||||
|
|
||||||
use aster_bigtcp::{socket::RawTcpOption, wire::IpEndpoint};
|
use aster_bigtcp::{socket::RawTcpOption, wire::IpEndpoint};
|
||||||
|
|
||||||
use super::{connecting::ConnectingStream, listen::ListenStream, StreamObserver};
|
use super::{connecting::ConnectingStream, listen::ListenStream, observer::StreamObserver};
|
||||||
use crate::{
|
use crate::{
|
||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
net::{
|
net::{
|
||||||
iface::BoundPort,
|
iface::BoundPort,
|
||||||
socket::{
|
socket::{
|
||||||
ip::common::{bind_port, get_ephemeral_endpoint},
|
ip::common::{bind_port, get_ephemeral_endpoint},
|
||||||
SocketAddr,
|
util::SocketAddr,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
|
@ -6,7 +6,7 @@ use aster_bigtcp::{
|
|||||||
wire::IpEndpoint,
|
wire::IpEndpoint,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{connected::ConnectedStream, StreamObserver};
|
use super::{connected::ConnectedStream, observer::StreamObserver};
|
||||||
use crate::{
|
use crate::{
|
||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
net::iface::{BoundPort, Iface, TcpListener},
|
net::iface::{BoundPort, Iface, TcpListener},
|
||||||
|
@ -10,6 +10,7 @@ use connected::{close_and_linger, ConnectedStream};
|
|||||||
use connecting::{ConnResult, ConnectingStream};
|
use connecting::{ConnResult, ConnectingStream};
|
||||||
use init::InitStream;
|
use init::InitStream;
|
||||||
use listen::ListenStream;
|
use listen::ListenStream;
|
||||||
|
use observer::StreamObserver;
|
||||||
use options::{
|
use options::{
|
||||||
Congestion, DeferAccept, Inq, KeepIdle, MaxSegment, NoDelay, SynCnt, UserTimeout, WindowClamp,
|
Congestion, DeferAccept, Inq, KeepIdle, MaxSegment, NoDelay, SynCnt, UserTimeout, WindowClamp,
|
||||||
KEEPALIVE_INTERVAL,
|
KEEPALIVE_INTERVAL,
|
||||||
@ -19,8 +20,8 @@ use takeable::Takeable;
|
|||||||
use util::{Retrans, TcpOptionSet};
|
use util::{Retrans, TcpOptionSet};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
addr::UNSPECIFIED_LOCAL_ENDPOINT,
|
||||||
options::{IpOptionSet, SetIpLevelOption},
|
options::{IpOptionSet, SetIpLevelOption},
|
||||||
UNSPECIFIED_LOCAL_ENDPOINT,
|
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
@ -33,10 +34,7 @@ use crate::{
|
|||||||
private::SocketPrivate,
|
private::SocketPrivate,
|
||||||
util::{
|
util::{
|
||||||
options::{SetSocketLevelOption, SocketOptionSet},
|
options::{SetSocketLevelOption, SocketOptionSet},
|
||||||
send_recv_flags::SendRecvFlags,
|
MessageHeader, SendRecvFlags, SockShutdownCmd, SocketAddr,
|
||||||
shutdown_cmd::SockShutdownCmd,
|
|
||||||
socket_addr::SocketAddr,
|
|
||||||
MessageHeader,
|
|
||||||
},
|
},
|
||||||
Socket,
|
Socket,
|
||||||
},
|
},
|
||||||
@ -50,13 +48,10 @@ mod connected;
|
|||||||
mod connecting;
|
mod connecting;
|
||||||
mod init;
|
mod init;
|
||||||
mod listen;
|
mod listen;
|
||||||
mod observer;
|
pub(super) mod observer;
|
||||||
pub mod options;
|
pub mod options;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
pub(in crate::net) use self::observer::StreamObserver;
|
|
||||||
pub use self::util::CongestionControl;
|
|
||||||
|
|
||||||
pub struct StreamSocket {
|
pub struct StreamSocket {
|
||||||
// Lock order: `state` first, `options` second
|
// Lock order: `state` first, `options` second
|
||||||
state: RwLock<Takeable<State>, PreemptDisabled>,
|
state: RwLock<Takeable<State>, PreemptDisabled>,
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use super::CongestionControl;
|
use crate::{impl_socket_options, prelude::*};
|
||||||
use crate::impl_socket_options;
|
|
||||||
|
|
||||||
impl_socket_options!(
|
impl_socket_options!(
|
||||||
pub struct NoDelay(bool);
|
pub struct NoDelay(bool);
|
||||||
@ -15,6 +14,34 @@ impl_socket_options!(
|
|||||||
pub struct Inq(bool);
|
pub struct Inq(bool);
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
pub enum CongestionControl {
|
||||||
|
Reno,
|
||||||
|
Cubic,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CongestionControl {
|
||||||
|
const RENO: &'static str = "reno";
|
||||||
|
const CUBIC: &'static str = "cubic";
|
||||||
|
|
||||||
|
pub fn new(name: &str) -> Result<Self> {
|
||||||
|
let congestion = match name {
|
||||||
|
Self::RENO => Self::Reno,
|
||||||
|
Self::CUBIC => Self::Cubic,
|
||||||
|
_ => return_errno_with_message!(Errno::ENOENT, "unsupported congestion name"),
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(congestion)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn name(&self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
Self::Reno => Self::RENO,
|
||||||
|
Self::Cubic => Self::CUBIC,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The keepalive interval.
|
/// The keepalive interval.
|
||||||
///
|
///
|
||||||
/// The linux value can be found at `/proc/sys/net/ipv4/tcp_keepalive_intvl`,
|
/// The linux value can be found at `/proc/sys/net/ipv4/tcp_keepalive_intvl`,
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use aster_bigtcp::time::Duration;
|
use aster_bigtcp::time::Duration;
|
||||||
|
|
||||||
|
use super::options::CongestionControl;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, CopyGetters, Setters)]
|
#[derive(Debug, Clone, Copy, CopyGetters, Setters)]
|
||||||
@ -102,31 +103,3 @@ impl Retrans {
|
|||||||
period
|
period
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
|
||||||
pub enum CongestionControl {
|
|
||||||
Reno,
|
|
||||||
Cubic,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CongestionControl {
|
|
||||||
const RENO: &'static str = "reno";
|
|
||||||
const CUBIC: &'static str = "cubic";
|
|
||||||
|
|
||||||
pub fn new(name: &str) -> Result<Self> {
|
|
||||||
let congestion = match name {
|
|
||||||
Self::RENO => Self::Reno,
|
|
||||||
Self::CUBIC => Self::Cubic,
|
|
||||||
_ => return_errno_with_message!(Errno::ENOENT, "unsupported congestion name"),
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(congestion)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn name(&self) -> &'static str {
|
|
||||||
match self {
|
|
||||||
Self::Reno => Self::RENO,
|
|
||||||
Self::Cubic => Self::CUBIC,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use self::options::SocketOption;
|
use options::SocketOption;
|
||||||
pub use self::util::{
|
use util::{MessageHeader, SendRecvFlags, SockShutdownCmd, SocketAddr};
|
||||||
options::LingerOption, send_recv_flags::SendRecvFlags, shutdown_cmd::SockShutdownCmd,
|
|
||||||
socket_addr::SocketAddr, MessageHeader,
|
|
||||||
};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
fs::{
|
fs::{
|
||||||
file_handle::FileLike,
|
file_handle::FileLike,
|
||||||
@ -18,7 +16,7 @@ pub mod ip;
|
|||||||
pub mod netlink;
|
pub mod netlink;
|
||||||
pub mod options;
|
pub mod options;
|
||||||
pub mod unix;
|
pub mod unix;
|
||||||
mod util;
|
pub mod util;
|
||||||
pub mod vsock;
|
pub mod vsock;
|
||||||
|
|
||||||
mod private {
|
mod private {
|
||||||
|
@ -4,7 +4,7 @@ mod multicast;
|
|||||||
|
|
||||||
pub use multicast::{GroupIdSet, MAX_GROUPS};
|
pub use multicast::{GroupIdSet, MAX_GROUPS};
|
||||||
|
|
||||||
use crate::{net::socket::SocketAddr, prelude::*};
|
use crate::{net::socket::util::SocketAddr, prelude::*};
|
||||||
|
|
||||||
/// The socket address of a netlink socket.
|
/// The socket address of a netlink socket.
|
||||||
///
|
///
|
||||||
|
@ -13,8 +13,11 @@ use crate::{
|
|||||||
netlink::{table::SupportedNetlinkProtocol, AddMembership, DropMembership},
|
netlink::{table::SupportedNetlinkProtocol, AddMembership, DropMembership},
|
||||||
options::SocketOption,
|
options::SocketOption,
|
||||||
private::SocketPrivate,
|
private::SocketPrivate,
|
||||||
util::datagram_common::{select_remote_and_bind, Bound, Inner},
|
util::{
|
||||||
MessageHeader, SendRecvFlags, Socket, SocketAddr,
|
datagram_common::{select_remote_and_bind, Bound, Inner},
|
||||||
|
MessageHeader, SendRecvFlags, SocketAddr,
|
||||||
|
},
|
||||||
|
Socket,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{PollHandle, Pollable, Pollee},
|
process::signal::{PollHandle, Pollable, Pollee},
|
||||||
|
@ -7,8 +7,7 @@ use crate::{
|
|||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
net::socket::{
|
net::socket::{
|
||||||
netlink::{common::BoundNetlink, NetlinkSocketAddr},
|
netlink::{common::BoundNetlink, NetlinkSocketAddr},
|
||||||
util::datagram_common,
|
util::{datagram_common, SendRecvFlags},
|
||||||
SendRecvFlags,
|
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
util::{MultiRead, MultiWrite},
|
util::{MultiRead, MultiWrite},
|
||||||
|
@ -18,7 +18,8 @@ use crate::{
|
|||||||
table::{NetlinkUeventProtocol, SupportedNetlinkProtocol},
|
table::{NetlinkUeventProtocol, SupportedNetlinkProtocol},
|
||||||
GroupIdSet, NetlinkSocketAddr, NetlinkUeventSocket,
|
GroupIdSet, NetlinkSocketAddr, NetlinkUeventSocket,
|
||||||
},
|
},
|
||||||
SendRecvFlags, Socket, SocketAddr,
|
util::{SendRecvFlags, SocketAddr},
|
||||||
|
Socket,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
@ -10,8 +10,7 @@ use crate::{
|
|||||||
common::BoundNetlink, message::ProtocolSegment,
|
common::BoundNetlink, message::ProtocolSegment,
|
||||||
route::kernel::get_netlink_route_kernel, NetlinkSocketAddr,
|
route::kernel::get_netlink_route_kernel, NetlinkSocketAddr,
|
||||||
},
|
},
|
||||||
util::datagram_common,
|
util::{datagram_common, SendRecvFlags},
|
||||||
SendRecvFlags,
|
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
util::{MultiRead, MultiWrite},
|
util::{MultiRead, MultiWrite},
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
|
use super::util::LingerOption;
|
||||||
use crate::{impl_socket_options, prelude::*};
|
use crate::{impl_socket_options, prelude::*};
|
||||||
mod macros;
|
|
||||||
|
|
||||||
use super::LingerOption;
|
mod macros;
|
||||||
|
|
||||||
/// Socket options. This trait represents all options that can be set or got for a socket, including
|
/// Socket options. This trait represents all options that can be set or got for a socket, including
|
||||||
/// socket level options and options for specific socket type like tcp socket.
|
/// socket level options and options for specific socket type like tcp socket.
|
||||||
|
@ -5,7 +5,7 @@ use keyable_arc::KeyableArc;
|
|||||||
use super::ns::{self, AbstractHandle};
|
use super::ns::{self, AbstractHandle};
|
||||||
use crate::{
|
use crate::{
|
||||||
fs::{path::Dentry, utils::Inode},
|
fs::{path::Dentry, utils::Inode},
|
||||||
net::socket::util::socket_addr::SocketAddr,
|
net::socket::util::SocketAddr,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ use crate::{
|
|||||||
fs::utils::{Channel, Consumer, Producer},
|
fs::utils::{Channel, Consumer, Producer},
|
||||||
net::socket::{
|
net::socket::{
|
||||||
unix::{addr::UnixSocketAddrBound, UnixSocketAddr},
|
unix::{addr::UnixSocketAddrBound, UnixSocketAddr},
|
||||||
SockShutdownCmd,
|
util::SockShutdownCmd,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{PollHandle, Pollee},
|
process::signal::{PollHandle, Pollee},
|
||||||
|
@ -10,7 +10,7 @@ use crate::{
|
|||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
net::socket::{
|
net::socket::{
|
||||||
unix::addr::{UnixSocketAddr, UnixSocketAddrBound},
|
unix::addr::{UnixSocketAddr, UnixSocketAddrBound},
|
||||||
SockShutdownCmd,
|
util::SockShutdownCmd,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{PollHandle, Pollee},
|
process::signal::{PollHandle, Pollee},
|
||||||
|
@ -14,7 +14,7 @@ use crate::{
|
|||||||
fs::file_handle::FileLike,
|
fs::file_handle::FileLike,
|
||||||
net::socket::{
|
net::socket::{
|
||||||
unix::addr::{UnixSocketAddrBound, UnixSocketAddrKey},
|
unix::addr::{UnixSocketAddrBound, UnixSocketAddrKey},
|
||||||
SockShutdownCmd, SocketAddr,
|
util::{SockShutdownCmd, SocketAddr},
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{PollHandle, Pollee},
|
process::signal::{PollHandle, Pollee},
|
||||||
|
@ -15,8 +15,8 @@ use crate::{
|
|||||||
net::socket::{
|
net::socket::{
|
||||||
private::SocketPrivate,
|
private::SocketPrivate,
|
||||||
unix::UnixSocketAddr,
|
unix::UnixSocketAddr,
|
||||||
util::{send_recv_flags::SendRecvFlags, socket_addr::SocketAddr, MessageHeader},
|
util::{MessageHeader, SendRecvFlags, SockShutdownCmd, SocketAddr},
|
||||||
SockShutdownCmd, Socket,
|
Socket,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{PollHandle, Pollable},
|
process::signal::{PollHandle, Pollable},
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use ostd::sync::RwMutex;
|
use ostd::sync::RwMutex;
|
||||||
|
|
||||||
use super::send_recv_flags::SendRecvFlags;
|
use super::SendRecvFlags;
|
||||||
use crate::{
|
use crate::{
|
||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
process::signal::Pollee,
|
process::signal::Pollee,
|
||||||
|
23
kernel/src/net/socket/util/linger_option.rs
Normal file
23
kernel/src/net/socket/util/linger_option.rs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
|
use core::time::Duration;
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Clone, Copy)]
|
||||||
|
pub struct LingerOption {
|
||||||
|
is_on: bool,
|
||||||
|
timeout: Duration,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LingerOption {
|
||||||
|
pub fn new(is_on: bool, timeout: Duration) -> Self {
|
||||||
|
Self { is_on, timeout }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_on(&self) -> bool {
|
||||||
|
self.is_on
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn timeout(&self) -> Duration {
|
||||||
|
self.timeout
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use super::socket_addr::SocketAddr;
|
use super::SocketAddr;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
/// Message header used for sendmsg/recvmsg.
|
/// Message header used for sendmsg/recvmsg.
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
pub mod datagram_common;
|
pub(super) mod datagram_common;
|
||||||
|
mod linger_option;
|
||||||
mod message_header;
|
mod message_header;
|
||||||
pub mod options;
|
pub(super) mod options;
|
||||||
pub mod send_recv_flags;
|
mod send_recv_flags;
|
||||||
pub mod shutdown_cmd;
|
mod shutdown_cmd;
|
||||||
pub mod socket_addr;
|
mod socket_addr;
|
||||||
|
|
||||||
|
pub use linger_option::LingerOption;
|
||||||
pub use message_header::MessageHeader;
|
pub use message_header::MessageHeader;
|
||||||
|
pub use send_recv_flags::SendRecvFlags;
|
||||||
|
pub use shutdown_cmd::SockShutdownCmd;
|
||||||
|
pub use socket_addr::SocketAddr;
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use core::time::Duration;
|
|
||||||
|
|
||||||
use aster_bigtcp::socket::{
|
use aster_bigtcp::socket::{
|
||||||
NeedIfacePoll, TCP_RECV_BUF_LEN, TCP_SEND_BUF_LEN, UDP_RECV_PAYLOAD_LEN, UDP_SEND_PAYLOAD_LEN,
|
NeedIfacePoll, TCP_RECV_BUF_LEN, TCP_SEND_BUF_LEN, UDP_RECV_PAYLOAD_LEN, UDP_SEND_PAYLOAD_LEN,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use super::LingerOption;
|
||||||
use crate::{
|
use crate::{
|
||||||
match_sock_option_mut, match_sock_option_ref,
|
match_sock_option_mut, match_sock_option_ref,
|
||||||
net::socket::options::{
|
net::socket::options::{
|
||||||
@ -137,26 +136,6 @@ impl SocketOptionSet {
|
|||||||
pub const MIN_SENDBUF: u32 = 2304;
|
pub const MIN_SENDBUF: u32 = 2304;
|
||||||
pub const MIN_RECVBUF: u32 = 2304;
|
pub const MIN_RECVBUF: u32 = 2304;
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy)]
|
|
||||||
pub struct LingerOption {
|
|
||||||
is_on: bool,
|
|
||||||
timeout: Duration,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl LingerOption {
|
|
||||||
pub fn new(is_on: bool, timeout: Duration) -> Self {
|
|
||||||
Self { is_on, timeout }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_on(&self) -> bool {
|
|
||||||
self.is_on
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn timeout(&self) -> Duration {
|
|
||||||
self.timeout
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A trait used for setting socket level options on actual sockets.
|
/// A trait used for setting socket level options on actual sockets.
|
||||||
pub(in crate::net) trait SetSocketLevelOption {
|
pub(in crate::net) trait SetSocketLevelOption {
|
||||||
/// Sets whether keepalive messages are enabled.
|
/// Sets whether keepalive messages are enabled.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use aster_virtio::device::socket::header::VsockDeviceAddr;
|
use aster_virtio::device::socket::header::VsockDeviceAddr;
|
||||||
|
|
||||||
use crate::{net::socket::SocketAddr, prelude::*};
|
use crate::{net::socket::util::SocketAddr, prelude::*};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub struct VsockSocketAddr {
|
pub struct VsockSocketAddr {
|
||||||
|
@ -6,8 +6,8 @@ use super::connecting::Connecting;
|
|||||||
use crate::{
|
use crate::{
|
||||||
events::IoEvents,
|
events::IoEvents,
|
||||||
net::socket::{
|
net::socket::{
|
||||||
|
util::{SendRecvFlags, SockShutdownCmd},
|
||||||
vsock::{addr::VsockSocketAddr, VSOCK_GLOBAL},
|
vsock::{addr::VsockSocketAddr, VSOCK_GLOBAL},
|
||||||
SendRecvFlags, SockShutdownCmd,
|
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{PollHandle, Pollee},
|
process::signal::{PollHandle, Pollee},
|
||||||
|
@ -8,8 +8,9 @@ use crate::{
|
|||||||
fs::file_handle::FileLike,
|
fs::file_handle::FileLike,
|
||||||
net::socket::{
|
net::socket::{
|
||||||
private::SocketPrivate,
|
private::SocketPrivate,
|
||||||
|
util::{MessageHeader, SendRecvFlags, SockShutdownCmd, SocketAddr},
|
||||||
vsock::{addr::VsockSocketAddr, VSOCK_GLOBAL},
|
vsock::{addr::VsockSocketAddr, VSOCK_GLOBAL},
|
||||||
MessageHeader, SendRecvFlags, SockShutdownCmd, Socket, SocketAddr,
|
Socket,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
process::signal::{PollHandle, Pollable, Poller},
|
process::signal::{PollHandle, Pollable, Poller},
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use super::SyscallReturn;
|
use super::SyscallReturn;
|
||||||
use crate::{
|
use crate::{
|
||||||
fs::file_table::{get_file_fast, FileDesc},
|
fs::file_table::{get_file_fast, FileDesc},
|
||||||
net::socket::SendRecvFlags,
|
net::socket::util::SendRecvFlags,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
util::net::write_socket_addr_to_user,
|
util::net::write_socket_addr_to_user,
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use super::SyscallReturn;
|
use super::SyscallReturn;
|
||||||
use crate::{
|
use crate::{
|
||||||
fs::file_table::{get_file_fast, FileDesc},
|
fs::file_table::{get_file_fast, FileDesc},
|
||||||
net::socket::SendRecvFlags,
|
net::socket::util::SendRecvFlags,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
util::net::CUserMsgHdr,
|
util::net::CUserMsgHdr,
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use super::SyscallReturn;
|
use super::SyscallReturn;
|
||||||
use crate::{
|
use crate::{
|
||||||
fs::file_table::{get_file_fast, FileDesc},
|
fs::file_table::{get_file_fast, FileDesc},
|
||||||
net::socket::{MessageHeader, SendRecvFlags},
|
net::socket::util::{MessageHeader, SendRecvFlags},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
util::net::CUserMsgHdr,
|
util::net::CUserMsgHdr,
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use super::SyscallReturn;
|
use super::SyscallReturn;
|
||||||
use crate::{
|
use crate::{
|
||||||
fs::file_table::{get_file_fast, FileDesc},
|
fs::file_table::{get_file_fast, FileDesc},
|
||||||
net::socket::{MessageHeader, SendRecvFlags},
|
net::socket::util::{MessageHeader, SendRecvFlags},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
util::net::read_socket_addr_from_user,
|
util::net::read_socket_addr_from_user,
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use super::SyscallReturn;
|
use super::SyscallReturn;
|
||||||
use crate::{
|
use crate::{
|
||||||
fs::file_table::{get_file_fast, FileDesc},
|
fs::file_table::{get_file_fast, FileDesc},
|
||||||
net::socket::SockShutdownCmd,
|
net::socket::util::SockShutdownCmd,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ use super::SyscallReturn;
|
|||||||
use crate::{
|
use crate::{
|
||||||
fs::{file_handle::FileLike, file_table::FdFlags},
|
fs::{file_handle::FileLike, file_table::FdFlags},
|
||||||
net::socket::{
|
net::socket::{
|
||||||
ip::{datagram::DatagramSocket, stream::StreamSocket},
|
ip::{DatagramSocket, StreamSocket},
|
||||||
netlink::{
|
netlink::{
|
||||||
is_valid_protocol, NetlinkRouteSocket, NetlinkUeventSocket, StandardNetlinkProtocol,
|
is_valid_protocol, NetlinkRouteSocket, NetlinkUeventSocket, StandardNetlinkProtocol,
|
||||||
},
|
},
|
||||||
|
@ -5,7 +5,7 @@ use core::cmp::min;
|
|||||||
use ostd::task::Task;
|
use ostd::task::Task;
|
||||||
|
|
||||||
use super::{ip::CSocketAddrInet, netlink::CSocketAddrNetlink, unix, vsock::CSocketAddrVm};
|
use super::{ip::CSocketAddrInet, netlink::CSocketAddrNetlink, unix, vsock::CSocketAddrVm};
|
||||||
use crate::{current_userspace, net::socket::SocketAddr, prelude::*};
|
use crate::{current_userspace, net::socket::util::SocketAddr, prelude::*};
|
||||||
|
|
||||||
/// Address family.
|
/// Address family.
|
||||||
///
|
///
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use super::RawSocketOption;
|
use super::RawSocketOption;
|
||||||
use crate::{
|
use crate::{
|
||||||
impl_raw_socket_option,
|
impl_raw_socket_option,
|
||||||
net::socket::ip::stream::options::{
|
net::socket::ip::stream_options::{
|
||||||
Congestion, DeferAccept, Inq, KeepIdle, MaxSegment, NoDelay, SynCnt, UserTimeout,
|
Congestion, DeferAccept, Inq, KeepIdle, MaxSegment, NoDelay, SynCnt, UserTimeout,
|
||||||
WindowClamp,
|
WindowClamp,
|
||||||
},
|
},
|
||||||
|
@ -5,8 +5,8 @@ use core::{num::NonZeroU8, time::Duration};
|
|||||||
use crate::{
|
use crate::{
|
||||||
current_userspace,
|
current_userspace,
|
||||||
net::socket::{
|
net::socket::{
|
||||||
ip::{options::IpTtl, stream::CongestionControl},
|
ip::{options::IpTtl, stream_options::CongestionControl},
|
||||||
LingerOption,
|
util::LingerOption,
|
||||||
},
|
},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use super::read_socket_addr_from_user;
|
use super::read_socket_addr_from_user;
|
||||||
use crate::{
|
use crate::{
|
||||||
net::socket::SocketAddr,
|
net::socket::util::SocketAddr,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
util::{net::write_socket_addr_with_max_len, VmReaderArray, VmWriterArray},
|
util::{net::write_socket_addr_with_max_len, VmReaderArray, VmWriterArray},
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user