pub fn parse(data: &[u8]) -> Result<EtherPacket<B>> {
        let hsize = mem::size_of::<RawEtherPacketHeader>();
        if data.len() < hsize {
            Err(PacketParseError::from("unable to parse ethernet packet, not enough data"))
        } else {
            let header = EtherPacketHeader::parse(&data[..hsize]);
            let body   = try!(B::parse(&data[hsize..]));
            let btype  = body.packet_type();
            if btype == EtherPacketType::UNKNOWN ||
                btype == EtherPacketType::from(header.etype) {
                Ok(EtherPacket::new(header, body))
            } else {
                Err(PacketParseError::from("expect and actual ethernet packet types do not match"))
            }
        }
    }
/// Parse a given ethernet packet.
Parse a given ethernet packet.
Parse a given ethernet packet .
pub fn parse(data: &[u8]) -> Result<EtherPacket<B>> {
        let hsize = mem::size_of::<RawEtherPacketHeader>();
        if data.len() < hsize {
            Err(PacketParseError::from("unable to parse ethernet packet, not enough data"))
        } else {
            let header = EtherPacketHeader::parse(&data[..hsize]);
            let body   = try!(B::parse(&data[hsize..]));
            let btype  = body.packet_type();
            if btype == EtherPacketType::UNKNOWN ||
                btype == EtherPacketType::from(header.etype) {
                Ok(EtherPacket::new(header, body))
            } else {
                Err(PacketParseError::from("expect and actual ethernet packet types do not match"))
            }
        }
    }
pub fn parse ( data : & [ u8 ] ) -> Result < EtherPacket < B > > { let hsize = mem :: size_of :: < RawEtherPacketHeader > ( ) ; if data . len ( ) < hsize { Err ( PacketParseError :: from ( " " ) ) } else { let header = EtherPacketHeader :: parse ( & data [ .. hsize ] ) ; let body = try ! ( B parse ( data [ hsize ] ) ) ; let btype = body . packet_type ( ) ; if btype == EtherPacketType :: UNKNOWN || btype == EtherPacketType :: from ( header . etype ) { Ok ( EtherPacket :: new ( header , body ) ) } else { Err ( PacketParseError :: from ( " " ) ) } } }
Parse a given ethernet packet.
Parse a given ethernet packet .
data
&[u8]
data
&[u8]