summaryrefslogtreecommitdiff
path: root/src/packet/packet.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/packet/packet.rs')
-rw-r--r--src/packet/packet.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/packet/packet.rs b/src/packet/packet.rs
index 1b4602c..84f75f1 100644
--- a/src/packet/packet.rs
+++ b/src/packet/packet.rs
@@ -3,6 +3,7 @@ use crate::protocol::codec::Decode;
use crate::protocol::ethernet::EtherType;
use crate::protocol::ethernet::EthernetFrame;
use crate::protocol::icmp::IcmpHeader;
+use crate::protocol::icmpv6::Icmpv6Header;
use crate::protocol::ip::IPProtocol;
use crate::protocol::ipv4::IPv4Header;
use crate::protocol::ipv6::IPv6Header;
@@ -22,6 +23,7 @@ pub enum Encapsulation<'a> {
L4_TCP(TcpHeader, &'a [u8]),
L4_UDP(UdpHeader, &'a [u8]),
L4_ICMP(IcmpHeader, &'a [u8]),
+ L4_ICMPV6(Icmpv6Header, &'a [u8]),
UNSUPPORTED(&'a [u8]),
}
@@ -43,6 +45,7 @@ pub enum PacketEvent {
TCP_EVENT,
UDP_EVENT,
ICMP_EVENT,
+ ICMPV6_EVENT,
}
#[derive(Debug)]
@@ -477,6 +480,22 @@ fn handle_l4<'a>(
return Err(PacketError::IncompleteIcmpHeader);
}
}
+ IPProtocol::ICMP6 => {
+ let result = Icmpv6Header::decode(input);
+ if let Ok((payload, header)) = result {
+ dbg!(&header);
+
+ packet
+ .encapsulation
+ .push(Encapsulation::L4_ICMPV6(header, payload));
+
+ packet.event.push(PacketEvent::L4_EVENT);
+ packet.event.push(PacketEvent::ICMPV6_EVENT);
+ return Ok(());
+ } else {
+ return Err(PacketError::IncompleteIcmpv6Header);
+ }
+ }
IPProtocol::UDP => {
let result = UdpHeader::decode(input);
if let Ok((payload, header)) = result {