X-Git-Url: https://code.octet-stream.net/m17rt/blobdiff_plain/21b7d95e42fd374a33e0f18d3e3f406642e46322..7b7b572052951018da4d6d0f5753d627836236ad:/m17core/src/protocol.rs diff --git a/m17core/src/protocol.rs b/m17core/src/protocol.rs index 382fb9f..82a5721 100755 --- a/m17core/src/protocol.rs +++ b/m17core/src/protocol.rs @@ -29,7 +29,7 @@ pub enum EncryptionType { pub enum Frame { Lsf(LsfFrame), Stream(StreamFrame), - // Packet + Packet(PacketFrame), // BERT } @@ -133,6 +133,8 @@ impl LsfFrame { } } + // TODO: encryption sub-type + pub fn channel_access_number(&self) -> u8 { (self.0[12] >> 7) & 0x0f } @@ -156,6 +158,33 @@ pub struct StreamFrame { pub stream_data: [u8; 16], } +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct PacketFrame { + /// Application packet payload (chunk) + pub payload: [u8; 25], + + /// Frame counter, which provides different information depending on whether this is the last frame or not. + pub counter: PacketFrameCounter, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum PacketFrameCounter { + /// Any packet frame that comes after the LSF and is not the final frame. + Frame { + /// Which frame this is in the superframe, from 0 to 31 inclusive. + /// + /// If a 33rd frame exists (index 32), it will be a `FinalFrame` instead. + /// + /// All 25 bytes of of `payload` are filled and valid. + index: usize, + }, + /// The final frame in the packet superframe. + FinalFrame { + /// The number of bytes in `payload` that are filled. + payload_len: usize, + }, +} + pub struct LichCollection([Option<[u8; 5]>; 6]); impl LichCollection {