pub fn build_icmp_time_exceeded_response(original_ip_packet: &Ipv4Packet) -> Vec<u8> {
    let mut result = vec![
        0;
        MutableTimeExceededPacket::minimum_packet_size()
            + original_ip_packet.packet_size()
    ];

    let mut packet = MutableTimeExceededPacket::new(&mut result)
        .expect("Could not create ICMP time exceeded packet from empty buffer");
    packet.populate(&TimeExceeded {
        icmp_type: IcmpTypes::TimeExceeded,
        icmp_code: pnet_packet::icmp::time_exceeded::IcmpCodes::TimeToLiveExceededInTransit,
        checksum: 0,
        unused: 0,
        payload: original_ip_packet.packet().to_vec(),
    });
    packet.set_checksum(checksum(&IcmpPacket::new(packet.packet()).unwrap()));

    result
}
/// Build an *ICMP timeout exceeded* packet.
///
/// The *timeout exceeded* packets should be generated when an IP packet's time to live
/// reaches 0. It also includes the failed original packet which can be provided via
/// `original_ip_packet`.
Build an *ICMP timeout exceeded* packet.
The *timeout exceeded* packets should be generated when an IP packet's time to live
reaches 0. It also includes the failed original packet which can be provided via
`original_ip_packet`.
Build an * ICMP timeout exceeded * packet . The * timeout exceeded * packets should be generated when an IP packet ' s time to live reaches 0 . It also includes the failed original packet which can be provided via ` original_ip_packet ` .
pub fn build_icmp_time_exceeded_response(original_ip_packet: &Ipv4Packet) -> Vec<u8> {
    let mut result = vec![
        0;
        MutableTimeExceededPacket::minimum_packet_size()
            + original_ip_packet.packet_size()
    ];
    let mut packet = MutableTimeExceededPacket::new(&mut result)
        .expect("Could not create ICMP time exceeded packet from empty buffer");
    packet.populate(&TimeExceeded {
        icmp_type: IcmpTypes::TimeExceeded,
        icmp_code: pnet_packet::icmp::time_exceeded::IcmpCodes::TimeToLiveExceededInTransit,
        checksum: 0,
        unused: 0,
        payload: original_ip_packet.packet().to_vec(),
    });
    packet.set_checksum(checksum(&IcmpPacket::new(packet.packet()).unwrap()));
    result
}
pub fn build_icmp_time_exceeded_response ( original_ip_packet : & Ipv4Packet ) -> Vec < u8 > { let mut result = vec ! [ 0 MutableTimeExceededPacket minimum_packet_size ( ) original_ip_packet packet_size ( ) ] ; let mut packet = MutableTimeExceededPacket :: new ( & mut result ) . expect ( " " ) ; packet . populate ( & TimeExceeded { icmp_type : IcmpTypes :: TimeExceeded , icmp_code : pnet_packet :: icmp :: time_exceeded :: IcmpCodes :: TimeToLiveExceededInTransit , checksum : 0 , unused : 0 , payload : original_ip_packet . packet ( ) . to_vec ( ) , } ) ; packet . set_checksum ( checksum ( & IcmpPacket :: new ( packet . packet ( ) ) . unwrap ( ) ) ) ; result }
Build an *ICMP timeout exceeded* packet.
Build an * ICMP timeout exceeded * packet .
original_ip_packet
&Ipv4Packet
original_ip_packet
&Ipv4Packet