diff --git a/tuic/src/protocol/authenticate.rs b/tuic/src/protocol/authenticate.rs index 988230d..ba016da 100644 --- a/tuic/src/protocol/authenticate.rs +++ b/tuic/src/protocol/authenticate.rs @@ -7,7 +7,7 @@ use super::Command; // +-------+ #[derive(Clone, Debug)] pub struct Authenticate { - pub token: [u8; 8], + token: [u8; 8], } impl Authenticate { @@ -16,6 +16,10 @@ impl Authenticate { pub const fn new(token: [u8; 8]) -> Self { Self { token } } + + pub fn token(&self) -> &[u8; 8] { + &self.token + } } impl Command for Authenticate { diff --git a/tuic/src/protocol/connect.rs b/tuic/src/protocol/connect.rs index db57013..f32c6e7 100644 --- a/tuic/src/protocol/connect.rs +++ b/tuic/src/protocol/connect.rs @@ -7,7 +7,7 @@ use super::{Address, Command}; // +----------+ #[derive(Clone, Debug)] pub struct Connect { - pub addr: Address, + addr: Address, } impl Connect { @@ -16,6 +16,10 @@ impl Connect { pub const fn new(addr: Address) -> Self { Self { addr } } + + pub fn addr(&self) -> &Address { + &self.addr + } } impl Command for Connect { diff --git a/tuic/src/protocol/dissociate.rs b/tuic/src/protocol/dissociate.rs index d931d13..dc4dcf3 100644 --- a/tuic/src/protocol/dissociate.rs +++ b/tuic/src/protocol/dissociate.rs @@ -7,7 +7,7 @@ use super::Command; // +----------+ #[derive(Clone, Debug)] pub struct Dissociate { - pub assoc_id: u16, + assoc_id: u16, } impl Dissociate { @@ -16,6 +16,10 @@ impl Dissociate { pub const fn new(assoc_id: u16) -> Self { Self { assoc_id } } + + pub fn assoc_id(&self) -> u16 { + self.assoc_id + } } impl Command for Dissociate { diff --git a/tuic/src/protocol/packet.rs b/tuic/src/protocol/packet.rs index 62a8219..c4d2a2b 100644 --- a/tuic/src/protocol/packet.rs +++ b/tuic/src/protocol/packet.rs @@ -1,18 +1,18 @@ use super::{Address, Command}; -// +----------+--------+------------+---------+-----+----------+ -// | ASSOC_ID | PKT_ID | FRAG_TOTAL | FRAG_ID | LEN | ADDR | -// +----------+--------+------------+---------+-----+----------+ -// | 2 | 2 | 1 | 1 | 2 | Variable | -// +----------+--------+------------+---------+-----+----------+ +// +----------+--------+------------+---------+------+----------+ +// | ASSOC_ID | PKT_ID | FRAG_TOTAL | FRAG_ID | SIZE | ADDR | +// +----------+--------+------------+---------+------+----------+ +// | 2 | 2 | 1 | 1 | 2 | Variable | +// +----------+--------+------------+---------+------+----------+ #[derive(Clone, Debug)] pub struct Packet { - pub assoc_id: u16, - pub pkt_id: u16, - pub frag_total: u8, - pub frag_id: u8, - pub len: u16, - pub addr: Address, + assoc_id: u16, + pkt_id: u16, + frag_total: u8, + frag_id: u8, + size: u16, + addr: Address, } impl Packet { @@ -23,7 +23,7 @@ impl Packet { pkt_id: u16, frag_total: u8, frag_id: u8, - len: u16, + size: u16, addr: Address, ) -> Self { Self { @@ -31,11 +31,35 @@ impl Packet { pkt_id, frag_total, frag_id, - len, + size, addr, } } + pub fn assoc_id(&self) -> u16 { + self.assoc_id + } + + pub fn pkt_id(&self) -> u16 { + self.pkt_id + } + + pub fn frag_total(&self) -> u8 { + self.frag_total + } + + pub fn frag_id(&self) -> u8 { + self.frag_id + } + + pub fn size(&self) -> u16 { + self.size + } + + pub fn addr(&self) -> &Address { + &self.addr + } + pub const fn len_without_addr() -> usize { 2 + 2 + 1 + 1 + 2 }