aboutsummaryrefslogtreecommitdiff
path: root/examples/std/src/tuntap.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/std/src/tuntap.rs')
-rw-r--r--examples/std/src/tuntap.rs16
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 @@
1use async_io::Async;
2use log::*;
3use std::io; 1use std::io;
4use std::io::{Read, Write}; 2use std::io::{Read, Write};
5use std::os::unix::io::{AsRawFd, RawFd}; 3use std::os::unix::io::{AsRawFd, RawFd};
6 4
5use async_io::Async;
6use log::*;
7
7pub const SIOCGIFMTU: libc::c_ulong = 0x8921; 8pub const SIOCGIFMTU: libc::c_ulong = 0x8921;
8pub const _SIOCGIFINDEX: libc::c_ulong = 0x8933; 9pub const _SIOCGIFINDEX: libc::c_ulong = 0x8933;
9pub const _ETH_P_ALL: libc::c_short = 0x0003; 10pub 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
35fn ifreq_ioctl( 36fn 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
143use core::task::Waker; 140use core::task::Waker;
144use embassy_net::{
145 Device, DeviceCapabilities, LinkState, Packet, PacketBox, PacketBoxExt, PacketBuf,
146};
147use std::task::Context; 141use std::task::Context;
148 142
143use embassy_net::{Device, DeviceCapabilities, LinkState, Packet, PacketBox, PacketBoxExt, PacketBuf};
144
149impl Device for TunTapDevice { 145impl Device for TunTapDevice {
150 fn is_transmit_ready(&mut self) -> bool { 146 fn is_transmit_ready(&mut self) -> bool {
151 true 147 true