Skip to content

Add LoWPAN enhancements #3556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

akestoridis
Copy link
Contributor

  • Create an mle layer
  • Improve the dissection of secured MAC Data packets
  • Improve the dissection of secured MAC Beacon packets
  • Enable the dissection of Thread beacons
  • Improve the dissection of secured MAC Command packets
  • Improve the dissection of 6LoWPAN Mesh header fields
  • Fix bug in the extraction of the source address of 6LoWPAN packets
  • Improve the dissection of 6LoWPAN IPHC header fields
  • Fix bug in the 6LoWPAN dispatcher
  • Add unit tests

@codecov
Copy link

codecov bot commented Apr 26, 2022

Codecov Report

Merging #3556 (14b4038) into master (e0c96c5) will decrease coverage by 0.01%.
The diff coverage is 79.64%.

❗ Current head 14b4038 differs from pull request most recent head 123db03. Consider uploading reports for the commit 123db03 to get more accurate results

@@            Coverage Diff             @@
##           master    #3556      +/-   ##
==========================================
- Coverage   86.18%   86.17%   -0.02%     
==========================================
  Files         284      285       +1     
  Lines       64874    65024     +150     
==========================================
+ Hits        55914    56032     +118     
- Misses       8960     8992      +32     
Impacted Files Coverage Δ
scapy/config.py 81.16% <ø> (ø)
scapy/layers/dot15d4.py 78.80% <77.58%> (-0.77%) ⬇️
scapy/layers/mle.py 80.64% <80.64%> (ø)
scapy/layers/sixlowpan.py 86.06% <89.47%> (+0.62%) ⬆️
scapy/layers/zigbee.py 79.77% <100.00%> (-0.08%) ⬇️
scapy/arch/windows/__init__.py 67.73% <0.00%> (-0.57%) ⬇️
scapy/layers/ntp.py 84.55% <0.00%> (-0.28%) ⬇️
scapy/contrib/isotp/isotp_soft_socket.py 83.23% <0.00%> (-0.20%) ⬇️
scapy/fields.py 91.13% <0.00%> (-0.06%) ⬇️
... and 1 more

@akestoridis akestoridis force-pushed the lowpan-enhancements branch from 14b4038 to 90a8932 Compare April 26, 2022 20:54
@akestoridis akestoridis force-pushed the lowpan-enhancements branch from 90a8932 to 123db03 Compare April 26, 2022 21:42
@akestoridis
Copy link
Contributor Author

Fixed compatibility with Python 2.7, added more unit tests, squashed them into one commit, and rebased against master.

if len(payload) > 0:
if (
(isinstance(payload[0], int) and payload[0] == 0x03) or
(isinstance(payload[0], bytes) and payload[0] == b'\x03')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use orb(payload[0]) == 0x03 to work on all Python versions (from scapy.compat import orb)

return ThreadBeacon
elif (
(isinstance(payload[0], int) and payload[0] == 0x00) or
(isinstance(payload[0], bytes) and payload[0] == b'\x00')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

elif self.aux_sec_header.sec_sc_seclevel in {3, 7}:
mic_length = 16
else:
mic_length = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a lot of code that is re-used. Could you exerternalize it to a function?

self.aux_sec_header.remove_payload()
if mic_length > 0 and mic_length <= len(self.sec_payload):
self.mic = self.sec_payload[-mic_length:]
self.sec_payload = self.sec_payload[:-mic_length]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same: you could reuse the function defined above.

@gpotter2
Copy link
Member

gpotter2 commented May 9, 2022

Thanks for the PR, I have a few comments to start with. Very sorry for the review delay

@akestoridis
Copy link
Contributor Author

Thank you for reviewing the PR. Unfortunately, I am unable to make further changes. However, you are welcome to refactor the code in a follow-up commit. The unit tests of this PR should pass even after the suggested changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants