pub struct TestInterface<'a> { /* private fields */ }
Expand description
A TestEndpoint
that is installed in a realm’s Netstack.
Note that a TestInterface
adds to the reference count of the underlying
realm of its TestRealm
. That is, a TestInterface
that outlives the
TestRealm
it created is sufficient to keep the underlying realm alive.
Implementations§
Source§impl<'a> TestInterface<'a>
impl<'a> TestInterface<'a>
Sourcepub fn endpoint(&self) -> &TestEndpoint<'a>
pub fn endpoint(&self) -> &TestEndpoint<'a>
Returns the endpoint associated with the interface.
Returns the authorization token for this interface.
Sourcepub fn connect_stack(&self) -> Result<StackProxy, Error>
pub fn connect_stack(&self) -> Result<StackProxy, Error>
Connects to fuchsia.net.stack in this interface’s realm.
Sourcepub async fn add_route_either(
&self,
destination: Subnet,
next_hop: Option<IpAddress>,
metric: SpecifiedMetric,
) -> Result<bool, Error>
pub async fn add_route_either( &self, destination: Subnet, next_hop: Option<IpAddress>, metric: SpecifiedMetric, ) -> Result<bool, Error>
Installs a route in the realm’s netstack’s global route table with self
as the outgoing
interface with the given destination
and metric
, optionally via the next_hop
.
Returns whether the route was newly added to the stack. Returns Err
if destination
and
next_hop
don’t share the same IP version.
Sourcepub async fn add_subnet_route(&self, subnet: Subnet) -> Result<(), Error>
pub async fn add_subnet_route(&self, subnet: Subnet) -> Result<(), Error>
Add a direct route from the interface to the given subnet.
Sourcepub async fn del_subnet_route(&self, subnet: Subnet) -> Result<(), Error>
pub async fn del_subnet_route(&self, subnet: Subnet) -> Result<(), Error>
Delete a direct route from the interface to the given subnet.
Sourcepub async fn add_default_route_with_metric(
&self,
next_hop: IpAddress,
metric: SpecifiedMetric,
) -> Result<(), Error>
pub async fn add_default_route_with_metric( &self, next_hop: IpAddress, metric: SpecifiedMetric, ) -> Result<(), Error>
Add a default route through the given next_hop
with the given metric
.
Sourcepub async fn add_default_route_with_explicit_metric(
&self,
next_hop: IpAddress,
metric: u32,
) -> Result<(), Error>
pub async fn add_default_route_with_explicit_metric( &self, next_hop: IpAddress, metric: u32, ) -> Result<(), Error>
Add a default route through the given next_hop
with the given metric
.
Sourcepub async fn add_default_route(&self, next_hop: IpAddress) -> Result<(), Error>
pub async fn add_default_route(&self, next_hop: IpAddress) -> Result<(), Error>
Add a default route through the given next_hop
.
Sourcepub async fn remove_default_route(
&self,
next_hop: IpAddress,
) -> Result<(), Error>
pub async fn remove_default_route( &self, next_hop: IpAddress, ) -> Result<(), Error>
Remove a default route through the given address.
Sourcepub async fn add_gateway_route(
&self,
destination: Subnet,
next_hop: IpAddress,
) -> Result<(), Error>
pub async fn add_gateway_route( &self, destination: Subnet, next_hop: IpAddress, ) -> Result<(), Error>
Add a route to the given destination
subnet via the given next_hop
.
Sourcepub async fn create_authenticated_global_route_set<I: FidlRouteIpExt + FidlRouteAdminIpExt>(
&self,
) -> Result<<I::RouteSetMarker as ProtocolMarker>::Proxy, Error>
pub async fn create_authenticated_global_route_set<I: FidlRouteIpExt + FidlRouteAdminIpExt>( &self, ) -> Result<<I::RouteSetMarker as ProtocolMarker>::Proxy, Error>
Create a root route set authenticated to manage routes through this interface.
Sourcepub async fn get_addrs(
&self,
included_addresses: IncludedAddresses,
) -> Result<Vec<Address<AllInterest>>, Error>
pub async fn get_addrs( &self, included_addresses: IncludedAddresses, ) -> Result<Vec<Address<AllInterest>>, Error>
Gets the interface’s addresses.
Sourcepub async fn get_interface_name(&self) -> Result<String, Error>
pub async fn get_interface_name(&self) -> Result<String, Error>
Gets the interface’s device name.
Sourcepub async fn get_port_class(&self) -> Result<PortClass, Error>
pub async fn get_port_class(&self) -> Result<PortClass, Error>
Gets the interface’s port class.
Sourcepub async fn mac(&self) -> MacAddress
pub async fn mac(&self) -> MacAddress
Gets the interface’s MAC address.
Sourcepub async fn start_dhcp<D: DhcpClient>(&self) -> Result<(), Error>
pub async fn start_dhcp<D: DhcpClient>(&self) -> Result<(), Error>
Starts DHCP on this interface.
Sourcepub async fn stop_dhcp<D: DhcpClient>(&self) -> Result<(), Error>
pub async fn stop_dhcp<D: DhcpClient>(&self) -> Result<(), Error>
Stops DHCP on this interface.
Sourcepub async fn add_address(&self, subnet: Subnet) -> Result<(), Error>
pub async fn add_address(&self, subnet: Subnet) -> Result<(), Error>
Adds an address, waiting until the address assignment state is
ASSIGNED
.
Sourcepub async fn add_address_and_subnet_route(
&self,
subnet: Subnet,
) -> Result<(), Error>
pub async fn add_address_and_subnet_route( &self, subnet: Subnet, ) -> Result<(), Error>
Adds an address and a subnet route, waiting until the address assignment
state is ASSIGNED
.
Sourcepub async fn del_address_and_subnet_route(
&self,
addr_with_prefix: Subnet,
) -> Result<bool, Error>
pub async fn del_address_and_subnet_route( &self, addr_with_prefix: Subnet, ) -> Result<bool, Error>
Removes an address and its corresponding subnet route.
Sourcepub async fn remove_ipv6_linklocal_addresses(
&self,
) -> Result<Vec<Address<AllInterest>>, Error>
pub async fn remove_ipv6_linklocal_addresses( &self, ) -> Result<Vec<Address<AllInterest>>, Error>
Removes all IPv6 LinkLocal addresses on the interface.
Useful to purge the interface of autogenerated SLAAC addresses.
Sourcepub async fn set_ipv6_forwarding_enabled(
&self,
enabled: bool,
) -> Result<(), Error>
pub async fn set_ipv6_forwarding_enabled( &self, enabled: bool, ) -> Result<(), Error>
Enable/disable IPv6 forwarding on this interface.
Sourcepub async fn set_ipv4_forwarding_enabled(
&self,
enabled: bool,
) -> Result<(), Error>
pub async fn set_ipv4_forwarding_enabled( &self, enabled: bool, ) -> Result<(), Error>
Enable/disable IPv4 forwarding on this interface.
Sourcepub async fn remove(
self,
) -> Result<(EndpointProxy, Option<DeviceControlProxy>), Error>
pub async fn remove( self, ) -> Result<(EndpointProxy, Option<DeviceControlProxy>), Error>
Consumes this TestInterface
and removes the associated interface
in the Netstack, returning the device lifetime-carrying channels.
Sourcepub fn remove_device(self) -> (Control, Option<DeviceControlProxy>)
pub fn remove_device(self) -> (Control, Option<DeviceControlProxy>)
Consumes this TestInterface
and removes the underlying device. The
Netstack will implicitly remove the interface and clients can expect to
observe a PEER_CLOSED
event on the returned control channel.
Sourcepub async fn wait_removal(self) -> Result<InterfaceRemovedReason, Error>
pub async fn wait_removal(self) -> Result<InterfaceRemovedReason, Error>
Waits for this interface to signal that it’s been removed.
Methods from Deref<Target = EndpointProxy>§
Sourcepub fn take_event_stream(&self) -> EndpointEventStream
pub fn take_event_stream(&self) -> EndpointEventStream
Get a Stream of events from the remote end of the protocol.
§Panics
Panics if the event stream was already taken.
pub fn get_config(&self) -> QueryResponseFut<EndpointConfig>
Sourcepub fn set_link_up(&self, up: bool) -> QueryResponseFut<()>
pub fn set_link_up(&self, up: bool) -> QueryResponseFut<()>
Sends link up or down signal
Sourcepub fn get_port(&self, port: ServerEnd<PortMarker>) -> Result<(), Error>
pub fn get_port(&self, port: ServerEnd<PortMarker>) -> Result<(), Error>
Connects to the underlying device port.
Sourcepub fn get_proxy_(
&self,
proxy: ServerEnd<DeviceProxy_Marker>,
) -> Result<(), Error>
pub fn get_proxy_( &self, proxy: ServerEnd<DeviceProxy_Marker>, ) -> Result<(), Error>
Gets a proxy to open requests with zircon ethernet device.