mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-24 01:43:22 +00:00
Fix error codes in bind
, listen
, and accept
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
346887ace5
commit
92a9f5616e
@ -16,53 +16,53 @@ mod util;
|
||||
pub trait Socket: FileLike + Send + Sync {
|
||||
/// Assign the address specified by socket_addr to the socket
|
||||
fn bind(&self, socket_addr: SocketAddr) -> Result<()> {
|
||||
return_errno_with_message!(Errno::EINVAL, "bind not implemented");
|
||||
return_errno_with_message!(Errno::EOPNOTSUPP, "bind() is not supported");
|
||||
}
|
||||
|
||||
/// Build connection for a given address
|
||||
fn connect(&self, socket_addr: SocketAddr) -> Result<()> {
|
||||
return_errno_with_message!(Errno::EINVAL, "connect not implemented");
|
||||
return_errno_with_message!(Errno::EOPNOTSUPP, "connect() is not supported");
|
||||
}
|
||||
|
||||
/// Listen for connections on a socket
|
||||
fn listen(&self, backlog: usize) -> Result<()> {
|
||||
return_errno_with_message!(Errno::EINVAL, "connect not implemented");
|
||||
return_errno_with_message!(Errno::EOPNOTSUPP, "connect() is not supported");
|
||||
}
|
||||
|
||||
/// Accept a connection on a socket
|
||||
fn accept(&self) -> Result<(Arc<dyn FileLike>, SocketAddr)> {
|
||||
return_errno_with_message!(Errno::EINVAL, "accept not implemented");
|
||||
return_errno_with_message!(Errno::EOPNOTSUPP, "accept() is not supported");
|
||||
}
|
||||
|
||||
/// Shut down part of a full-duplex connection
|
||||
fn shutdown(&self, cmd: SockShutdownCmd) -> Result<()> {
|
||||
return_errno_with_message!(Errno::EINVAL, "shutdown not implemented");
|
||||
return_errno_with_message!(Errno::EOPNOTSUPP, "shutdown() is not supported");
|
||||
}
|
||||
|
||||
/// Get address of this socket.
|
||||
fn addr(&self) -> Result<SocketAddr> {
|
||||
return_errno_with_message!(Errno::EINVAL, "getsockname not implemented");
|
||||
return_errno_with_message!(Errno::EOPNOTSUPP, "getsockname() is not supported");
|
||||
}
|
||||
|
||||
/// Get address of peer socket
|
||||
fn peer_addr(&self) -> Result<SocketAddr> {
|
||||
return_errno_with_message!(Errno::EINVAL, "getpeername not implemented");
|
||||
return_errno_with_message!(Errno::EOPNOTSUPP, "getpeername() is not supported");
|
||||
}
|
||||
|
||||
/// Get options on the socket. The resulted option will put in the `option` parameter, if
|
||||
/// this method returns success.
|
||||
fn get_option(&self, option: &mut dyn SocketOption) -> Result<()> {
|
||||
return_errno_with_message!(Errno::EINVAL, "getsockopt not implemented");
|
||||
return_errno_with_message!(Errno::EOPNOTSUPP, "getsockopt() is not supported");
|
||||
}
|
||||
|
||||
/// Set options on the socket.
|
||||
fn set_option(&self, option: &dyn SocketOption) -> Result<()> {
|
||||
return_errno_with_message!(Errno::EINVAL, "setsockopt not implemented");
|
||||
return_errno_with_message!(Errno::EOPNOTSUPP, "setsockopt() is not supported");
|
||||
}
|
||||
|
||||
/// Receive a message from a socket
|
||||
fn recvfrom(&self, buf: &mut [u8], flags: SendRecvFlags) -> Result<(usize, SocketAddr)> {
|
||||
return_errno_with_message!(Errno::EINVAL, "recvfrom not implemented");
|
||||
return_errno_with_message!(Errno::EOPNOTSUPP, "recvfrom() is not supported");
|
||||
}
|
||||
|
||||
/// Send a message on a socket
|
||||
@ -72,6 +72,6 @@ pub trait Socket: FileLike + Send + Sync {
|
||||
remote: Option<SocketAddr>,
|
||||
flags: SendRecvFlags,
|
||||
) -> Result<usize> {
|
||||
return_errno_with_message!(Errno::EINVAL, "recvfrom not implemented");
|
||||
return_errno_with_message!(Errno::EOPNOTSUPP, "recvfrom() is not supported");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user