pub struct NatTable {
pub host_ip: u32,
pub port_mappings: Vec<NatPortMapping>,
pub masquerade_enabled: bool,
}Expand description
NAT masquerade table for outbound SNAT and inbound port forwarding.
Fields§
§host_ip: u32Host external IP address.
port_mappings: Vec<NatPortMapping>Port mappings for inbound (DNAT).
masquerade_enabled: boolWhether SNAT masquerade is enabled.
Implementations§
Source§impl NatTable
impl NatTable
pub fn new(host_ip: u32) -> Self
Sourcepub fn enable_masquerade(&mut self)
pub fn enable_masquerade(&mut self)
Enable SNAT masquerade for outbound traffic.
Sourcepub fn add_port_mapping(
&mut self,
mapping: NatPortMapping,
) -> Result<(), KernelError>
pub fn add_port_mapping( &mut self, mapping: NatPortMapping, ) -> Result<(), KernelError>
Add a port mapping for inbound traffic.
Sourcepub fn remove_port_mapping(&mut self, external_port: u16, protocol: u8) -> bool
pub fn remove_port_mapping(&mut self, external_port: u16, protocol: u8) -> bool
Remove a port mapping.
Sourcepub fn lookup_inbound(
&self,
external_port: u16,
protocol: u8,
) -> Option<&NatPortMapping>
pub fn lookup_inbound( &self, external_port: u16, protocol: u8, ) -> Option<&NatPortMapping>
Look up a port mapping for inbound traffic.
Sourcepub fn snat_rewrite(&self, _src_ip: u32) -> Option<u32>
pub fn snat_rewrite(&self, _src_ip: u32) -> Option<u32>
Apply SNAT: rewrite source IP to host IP for outbound packets.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NatTable
impl RefUnwindSafe for NatTable
impl Send for NatTable
impl Sync for NatTable
impl Unpin for NatTable
impl UnwindSafe for NatTable
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)