diff options
Diffstat (limited to 'examples/std/src/tuntap.rs')
| -rw-r--r-- | examples/std/src/tuntap.rs | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/examples/std/src/tuntap.rs b/examples/std/src/tuntap.rs index b70767a3a..a0cace7f7 100644 --- a/examples/std/src/tuntap.rs +++ b/examples/std/src/tuntap.rs | |||
| @@ -1,9 +1,10 @@ | |||
| 1 | use async_io::Async; | ||
| 2 | use log::*; | ||
| 3 | use std::io; | 1 | use std::io; |
| 4 | use std::io::{Read, Write}; | 2 | use std::io::{Read, Write}; |
| 5 | use std::os::unix::io::{AsRawFd, RawFd}; | 3 | use std::os::unix::io::{AsRawFd, RawFd}; |
| 6 | 4 | ||
| 5 | use async_io::Async; | ||
| 6 | use log::*; | ||
| 7 | |||
| 7 | pub const SIOCGIFMTU: libc::c_ulong = 0x8921; | 8 | pub const SIOCGIFMTU: libc::c_ulong = 0x8921; |
| 8 | pub const _SIOCGIFINDEX: libc::c_ulong = 0x8933; | 9 | pub const _SIOCGIFINDEX: libc::c_ulong = 0x8933; |
| 9 | pub const _ETH_P_ALL: libc::c_short = 0x0003; | 10 | pub const _ETH_P_ALL: libc::c_short = 0x0003; |
| @@ -32,11 +33,7 @@ fn ifreq_for(name: &str) -> ifreq { | |||
| 32 | ifreq | 33 | ifreq |
| 33 | } | 34 | } |
| 34 | 35 | ||
| 35 | fn ifreq_ioctl( | 36 | fn ifreq_ioctl(lower: libc::c_int, ifreq: &mut ifreq, cmd: libc::c_ulong) -> io::Result<libc::c_int> { |
| 36 | lower: libc::c_int, | ||
| 37 | ifreq: &mut ifreq, | ||
| 38 | cmd: libc::c_ulong, | ||
| 39 | ) -> io::Result<libc::c_int> { | ||
| 40 | unsafe { | 37 | unsafe { |
| 41 | let res = libc::ioctl(lower, cmd as _, ifreq as *mut ifreq); | 38 | let res = libc::ioctl(lower, cmd as _, ifreq as *mut ifreq); |
| 42 | if res == -1 { | 39 | if res == -1 { |
| @@ -141,11 +138,10 @@ impl TunTapDevice { | |||
| 141 | } | 138 | } |
| 142 | 139 | ||
| 143 | use core::task::Waker; | 140 | use core::task::Waker; |
| 144 | use embassy_net::{ | ||
| 145 | Device, DeviceCapabilities, LinkState, Packet, PacketBox, PacketBoxExt, PacketBuf, | ||
| 146 | }; | ||
| 147 | use std::task::Context; | 141 | use std::task::Context; |
| 148 | 142 | ||
| 143 | use embassy_net::{Device, DeviceCapabilities, LinkState, Packet, PacketBox, PacketBoxExt, PacketBuf}; | ||
| 144 | |||
| 149 | impl Device for TunTapDevice { | 145 | impl Device for TunTapDevice { |
| 150 | fn is_transmit_ready(&mut self) -> bool { | 146 | fn is_transmit_ready(&mut self) -> bool { |
| 151 | true | 147 | true |
