Make sure the ID is right
This commit is contained in:
1 parent
6e8b50bc7f
commit
431f578460
1 file changed
+6
-1
+6
-1
@@ -20,13 +20,18 @@ impl PingListener for PingerICMPEchoListener {
|
||||
id: u16,
|
||||
reflector: IpAddr,
|
||||
buf: &[u8],
|
||||
len: usize,
|
||||
) -> Result<PingReply, Box<dyn Error>> {
|
||||
match SlicedPacket::from_ip(buf) {
|
||||
Err(value) => println!("Err {:?}", value),
|
||||
Ok(value) => match value.transport {
|
||||
Some(Icmpv4(icmp)) => match icmp.icmp_type() {
|
||||
Icmpv4Type::EchoReply(echo) => {
|
||||
if echo.id != id {
|
||||
return Err(Box::new(PingParseError {
|
||||
msg: "Wrong ID".to_string(),
|
||||
}));
|
||||
}
|
||||
|
||||
let time_sent = icmp
|
||||
.payload()
|
||||
.read_u64::<NativeEndian>()
|
||||
|
||||
Reference in new issue
Block a user