pub struct TestApi<'a, BT: BindingsTypes>(/* private fields */);Expand description
An API struct for test utilities.
Implementations§
Source§impl<'l, BC> TestApi<'l, BC>where
BC: BindingsContext,
impl<'l, BC> TestApi<'l, BC>where
BC: BindingsContext,
Sourcepub fn join_ip_multicast<A: IpAddress>(
&mut self,
device: &DeviceId<BC>,
multicast_addr: MulticastAddr<A>,
)where
A::Version: IpExt,
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<A::Version, BC>,
BC: IpBindingsContext<A::Version>,
pub fn join_ip_multicast<A: IpAddress>(
&mut self,
device: &DeviceId<BC>,
multicast_addr: MulticastAddr<A>,
)where
A::Version: IpExt,
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<A::Version, BC>,
BC: IpBindingsContext<A::Version>,
Joins the multicast group multicast_addr for device.
Sourcepub fn leave_ip_multicast<A: IpAddress>(
&mut self,
device: &DeviceId<BC>,
multicast_addr: MulticastAddr<A>,
)where
A::Version: IpExt,
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<A::Version, BC>,
BC: IpBindingsContext<A::Version>,
pub fn leave_ip_multicast<A: IpAddress>(
&mut self,
device: &DeviceId<BC>,
multicast_addr: MulticastAddr<A>,
)where
A::Version: IpExt,
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<A::Version, BC>,
BC: IpBindingsContext<A::Version>,
Leaves the multicast group multicast_addr for device.
Sourcepub fn is_in_ip_multicast<A: IpAddress>(
&mut self,
device: &DeviceId<BC>,
addr: MulticastAddr<A>,
) -> boolwhere
A::Version: IpExt,
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<A::Version, BC>,
BC: IpBindingsContext<A::Version>,
pub fn is_in_ip_multicast<A: IpAddress>(
&mut self,
device: &DeviceId<BC>,
addr: MulticastAddr<A>,
) -> boolwhere
A::Version: IpExt,
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<A::Version, BC>,
BC: IpBindingsContext<A::Version>,
Returns whether device is in the multicast group addr.
Sourcepub fn receive_ip_packet<I: Ip, B: BufferMut>(
&mut self,
device: &DeviceId<BC>,
frame_dst: Option<FrameDestination>,
buffer: B,
)
pub fn receive_ip_packet<I: Ip, B: BufferMut>( &mut self, device: &DeviceId<BC>, frame_dst: Option<FrameDestination>, buffer: B, )
Receive an IP packet from a device.
receive_ip_packet injects a packet directly at the IP layer for this
context.
Sourcepub fn receive_ip_packet_with_marks<I: Ip, B: BufferMut>(
&mut self,
device: &DeviceId<BC>,
frame_dst: Option<FrameDestination>,
buffer: B,
marks: Marks,
)
pub fn receive_ip_packet_with_marks<I: Ip, B: BufferMut>( &mut self, device: &DeviceId<BC>, frame_dst: Option<FrameDestination>, buffer: B, marks: Marks, )
Receive an IP packet from a device with given marks.
receive_ip_packet_with_marks injects a packet directly at the IP layer
for this context with the given marks.
Sourcepub fn add_route(
&mut self,
entry: AddableEntryEither<DeviceId<BC>>,
) -> Result<(), AddRouteError>
pub fn add_route( &mut self, entry: AddableEntryEither<DeviceId<BC>>, ) -> Result<(), AddRouteError>
Add a route directly to the forwarding table.
Sourcepub fn set_rules<I: IpExt>(&mut self, rules: Vec<Rule<I, DeviceId<BC>, BC>>)where
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>,
BC: IpBindingsContext<I>,
pub fn set_rules<I: IpExt>(&mut self, rules: Vec<Rule<I, DeviceId<BC>, BC>>)where
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>,
BC: IpBindingsContext<I>,
Install rules, these rules will replace the rules currently installed.
Sourcepub fn resolve_route_with_src_addr<I: IpExt>(
&mut self,
src_ip: IpDeviceAddr<I::Addr>,
dst_ip: Option<RoutableIpAddr<I::Addr>>,
) -> Result<ResolvedRoute<I, DeviceId<BC>>, ResolveRouteError>where
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>,
BC: IpBindingsContext<I>,
pub fn resolve_route_with_src_addr<I: IpExt>(
&mut self,
src_ip: IpDeviceAddr<I::Addr>,
dst_ip: Option<RoutableIpAddr<I::Addr>>,
) -> Result<ResolvedRoute<I, DeviceId<BC>>, ResolveRouteError>where
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>,
BC: IpBindingsContext<I>,
Resolves a route with a given source address.
Sourcepub fn resolve_route_with_marks<I: IpExt>(
&mut self,
dst_ip: Option<RoutableIpAddr<I::Addr>>,
marks: &Marks,
) -> Result<ResolvedRoute<I, DeviceId<BC>>, ResolveRouteError>where
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>,
BC: IpBindingsContext<I>,
pub fn resolve_route_with_marks<I: IpExt>(
&mut self,
dst_ip: Option<RoutableIpAddr<I::Addr>>,
marks: &Marks,
) -> Result<ResolvedRoute<I, DeviceId<BC>>, ResolveRouteError>where
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>,
BC: IpBindingsContext<I>,
Resolves a route with a given mark.
Sourcepub fn del_routes_to_subnet(
&mut self,
subnet: SubnetEither,
) -> Result<(), NotFoundError>
pub fn del_routes_to_subnet( &mut self, subnet: SubnetEither, ) -> Result<(), NotFoundError>
Delete a route from the forwarding table, returning Err if no route
was found to be deleted.
Sourcepub fn del_device_routes(&mut self, device: &DeviceId<BC>)
pub fn del_device_routes(&mut self, device: &DeviceId<BC>)
Deletes all routes targeting device.
Sourcepub fn clear_routes_and_remove_device<D: Into<DeviceId<BC>>>(
&mut self,
device: D,
)
pub fn clear_routes_and_remove_device<D: Into<DeviceId<BC>>>( &mut self, device: D, )
Removes all of the routes through the device, then removes the device.
Sourcepub fn set_ip_device_enabled<I: IpExt>(
&mut self,
device: &DeviceId<BC>,
enabled: bool,
) -> boolwhere
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>,
BC: IpBindingsContext<I>,
pub fn set_ip_device_enabled<I: IpExt>(
&mut self,
device: &DeviceId<BC>,
enabled: bool,
) -> boolwhere
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>,
BC: IpBindingsContext<I>,
Enables or disables the device for IP version I and returns whether it
was enabled before.
Sourcepub fn enable_device(&mut self, device: &DeviceId<BC>)
pub fn enable_device(&mut self, device: &DeviceId<BC>)
Enables device.
Sourcepub fn set_unicast_forwarding_enabled<I: IpExt>(
&mut self,
device: &DeviceId<BC>,
enabled: bool,
)where
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>,
BC: IpBindingsContext<I>,
pub fn set_unicast_forwarding_enabled<I: IpExt>(
&mut self,
device: &DeviceId<BC>,
enabled: bool,
)where
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>,
BC: IpBindingsContext<I>,
Enables or disables IP packet unicast forwarding on device.
Sourcepub fn set_multicast_forwarding_enabled<I: IpExt>(
&mut self,
device: &DeviceId<BC>,
enabled: bool,
)where
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>,
BC: IpBindingsContext<I>,
pub fn set_multicast_forwarding_enabled<I: IpExt>(
&mut self,
device: &DeviceId<BC>,
enabled: bool,
)where
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>,
BC: IpBindingsContext<I>,
Enables or disables IP packet multicast forwarding on device.
Sourcepub fn is_unicast_forwarding_enabled<I: IpExt>(
&mut self,
device: &DeviceId<BC>,
) -> boolwhere
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>,
BC: IpBindingsContext<I>,
pub fn is_unicast_forwarding_enabled<I: IpExt>(
&mut self,
device: &DeviceId<BC>,
) -> boolwhere
for<'macro_lifetime> UnlockedCoreCtx<'macro_lifetime, BC>: CoreContext<I, BC>,
BC: IpBindingsContext<I>,
Returns whether IP packet unicast forwarding is enabled on device.
Sourcepub fn add_loopback(&mut self) -> LoopbackDeviceId<BC>where
<BC as DeviceLayerStateTypes>::DeviceIdentifier: Default,
<BC as DeviceLayerStateTypes>::LoopbackDeviceState: Default,
pub fn add_loopback(&mut self) -> LoopbackDeviceId<BC>where
<BC as DeviceLayerStateTypes>::DeviceIdentifier: Default,
<BC as DeviceLayerStateTypes>::LoopbackDeviceState: Default,
Adds a loopback device with the IPv4/IPv6 loopback addresses assigned.
Source§impl<'a> TestApi<'a, FakeBindingsCtx>
impl<'a> TestApi<'a, FakeBindingsCtx>
Sourcepub fn handle_queued_rx_packets(&mut self) -> bool
pub fn handle_queued_rx_packets(&mut self) -> bool
Handles any pending frames and returns true if any frames that were in the RX queue were processed.
Auto Trait Implementations§
impl<'a, BT> Freeze for TestApi<'a, BT>
impl<'a, BT> RefUnwindSafe for TestApi<'a, BT>where
BT: RefUnwindSafe,
<BT as InstantBindingsTypes>::Instant: RefUnwindSafe,
<BT as IpRoutingBindingsTypes>::RoutingTableId: RefUnwindSafe,
impl<'a, BT> Send for TestApi<'a, BT>where
BT: Send,
<BT as InstantBindingsTypes>::AtomicInstant: Send + Sync,
<BT as MatcherBindingsTypes>::DeviceClass: Send + Sync,
<BT as MatcherBindingsTypes>::BindingsPacketMatcher: Sync + Send,
impl<'a, BT> Sync for TestApi<'a, BT>where
BT: Sync,
<BT as InstantBindingsTypes>::AtomicInstant: Send + Sync,
<BT as MatcherBindingsTypes>::DeviceClass: Send + Sync,
<BT as MatcherBindingsTypes>::BindingsPacketMatcher: Sync + Send,
impl<'a, BT> Unpin for TestApi<'a, BT>
impl<'a, BT> !UnwindSafe for TestApi<'a, BT>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more