/// Should we send an ICMP response?
///
/// `should_send_icmp_error` implements the logic described in RFC 1122 section
/// 3.2.2. It decides whether, upon receiving an incoming packet with the given
/// parameters, we should send an ICMP response or not. In particular, we do not
/// send an ICMP response if we've received:
/// - a packet destined to a broadcast or multicast address
/// - a packet sent in a link-layer broadcast
/// - a non-initial fragment
/// - a packet whose source address does not define a single host (a
///   zero/unspecified address, a loopback address, a broadcast address, a
///   multicast address, or a Class E address)
///
/// Note that `should_send_icmp_error` does NOT check whether the incoming
/// packet contained an ICMP error message. This is because that check is
/// unnecessary for some ICMP error conditions. The ICMP error message check can
/// be performed separately with `is_icmp_error_message`.
Should we send an ICMP response.
`should_send_icmp_error` implements the logic described in RFC 1122 section
3.2.2. It decides whether, upon receiving an incoming packet with the given
parameters, we should send an ICMP response or not. In particular, we do not
send an ICMP response if we've received:
a packet destined to a broadcast or multicast address
a packet sent in a link-layer broadcast
a non-initial fragment
a packet whose source address does not define a single host (a
zero/unspecified address, a loopback address, a broadcast address, a
multicast address, or a Class E address)

Note that `should_send_icmp_error` does NOT check whether the incoming
packet contained an ICMP error message. This is because that check is
unnecessary for some ICMP error conditions. The ICMP error message check can
be performed separately with `is_icmp_error_message`.
Should we send an ICMP response . ` should_send_icmp_error ` implements the logic described in RFC 1122 section 3 . 2 . 2 . It decides whether upon receiving an incoming packet with the given parameters we should send an ICMP response or not . In particular we do not send an ICMP response if we ' ve received : a packet destined to a broadcast or multicast address a packet sent in a link - layer broadcast a non - initial fragment a packet whose source address does not define a single host ( a zero / unspecified address a loopback address a broadcast address a multicast address or a Class E address ) Note that ` should_send_icmp_error ` does NOT check whether the incoming packet contained an ICMP error message . This is because that check is unnecessary for some ICMP error conditions . The ICMP error message check can be performed separately with ` is_icmp_error_message ` .
fn should_send_icmp_error<A: IpAddress>(frame_dst: FrameDestination, src_ip: A, dst_ip: A) -> bool {
    // TODO(joshlf): Implement the rest of the rules:
    // - a packet destined to a subnet broadcast address
    // - a non-initial fragment
    // - a packet whose source address is a subnet broadcast address
    !(dst_ip.is_multicast()
        || dst_ip.with_v4(Ipv4Addr::is_global_broadcast, false)
        || frame_dst.is_broadcast()
        || src_ip.is_unspecified()
        || src_ip.is_loopback()
        || src_ip.with_v4(Ipv4Addr::is_global_broadcast, false)
        || src_ip.is_multicast()
        || src_ip.with_v4(Ipv4Addr::is_class_e, false))
}
fn should_send_icmp_error < A : IpAddress > ( frame_dst : FrameDestination , src_ip : A , dst_ip : A ) -> bool { // TODO(joshlf): Implement the rest of the rules: // - a packet destined to a subnet broadcast address // - a non-initial fragment // - a packet whose source address is a subnet broadcast address ! ( dst_ip . is_multicast ( ) || dst_ip . with_v4 ( Ipv4Addr :: is_global_broadcast , false ) || frame_dst . is_broadcast ( ) || src_ip . is_unspecified ( ) || src_ip . is_loopback ( ) || src_ip . with_v4 ( Ipv4Addr :: is_global_broadcast , false ) || src_ip . is_multicast ( ) || src_ip . with_v4 ( Ipv4Addr :: is_class_e , false ) ) }
Should we send an ICMP response?
Should we send an ICMP response?
frame_dst
FrameDestination
src_ip
A
dst_ip
A