From 519efeb4dba6462c5bdad97855380eb60ede0ad2 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 1 Aug 2021 19:28:19 +0100 Subject: [PATCH] wip debug Signed-off-by: Ian Jackson --- src/slip.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/slip.rs b/src/slip.rs index f042a31..5b34c53 100644 --- a/src/slip.rs +++ b/src/slip.rs @@ -10,6 +10,8 @@ pub static SLIP_END_SLICE: &[u8] = &[SLIP_END]; pub fn check_checkmtu_mimeswap (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 packet = &mut packet[i+2 ..]; } } + +// eprintln!(" after: {}", DumpHex(data)); } pub type Frame = Vec; @@ -59,3 +63,11 @@ impl Frames { impl From 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)?; } + } +} -- 2.30.2