From 91cf70e7dfd30a54cdcd862a1aca5fc0d4e6a180 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 2 Aug 2021 03:17:29 +0100 Subject: [PATCH] wip rx, fix, mime Signed-off-by: Ian Jackson --- src/prelude.rs | 8 ++++---- src/slip.rs | 12 ++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/prelude.rs b/src/prelude.rs index 3b1bed5..e95aa9c 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -53,10 +53,10 @@ pub use anyhow::Error as AE; pub use ErrorKind as EK; pub use PacketError as PE; -pub const SLIP_END: u8 = 0o300; -pub const SLIP_ESC: u8 = 0o333; -pub const SLIP_ESC_END: u8 = 0o334; -pub const SLIP_ESC_ESC: u8 = 0o335; +pub const SLIP_END: u8 = 0o300; // c0 +pub const SLIP_ESC: u8 = 0o333; // db +pub const SLIP_ESC_END: u8 = 0o334; // dc +pub const SLIP_ESC_ESC: u8 = 0o335; // dd pub const SLIP_MIME_ESC: u8 = b'-'; pub use base64::STANDARD as BASE64_CONFIG; diff --git a/src/slip.rs b/src/slip.rs index c9e3aa8..ab90054 100644 --- a/src/slip.rs +++ b/src/slip.rs @@ -62,8 +62,8 @@ pub fn check( } if Some(was_mime) != M::CONV_TO { let c = match walk.get(i+1) { - Some(&SLIP_ESC_END) => SLIP_ESC, - Some(&SLIP_ESC_ESC) => SLIP_END, + Some(&SLIP_ESC_ESC) => SLIP_ESC, + Some(&SLIP_ESC_END) => SLIP_END, _ => throw!(PacketError::SLIP), }; let _ = wheader.write(&[c]); @@ -160,6 +160,7 @@ fn mime_slip_to_mime() { const MTU: u32 = 10; fn chk(i: &[u8], exp_p: &[&[u8]], exp_e: &[PacketError]) { + dbg!(M::CONV_TO, DumpHex(i)); let mut got_e = vec![]; let mut got_p = vec![]; check::<_,_,_,M>(MTU, i, &mut got_p, |_|Ok(()), |e| got_e.push(e)); @@ -187,4 +188,11 @@ fn mime_slip_to_mime() { ( &[b'x'; 20], &[ ], &[ PE::MTU { len: 20, mtu: MTU } ]); + + chk:: + ( &[ SLIP_END, SLIP_ESC, SLIP_ESC_END, b'-', b'X' ], + &[ &[ SLIP_ESC, SLIP_ESC_END, b'-', b'X' ] ], + &[ PE::Empty, ]); } + + -- 2.30.2