mirror of
https://github.com/espressif/openthread.git
synced 2026-08-20 01:19:51 +00:00
[tests] fix key_id_mode handling and add exception handle (#4927)
This commit fixes key_id_mode handling and added exception handling
when key_id_mode is 0.
According to IEEE Std 802.15.4-2015, when Key Id Mode is 0x00:
Key is determined implicitly from the originator and recipient(s)
of the frame, as indicated in the frame header.
Our test scripts cannot handle such packets. If we leave key_id_mode =
0 case unhandled, we would get some exceptions that may cause
developers to think that something is wrong. However dropping packets
in this case is a normal behavior.
This commit is contained in:
@@ -42,6 +42,15 @@ from net_crypto import (
|
||||
)
|
||||
|
||||
|
||||
class KeyIdMode0Exception(Exception):
|
||||
"""
|
||||
Raised when key id mode of packet is 0.
|
||||
Such packet wouldn't be handled in test scripts,
|
||||
but it's not abnormal behavior.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class DeviceDescriptors:
|
||||
"""Class representing 802.15.4 Device Descriptors."""
|
||||
|
||||
@@ -377,11 +386,13 @@ class MacFrame:
|
||||
key_id_mode = (security_control & 0x18) >> 3
|
||||
|
||||
if key_id_mode == 0:
|
||||
key_id = data.read(9)
|
||||
raise KeyIdMode0Exception
|
||||
elif key_id_mode == 1:
|
||||
key_id = data.read(1)
|
||||
elif key_id_mode == 2:
|
||||
key_id = data.read(5)
|
||||
elif key_id_mode == 3:
|
||||
key_id = data.read(9)
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user