[stack] skeleton for ENTRY_UDP
This commit is contained in:
parent
78fb32b253
commit
b07895b043
|
@ -3,6 +3,7 @@
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use crate::device::QTInterface;
|
use crate::device::QTInterface;
|
||||||
|
use crate::drivers::error::DriverError;
|
||||||
use crate::stack::{PacketProcessingStage};
|
use crate::stack::{PacketProcessingStage};
|
||||||
|
|
||||||
/// The ENTRY stage of the packet processing stack for UDP packets
|
/// The ENTRY stage of the packet processing stack for UDP packets
|
||||||
|
@ -10,6 +11,29 @@ pub struct UDPPacketEntryStage {}
|
||||||
|
|
||||||
impl PacketProcessingStage for UDPPacketEntryStage {
|
impl PacketProcessingStage for UDPPacketEntryStage {
|
||||||
fn process_packet(pkt: Vec<u8>, from: &SocketAddr, interface: &QTInterface) -> Result<(), Box<dyn Error>> {
|
fn process_packet(pkt: Vec<u8>, from: &SocketAddr, interface: &QTInterface) -> Result<(), Box<dyn Error>> {
|
||||||
|
// 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<u8>, from: &SocketAddr, interface: &QTInterface) -> Result<(), Box<dyn Error>> {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
fn handle_handshake_response(pkt: Vec<u8>, from: &SocketAddr, interface: &QTInterface) -> Result<(), Box<dyn Error>> {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
fn handle_handshake_cookie_reply(pkt: Vec<u8>, from: &SocketAddr, interface: &QTInterface) -> Result<(), Box<dyn Error>> {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
fn handle_data_packet(pkt: Vec<u8>, from: &SocketAddr, interface: &QTInterface) -> Result<(), Box<dyn Error>> {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue