fn extract_tcp_probe(payload: &[u8]) -> TraceResult<u16> {
    let ip4 = Ipv4Packet::new(payload).unwrap();
    let header_len = usize::from(ip4.get_header_length() * 4);
    let nested_tcp = &payload[header_len..];
    if nested_tcp.len() < TcpPacket::minimum_packet_size() {
        let mut buf = [0_u8; TcpPacket::minimum_packet_size()];
        buf[..nested_tcp.len()].copy_from_slice(nested_tcp);
        Ok(TcpPacket::new(&buf).req()?.get_destination())
    } else {
        Ok(TcpPacket::new(nested_tcp).req()?.get_destination())
    }
}
/// Get the original `TcpPacket` packet embedded in the payload.
///
/// Unlike the embedded `ICMP` and `UDP` packets, which have a minimum header size of 8 bytes, the `TCP` packet header
/// is a minimum of 20 bytes.
///
/// The `ICMP` packets we are extracting these from, such as `TimeExceeded`, only guarantee that 8 bytes of the
/// original packet (plus the IP header) be returned and so we may not have a complete TCP packet.
///
/// We therefore have to detect this situation and ensure we provide buffer a large enough for a complete TCP packet
/// header.
Get the original `TcpPacket` packet embedded in the payload.

The `ICMP` packets we are extracting these from, such as `TimeExceeded`, only guarantee that 8 bytes of the
original packet (plus the IP header) be returned and so we may not have a complete TCP packet.

We therefore have to detect this situation and ensure we provide buffer a large enough for a complete TCP packet
header.
Get the original ` TcpPacket ` packet embedded in the payload . The ` ICMP ` packets we are extracting these from such as ` TimeExceeded ` only guarantee that 8 bytes of the original packet ( plus the IP header ) be returned and so we may not have a complete TCP packet . We therefore have to detect this situation and ensure we provide buffer a large enough for a complete TCP packet header .
fn extract_tcp_probe(payload: &[u8]) -> TraceResult<u16> {
    let ip4 = Ipv4Packet::new(payload).unwrap();
    let header_len = usize::from(ip4.get_header_length() * 4);
    let nested_tcp = &payload[header_len..];
    if nested_tcp.len() < TcpPacket::minimum_packet_size() {
        let mut buf = [0_u8; TcpPacket::minimum_packet_size()];
        buf[..nested_tcp.len()].copy_from_slice(nested_tcp);
        Ok(TcpPacket::new(&buf).req()?.get_destination())
    } else {
        Ok(TcpPacket::new(nested_tcp).req()?.get_destination())
    }
}
fn extract_tcp_probe ( payload : & [ u8 ] ) -> TraceResult < u16 > { let ip4 = Ipv4Packet :: new ( payload ) . unwrap ( ) ; let header_len = usize :: from ( ip4 . get_header_length ( ) * 4 ) ; let nested_tcp = & payload [ header_len .. ] ; if nested_tcp . len ( ) < TcpPacket :: minimum_packet_size ( ) { let mut buf = [ 0_u8 ; TcpPacket :: minimum_packet_size ( ) ] ; buf [ .. nested_tcp . len ( ) ] . copy_from_slice ( nested_tcp ) ; Ok ( TcpPacket :: new ( & buf ) . req ( ) ? . get_destination ( ) ) } else { Ok ( TcpPacket :: new ( nested_tcp ) . req ( ) ? . get_destination ( ) ) } }
Get the original `TcpPacket` packet embedded in the payload.
Get the original ` TcpPacket ` packet embedded in the payload .
payload
&[u8]