fn compute_ipv6_cached_info<C: IpSocketContext<Ipv6>>(
    ctx: &C,
    defn: &IpSockDefinition<Ipv6>,
) -> Result<CachedInfo<Ipv6, C::DeviceId>, IpSockUnroutableError> {
    ctx.lookup_route(defn.remote_ip).ok_or(IpSockUnroutableError::NoRouteToRemoteAddr).and_then(
        |dst| {
            // TODO(joshlf):
            // - Allow the specified local IP to be the local IP of a
            //   different device so long as we're operating in the weak
            //   host model.
            // - What about when the socket is bound to a device? How does
            //   that affect things?
            if ctx
                .get_ip_device_state(dst.device)
                .find_addr(&defn.local_ip)
                .map_or(true, |entry| entry.state.is_tentative())
            {
                return Err(IpSockUnroutableError::LocalAddrNotAssigned);
            }

            let next_hop = if ctx
                .get_ip_device_state(dst.device)
                .iter_assigned_ipv6_addrs()
                .any(|addr_sub| addr_sub.addr() == defn.remote_ip)
            {
                NextHop::Local
            } else {
                NextHop::Remote(dst.next_hop)
            };

            let builder =
                Ipv6PacketBuilder::new(defn.local_ip, defn.remote_ip, defn.hop_limit, defn.proto);

            Ok(CachedInfo { builder, device: dst.device, next_hop })
        },
    )
}
/// Computes the [`CachedInfo`] for an IPv6 socket based on its definition.
///
/// Returns an error if the socket is currently unroutable.
Computes the [`CachedInfo`] for an IPv6 socket based on its definition.
Returns an error if the socket is currently unroutable.
Computes the [ ` CachedInfo ` ] for an IPv6 socket based on its definition . Returns an error if the socket is currently unroutable .
fn compute_ipv6_cached_info<C: IpSocketContext<Ipv6>>(
    ctx: &C,
    defn: &IpSockDefinition<Ipv6>,
) -> Result<CachedInfo<Ipv6, C::DeviceId>, IpSockUnroutableError> {
    ctx.lookup_route(defn.remote_ip).ok_or(IpSockUnroutableError::NoRouteToRemoteAddr).and_then(
        |dst| {
            // TODO(joshlf):
            // - Allow the specified local IP to be the local IP of a
            //   different device so long as we're operating in the weak
            //   host model.
            // - What about when the socket is bound to a device? How does
            //   that affect things?
            if ctx
                .get_ip_device_state(dst.device)
                .find_addr(&defn.local_ip)
                .map_or(true, |entry| entry.state.is_tentative())
            {
                return Err(IpSockUnroutableError::LocalAddrNotAssigned);
            }
            let next_hop = if ctx
                .get_ip_device_state(dst.device)
                .iter_assigned_ipv6_addrs()
                .any(|addr_sub| addr_sub.addr() == defn.remote_ip)
            {
                NextHop::Local
            } else {
                NextHop::Remote(dst.next_hop)
            };
            let builder =
                Ipv6PacketBuilder::new(defn.local_ip, defn.remote_ip, defn.hop_limit, defn.proto);
            Ok(CachedInfo { builder, device: dst.device, next_hop })
        },
    )
}
fn compute_ipv6_cached_info < C : IpSocketContext < Ipv6 > > ( ctx : & C , defn : & IpSockDefinition < Ipv6 > , ) -> Result < CachedInfo < Ipv6 , C :: DeviceId > , IpSockUnroutableError > { ctx . lookup_route ( defn . remote_ip ) . ok_or ( IpSockUnroutableError :: NoRouteToRemoteAddr ) . and_then ( | dst | { // TODO(joshlf): // - Allow the specified local IP to be the local IP of a //   different device so long as we're operating in the weak //   host model. // - What about when the socket is bound to a device? How does //   that affect things? if ctx . get_ip_device_state ( dst . device ) . find_addr ( & defn . local_ip ) . map_or ( true , | entry | entry . state . is_tentative ( ) ) { return Err ( IpSockUnroutableError :: LocalAddrNotAssigned ) ; } let next_hop = if ctx . get_ip_device_state ( dst . device ) . iter_assigned_ipv6_addrs ( ) . any ( | addr_sub | addr_sub . addr ( ) == defn . remote_ip ) { NextHop :: Local } else { NextHop :: Remote ( dst . next_hop ) } ; let builder = Ipv6PacketBuilder :: new ( defn . local_ip , defn . remote_ip , defn . hop_limit , defn . proto ) ; Ok ( CachedInfo { builder , device : dst . device , next_hop } ) } , ) }
Computes the [`CachedInfo`] for an IPv6 socket based on its definition.
Computes the [ ` CachedInfo ` ] for an IPv6 socket based on its definition .
ctx
&C
defn
&IpSockDefinition<Ipv6>
ctx
&C
defn
&IpSockDefinition<Ipv6>