forked from meh/rust-tun
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for concurrent send/recv apis for tun device (meh#87)
* 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.
- Loading branch information
1 parent
777ba78
commit 93af5c3
Showing
9 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters