Samuka007 5 months ago
parent
commit
bca5197bdf

+ 4 - 1
kernel/src/net/socket/family.rs

@@ -117,5 +117,8 @@ use crate::net::socket;
 use alloc::sync::Arc;
 
 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>;
 }

+ 1 - 1
kernel/src/net/socket/inet/stream/inner.rs

@@ -66,7 +66,7 @@ impl Init {
             Init::Bound(_) => {
                 log::debug!("Already Bound");
                 Err(EINVAL)
-            },
+            }
         }
     }
 

+ 8 - 6
kernel/src/net/socket/inet/stream/mod.rs

@@ -73,7 +73,7 @@ impl TcpSocket {
                 writer.replace(any);
                 log::error!("TcpSocket::do_bind: not Init");
                 Err(EINVAL)
-            },
+            }
         }
     }
 
@@ -234,11 +234,13 @@ impl Socket for TcpSocket {
 
     fn get_name(&self) -> Result<Endpoint, SystemError> {
         match self.inner.read().as_ref().expect("Tcp Inner is None") {
-            Inner::Init(Init::Unbound((_, v4))) => if *v4 {
-                Ok(Endpoint::Ip(UNSPECIFIED_LOCAL_ENDPOINT_V4))
-            } else {
-                Ok(Endpoint::Ip(UNSPECIFIED_LOCAL_ENDPOINT_V6))
-            },
+            Inner::Init(Init::Unbound((_, v4))) => {
+                if *v4 {
+                    Ok(Endpoint::Ip(UNSPECIFIED_LOCAL_ENDPOINT_V4))
+                } else {
+                    Ok(Endpoint::Ip(UNSPECIFIED_LOCAL_ENDPOINT_V6))
+                }
+            }
             Inner::Init(Init::Bound((_, local))) => Ok(Endpoint::Ip(*local)),
             Inner::Connecting(connecting) => Ok(Endpoint::Ip(connecting.get_name())),
             Inner::Established(established) => Ok(Endpoint::Ip(established.local_endpoint())),

+ 7 - 2
kernel/src/net/socket/inet/syscall.rs

@@ -44,7 +44,8 @@ fn create_inet_socket(
 pub struct Inet;
 impl family::Family for Inet {
     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))
     }
 }
@@ -52,7 +53,11 @@ impl family::Family for Inet {
 pub struct Inet6;
 impl family::Family for Inet6 {
     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))
     }
 }