pub struct BridgeBuilder { /* private fields */ }Expand description
Builder for Bridge.
Creates paired RX+TX handles on two interfaces. By default both sides
inherit a single RingProfile and share promiscuous / qdisc_bypass
flags. Per-direction overrides exist for asymmetric setups (e.g., capture
jumbo on A, retransmit standard MTU on B).
Promiscuous mode and qdisc bypass are enabled by default (optimal for transparent bridging).
Implementations§
Source§impl BridgeBuilder
impl BridgeBuilder
Sourcepub fn interface_a(self, name: &str) -> Self
pub fn interface_a(self, name: &str) -> Self
Set interface A (required).
Sourcepub fn interface_b(self, name: &str) -> Self
pub fn interface_b(self, name: &str) -> Self
Set interface B (required).
Sourcepub fn profile(self, profile: RingProfile) -> Self
pub fn profile(self, profile: RingProfile) -> Self
Set the ring buffer profile for both interfaces. Default: RingProfile::Default.
Sourcepub fn promiscuous(self, enable: bool) -> Self
pub fn promiscuous(self, enable: bool) -> Self
Enable promiscuous mode on both interfaces. Default: true.
Sourcepub fn qdisc_bypass(self, enable: bool) -> Self
pub fn qdisc_bypass(self, enable: bool) -> Self
Bypass qdisc for TX on both interfaces. Default: true.
Sourcepub fn poll_timeout(self, timeout: Duration) -> Self
pub fn poll_timeout(self, timeout: Duration) -> Self
Maximum time the bridge waits in poll(2) between iterations.
Smaller values reduce shutdown latency at the cost of more frequent syscalls when traffic is sparse. Default: 100 ms.
Sourcepub fn a_block_size(self, bytes: usize) -> Self
pub fn a_block_size(self, bytes: usize) -> Self
Override RX block size on interface A. None = inherit from profile.
Sourcepub fn a_block_count(self, n: usize) -> Self
pub fn a_block_count(self, n: usize) -> Self
Override RX block count on interface A.
Sourcepub fn a_frame_size(self, bytes: usize) -> Self
pub fn a_frame_size(self, bytes: usize) -> Self
Override RX frame size on interface A.
Sourcepub fn a_block_timeout_ms(self, ms: u32) -> Self
pub fn a_block_timeout_ms(self, ms: u32) -> Self
Override RX block-retire timeout on interface A.
Sourcepub fn b_block_size(self, bytes: usize) -> Self
pub fn b_block_size(self, bytes: usize) -> Self
Override RX block size on interface B.
Sourcepub fn b_block_count(self, n: usize) -> Self
pub fn b_block_count(self, n: usize) -> Self
Override RX block count on interface B.
Sourcepub fn b_frame_size(self, bytes: usize) -> Self
pub fn b_frame_size(self, bytes: usize) -> Self
Override RX frame size on interface B.
Sourcepub fn b_block_timeout_ms(self, ms: u32) -> Self
pub fn b_block_timeout_ms(self, ms: u32) -> Self
Override RX block-retire timeout on interface B.
Sourcepub fn tx_a_frame_size(self, bytes: usize) -> Self
pub fn tx_a_frame_size(self, bytes: usize) -> Self
Override TX frame size on interface A (B→A direction). None = inherit RX frame_size.
Sourcepub fn tx_b_frame_size(self, bytes: usize) -> Self
pub fn tx_b_frame_size(self, bytes: usize) -> Self
Override TX frame size on interface B (A→B direction). None = inherit RX frame_size.
Sourcepub fn tx_a_frame_count(self, n: usize) -> Self
pub fn tx_a_frame_count(self, n: usize) -> Self
Override TX frame count on interface A.
Sourcepub fn tx_b_frame_count(self, n: usize) -> Self
pub fn tx_b_frame_count(self, n: usize) -> Self
Override TX frame count on interface B.
Sourcepub fn build(self) -> Result<Bridge, Error>
pub fn build(self) -> Result<Bridge, Error>
Validate and create the Bridge.
Creates 4 handles: RX on A, TX on B, RX on B, TX on A.
§Errors
Returns Error::Config if interface names are missing,
Error::PermissionDenied without CAP_NET_RAW, or other
socket/mmap errors.