1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use std::net::IpAddr;
pub mod icmpv4;
pub mod icmpv6;
#[derive(Debug)]
pub enum IcmpPacket {
V4(icmpv4::Icmpv4Packet),
V6(icmpv6::Icmpv6Packet),
}
impl IcmpPacket {
pub fn check_reply_packet(&self, destination: IpAddr, seq_cnt: u16, identifier: u16) -> bool {
match self {
IcmpPacket::V4(packet) => {
destination.eq(&IpAddr::V4(packet.get_real_dest()))
&& packet.get_sequence() == seq_cnt
&& packet.get_identifier() == identifier
},
IcmpPacket::V6(packet) => {
packet.get_sequence() == seq_cnt && packet.get_identifier() == identifier
}
}
}
}