Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace deprecated ioctl with nix (#86) #87

Closed
wants to merge 1 commit into from

Conversation

zonyitoo
Copy link
Contributor

@zonyitoo zonyitoo commented Feb 18, 2024

This PR is going to replace the deprecated ioctl (or ioctl-sys) with a more actively maintained crate nix.

fixed #86 .

KKRainbow pushed a commit to EasyTier/rust-tun that referenced this pull request Aug 6, 2024
* Add send and recv apis similar to Tokio::UdpSocket

Tokio supports async api's for UDP socket which does not need `&mut self`

pub async fn recv(&self, buf: &mut [u8]) -> Result<usize>
pub async fn send(&self, buf: &[u8]) -> Result<usize>

This makes it pretty easy to call it concurrently, without adding Arc<Mutex<T>> to
UdpSocket.

This PR tries to add support for similar apis to tun device.
In this commit, only sync version of recv/send apis are added. Async version will be added in
further commit.

Reference:
https://docs.rs/tokio/latest/tokio/net/struct.UdpSocket.html#method.recv
https://docs.rs/tokio/latest/tokio/net/struct.UdpSocket.html#method.send

* Refactor to use STACK_BUF_LEN as const

* Add async unix send/recv apis for unix

Since unix uses AsyncFd from tokio, it is easier to wait for Ready
on AsyncFd and call sync send/recv apis

This commit does not take care of windows, which is not as straight-forward as posix variants.
@ssrlive ssrlive closed this Oct 27, 2024
@zonyitoo zonyitoo deleted the feature-replace-ioctl branch October 29, 2024 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ioctl is marked as "deprecated", should be replaced with nix
2 participants