chiark / gitweb /
wip debug
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 Aug 2021 18:28:19 +0000 (19:28 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 Aug 2021 18:38:35 +0000 (19:38 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/slip.rs

index f042a31e6fca3a496a81bc04de5c397bd0eeeb93..5b34c534edc58de36a66056cd6c47bda2ba9558e 100644 (file)
@@ -10,6 +10,8 @@ pub static SLIP_END_SLICE: &[u8] = &[SLIP_END];
 pub fn check_checkmtu_mimeswap<const TO_MIME: bool>
   (ic: &InstanceConfig, data: &mut [u8])
 {
+//  eprintln!("before: {}", DumpHex(data));
+
   for mut packet in data.split_mut(|&c| c == SLIP_END) {
     if packet.len() > ic.mtu.sat() {
       throw!(anyhow!("mtu exceeded ({} > {})", packet.len(), ic.mtu));
@@ -27,6 +29,8 @@ pub fn check_checkmtu_mimeswap<const TO_MIME: bool>
       packet = &mut packet[i+2 ..];
     }
   }
+
+//  eprintln!(" after: {}", DumpHex(data));
 }
 
 pub type Frame = Vec<u8>;
@@ -59,3 +63,11 @@ impl Frames {
 impl From<Frames> for FramesData {
   fn from(frames: Frames) -> FramesData { frames.frames }
 }
+
+struct DumpHex<'b>(pub &'b [u8]);
+impl Display for DumpHex<'_> {
+  #[throws(fmt::Error)]
+  fn fmt(&self, f: &mut fmt::Formatter) {
+    for v in self.0 { write!(f, "{:02x}", v)?; }
+  }
+}