Skip to content

Commit 0f2b394

Browse files
authored
Change ID field to use little-endian byte order (#4629)
* Change ID field to use little-endian byte order * Add unit tests to verify encoding and decoding of Dot11 ID field
1 parent f998c63 commit 0f2b394

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

scapy/layers/dot11.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ class Dot11(Packet):
730730
["next_tbtt", "comp_ssid", "ano"]),
731731
lambda pkt: (pkt.type, pkt.subtype) == (3, 1)
732732
),
733-
ShortField("ID", 0),
733+
LEShortField("ID", 0),
734734
_Dot11MacField("addr1", ETHER_ANY, 1),
735735
ConditionalField(
736736
_Dot11MacField("addr2", ETHER_ANY, 2),

test/scapy/layers/dot11.uts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ len(dpl_ether) == 1 and Ether in dpl_ether[0]
1818
s = raw(Dot11())
1919
s == b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
2020

21+
pkt = Dot11(ID=0x1205)
22+
raw_data = raw(pkt)
23+
expected = b'\x05\x12'
24+
assert raw_data[2:4] == b'\x05\x12', f"Encoded Dot11 ID field is {raw_data[2:4]}, expected {repr(expected)}."
25+
2126
= Dot11 - dissection
2227
p = Dot11(s)
2328
Dot11 in p and p.addr3 == "00:00:00:00:00:00"
@@ -26,6 +31,10 @@ assert "DA" in p.address_meaning(1)
2631
assert "SA" in p.address_meaning(2)
2732
assert "BSSID" in p.address_meaning(3)
2833

34+
pkt = b'\x00\x00\x05\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
35+
decoded_pkt = Dot11(pkt)
36+
assert decoded_pkt.ID == 0x1205, f"Decoded Dot11 ID field is {hex(decoded_pkt.ID)}, expected 0x1205."
37+
2938
= Dot11QoS - build
3039
s = raw(Dot11()/Dot11QoS(Ack_Policy=1))
3140
assert s == b'\xc8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00'

0 commit comments

Comments
 (0)