use crate::{Frame, IpPrefix, L2Device, L2Handler, L3Device, L3Handler, MacAddr, Packet, Result};
use std::io;
#[derive(Debug, Clone, Default)]
pub struct TuntapConfig {
pub name: String,
}
fn unsupported<T>() -> Result<T> {
Err(io::Error::new(
io::ErrorKind::Unsupported,
"TUN/TAP is only implemented for Linux and macOS",
))
}
#[derive(Debug)]
pub struct Tun(());
impl Tun {
pub fn open(_cfg: TuntapConfig) -> Result<Tun> {
unsupported()
}
pub fn name(&self) -> &str {
""
}
}
#[derive(Debug)]
pub struct Tap(());
impl Tap {
pub fn open(_cfg: TuntapConfig) -> Result<Tap> {
unsupported()
}
pub fn name(&self) -> &str {
""
}
}
impl L3Device for Tun {
fn set_handler(&self, _h: L3Handler) {}
fn send(&self, _p: &Packet) -> Result<()> {
unsupported()
}
fn addr(&self) -> IpPrefix {
IpPrefix::default()
}
fn set_addr(&self, _p: IpPrefix) -> Result<()> {
unsupported()
}
fn close(&self) -> Result<()> {
Ok(())
}
}
impl L2Device for Tap {
fn set_handler(&self, _h: L2Handler) {}
fn send(&self, _f: &Frame) -> Result<()> {
unsupported()
}
fn hw_addr(&self) -> MacAddr {
MacAddr::zero()
}
fn close(&self) -> Result<()> {
Ok(())
}
}