From: Ian Jackson Date: Tue, 3 Aug 2021 18:02:22 +0000 (+0100) Subject: use slip::check1 on already-split frames X-Git-Tag: hippotat/1.0.0~373 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=5cc0772fd75f593f9943c1c6eda5f813db8d6884;p=hippotat.git use slip::check1 on already-split frames Signed-off-by: Ian Jackson --- diff --git a/src/bin/client.rs b/src/bin/client.rs index a87c6d1..9e99810 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -214,16 +214,17 @@ async fn run_client( .ok_or_else(|| io::Error::from(io::ErrorKind::UnexpectedEof))?; //eprintln!("data={:?}", DumpHex(&data)); - check - ::<_,_,_,Slip2Mime>(ic.mtu, &data, &mut packets, |header| { + match check1 + ::<_,Slip2Mime>(ic.mtu, &data, |header| { let addr = ip_packet_addr::(header)?; if addr != ic.link.client.0 { throw!(PE::Src(addr)) } Ok(()) - }, |e| match e { - PE::Empty => { }, - e@ PE::Src(_) => debug!("{}: tx discarding: {}", &ic, e), - e => error!("{}: tx discarding: {}", &ic, e), - }); + }) { + Ok(packet) => packets.push_back(packet), + Err(PE::Empty) => { }, + Err(e@ PE::Src(_)) => debug!("{}: tx discarding: {}", &ic, e), + Err(e) => error!("{}: tx discarding: {}", &ic, e), + }; }, _ = async { }, @@ -256,7 +257,7 @@ async fn run_client( if let Some(got) = got { //eprintln!("got={:?}", DumpHex(&got)); - check + checkn ::<_,_,_,SlipNoConv>(ic.mtu, &got, &mut rx_queue, |header| { let addr = ip_packet_addr::(header)?; if addr != ic.link.client.0 { throw!(PE::Dst(addr)) } diff --git a/src/slip.rs b/src/slip.rs index b179f54..2f7ba88 100644 --- a/src/slip.rs +++ b/src/slip.rs @@ -24,7 +24,7 @@ impl SlipMime for Slip2Mime { const CONV_TO: Option = Some(true); } impl SlipMime for Mime2Slip { const CONV_TO: Option = Some(false); } impl SlipMime for SlipNoConv { const CONV_TO: Option = None; } -pub fn check( +pub fn checkn( mtu: u32, data: &[u8], out: &mut OUT,