/// Read header from a given raw representation.
Read header from a given raw representation.
Read header from a given raw representation .
fn parse(data: &[u8]) -> EtherPacketHeader {
        assert_eq!(data.len(), mem::size_of::<RawEtherPacketHeader>());
        let ptr = data.as_ptr();
        let ptr = ptr as *const RawEtherPacketHeader;
        let rh  = unsafe {
            &*ptr
        };
        EtherPacketHeader {
            src:   MacAddr::from_slice(&rh.src),
            dst:   MacAddr::from_slice(&rh.dst),
            etype: u16::from_be(rh.etype)
        }
    }
fn parse ( data : & [ u8 ] ) -> EtherPacketHeader { assert_eq ! ( data len ( ) mem size_of RawEtherPacketHeader ( ) ) ; let ptr = data . as_ptr ( ) ; let ptr = ptr as * const RawEtherPacketHeader ; let rh = unsafe { & * ptr } ; EtherPacketHeader { src : MacAddr :: from_slice ( & rh . src ) , dst : MacAddr :: from_slice ( & rh . dst ) , etype : u16 :: from_be ( rh . etype ) } }
Read header from a given raw representation.
Read header from a given raw representation .
data
&[u8]