ieee80154: process packets without the FCS.
We assume the FCS is checked by lower layers or by hardware. - Makes it consistent with Ethernet mediums, where we don't handle the FCS either. - Linux ieee802154 raw sockets send/receive packets without the FCS.master
parent
c9712939fb
commit
7c35a061a4
|
@ -1136,7 +1136,6 @@ impl<'a> InterfaceInner<'a> {
|
|||
let payload = iphc_packet.payload();
|
||||
let ip_repr = IpRepr::Sixlowpan(iphc_repr);
|
||||
|
||||
|
||||
// Currently we assume the next header is a UDP, so we mark all the rest with todo.
|
||||
match iphc_repr.next_header {
|
||||
SixlowpanNextHeader::Compressed => {
|
||||
|
@ -2421,8 +2420,6 @@ impl<'a> InterfaceInner<'a> {
|
|||
_ => return Err(Error::Unrecognized),
|
||||
}
|
||||
|
||||
//tx_len += 2; // XXX: FCS calculation not needed when doing it in hardware
|
||||
|
||||
tx_token.consume(cx.now, tx_len, |mut tx_buffer| {
|
||||
// 1. Create the header of 802.15.4
|
||||
let mut ieee_packet = Ieee802154Frame::new_unchecked(&mut tx_buffer);
|
||||
|
@ -2465,10 +2462,6 @@ impl<'a> InterfaceInner<'a> {
|
|||
_ => return Err(Error::Unrecognized),
|
||||
}
|
||||
|
||||
//let fcs = crate::wire::ieee802154::calculate_crc(&tx_buffer[..tx_len-2]);
|
||||
//tx_buffer[tx_len-1] = ((fcs >> 8) & 0xff) as u8;
|
||||
//tx_buffer[tx_len-2] = (fcs & 0xff) as u8;
|
||||
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
|
|
@ -516,12 +516,6 @@ impl<T: AsRef<[u8]>> Frame<T> {
|
|||
|
||||
todo!();
|
||||
}
|
||||
|
||||
/// Return the FCS fields
|
||||
#[inline]
|
||||
pub fn fcs(&self) -> &[u8] {
|
||||
&self.buffer.as_ref()[self.buffer.as_ref().len() - 2..]
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: AsRef<[u8]> + ?Sized> Frame<&'a T> {
|
||||
|
@ -533,7 +527,7 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Frame<&'a T> {
|
|||
let data = &self.buffer.as_ref()[field::ADDRESSING];
|
||||
let offset = self.addressing_fields().unwrap().len();
|
||||
|
||||
Some(&data[offset..data.len() - 2]) // Remove the FCS field of the IEEE80.15.4 frame.
|
||||
Some(&data[offset..])
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
|
@ -692,14 +686,13 @@ impl<T: AsRef<[u8]>> fmt::Display for Frame<T> {
|
|||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"IEEE802.15.4 frame type={} seq={:2x?} dst_pan={:x?} dest={:x?} src_pan={:?} src={:x?} fcs={:x?}",
|
||||
"IEEE802.15.4 frame type={} seq={:2x?} dst_pan={:x?} dest={:x?} src_pan={:?} src={:x?}",
|
||||
self.frame_type(),
|
||||
self.sequence_number(),
|
||||
self.dst_pan_id(),
|
||||
self.dst_addr(),
|
||||
self.src_pan_id(),
|
||||
self.src_addr(),
|
||||
self.fcs(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -908,7 +901,6 @@ mod test {
|
|||
0xff, 0xff, // Short destination address
|
||||
0xc7, 0xd9, 0xb5, 0x14, 0x00, 0x4b, 0x12, 0x00, // Extended source address
|
||||
0x2b, 0x00, 0x00, 0x00, // payload
|
||||
0xb3, 0x0d // FSM
|
||||
];
|
||||
frame_type -> FrameType::Data,
|
||||
security_enabled -> false,
|
||||
|
@ -919,6 +911,5 @@ mod test {
|
|||
frame_version -> FrameVersion::Ieee802154_2006,
|
||||
src_addressing_mode -> AddressingMode::Extended,
|
||||
//payload -> Some(&[0x2b, 0x00, 0x00, 0x00]),
|
||||
fcs -> [0xb3, 0x0d],
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue