add a Packet type alias and comment out debug thingies :<
This commit is contained in:
parent
81e1ed42a0
commit
2eb03ac768
1 changed files with 9 additions and 5 deletions
|
|
@ -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)
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue