libpnet icon indicating copy to clipboard operation
libpnet copied to clipboard

`MutableEchoRequestPacket` doesn't set the ICMP type

Open nikclayton opened this issue 4 years ago • 0 comments

Not sure if this is a code-bug or a documentation-bug.

Creating a new MutableEchoRequestPacket, e.g., with:

let mut buf = [0u8; 64]; // 56 (payload size) + 8 bytes of header
let mut packet =
    MutableEchoRequestPacket::new(&mut buf[..]).ok_or(SurgeError::IncorrectBufferSize)?;

doesn't set the ICMP type. You also have to call:

packet.set_icmp_type(IcmpTypes::EchoRequest);

I found this surprising with this constructor. Given the name, I anticipated that would already be set.

nikclayton avatar May 01 '21 18:05 nikclayton