Skip to content

Make Dot11EltVendorSpecific packet extensible #4660

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

Merged
merged 5 commits into from
Apr 23, 2025

Conversation

Hoolean
Copy link
Contributor

@Hoolean Hoolean commented Feb 7, 2025

See #4659

This commit allows the Dot11EltVendorSpecific packet to dispatch to its subclasses based on their OUI, with the same idiom that the parent Dot11Elt uses to select subclasses based on their ID already:

scapy/scapy/layers/dot11.py

Lines 1057 to 1074 in c15a670

registered_ies = {}
@classmethod
def register_variant(cls, id=None):
id = id or cls.ID.default
if id not in cls.registered_ies:
cls.registered_ies[id] = cls
@classmethod
def dispatch_hook(cls, _pkt=None, *args, **kargs):
if _pkt:
_id = ord(_pkt[:1])
idcls = cls.registered_ies.get(_id, cls)
if idcls.dispatch_hook != cls.dispatch_hook:
# Vendor has its own dispatch_hook
return idcls.dispatch_hook(_pkt=_pkt, *args, **kargs)
cls = idcls
return cls

This is just a rough sketch, so feedback very welcome; is the approach heading in the right direction? :)

See secdev#4659

This commit allows the Dot11EltVendorSpecific packet to dispatch to its
subclasses based on their OUI, with the same idiom that the parent
Dot11Elt uses to select subclasses based on their ID already:

https://github.com/secdev/scapy/blob/c15a670926185f6ddb9b3330ed1f947ff6f14b92/scapy/layers/dot11.py#L1057-L1074

This is just a rough sketch, so feedback very welcome to make sure it is
heading in the right direction :)
Copy link

codecov bot commented Feb 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.20%. Comparing base (c15a670) to head (37c6521).
Report is 38 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4660      +/-   ##
==========================================
+ Coverage   81.55%   82.20%   +0.64%     
==========================================
  Files         359      361       +2     
  Lines       86557    87195     +638     
==========================================
+ Hits        70592    71679    +1087     
+ Misses      15965    15516     -449     
Files with missing lines Coverage Δ
scapy/layers/dot11.py 91.46% <100.00%> (+0.21%) ⬆️

... and 59 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gpotter2 gpotter2 marked this pull request as ready for review April 21, 2025 21:52
@gpotter2
Copy link
Member

Hi, thanks for the PR & sorry for the delay.
I like the PR ! I've pushed a tiny change. If the tests pass we're all good.

@gpotter2 gpotter2 merged commit 0648c0d into secdev:master Apr 23, 2025
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants