pub struct DeviceIpApi<I: Ip, C>(/* private fields */);
Expand description
Provides an API for dealing with devices at the IP layer, aka interfaces.
Implementations§
Source§impl<I, C> DeviceIpApi<I, C>where
I: IpDeviceIpExt,
C: ContextPair,
C::CoreContext: IpDeviceConfigurationContext<I, C::BindingsContext> + IpDeviceConfigurationHandler<I, C::BindingsContext> + IpRoutingDeviceContext<I>,
C::BindingsContext: IpDeviceBindingsContext<I, <C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId>,
impl<I, C> DeviceIpApi<I, C>where
I: IpDeviceIpExt,
C: ContextPair,
C::CoreContext: IpDeviceConfigurationContext<I, C::BindingsContext> + IpDeviceConfigurationHandler<I, C::BindingsContext> + IpRoutingDeviceContext<I>,
C::BindingsContext: IpDeviceBindingsContext<I, <C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId>,
Sourcepub fn add_ip_addr_subnet(
&mut self,
device: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId,
addr_subnet: AddrSubnet<I::Addr>,
) -> Result<(), AddIpAddrSubnetError>
pub fn add_ip_addr_subnet( &mut self, device: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId, addr_subnet: AddrSubnet<I::Addr>, ) -> Result<(), AddIpAddrSubnetError>
Like DeviceIpApi::add_ip_addr_subnet_with_config
with a default
address configuration.
Sourcepub fn add_ip_addr_subnet_with_config(
&mut self,
device: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId,
addr_subnet: AddrSubnet<I::Addr>,
addr_config: I::ManualAddressConfig<<C::BindingsContext as InstantBindingsTypes>::Instant>,
) -> Result<(), AddIpAddrSubnetError>
pub fn add_ip_addr_subnet_with_config( &mut self, device: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId, addr_subnet: AddrSubnet<I::Addr>, addr_config: I::ManualAddressConfig<<C::BindingsContext as InstantBindingsTypes>::Instant>, ) -> Result<(), AddIpAddrSubnetError>
Adds an IP address and associated subnet to this device.
If Duplicate Address Detection (DAD) is enabled, begins performing DAD.
For IPv6, this function also joins the solicited-node multicast group.
Sourcepub fn del_ip_addr(
&mut self,
device: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId,
addr: SpecifiedAddr<I::Addr>,
) -> Result<RemoveResourceResultWithContext<AddrSubnet<I::Addr>, C::BindingsContext>, NotFoundError>
pub fn del_ip_addr( &mut self, device: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId, addr: SpecifiedAddr<I::Addr>, ) -> Result<RemoveResourceResultWithContext<AddrSubnet<I::Addr>, C::BindingsContext>, NotFoundError>
Delete an IP address on a device.
Sourcepub fn new_configuration_update<'a>(
&mut self,
device_id: &'a <C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId,
config: I::ConfigurationUpdate,
) -> Result<PendingIpDeviceConfigurationUpdate<'a, I, <C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId>, UpdateIpConfigurationError>
pub fn new_configuration_update<'a>( &mut self, device_id: &'a <C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId, config: I::ConfigurationUpdate, ) -> Result<PendingIpDeviceConfigurationUpdate<'a, I, <C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId>, UpdateIpConfigurationError>
Updates the IP configuration for a device.
Each field in [Ipv4DeviceConfigurationUpdate
] or
[Ipv6DeviceConfigurationUpdate
] represents an optionally updateable
configuration. If the field has a Some(_)
value, then an attempt will
be made to update that configuration on the device. A None
value
indicates that an update for the configuration is not requested.
Note that some fields have the type Option<Option<T>>
. In this case,
as long as the outer Option
is Some
, then an attempt will be made to
update the configuration.
This function returns a [PendingDeviceConfigurationUpdate
] which is
validated and [DeviceIpApi::apply
] can be called to apply the
configuration.
Sourcepub fn apply_configuration(
&mut self,
config: PendingIpDeviceConfigurationUpdate<'_, I, <C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId>,
) -> I::ConfigurationUpdate
pub fn apply_configuration( &mut self, config: PendingIpDeviceConfigurationUpdate<'_, I, <C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId>, ) -> I::ConfigurationUpdate
Applies a pre-validated pending configuration to the device.
Returns a configuration update with the previous value for all the
requested fields in config
.
Sourcepub fn update_configuration(
&mut self,
device_id: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId,
config: I::ConfigurationUpdate,
) -> Result<I::ConfigurationUpdate, UpdateIpConfigurationError>
pub fn update_configuration( &mut self, device_id: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId, config: I::ConfigurationUpdate, ) -> Result<I::ConfigurationUpdate, UpdateIpConfigurationError>
A shortcut for DeviceIpApi::new_configuration_update
followed by
DeviceIpApi::apply_configuration
.
Sourcepub fn get_configuration(
&mut self,
device_id: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId,
) -> IpDeviceConfigurationAndFlags<I>
pub fn get_configuration( &mut self, device_id: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId, ) -> IpDeviceConfigurationAndFlags<I>
Gets the IP configuration and flags for a device_id
.
Sourcepub fn get_routing_metric(
&mut self,
device_id: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId,
) -> RawMetric
pub fn get_routing_metric( &mut self, device_id: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId, ) -> RawMetric
Gets the routing metric for the device.
Sourcepub fn set_addr_properties(
&mut self,
device: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId,
address: SpecifiedAddr<I::Addr>,
next_properties: CommonAddressProperties<<C::BindingsContext as InstantBindingsTypes>::Instant>,
) -> Result<(), SetIpAddressPropertiesError>
pub fn set_addr_properties( &mut self, device: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId, address: SpecifiedAddr<I::Addr>, next_properties: CommonAddressProperties<<C::BindingsContext as InstantBindingsTypes>::Instant>, ) -> Result<(), SetIpAddressPropertiesError>
Sets properties on an IP address.
Sourcepub fn for_each_assigned_ip_addr_subnet<F: FnMut(AddrSubnet<I::Addr>)>(
&mut self,
device: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId,
f: F,
)
pub fn for_each_assigned_ip_addr_subnet<F: FnMut(AddrSubnet<I::Addr>)>( &mut self, device: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId, f: F, )
Calls f
for each assigned IP address on the device.
Sourcepub fn get_assigned_ip_addr_subnets(
&mut self,
device: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId,
) -> Vec<AddrSubnet<I::Addr>>
pub fn get_assigned_ip_addr_subnets( &mut self, device: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId, ) -> Vec<AddrSubnet<I::Addr>>
Shorthand for [DeviceIpApi::Collect_assigned_ip_addr_subnets
],
returning the addresses in a Vec
.
Sourcepub fn inspect<N: Inspector>(
&mut self,
device: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId,
inspector: &mut N,
)where
C::CoreContext: GmpStateContext<I, C::BindingsContext>,
pub fn inspect<N: Inspector>(
&mut self,
device: &<C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId,
inspector: &mut N,
)where
C::CoreContext: GmpStateContext<I, C::BindingsContext>,
Exports IP state for device
into inspector
.