fn build_icmp_echo_response(icmp_payload: &[u8]) -> Vec<u8> {
    let mut result = vec![0; MutableIcmpPacket::minimum_packet_size() + icmp_payload.len()];

    let mut packet = MutableIcmpPacket::new(&mut result)
        .expect("Could not construct ICMP packet with vector as buffer");
    packet.populate(&Icmp {
        icmp_type: IcmpTypes::EchoReply,
        icmp_code: IcmpCode(0),
        checksum: 0,
        payload: icmp_payload.to_vec(),
    });
    packet.set_checksum(checksum(&packet.to_immutable()));

    trace!(
        "Constructed ICMP response [response={:?}]",
        packet.to_immutable()
    );

    result
}
/// Build an ICMP packet that is an echo response and has the provided payload.
///
/// `icmp_payload` can usually simply be copied from an echo request because an echo response
/// should normally just respond with all data as it was provided.
Build an ICMP packet that is an echo response and has the provided payload.
`icmp_payload` can usually simply be copied from an echo request because an echo response
should normally just respond with all data as it was provided.
Build an ICMP packet that is an echo response and has the provided payload . ` icmp_payload ` can usually simply be copied from an echo request because an echo response should normally just respond with all data as it was provided .
fn build_icmp_echo_response(icmp_payload: &[u8]) -> Vec<u8> {
    let mut result = vec![0; MutableIcmpPacket::minimum_packet_size() + icmp_payload.len()];
    let mut packet = MutableIcmpPacket::new(&mut result)
        .expect("Could not construct ICMP packet with vector as buffer");
    packet.populate(&Icmp {
        icmp_type: IcmpTypes::EchoReply,
        icmp_code: IcmpCode(0),
        checksum: 0,
        payload: icmp_payload.to_vec(),
    });
    packet.set_checksum(checksum(&packet.to_immutable()));
    trace!(
        "Constructed ICMP response [response={:?}]",
        packet.to_immutable()
    );
    result
}
fn build_icmp_echo_response ( icmp_payload : & [ u8 ] ) -> Vec < u8 > { let mut result = vec ! [ 0 MutableIcmpPacket minimum_packet_size ( ) icmp_payload len ( ) ] ; let mut packet = MutableIcmpPacket :: new ( & mut result ) . expect ( " " ) ; packet . populate ( & Icmp { icmp_type : IcmpTypes :: EchoReply , icmp_code : IcmpCode ( 0 ) , checksum : 0 , payload : icmp_payload . to_vec ( ) , } ) ; packet . set_checksum ( checksum ( & packet . to_immutable ( ) ) ) ; trace ! ( " " packet to_immutable ( ) ) ; result }
Build an ICMP packet that is an echo response and has the provided payload.
Build an ICMP packet that is an echo response and has the provided payload .
icmp_payload
&[u8]
icmp_payload
&[u8]