microsandbox_network/host/mod.rs
1//! Platform-specific host network backends.
2//!
3//! Each backend creates the OS-level networking infrastructure (TAP device on
4//! Linux, vmnet interface on macOS) and provides raw ethernet frame RX/TX.
5
6use std::os::fd::RawFd;
7
8//--------------------------------------------------------------------------------------------------
9// Types
10//--------------------------------------------------------------------------------------------------
11
12/// Host network backend interface used by the packet relay engine.
13pub trait FrameTransport {
14 /// Returns the fd used for readiness notifications.
15 fn ready_fd(&self) -> RawFd;
16
17 /// Reads one ethernet frame from the backend.
18 fn read_frame(&self, buf: &mut [u8]) -> std::io::Result<usize>;
19
20 /// Writes one ethernet frame to the backend.
21 fn write_frame(&self, buf: &[u8]) -> std::io::Result<()>;
22}
23
24#[cfg(target_os = "linux")]
25pub mod linux;
26
27#[cfg(target_os = "macos")]
28pub mod macos;