alnyan/yggdrasil: remove old socket interface
This commit is contained in:
parent
cf17aeac1c
commit
159e86ffe8
@ -25,6 +25,7 @@ name = "abi-serde"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"compiler_builtins",
|
||||
"rustc-std-workspace-alloc",
|
||||
"rustc-std-workspace-core",
|
||||
]
|
||||
|
||||
|
@ -4,7 +4,7 @@ pub mod fd;
|
||||
|
||||
pub mod device;
|
||||
pub mod mapping;
|
||||
pub mod message_channel;
|
||||
// pub mod message_channel;
|
||||
pub mod net;
|
||||
pub mod pid;
|
||||
pub mod pipe;
|
||||
|
@ -1,10 +1,8 @@
|
||||
#![unstable(feature = "yggdrasil_os", issue = "none")]
|
||||
|
||||
use yggdrasil_rt::net::{self as rt, SocketInterfaceQuery};
|
||||
use yggdrasil_rt::sys as syscall;
|
||||
|
||||
use crate::io;
|
||||
use crate::mem::MaybeUninit;
|
||||
use crate::os::fd::{AsRawFd, FromRawFd, RawFd};
|
||||
use crate::sys::cvt_io;
|
||||
use crate::sys::io::FileDesc;
|
||||
@ -22,12 +20,11 @@ impl RawSocket {
|
||||
}
|
||||
|
||||
pub fn send(&self, data: &[u8]) -> io::Result<usize> {
|
||||
cvt_io(unsafe { syscall::send_to(self.0.as_raw_fd(), data, &None) })
|
||||
cvt_io(rt::socket::send(self.as_raw_fd(), data))
|
||||
}
|
||||
|
||||
pub fn recv(&self, data: &mut [u8]) -> io::Result<usize> {
|
||||
let mut discard = MaybeUninit::uninit();
|
||||
cvt_io(unsafe { syscall::receive_from(self.0.as_raw_fd(), data, &mut discard) })
|
||||
cvt_io(rt::socket::receive(self.as_raw_fd(), data))
|
||||
}
|
||||
|
||||
pub fn hardware_address(&self) -> io::Result<[u8; 6]> {
|
||||
|
@ -1,7 +1,6 @@
|
||||
use yggdrasil_rt::{io as rt_io, net as rt, sys as syscall};
|
||||
|
||||
use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
|
||||
use crate::mem::MaybeUninit;
|
||||
use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
|
||||
use crate::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
|
||||
use crate::sys::cvt_io;
|
||||
@ -146,23 +145,17 @@ impl SocketFileDesc {
|
||||
}
|
||||
|
||||
pub(crate) fn accept(&self) -> io::Result<(SocketFileDesc, SocketAddr)> {
|
||||
let mut remote = MaybeUninit::uninit();
|
||||
let raw = cvt_io(unsafe { syscall::accept(self.fd.as_raw_fd(), &mut remote) })?;
|
||||
let remote = unsafe { remote.assume_init() };
|
||||
let (raw, remote) = cvt_io(rt::socket::accept_ip(self.as_raw_fd()))?;
|
||||
let fd = unsafe { Self::from_raw_fd(raw) };
|
||||
Ok((fd, remote))
|
||||
}
|
||||
|
||||
pub(crate) fn recv_from(&self, buffer: &mut [u8]) -> io::Result<(usize, SocketAddr)> {
|
||||
let mut remote = MaybeUninit::uninit();
|
||||
let len =
|
||||
cvt_io(unsafe { syscall::receive_from(self.fd.as_raw_fd(), buffer, &mut remote) })?;
|
||||
Ok((len, unsafe { remote.assume_init() }))
|
||||
cvt_io(rt::socket::receive_from_ip(self.as_raw_fd(), buffer))
|
||||
}
|
||||
|
||||
pub(crate) fn recv(&self, buffer: &mut [u8]) -> io::Result<usize> {
|
||||
let mut ignore = MaybeUninit::uninit();
|
||||
cvt_io(unsafe { syscall::receive_from(self.fd.as_raw_fd(), buffer, &mut ignore) })
|
||||
cvt_io(rt::socket::receive(self.as_raw_fd(), buffer))
|
||||
}
|
||||
|
||||
pub(crate) fn recv_buf(&self, _buf: BorrowedCursor<'_>) -> io::Result<()> {
|
||||
@ -182,12 +175,11 @@ impl SocketFileDesc {
|
||||
}
|
||||
|
||||
pub(crate) fn send(&self, data: &[u8]) -> io::Result<usize> {
|
||||
cvt_io(unsafe { syscall::send_to(self.fd.as_raw_fd(), data, &None) })
|
||||
cvt_io(rt::socket::send(self.as_raw_fd(), data))
|
||||
}
|
||||
|
||||
pub(crate) fn send_to(&self, data: &[u8], dst: &SocketAddr) -> io::Result<usize> {
|
||||
let dst = Some(*dst);
|
||||
cvt_io(unsafe { syscall::send_to(self.fd.as_raw_fd(), data, &dst) })
|
||||
cvt_io(rt::socket::send_to_ip(self.as_raw_fd(), data, dst))
|
||||
}
|
||||
|
||||
pub(crate) fn send_vectored(&self, _data: &[IoSlice<'_>]) -> io::Result<usize> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user