fn compute_ipv6_cached_info<D: EventDispatcher>(
    ctx: &Ctx<D>,
    defn: &IpSockDefinition<Ipv6>,
) -> Result<CachedInfo<Ipv6, DeviceId>, IpSockUnroutableError> {
    super::lookup_route(ctx, 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 crate::device::get_ip_addr_state(ctx, dst.device, &defn.local_ip)
                .map_or(true, |state| state.is_tentative())
            {
                return Err(IpSockUnroutableError::LocalAddrNotAssigned);
            }

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

            Ok(CachedInfo { builder, device: dst.device, next_hop: dst.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<D: EventDispatcher>(
    ctx: &Ctx<D>,
    defn: &IpSockDefinition<Ipv6>,
) -> Result<CachedInfo<Ipv6, DeviceId>, IpSockUnroutableError> {
    super::lookup_route(ctx, 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 crate::device::get_ip_addr_state(ctx, dst.device, &defn.local_ip)
                .map_or(true, |state| state.is_tentative())
            {
                return Err(IpSockUnroutableError::LocalAddrNotAssigned);
            }
            let mut builder =
                Ipv6PacketBuilder::new(defn.local_ip, defn.remote_ip, defn.hop_limit, defn.proto);
            builder.flowlabel(defn.per_proto_data.flow_label);
            Ok(CachedInfo { builder, device: dst.device, next_hop: dst.next_hop })
        })
}
fn compute_ipv6_cached_info < D : EventDispatcher > ( ctx : & Ctx < D > , defn : & IpSockDefinition < Ipv6 > , ) -> Result < CachedInfo < Ipv6 , DeviceId > , IpSockUnroutableError > { super :: lookup_route ( ctx , 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 crate :: device :: get_ip_addr_state ( ctx , dst . device , & defn . local_ip ) . map_or ( true , | state | state . is_tentative ( ) ) { return Err ( IpSockUnroutableError :: LocalAddrNotAssigned ) ; } let mut builder = Ipv6PacketBuilder :: new ( defn . local_ip , defn . remote_ip , defn . hop_limit , defn . proto ) ; builder . flowlabel ( defn . per_proto_data . flow_label ) ; Ok ( CachedInfo { builder , device : dst . device , next_hop : dst . 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
&Ctx<D>
defn
&IpSockDefinition<Ipv6>
ctx
&Ctx<D>
defn
&IpSockDefinition<Ipv6>