[mac] change address filter and seek function to accept frame without PAN ID (#5389)

In 802.15.4-2015 spec Table 7-2, it is possible to receive frame with
destination address but without destination PAN ID. This commit
changes the address filter function to avoid dropping such frames.
This commit is contained in:
Jintao Lin
2020-08-17 22:34:38 -07:00
committed by GitHub
parent 5e34b5062d
commit 3f38068a71
5 changed files with 85 additions and 68 deletions
+19 -3
View File
@@ -217,9 +217,25 @@ class MacFrame:
self.payload = None
return
# Presence of PAN Ids is not fully implemented yet but should be enough
# for Thread.
dest_pan_id = struct.unpack("<H", data.read(2))[0]
dest_addr_present = dest_addr_mode != MacHeader.AddressMode.NOT_PRESENT
src_addr_present = source_addr_mode != MacHeader.AddressMode.NOT_PRESENT
if frame_version < 2:
dest_pan_present = dest_addr_present
else:
dest_pan_present = True
if not src_addr_present:
dest_pan_present = src_pan_present != panid_compression
elif not dest_addr_present:
dest_pan_present = False
else:
if dest_addr_mode == MacHeader.AddressMode.EXTENDED and source_addr_mode == MacHeader.AddressMode.EXTENDED and panid_compression:
dest_pan_present = False
if dest_pan_present:
dest_pan_id = struct.unpack("<H", data.read(2))[0]
else:
dest_pan_id = None
dest_address = self._parse_address(data, dest_addr_mode)