From: Ian Jackson Date: Sun, 1 Aug 2021 18:28:19 +0000 (+0100) Subject: wip debug X-Git-Tag: hippotat/1.0.0~395 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=519efeb4dba6462c5bdad97855380eb60ede0ad2;p=hippotat.git wip debug Signed-off-by: Ian Jackson --- 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)?; } + } +}