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,
|
id: u16,
|
||||||
reflector: IpAddr,
|
reflector: IpAddr,
|
||||||
buf: &[u8],
|
buf: &[u8],
|
||||||
len: usize,
|
|
||||||
) -> Result<PingReply, Box<dyn Error>> {
|
) -> Result<PingReply, Box<dyn Error>> {
|
||||||
match SlicedPacket::from_ip(buf) {
|
match SlicedPacket::from_ip(buf) {
|
||||||
Err(value) => println!("Err {:?}", value),
|
Err(value) => println!("Err {:?}", value),
|
||||||
Ok(value) => match value.transport {
|
Ok(value) => match value.transport {
|
||||||
Some(Icmpv4(icmp)) => match icmp.icmp_type() {
|
Some(Icmpv4(icmp)) => match icmp.icmp_type() {
|
||||||
Icmpv4Type::EchoReply(echo) => {
|
Icmpv4Type::EchoReply(echo) => {
|
||||||
|
if echo.id != id {
|
||||||
|
return Err(Box::new(PingParseError {
|
||||||
|
msg: "Wrong ID".to_string(),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
let time_sent = icmp
|
let time_sent = icmp
|
||||||
.payload()
|
.payload()
|
||||||
.read_u64::<NativeEndian>()
|
.read_u64::<NativeEndian>()
|
||||||
|
|||||||
Reference in new issue
Block a user