mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-28 20:03:22 +00:00
Implement UDP getsockopt and setsockopt
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
468dae33f0
commit
dc4df47007
@ -29,8 +29,8 @@ pub(super) enum SocketFamily {
|
||||
impl AnyUnboundSocket {
|
||||
pub fn new_tcp(observer: Weak<dyn Observer<()>>) -> Self {
|
||||
let raw_tcp_socket = {
|
||||
let rx_buffer = smoltcp::socket::tcp::SocketBuffer::new(vec![0u8; RECV_BUF_LEN]);
|
||||
let tx_buffer = smoltcp::socket::tcp::SocketBuffer::new(vec![0u8; SEND_BUF_LEN]);
|
||||
let rx_buffer = smoltcp::socket::tcp::SocketBuffer::new(vec![0u8; TCP_RECV_BUF_LEN]);
|
||||
let tx_buffer = smoltcp::socket::tcp::SocketBuffer::new(vec![0u8; TCP_SEND_BUF_LEN]);
|
||||
RawTcpSocket::new(rx_buffer, tx_buffer)
|
||||
};
|
||||
AnyUnboundSocket {
|
||||
@ -44,7 +44,7 @@ impl AnyUnboundSocket {
|
||||
let metadata = smoltcp::socket::udp::PacketMetadata::EMPTY;
|
||||
let rx_buffer = smoltcp::socket::udp::PacketBuffer::new(
|
||||
vec![metadata; UDP_METADATA_LEN],
|
||||
vec![0u8; UDP_RECEIVE_PAYLOAD_LEN],
|
||||
vec![0u8; UDP_RECV_PAYLOAD_LEN],
|
||||
);
|
||||
let tx_buffer = smoltcp::socket::udp::PacketBuffer::new(
|
||||
vec![metadata; UDP_METADATA_LEN],
|
||||
@ -209,10 +209,10 @@ impl Drop for AnyBoundSocketInner {
|
||||
}
|
||||
|
||||
// For TCP
|
||||
pub const RECV_BUF_LEN: usize = 65536;
|
||||
pub const SEND_BUF_LEN: usize = 65536;
|
||||
pub const TCP_RECV_BUF_LEN: usize = 65536;
|
||||
pub const TCP_SEND_BUF_LEN: usize = 65536;
|
||||
|
||||
// For UDP
|
||||
pub const UDP_SEND_PAYLOAD_LEN: usize = 65536;
|
||||
pub const UDP_RECV_PAYLOAD_LEN: usize = 65536;
|
||||
const UDP_METADATA_LEN: usize = 256;
|
||||
const UDP_SEND_PAYLOAD_LEN: usize = 65536;
|
||||
const UDP_RECEIVE_PAYLOAD_LEN: usize = 65536;
|
||||
|
@ -14,7 +14,8 @@ mod util;
|
||||
mod virtio;
|
||||
|
||||
pub use any_socket::{
|
||||
AnyBoundSocket, AnyUnboundSocket, RawTcpSocket, RawUdpSocket, RECV_BUF_LEN, SEND_BUF_LEN,
|
||||
AnyBoundSocket, AnyUnboundSocket, RawTcpSocket, RawUdpSocket, TCP_RECV_BUF_LEN,
|
||||
TCP_SEND_BUF_LEN, UDP_RECV_PAYLOAD_LEN, UDP_SEND_PAYLOAD_LEN,
|
||||
};
|
||||
pub use loopback::IfaceLoopback;
|
||||
use ostd::sync::LocalIrqDisabled;
|
||||
|
Reference in New Issue
Block a user