fn build_icmp6_echo_response(
    icmp_payload: &[u8],
    my_src_address: &Ipv6Addr,
    my_dst_address: &Ipv6Addr,
) -> Vec<u8> {
    let mut response = vec![0; MutableIcmpv6Packet::minimum_packet_size() + icmp_payload.len()];

    let mut packet = MutableIcmpv6Packet::new(&mut response)
        .expect("Could not create ICMPv6 packet with vector as buffer");
    packet.populate(&Icmpv6 {
        icmpv6_type: Icmpv6Types::EchoReply,
        icmpv6_code: Icmpv6Code(0),
        checksum: 0,
        payload: icmp_payload.to_vec(),
    });
    packet.set_checksum(checksum(
        &packet.to_immutable(),
        my_src_address,
        my_dst_address,
    ));

    response
}
/// Build an ICMPv6 packet that is an echo response and has the provided payload.
///
/// `icmp_payload` can usually be copied from an echo request because an echo response should
/// normally just response with all data as it was sent.
///
/// `src_address` and `dst_address` need to be provided to calculate an ICMPv6 checksum.
Build an ICMPv6 packet that is an echo response and has the provided payload.
`icmp_payload` can usually be copied from an echo request because an echo response should
normally just response with all data as it was sent.

`src_address` and `dst_address` need to be provided to calculate an ICMPv6 checksum.
Build an ICMPv6 packet that is an echo response and has the provided payload . ` icmp_payload ` can usually be copied from an echo request because an echo response should normally just response with all data as it was sent . ` src_address ` and ` dst_address ` need to be provided to calculate an ICMPv6 checksum .
fn build_icmp6_echo_response(
    icmp_payload: &[u8],
    my_src_address: &Ipv6Addr,
    my_dst_address: &Ipv6Addr,
) -> Vec<u8> {
    let mut response = vec![0; MutableIcmpv6Packet::minimum_packet_size() + icmp_payload.len()];
    let mut packet = MutableIcmpv6Packet::new(&mut response)
        .expect("Could not create ICMPv6 packet with vector as buffer");
    packet.populate(&Icmpv6 {
        icmpv6_type: Icmpv6Types::EchoReply,
        icmpv6_code: Icmpv6Code(0),
        checksum: 0,
        payload: icmp_payload.to_vec(),
    });
    packet.set_checksum(checksum(
        &packet.to_immutable(),
        my_src_address,
        my_dst_address,
    ));
    response
}
fn build_icmp6_echo_response ( icmp_payload : & [ u8 ] , my_src_address : & Ipv6Addr , my_dst_address : & Ipv6Addr , ) -> Vec < u8 > { let mut response = vec ! [ 0 MutableIcmpv6Packet minimum_packet_size ( ) icmp_payload len ( ) ] ; let mut packet = MutableIcmpv6Packet :: new ( & mut response ) . expect ( " " ) ; packet . populate ( & Icmpv6 { icmpv6_type : Icmpv6Types :: EchoReply , icmpv6_code : Icmpv6Code ( 0 ) , checksum : 0 , payload : icmp_payload . to_vec ( ) , } ) ; packet . set_checksum ( checksum ( & packet . to_immutable ( ) , my_src_address , my_dst_address , ) ) ; response }
Build an ICMPv6 packet that is an echo response and has the provided payload.
Build an ICMPv6 packet that is an echo response and has the provided payload .
icmp_payload
&[u8]
my_src_address
&Ipv6Addr
my_dst_address
&Ipv6Addr
icmp_payload
&[u8]
my_src_address
&Ipv6Addr
my_dst_address
&Ipv6Addr