Skip to main content

rawlink/
lib.rs

1//! Raw Ethernet I/O and classic pcap reading. Frames are opaque here; the
2//! Colorlight protocol lives in `colorlight`.
3//!
4//! [`Link`] is one interface opened for whole-frame send/receive: `/dev/bpf`
5//! on macOS, an `AF_PACKET` socket on Linux. Same API on both; `recv` returns
6//! within the read timeout with whatever arrived, possibly nothing.
7
8#[cfg(target_os = "macos")]
9mod bpf;
10#[cfg(target_os = "macos")]
11pub use bpf::{Frames, Link};
12
13#[cfg(target_os = "linux")]
14mod packet;
15#[cfg(target_os = "linux")]
16pub use packet::{Frames, Link};
17
18#[cfg(not(any(target_os = "macos", target_os = "linux")))]
19compile_error!("rawlink supports macOS (/dev/bpf) and Linux (AF_PACKET) only");
20
21mod pcap;
22pub use pcap::{parse_pcap, read_pcap, Packets, Pcap, PcapPacket};