diff options
Diffstat (limited to 'examples/std/src')
| -rw-r--r-- | examples/std/src/tuntap.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/std/src/tuntap.rs b/examples/std/src/tuntap.rs index a32099404..4d30118fb 100644 --- a/examples/std/src/tuntap.rs +++ b/examples/std/src/tuntap.rs | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | use async_io::Async; | 1 | use async_io::Async; |
| 2 | use libc; | ||
| 3 | use log::*; | 2 | use log::*; |
| 4 | use smoltcp::wire::EthernetFrame; | ||
| 5 | use std::io; | 3 | use std::io; |
| 6 | use std::io::{Read, Write}; | 4 | use std::io::{Read, Write}; |
| 7 | use std::os::unix::io::{AsRawFd, RawFd}; | 5 | use std::os::unix::io::{AsRawFd, RawFd}; |
| @@ -14,6 +12,8 @@ pub const _IFF_TUN: libc::c_int = 0x0001; | |||
| 14 | pub const IFF_TAP: libc::c_int = 0x0002; | 12 | pub const IFF_TAP: libc::c_int = 0x0002; |
| 15 | pub const IFF_NO_PI: libc::c_int = 0x1000; | 13 | pub const IFF_NO_PI: libc::c_int = 0x1000; |
| 16 | 14 | ||
| 15 | const ETHERNET_HEADER_LEN: usize = 14; | ||
| 16 | |||
| 17 | #[repr(C)] | 17 | #[repr(C)] |
| 18 | #[derive(Debug)] | 18 | #[derive(Debug)] |
| 19 | struct ifreq { | 19 | struct ifreq { |
| @@ -85,7 +85,7 @@ impl TunTap { | |||
| 85 | 85 | ||
| 86 | // SIOCGIFMTU returns the IP MTU (typically 1500 bytes.) | 86 | // SIOCGIFMTU returns the IP MTU (typically 1500 bytes.) |
| 87 | // smoltcp counts the entire Ethernet packet in the MTU, so add the Ethernet header size to it. | 87 | // smoltcp counts the entire Ethernet packet in the MTU, so add the Ethernet header size to it. |
| 88 | let mtu = ip_mtu + EthernetFrame::<&[u8]>::header_len(); | 88 | let mtu = ip_mtu + ETHERNET_HEADER_LEN; |
| 89 | 89 | ||
| 90 | Ok(TunTap { fd, mtu }) | 90 | Ok(TunTap { fd, mtu }) |
| 91 | } | 91 | } |
