summaryrefslogtreecommitdiff
path: root/src/sniffing
diff options
context:
space:
mode:
Diffstat (limited to 'src/sniffing')
-rw-r--r--src/sniffing/headers.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/sniffing/headers.rs b/src/sniffing/headers.rs
index 050f2d3..a5b0480 100644
--- a/src/sniffing/headers.rs
+++ b/src/sniffing/headers.rs
@@ -43,12 +43,13 @@ impl PacketInfo {
}
}
+// TODO: move these to some appropriate file for code readability.
type GenericError = Box<dyn std::error::Error + Send + Sync + 'static>;
type SniffedPacket = Result<PacketInfo, Box<dyn std::error::Error + Send + Sync + 'static>>;
+type Packet = [u8];
-pub fn sniff_raw_packets(packet: &[u8]) -> SniffedPacket {
+pub fn sniff_raw_packets(packet: &Packet) -> SniffedPacket {
let ver = packet[0] >> 4;
- dbg!(ver);
match ver {
4 => {
let dst_port = Port::from_be_bytes([packet[22], packet[23]]);
@@ -70,12 +71,13 @@ pub fn sniff_raw_packets(packet: &[u8]) -> SniffedPacket {
if !matches!(v4.protocol(), Protocol::Unsupported(_)) {
println!("{v4:?}");
} else {
- println!("oppsie unsupported");
+ // TODO: make --debug option which will include this diagnostic, for general use this
+ // should be off
+ // println!("oppsie unsupported protocol: {:?}", v4.protocol());
}
Ok(v4)
},
6 => {
- println!("im in 6!");
let dst_port = Port::from_be_bytes([packet[22], packet[23]]);
let dns;
if dst_port == 53 { dns = true; } else { dns = false; };
@@ -94,7 +96,9 @@ pub fn sniff_raw_packets(packet: &[u8]) -> SniffedPacket {
if !matches!(v6.protocol(), Protocol::Unsupported(_)) {
println!("{v6:?}");
} else {
- println!("oppsie unsupported");
+ // TODO: make --debug option which will include this diagnostic, for general use this
+ // should be off
+ // println!("oppsie unsupported protocol: {:?}", v6.protocol());
}
Ok(v6)
},