mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-08 22:36:48 +00:00
make fmt
This commit is contained in:
parent
e0c725556d
commit
bca5197bdf
@ -117,5 +117,8 @@ use crate::net::socket;
|
|||||||
use alloc::sync::Arc;
|
use alloc::sync::Arc;
|
||||||
|
|
||||||
pub trait Family {
|
pub trait Family {
|
||||||
fn socket(stype: socket::PSOCK, protocol: u32) -> Result<Arc<socket::Inode>, system_error::SystemError>;
|
fn socket(
|
||||||
|
stype: socket::PSOCK,
|
||||||
|
protocol: u32,
|
||||||
|
) -> Result<Arc<socket::Inode>, system_error::SystemError>;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ impl Init {
|
|||||||
Init::Bound(_) => {
|
Init::Bound(_) => {
|
||||||
log::debug!("Already Bound");
|
log::debug!("Already Bound");
|
||||||
Err(EINVAL)
|
Err(EINVAL)
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ impl TcpSocket {
|
|||||||
writer.replace(any);
|
writer.replace(any);
|
||||||
log::error!("TcpSocket::do_bind: not Init");
|
log::error!("TcpSocket::do_bind: not Init");
|
||||||
Err(EINVAL)
|
Err(EINVAL)
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,11 +234,13 @@ impl Socket for TcpSocket {
|
|||||||
|
|
||||||
fn get_name(&self) -> Result<Endpoint, SystemError> {
|
fn get_name(&self) -> Result<Endpoint, SystemError> {
|
||||||
match self.inner.read().as_ref().expect("Tcp Inner is None") {
|
match self.inner.read().as_ref().expect("Tcp Inner is None") {
|
||||||
Inner::Init(Init::Unbound((_, v4))) => if *v4 {
|
Inner::Init(Init::Unbound((_, v4))) => {
|
||||||
Ok(Endpoint::Ip(UNSPECIFIED_LOCAL_ENDPOINT_V4))
|
if *v4 {
|
||||||
} else {
|
Ok(Endpoint::Ip(UNSPECIFIED_LOCAL_ENDPOINT_V4))
|
||||||
Ok(Endpoint::Ip(UNSPECIFIED_LOCAL_ENDPOINT_V6))
|
} else {
|
||||||
},
|
Ok(Endpoint::Ip(UNSPECIFIED_LOCAL_ENDPOINT_V6))
|
||||||
|
}
|
||||||
|
}
|
||||||
Inner::Init(Init::Bound((_, local))) => Ok(Endpoint::Ip(*local)),
|
Inner::Init(Init::Bound((_, local))) => Ok(Endpoint::Ip(*local)),
|
||||||
Inner::Connecting(connecting) => Ok(Endpoint::Ip(connecting.get_name())),
|
Inner::Connecting(connecting) => Ok(Endpoint::Ip(connecting.get_name())),
|
||||||
Inner::Established(established) => Ok(Endpoint::Ip(established.local_endpoint())),
|
Inner::Established(established) => Ok(Endpoint::Ip(established.local_endpoint())),
|
||||||
|
@ -44,7 +44,8 @@ fn create_inet_socket(
|
|||||||
pub struct Inet;
|
pub struct Inet;
|
||||||
impl family::Family for Inet {
|
impl family::Family for Inet {
|
||||||
fn socket(stype: PSOCK, protocol: u32) -> Result<Arc<Inode>, SystemError> {
|
fn socket(stype: PSOCK, protocol: u32) -> Result<Arc<Inode>, SystemError> {
|
||||||
let socket = create_inet_socket(true, stype, smoltcp::wire::IpProtocol::from(protocol as u8))?;
|
let socket =
|
||||||
|
create_inet_socket(true, stype, smoltcp::wire::IpProtocol::from(protocol as u8))?;
|
||||||
Ok(Inode::new(socket))
|
Ok(Inode::new(socket))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,7 +53,11 @@ impl family::Family for Inet {
|
|||||||
pub struct Inet6;
|
pub struct Inet6;
|
||||||
impl family::Family for Inet6 {
|
impl family::Family for Inet6 {
|
||||||
fn socket(stype: PSOCK, protocol: u32) -> Result<Arc<Inode>, SystemError> {
|
fn socket(stype: PSOCK, protocol: u32) -> Result<Arc<Inode>, SystemError> {
|
||||||
let socket = create_inet_socket(false, stype, smoltcp::wire::IpProtocol::from(protocol as u8))?;
|
let socket = create_inet_socket(
|
||||||
|
false,
|
||||||
|
stype,
|
||||||
|
smoltcp::wire::IpProtocol::from(protocol as u8),
|
||||||
|
)?;
|
||||||
Ok(Inode::new(socket))
|
Ok(Inode::new(socket))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user