From 142ac2e4616103e4654a97b3abe61ae7160e4fa4 Mon Sep 17 00:00:00 2001 From: EAimTY Date: Sat, 4 Mar 2023 19:43:19 +0900 Subject: [PATCH] adding more packet info getter --- tuic/src/model/packet.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tuic/src/model/packet.rs b/tuic/src/model/packet.rs index ded42db..b41d523 100644 --- a/tuic/src/model/packet.rs +++ b/tuic/src/model/packet.rs @@ -51,6 +51,12 @@ impl Packet { tx.assoc_id } + /// Returns the packet ID + pub fn pkt_id(&self) -> u16 { + let Side::Tx(tx) = &self.inner else { unreachable!() }; + tx.pkt_id + } + /// Returns the address pub fn addr(&self) -> &Address { let Side::Tx(tx) = &self.inner else { unreachable!() }; @@ -129,6 +135,24 @@ where rx.assoc_id } + /// Returns the packet ID + pub fn pkt_id(&self) -> u16 { + let Side::Rx(rx) = &self.inner else { unreachable!() }; + rx.pkt_id + } + + /// Returns the fragment ID + pub fn frag_id(&self) -> u8 { + let Side::Rx(rx) = &self.inner else { unreachable!() }; + rx.frag_id + } + + /// Returns the total number of fragments + pub fn frag_total(&self) -> u8 { + let Side::Rx(rx) = &self.inner else { unreachable!() }; + rx.frag_total + } + /// Returns the address pub fn addr(&self) -> &Address { let Side::Rx(rx) = &self.inner else { unreachable!() };