message: Adapt pcap backend to &[u8] datalink
diff: @@ -9,8 +9,6 @@ use self::pcap::{Active, Activated};
  use datalink::{self, NetworkInterface};
  use datalink::{EthernetDataLinkChannelIterator, EthernetDataLinkReceiver, EthernetDataLinkSender};
  use datalink::Channel::Ethernet;
  -use packet::Packet;
  -use packet::ethernet::{EthernetPacket, MutableEthernetPacket};
  use std::sync::{Arc, Mutex};
  use std::time::Duration;
  use std::path::Path;
  @@ -99,14 +97,11 @@ impl EthernetDataLinkSender for DataLinkSenderImpl {
  fn build_and_send(&mut self,
  num_packets: usize,
  packet_size: usize,
  - func: &mut FnMut(MutableEthernetPacket))
  + func: &mut FnMut(&mut [u8]))
  -> Option<io::Result<()>> {
  for _ in 0..num_packets {
  let mut data = vec![0; packet_size];
  - {
  - let eh = MutableEthernetPacket::new(&mut data).unwrap();
  - func(eh);
  - }
  + func(&mut data);
  let mut cap = self.capture.lock().unwrap();
  if let Err(e) = cap.sendpacket(data) {
  return Some(Err(io::Error::new(io::ErrorKind::Other, e)))
  @@ -117,10 +112,10 @@ impl EthernetDataLinkSender for DataLinkSenderImpl {
  #[inline]
  fn send_to(&mut self,
  - packet: &EthernetPacket,
  + packet: &[u8],
  _dst: Option<NetworkInterface>) -> Option<io::Result<()>> {
  let mut cap = self.capture.lock().unwrap();
  - Some(match cap.sendpacket(packet.packet()) {
  + Some(match cap.sendpacket(packet) {
  Ok(()) => Ok(()),
  Err(e) => Err(io::Error::new(io::ErrorKind::Other, e)),
  })
  @@ -134,14 +129,14 @@ impl EthernetDataLinkSender for InvalidDataLinkSenderImpl {
  fn build_and_send(&mut self,
  _num_packets: usize,
  _packet_size: usize,
  - _func: &mut FnMut(MutableEthernetPacket))
  + _func: &mut FnMut(&mut [u8]))
  -> Option<io::Result<()>> {
  None
  }
  #[inline]
  fn send_to(&mut self,
  - _packet: &EthernetPacket,
  + _packet: &[u8],
  _dst: Option<NetworkInterface>) -> Option<io::Result<()>> {
  None
  }
  @@ -163,7 +158,7 @@ struct DataLinkChannelIteratorImpl<'a, T: Activated + Send + Sync + 'a> {
  }
  impl<'a, T: Activated + Send + Sync> EthernetDataLinkChannelIterator<'a> for DataLinkChannelIteratorImpl<'a, T> {
  - fn next(&mut self) -> io::Result<EthernetPacket> {
  + fn next(&mut self) -> io::Result<&[u8]> {
  let mut cap = self.pc.capture.lock().unwrap();
  match cap.next() {
  Ok(pkt) => {
  @@ -172,7 +167,7 @@ impl<'a, T: Activated + Send + Sync> EthernetDataLinkChannelIterator<'a> for Dat
  },
  Err(e) => return Err(io::Error::new(io::ErrorKind::Other, e)),
  };
  - Ok(EthernetPacket::new(&self.pc.read_buffer).unwrap())
  + Ok(&self.pc.read_buffer)
  }
  }
  