ndn_faces/l2/wfb.rs
1use bytes::Bytes;
2use ndn_transport::{Face, FaceError, FaceId, FaceKind};
3
4/// NDN face over Wifibroadcast NG (wfb-ng).
5///
6/// wfb-ng uses 802.11 monitor mode with raw frame injection to implement a
7/// **unidirectional broadcast link** with FEC, discarding the 802.11 MAC
8/// entirely (no association, ACK, or CSMA/CA).
9///
10/// Because wfb-ng links are inherently unidirectional, this face is paired
11/// with a complementary face via `FacePairTable` in the engine dispatcher:
12/// when Data needs to return on a wfb-ng rx face, the dispatcher redirects it
13/// to the paired tx face.
14pub struct WfbFace {
15 id: FaceId,
16 direction: WfbDirection,
17}
18
19#[derive(Clone, Copy, Debug, PartialEq, Eq)]
20pub enum WfbDirection {
21 /// Receive-only (downlink from air unit to ground station).
22 Rx,
23 /// Transmit-only (uplink from ground station to air unit).
24 Tx,
25}
26
27impl WfbFace {
28 pub fn new(id: FaceId, direction: WfbDirection) -> Self {
29 Self { id, direction }
30 }
31}
32
33impl Face for WfbFace {
34 fn id(&self) -> FaceId {
35 self.id
36 }
37 fn kind(&self) -> FaceKind {
38 FaceKind::Wfb
39 }
40
41 async fn recv(&self) -> Result<Bytes, FaceError> {
42 match self.direction {
43 WfbDirection::Rx => Err(FaceError::Closed), // placeholder — monitor mode capture
44 WfbDirection::Tx => futures_pending().await,
45 }
46 }
47
48 async fn send(&self, _pkt: Bytes) -> Result<(), FaceError> {
49 match self.direction {
50 WfbDirection::Tx => Err(FaceError::Closed), // placeholder — raw frame injection
51 WfbDirection::Rx => Err(FaceError::Closed), // tx not supported on rx face
52 }
53 }
54}
55
56/// Never resolves — used to park the recv task on a tx-only face.
57async fn futures_pending() -> Result<Bytes, FaceError> {
58 std::future::pending::<()>().await;
59 unreachable!()
60}