Skip to content

Commit f4715e6

Browse files
committed
Fix 802.11 control frames type 1 addr
Fix #3808
1 parent 3c66f92 commit f4715e6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

scapy/layers/dot11.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,11 +713,12 @@ class Dot11(Packet):
713713
ConditionalField(
714714
_Dot11MacField("addr2", ETHER_ANY, 2),
715715
lambda pkt: (pkt.type != 1 or
716-
pkt.subtype in [0x8, 0x9, 0xa, 0xb, 0xe, 0xf]),
716+
pkt.subtype in [0x4, 0x5, 0x6, 0x8, 0x9, 0xa, 0xb, 0xe, 0xf]),
717717
),
718718
ConditionalField(
719719
_Dot11MacField("addr3", ETHER_ANY, 3),
720-
lambda pkt: pkt.type in [0, 2],
720+
lambda pkt: (pkt.type in [0, 2] or
721+
((pkt.type, pkt.subtype) == (1, 6) and pkt.cfe == 6)),
721722
),
722723
ConditionalField(LEShortField("SC", 0), lambda pkt: pkt.type != 1),
723724
ConditionalField(
@@ -770,6 +771,8 @@ def address_meaning(self, index):
770771
if self.type == 0: # Management
771772
return _dot11_addr_meaning[0][index]
772773
elif self.type == 1: # Control
774+
if (self.type, self.subtype) == (1, 6) and self.cfe == 6:
775+
return ["RA", "NAV-SA", "NAV-DA"][index]
773776
return _dot11_addr_meaning[1][index]
774777
elif self.type == 2: # Data
775778
meaning = _dot11_addr_meaning[2][index][

test/scapy/layers/dot11.uts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ assert Dot11Elt(info="scapy").summary() == "SSID='scapy'"
6161
assert Dot11Elt(ID=1).mysummary() == ""
6262
assert Dot11(b'\x84\x00\x00\x00\x00\x11\x22\x33\x44\x55\x00\x11\x22\x33\x44\x55').addr2 == '00:11:22:33:44:55'
6363

64+
= Dot11 - type 1 subtype 4, 5, 6
65+
66+
assert raw(Dot11(type=1, subtype=4, addr2="ff:ff:ff:ff:ff:ff")) == b'D\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff'
67+
assert raw(Dot11(type=1, subtype=5, addr2="ff:ff:ff:ff:ff:ff")) == b'T\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff'
68+
assert raw(Dot11(type=1, subtype=6, addr2="ff:ff:ff:ff:ff:ff", cfe=3)) == b'd0\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff'
69+
assert raw(Dot11(type=1, subtype=6, addr2="ff:ff:ff:ff:ff:ff", cfe=6, addr3="aa:aa:aa:aa:aa:aa")) == b'd`\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xaa\xaa\xaa\xaa\xaa\xaa'
70+
71+
assert Dot11(type=1, subtype=5).address_meaning(1) == 'RA'
72+
assert Dot11(type=1, subtype=6, cfe=5).address_meaning(2) == 'TA'
73+
assert Dot11(type=1, subtype=6, cfe=6).address_meaning(2) == 'NAV-SA'
74+
assert Dot11(type=1, subtype=6, cfe=6).address_meaning(3) == 'NAV-DA'
75+
6476
= Multiple Dot11Elt layers
6577
pkt = Dot11() / Dot11Beacon() / Dot11Elt(ID="Supported Rates") / Dot11Elt(ID="SSID", info="Scapy")
6678
assert pkt[Dot11Elt::{"ID": 0}].info == b"Scapy"

0 commit comments

Comments
 (0)