net: move tuntap from std example to separate crate. (#1737)

This commit is contained in:
Dario Nieuwenhuis 2023-08-03 14:23:11 +02:00 committed by GitHub
parent 2c96fe917d
commit 4d60c715e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 18 deletions

View File

@ -0,0 +1,19 @@
[package]
name = "embassy-net-tuntap"
version = "0.1.0"
description = "embassy-net driver for Linux TUN/TAP interfaces."
keywords = ["embedded", "tuntap", "embassy-net", "embedded-hal-async", "ethernet", "async"]
categories = ["embedded", "hardware-support", "no-std", "network-programming", "async"]
license = "MIT OR Apache-2.0"
edition = "2021"
[dependencies]
embassy-net-driver = { version = "0.1.0", path = "../embassy-net-driver" }
async-io = "1.6.0"
log = "0.4.14"
libc = "0.2.101"
[package.metadata.embassy_docs]
src_base = "https://github.com/embassy-rs/embassy/blob/embassy-net-tuntap-v$VERSION/embassy-net-tuntap/src/"
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-net-tuntap/src/"
target = "thumbv7em-none-eabi"

View File

@ -0,0 +1,17 @@
# `embassy-net` integration for Linux TUN/TAP interfaces.
[`embassy-net`](https://crates.io/crates/embassy-net) integration for for Linux TUN (IP medium) and TAP (Ethernet medium) interfaces.
## Interoperability
This crate can run on any executor.
## License
This work is licensed under either of
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.

View File

@ -19,6 +19,7 @@ const ETHERNET_HEADER_LEN: usize = 14;
#[repr(C)]
#[derive(Debug)]
#[allow(non_camel_case_types)]
struct ifreq {
ifr_name: [libc::c_char; libc::IF_NAMESIZE],
ifr_data: libc::c_int, /* ifr_ifindex or ifr_mtu */

View File

@ -9,7 +9,7 @@ embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["lo
embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-std", "executor-thread", "log", "nightly", "integrated-timers"] }
embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["log", "std", "nightly"] }
embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "nightly", "log", "medium-ethernet", "tcp", "udp", "dns", "dhcpv4", "unstable-traits", "proto-ipv6"] }
embassy-net-driver = { version = "0.1.0", path = "../../embassy-net-driver" }
embassy-net-tuntap = { version = "0.1.0", path = "../../embassy-net-tuntap" }
embedded-io = { version = "0.4.0", features = ["async", "std", "futures"] }
critical-section = { version = "1.1", features = ["std"] }
@ -18,7 +18,6 @@ env_logger = "0.9.0"
futures = { version = "0.3.17" }
log = "0.4.14"
nix = "0.26.2"
libc = "0.2.101"
clap = { version = "3.0.0-beta.5", features = ["derive"] }
rand_core = { version = "0.6.3", features = ["std"] }
heapless = { version = "0.7.5", default-features = false }

View File

@ -6,6 +6,7 @@ use clap::Parser;
use embassy_executor::{Executor, Spawner};
use embassy_net::tcp::TcpSocket;
use embassy_net::{Config, Ipv4Address, Ipv4Cidr, Stack, StackResources};
use embassy_net_tuntap::TunTapDevice;
use embassy_time::Duration;
use embedded_io::asynch::Write;
use heapless::Vec;
@ -13,10 +14,6 @@ use log::*;
use rand_core::{OsRng, RngCore};
use static_cell::{make_static, StaticCell};
#[path = "../tuntap.rs"]
mod tuntap;
use crate::tuntap::TunTapDevice;
#[derive(Parser)]
#[clap(version = "1.0")]
struct Opts {

View File

@ -6,15 +6,12 @@ use clap::Parser;
use embassy_executor::{Executor, Spawner};
use embassy_net::dns::DnsQueryType;
use embassy_net::{Config, Ipv4Address, Ipv4Cidr, Stack, StackResources};
use embassy_net_tuntap::TunTapDevice;
use heapless::Vec;
use log::*;
use rand_core::{OsRng, RngCore};
use static_cell::{make_static, StaticCell};
#[path = "../tuntap.rs"]
mod tuntap;
use crate::tuntap::TunTapDevice;
#[derive(Parser)]
#[clap(version = "1.0")]
struct Opts {

View File

@ -4,15 +4,12 @@ use clap::Parser;
use embassy_executor::{Executor, Spawner};
use embassy_net::udp::{PacketMetadata, UdpSocket};
use embassy_net::{Config, Ipv4Address, Ipv4Cidr, Stack, StackResources};
use embassy_net_tuntap::TunTapDevice;
use heapless::Vec;
use log::*;
use rand_core::{OsRng, RngCore};
use static_cell::{make_static, StaticCell};
#[path = "../tuntap.rs"]
mod tuntap;
use crate::tuntap::TunTapDevice;
#[derive(Parser)]
#[clap(version = "1.0")]
struct Opts {

View File

@ -7,6 +7,7 @@ use clap::Parser;
use embassy_executor::{Executor, Spawner};
use embassy_net::tcp::TcpSocket;
use embassy_net::{Config, Ipv4Address, Ipv4Cidr, Stack, StackResources};
use embassy_net_tuntap::TunTapDevice;
use embassy_time::{Duration, Timer};
use embedded_io::asynch::Write as _;
use heapless::Vec;
@ -14,10 +15,6 @@ use log::*;
use rand_core::{OsRng, RngCore};
use static_cell::{make_static, StaticCell};
#[path = "../tuntap.rs"]
mod tuntap;
use crate::tuntap::TunTapDevice;
#[derive(Parser)]
#[clap(version = "1.0")]
struct Opts {