fn compute_ipv4_cached_info<D: EventDispatcher>(
    ctx: &Ctx<D>,
    defn: &IpSockDefinition<Ipv4>,
) -> Result<CachedInfo<Ipv4, DeviceId>, IpSockUnroutableError> {
    super::lookup_route(ctx, defn.remote_ip)
        .ok_or(IpSockUnroutableError::NoRouteToRemoteAddr)
        .and_then(|dst| {
            if !crate::device::get_assigned_ip_addr_subnets::<_, Ipv4Addr>(ctx, dst.device)
                .any(|addr_sub| defn.local_ip == addr_sub.addr())
            {
                return Err(IpSockUnroutableError::LocalAddrNotAssigned);
            }

            Ok(CachedInfo {
                builder: Ipv4PacketBuilder::new(
                    defn.local_ip,
                    defn.remote_ip,
                    defn.hop_limit,
                    defn.proto,
                ),
                device: dst.device,
                next_hop: dst.next_hop,
            })
        })
}
/// Computes the [`CachedInfo`] for an IPv4 socket based on its definition.
///
/// Returns an error if the socket is currently unroutable.
Computes the [`CachedInfo`] for an IPv4 socket based on its definition.
Returns an error if the socket is currently unroutable.
Computes the [ ` CachedInfo ` ] for an IPv4 socket based on its definition . Returns an error if the socket is currently unroutable .
fn compute_ipv4_cached_info<D: EventDispatcher>(
    ctx: &Ctx<D>,
    defn: &IpSockDefinition<Ipv4>,
) -> Result<CachedInfo<Ipv4, DeviceId>, IpSockUnroutableError> {
    super::lookup_route(ctx, defn.remote_ip)
        .ok_or(IpSockUnroutableError::NoRouteToRemoteAddr)
        .and_then(|dst| {
            if !crate::device::get_assigned_ip_addr_subnets::<_, Ipv4Addr>(ctx, dst.device)
                .any(|addr_sub| defn.local_ip == addr_sub.addr())
            {
                return Err(IpSockUnroutableError::LocalAddrNotAssigned);
            }
            Ok(CachedInfo {
                builder: Ipv4PacketBuilder::new(
                    defn.local_ip,
                    defn.remote_ip,
                    defn.hop_limit,
                    defn.proto,
                ),
                device: dst.device,
                next_hop: dst.next_hop,
            })
        })
}
fn compute_ipv4_cached_info < D : EventDispatcher > ( ctx : & Ctx < D > , defn : & IpSockDefinition < Ipv4 > , ) -> Result < CachedInfo < Ipv4 , DeviceId > , IpSockUnroutableError > { super :: lookup_route ( ctx , defn . remote_ip ) . ok_or ( IpSockUnroutableError :: NoRouteToRemoteAddr ) . and_then ( | dst | { if ! crate :: device :: get_assigned_ip_addr_subnets :: < _ , Ipv4Addr > ( ctx , dst . device ) . any ( | addr_sub | defn . local_ip == addr_sub . addr ( ) ) { return Err ( IpSockUnroutableError :: LocalAddrNotAssigned ) ; } Ok ( CachedInfo { builder : Ipv4PacketBuilder :: new ( defn . local_ip , defn . remote_ip , defn . hop_limit , defn . proto , ) , device : dst . device , next_hop : dst . next_hop , } ) } ) }
Computes the [`CachedInfo`] for an IPv4 socket based on its definition.
Computes the [ ` CachedInfo ` ] for an IPv4 socket based on its definition .
ctx
&Ctx<D>
defn
&IpSockDefinition<Ipv4>
ctx
&Ctx<D>
defn
&IpSockDefinition<Ipv4>