ndn_faces/l2/mod.rs
1//! # `ndn_faces::l2` — Layer-2 (Ethernet and radio) faces
2//!
3//! Link-layer face implementations for NDN over raw Ethernet (Ethertype
4//! `0x8624`), Wifibroadcast, and Bluetooth LE.
5//!
6//! ## Key types
7//!
8//! - [`NamedEtherFace`] / [`MulticastEtherFace`] — unicast and multicast raw Ethernet faces
9//! - [`WfbFace`] — Wifibroadcast NG face for 802.11 monitor-mode injection (Linux only)
10//! - [`BleFace`] — BLE GATT face implementing the NDNts web-bluetooth-transport
11//! protocol (Linux only; requires `bluetooth` feature and BlueZ)
12//! - [`RadioTable`] — metadata registry for radio-based faces
13//! - [`EtherNeighborDiscovery`] — link-layer neighbor discovery (Linux only)
14//!
15//! ## Platform support
16//!
17//! - **Linux** — `AF_PACKET` raw sockets (full feature set)
18//! - **macOS** — `PF_NDRV` for Ethernet faces
19//! - **Windows** — Npcap/WinPcap for Ethernet faces
20//! - **Android / iOS** — raw Ethernet faces are unavailable; only [`RadioTable`]
21//! and [`NDN_ETHERTYPE`] are exported. Use `UdpFace`/`TcpFace` and
22//! `InProcFace` from `ndn_faces::net`/`ndn_faces::local` for mobile deployments.
23
24#![allow(missing_docs)]
25
26// AF_PACKET raw sockets, WfbFace (802.11 monitor-mode injection), and
27// BleFace (BLE GATT) all require Linux kernel APIs that do not exist on
28// macOS, Windows, Android, or embedded targets.
29#[cfg(target_os = "linux")]
30pub mod af_packet;
31
32/// macOS raw Ethernet via PF_NDRV (Network Driver Raw).
33#[cfg(target_os = "macos")]
34pub mod ndrv;
35
36/// Windows raw Ethernet via Npcap/WinPcap (`pcap` crate).
37#[cfg(target_os = "windows")]
38pub mod pcap_face;
39
40#[cfg(target_os = "linux")]
41pub mod ether;
42
43#[cfg(target_os = "linux")]
44pub mod multicast_ether;
45
46/// macOS Ethernet faces (`NamedEtherFace` + `MulticastEtherFace`) over PF_NDRV.
47#[cfg(target_os = "macos")]
48pub mod ether_macos;
49
50/// Windows Ethernet faces (`NamedEtherFace` + `MulticastEtherFace`) over Npcap.
51#[cfg(target_os = "windows")]
52pub mod ether_windows;
53
54#[cfg(target_os = "linux")]
55pub mod wfb;
56
57#[cfg(all(any(target_os = "linux", target_os = "macos"), feature = "bluetooth"))]
58pub mod bluetooth;
59
60// NeighborDiscovery uses AF_PACKET raw sockets, so it is Linux-only.
61// RadioTable is a pure data structure and compiles everywhere.
62#[cfg(target_os = "linux")]
63pub mod neighbor;
64pub mod radio;
65
66#[cfg(target_os = "linux")]
67pub use af_packet::MacAddr;
68#[cfg(target_os = "linux")]
69pub use af_packet::get_interface_mac;
70
71#[cfg(target_os = "linux")]
72pub use ether::NamedEtherFace;
73#[cfg(target_os = "macos")]
74pub use ether_macos::NamedEtherFace;
75#[cfg(target_os = "windows")]
76pub use ether_windows::NamedEtherFace;
77
78#[cfg(target_os = "macos")]
79pub use ether_macos::MulticastEtherFace;
80#[cfg(target_os = "windows")]
81pub use ether_windows::MulticastEtherFace;
82#[cfg(target_os = "linux")]
83pub use multicast_ether::MulticastEtherFace;
84
85#[cfg(target_os = "linux")]
86pub use wfb::WfbFace;
87
88#[cfg(all(any(target_os = "linux", target_os = "macos"), feature = "bluetooth"))]
89pub use bluetooth::BleFace;
90
91#[cfg(target_os = "linux")]
92pub use neighbor::NeighborDiscovery;
93pub use radio::{RadioFaceMetadata, RadioTable};
94
95/// IANA-assigned Ethertype for NDN over Ethernet (IEEE 802.3).
96pub const NDN_ETHERTYPE: u16 = 0x8624;