.ok_or_else(|| io::Error::from(io::ErrorKind::UnexpectedEof))?;
//eprintln!("data={:?}", DumpHex(&data));
- match check1
- ::<_,Slip2Mime>(ic.mtu, &data, |header| {
- let addr = ip_packet_addr::<false>(header)?;
- if addr != ic.link.client.0 { throw!(PE::Src(addr)) }
- Ok(())
- }) {
- 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),
- };
+ match check1(Slip2Mime, ic.mtu, &data, |header| {
+ let addr = ip_packet_addr::<false>(header)?;
+ if addr != ic.link.client.0 { throw!(PE::Src(addr)) }
+ Ok(())
+ }) {
+ 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 { },
if let Some(got) = got {
//eprintln!("got={:?}", DumpHex(&got));
- checkn
- ::<_,_,_,SlipNoConv>(ic.mtu, &got, &mut rx_queue, |header| {
- let addr = ip_packet_addr::<true>(header)?;
- if addr != ic.link.client.0 { throw!(PE::Dst(addr)) }
- Ok(())
- }, |e| error!("{} #{}: rx discarding: {}", &ic, req_num, e));
+ checkn(SlipNoConv,ic.mtu, &got, &mut rx_queue, |header| {
+ let addr = ip_packet_addr::<true>(header)?;
+ if addr != ic.link.client.0 { throw!(PE::Dst(addr)) }
+ Ok(())
+ }, |e| error!("{} #{}: rx discarding: {}", &ic, req_num, e));
dbg!(&rx_queue.len());
rx_queue = default(); // xxx
impl SlipMime for Mime2Slip { const CONV_TO: Option<bool> = Some(false); }
impl SlipMime for SlipNoConv { const CONV_TO: Option<bool> = None; }
-pub fn checkn<AC, EH, OUT, M: SlipMime>(
+pub fn checkn<AC, EH, OUT, M: SlipMime+Copy>(
+ mime: M,
mtu: u32,
data: &[u8],
out: &mut OUT,
{
// eprintln!("before: {:?}", DumpHex(data));
for packet in data.split(|&c| c == SLIP_END) {
- match check1::<AC,M>(mtu, packet, addr_chk) {
+ match check1(mime, mtu, packet, addr_chk) {
Err(e) => error_handler(e),
Ok(packet) => out.extend(iter::once(packet)),
}
#[throws(PacketError)]
pub fn check1<AC, M: SlipMime>(
+ _mime: M,
mtu: u32,
packet: &[u8],
addr_chk: AC,