diff --git a/quicktap/src/stack/entry_udp.rs b/quicktap/src/stack/entry_udp.rs index 5687456..f8481fe 100644 --- a/quicktap/src/stack/entry_udp.rs +++ b/quicktap/src/stack/entry_udp.rs @@ -3,6 +3,7 @@ use std::error::Error; use std::net::SocketAddr; use crate::device::QTInterface; +use crate::drivers::error::DriverError; use crate::stack::{PacketProcessingStage}; /// The ENTRY stage of the packet processing stack for UDP packets @@ -10,6 +11,29 @@ pub struct UDPPacketEntryStage {} impl PacketProcessingStage for UDPPacketEntryStage { fn process_packet(pkt: Vec, from: &SocketAddr, interface: &QTInterface) -> Result<(), Box> { + // packet types are determined by the first byte of the packet + // if it is not a known packet type, return an error and drop the packet + match pkt.first().ok_or(DriverError::InvalidPacketTypeRecvOnInterface)? { + 1 => Self::handle_new_handshake(pkt, from, interface), + 2 => Self::handle_handshake_response(pkt, from, interface), + 3 => Self::handle_handshake_cookie_reply(pkt, from, interface), + 4 => Self::handle_data_packet(pkt, from, interface), + _ => Err(DriverError::InvalidPacketTypeRecvOnInterface.into()) + } + } +} + +impl UDPPacketEntryStage { + fn handle_new_handshake(pkt: Vec, from: &SocketAddr, interface: &QTInterface) -> Result<(), Box> { + unimplemented!(); + } + fn handle_handshake_response(pkt: Vec, from: &SocketAddr, interface: &QTInterface) -> Result<(), Box> { + unimplemented!(); + } + fn handle_handshake_cookie_reply(pkt: Vec, from: &SocketAddr, interface: &QTInterface) -> Result<(), Box> { + unimplemented!(); + } + fn handle_data_packet(pkt: Vec, from: &SocketAddr, interface: &QTInterface) -> Result<(), Box> { unimplemented!(); } } \ No newline at end of file