]> code.octet-stream.net Git - m17rt/blobdiff - m17core/src/protocol.rs
Fix packet encoding
[m17rt] / m17core / src / protocol.rs
index abc9e1bacbb69a3077ba183244f2f711406e1641..f2e154ea944cb9c4e25517c9dfc1cfa7177b4fba 100755 (executable)
@@ -93,6 +93,26 @@ impl PacketType {
 pub struct LsfFrame(pub [u8; 30]);
 
 impl LsfFrame {
 pub struct LsfFrame(pub [u8; 30]);
 
 impl LsfFrame {
+    pub fn new_voice(source: &Address, destination: &Address) -> Self {
+        let mut out = Self([0u8; 30]);
+        out.set_source(source);
+        out.set_destination(destination);
+        out.set_mode(Mode::Stream);
+        out.set_data_type(DataType::Voice);
+        out.set_encryption_type(EncryptionType::None);
+        out
+    }
+
+    pub fn new_packet(source: &Address, destination: &Address) -> Self {
+        let mut out = Self([0u8; 30]);
+        out.set_source(source);
+        out.set_destination(destination);
+        out.set_mode(Mode::Packet);
+        out.set_data_type(DataType::Data);
+        out.set_encryption_type(EncryptionType::None);
+        out
+    }
+
     /// Calculate crc of entire frame. If zero, it is a valid frame.
     pub fn check_crc(&self) -> u16 {
         crate::crc::m17_crc(&self.0)
     /// Calculate crc of entire frame. If zero, it is a valid frame.
     pub fn check_crc(&self) -> u16 {
         crate::crc::m17_crc(&self.0)