Skip to content
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

Make Dot11EltVendorSpecific packet extensible #4660

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Hoolean
Copy link

@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 78.57%. Comparing base (c15a670) to head (05b4154).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4660      +/-   ##
==========================================
- Coverage   81.55%   78.57%   -2.99%     
==========================================
  Files         359      334      -25     
  Lines       86557    81372    -5185     
==========================================
- Hits        70592    63934    -6658     
- Misses      15965    17438    +1473     
Files with missing lines Coverage Δ
scapy/layers/dot11.py 91.44% <100.00%> (+0.20%) ⬆️

... and 286 files with indirect coverage changes

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.

1 participant