Trait FilterIpContext

Source
pub trait FilterIpContext<I: IpExt, BT: FilterBindingsTypes>: IpDeviceAddressIdContext<I, DeviceId: InterfaceProperties<BT::DeviceClass>> {
    type NatCtx<'a>: NatContext<I, BT, DeviceId = Self::DeviceId, WeakAddressId = Self::WeakAddressId>;

    // Required method
    fn with_filter_state_and_nat_ctx<O, F: FnOnce(&State<I, Self::WeakAddressId, BT>, &mut Self::NatCtx<'_>) -> O>(
        &mut self,
        cb: F,
    ) -> O;

    // Provided method
    fn with_filter_state<O, F: FnOnce(&State<I, Self::WeakAddressId, BT>) -> O>(
        &mut self,
        cb: F,
    ) -> O { ... }
}
Expand description

The IP version-specific execution context for packet filtering.

This trait exists to abstract over access to the filtering state. It is useful to implement filtering logic in terms of this trait, as opposed to, for example, crate::logic::FilterHandler methods taking the state directly as an argument, because it allows Netstack3 Core to use lock ordering types to enforce that filtering state is only acquired at or before a given lock level, while keeping test code free of locking concerns.

Required Associated Types§

Source

type NatCtx<'a>: NatContext<I, BT, DeviceId = Self::DeviceId, WeakAddressId = Self::WeakAddressId>

The execution context that allows the filtering engine to perform Network Address Translation (NAT).

Required Methods§

Source

fn with_filter_state_and_nat_ctx<O, F: FnOnce(&State<I, Self::WeakAddressId, BT>, &mut Self::NatCtx<'_>) -> O>( &mut self, cb: F, ) -> O

Calls the function with a reference to filtering state and the NAT context.

Provided Methods§

Source

fn with_filter_state<O, F: FnOnce(&State<I, Self::WeakAddressId, BT>) -> O>( &mut self, cb: F, ) -> O

Calls the function with a reference to filtering state.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

impl<BC: BindingsContext, L: LockBefore<FilterState<Ipv4>>> FilterIpContext<Ipv4, BC> for CoreCtx<'_, BC, L>

impl<BC: BindingsContext, L: LockBefore<FilterState<Ipv6>>> FilterIpContext<Ipv6, BC> for CoreCtx<'_, BC, L>