// Should we deliver this IPv4 packet locally?
// deliver returns true if:
// - dst_ip is equal to the address set on the device
// - dst_ip is equal to the broadcast address of the subnet set on the device
// - dst_ip is equal to the limited broadcast address
// - dst_ip is equal to a mutlicast group that `device` joined
Should we deliver this IPv4 packet locally.
deliver returns true if:
dst_ip is equal to the address set on the device
dst_ip is equal to the broadcast address of the subnet set on the device
dst_ip is equal to the limited broadcast address
dst_ip is equal to a mutlicast group that `device` joined
Should we deliver this IPv4 packet locally . deliver returns true if : dst_ip is equal to the address set on the device dst_ip is equal to the broadcast address of the subnet set on the device dst_ip is equal to the limited broadcast address dst_ip is equal to a mutlicast group that ` device ` joined
fn deliver_ipv4<D: EventDispatcher>(
    ctx: &mut Ctx<D>,
    device: DeviceId,
    dst_ip: SpecifiedAddr<Ipv4Addr>,
) -> bool {
    // TODO(joshlf):
    // - This implements a strict host model (in which we only accept packets
    //   which are addressed to the device over which they were received). This
    //   is the easiest to implement for the time being, but we should actually
    //   put real thought into what our host model should be (fxbug.dev/20852).
    let dst_ip = dst_ip.get();
    crate::device::get_assigned_ip_addr_subnets::<_, Ipv4Addr>(ctx, device)
        .by_ref()
        .map(AddrSubnet::addr_subnet)
        .any(|(addr, subnet)| dst_ip == addr.get() || dst_ip == subnet.broadcast())
        || dst_ip.is_limited_broadcast()
        || MulticastAddr::new(dst_ip)
            .map_or(false, |a| crate::device::is_in_ip_multicast(ctx, device, a))
}
fn deliver_ipv4 < D : EventDispatcher > ( ctx : & mut Ctx < D > , device : DeviceId , dst_ip : SpecifiedAddr < Ipv4Addr > , ) -> bool { // TODO(joshlf): // - This implements a strict host model (in which we only accept packets //   which are addressed to the device over which they were received). This //   is the easiest to implement for the time being, but we should actually //   put real thought into what our host model should be (fxbug.dev/20852). let dst_ip = dst_ip . get ( ) ; crate :: device :: get_assigned_ip_addr_subnets :: < _ , Ipv4Addr > ( ctx , device ) . by_ref ( ) . map ( AddrSubnet :: addr_subnet ) . any ( | ( addr , subnet ) | dst_ip == addr . get ( ) || dst_ip == subnet . broadcast ( ) ) || dst_ip . is_limited_broadcast ( ) || MulticastAddr :: new ( dst_ip ) . map_or ( false , | a | crate :: device :: is_in_ip_multicast ( ctx , device , a ) ) }
Should we deliver this IPv4 packet locally?
Should we deliver this IPv4 packet locally?
ctx
&mut Ctx<D>
device
DeviceId
dst_ip
SpecifiedAddr<Ipv4Addr>