From d6fbf79ded8c99db549d136cfa59059783002f18 Mon Sep 17 00:00:00 2001 From: DJMrTV Date: Sun, 19 Jan 2025 20:33:15 +0100 Subject: [PATCH] continue working on endpoints and reenabled reading packet options --- src/prudp/endpoint.rs | 9 +++++++-- src/prudp/packet.rs | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/prudp/endpoint.rs b/src/prudp/endpoint.rs index 6a11010..1ddc63c 100644 --- a/src/prudp/endpoint.rs +++ b/src/prudp/endpoint.rs @@ -3,7 +3,7 @@ use std::net::UdpSocket; use std::sync::{Arc, RwLock}; use log::{error, info}; use rand::random; -use crate::prudp::packet::{flags, PRUDPPacket, VirtualPort}; +use crate::prudp::packet::{flags, PRUDPPacket, types, VirtualPort}; use crate::prudp::sockaddr::PRUDPSockAddr; #[derive(Debug)] @@ -60,7 +60,7 @@ impl Endpoint{ return; }; - if ((packet.header.types_and_flags.get_flags() & flags::NEED_ACK) != 0) || + if //((packet.header.types_and_flags.get_flags() & flags::NEED_ACK) != 0) || ((packet.header.types_and_flags.get_flags() & flags::ACK) != 0) || ((packet.header.types_and_flags.get_flags() & flags::RELIABLE) != 0) || ((packet.header.types_and_flags.get_flags() & flags::MULTI_ACK) != 0) { @@ -70,7 +70,12 @@ impl Endpoint{ } + match packet.header.types_and_flags.get_types() { + types::SYN => { + } + _ => unimplemented!() + } } diff --git a/src/prudp/packet.rs b/src/prudp/packet.rs index 60953ef..c29433c 100644 --- a/src/prudp/packet.rs +++ b/src/prudp/packet.rs @@ -59,6 +59,10 @@ pub mod flags{ } +pub mod types { + pub const SYN: u8 = 0x0; +} + impl Debug for TypesFlags{ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { let stream_type = self.get_types(); @@ -196,7 +200,7 @@ impl PRUDPPacket{ //no clue whats up with options but they are broken - /*let mut packet_specific_data_cursor = Cursor::new(&packet_specific_buffer); + let mut packet_specific_data_cursor = Cursor::new(&packet_specific_buffer); loop { @@ -226,7 +230,7 @@ impl PRUDPPacket{ if packet_specific_data_cursor.read_exact(&mut option_data).is_err(){ break; } - }*/ + } let mut payload = vec![0u8; header.payload_size as usize];