Function parse_icmpv4

Source
fn parse_icmpv4(
    packet_bytes: &[u8],
    measurement_id: u32,
    origin_map: &Vec<Origin>,
) -> Option<(Reply, bool)>
Expand description

Parse ICMPv4 packets (including v4 headers) into a Reply result.

Filters out spoofed packets and only parses ICMP echo replies valid for the current measurement.

§Arguments

  • packet_bytes - the bytes of the packet to parse

  • measurement_id - the ID of the current measurement

  • origin_map - mapping of origin to origin ID

§Returns

  • Option<Reply> - the received ping reply

§Remarks

The function returns None if the packet is not an ICMP echo reply or if the packet is too short to contain the necessary information.

The function also discards packets that do not belong to the current measurement.