netemul

Struct TestInterface

Source
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>

Source

pub fn id(&self) -> u64

Gets the interface identifier.

Source

pub fn endpoint(&self) -> &TestEndpoint<'a>

Returns the endpoint associated with the interface.

Source

pub fn control(&self) -> &Control

Returns the interface’s control handle.

Source

pub async fn get_authorization( &self, ) -> Result<GrantForInterfaceAuthorization, Error>

Returns the authorization token for this interface.

Source

pub fn connect_stack(&self) -> Result<StackProxy, Error>

Connects to fuchsia.net.stack in this interface’s realm.

Source

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.

Source

pub async fn add_subnet_route(&self, subnet: Subnet) -> Result<(), Error>

Add a direct route from the interface to the given subnet.

Source

pub async fn del_subnet_route(&self, subnet: Subnet) -> Result<(), Error>

Delete a direct route from the interface to the given subnet.

Source

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.

Source

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.

Source

pub async fn add_default_route(&self, next_hop: IpAddress) -> Result<(), Error>

Add a default route through the given next_hop.

Source

pub async fn remove_default_route( &self, next_hop: IpAddress, ) -> Result<(), Error>

Remove a default route through the given address.

Source

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.

Source

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.

Source

pub async fn get_addrs( &self, included_addresses: IncludedAddresses, ) -> Result<Vec<Address<AllInterest>>, Error>

Gets the interface’s addresses.

Source

pub async fn get_interface_name(&self) -> Result<String, Error>

Gets the interface’s device name.

Source

pub async fn get_port_class(&self) -> Result<PortClass, Error>

Gets the interface’s port class.

Source

pub async fn mac(&self) -> MacAddress

Gets the interface’s MAC address.

Source

pub async fn start_dhcp<D: DhcpClient>(&self) -> Result<(), Error>

Starts DHCP on this interface.

Source

pub async fn stop_dhcp<D: DhcpClient>(&self) -> Result<(), Error>

Stops DHCP on this interface.

Source

pub async fn add_address(&self, subnet: Subnet) -> Result<(), Error>

Adds an address, waiting until the address assignment state is ASSIGNED.

Source

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.

Source

pub async fn del_address_and_subnet_route( &self, addr_with_prefix: Subnet, ) -> Result<bool, Error>

Removes an address and its corresponding subnet route.

Source

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.

Source

pub async fn set_ipv6_forwarding_enabled( &self, enabled: bool, ) -> Result<(), Error>

Enable/disable IPv6 forwarding on this interface.

Source

pub async fn set_ipv4_forwarding_enabled( &self, enabled: bool, ) -> Result<(), Error>

Enable/disable IPv4 forwarding on this interface.

Source

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.

Source

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.

Source

pub async fn wait_removal(self) -> Result<InterfaceRemovedReason, Error>

Waits for this interface to signal that it’s been removed.

Source

pub async fn set_dad_transmits( &self, dad_transmits: u16, ) -> Result<Option<u16>, Error>

Sets the number of DAD transmits on this interface.

Returns the previous configuration value, if reported by the API.

Source

pub async fn set_temporary_address_generation_enabled( &self, enabled: bool, ) -> Result<(), Error>

Sets whether temporary SLAAC address generation is enabled or disabled on this interface.

Methods from Deref<Target = EndpointProxy>§

Source

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.

Source

pub fn get_config(&self) -> QueryResponseFut<EndpointConfig>

Source

pub fn get_name(&self) -> QueryResponseFut<String>

Gets endpoint name.

Sends link up or down signal

Source

pub fn get_port(&self, port: ServerEnd<PortMarker>) -> Result<(), Error>

Connects to the underlying device port.

Source

pub fn get_proxy_( &self, proxy: ServerEnd<DeviceProxy_Marker>, ) -> Result<(), Error>

Gets a proxy to open requests with zircon ethernet device.

Trait Implementations§

Source§

impl<'a> Debug for TestInterface<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a> Deref for TestInterface<'a>

Source§

type Target = EndpointProxy

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'a> !Freeze for TestInterface<'a>

§

impl<'a> !RefUnwindSafe for TestInterface<'a>

§

impl<'a> Send for TestInterface<'a>

§

impl<'a> Sync for TestInterface<'a>

§

impl<'a> Unpin for TestInterface<'a>

§

impl<'a> !UnwindSafe for TestInterface<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoAny for T
where T: 'static + Send + Sync,

§

fn into_any(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Cast the given object into a dyn std::any::Any.
§

impl<T, U> IntoExt<U> for T
where U: FromExt<T>,

§

fn into_ext(self) -> U

Performs the conversion.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T, U> TryIntoExt<U> for T
where U: TryFromExt<T>,

§

type Error = <U as TryFromExt<T>>::Error

§

fn try_into_ext(self) -> Result<U, <T as TryIntoExt<U>>::Error>

Tries to perform the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<St> WithTag for St

§

fn tagged<T>(self, tag: T) -> Tagged<T, St>

Produce a new stream from this one which yields item tupled with a constant tag