Skip to content

Commit

Permalink
Fixup of PR #423 (IEEE80211 DELBA frame) (#516)
Browse files Browse the repository at this point in the history
* Implement decoding of DELBA Mgmt Action (Delete Block Ack).
  • Loading branch information
obormot committed Dec 28, 2020
1 parent dc83735 commit b5efa33
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions dpkt/ieee80211.py
Expand Up @@ -115,6 +115,7 @@
# Block ack category action codes
BLOCK_ACK_CODE_REQUEST = 0
BLOCK_ACK_CODE_RESPONSE = 1
BLOCK_ACK_CODE_DELBA = 2


class IEEE80211(dpkt.Packet):
Expand All @@ -132,6 +133,10 @@ class IEEE80211(dpkt.Packet):
('duration', 'H', 0)
)

# The standard really defines the entire MAC protocol as little-endian on the wire,
# however there is broken logic in the rest of the module preventing this from working right now
#__byte_order__ = '<'

@property
def version(self):
return (self.framectl & _VERSION_MASK) >> _VERSION_SHIFT
Expand Down Expand Up @@ -517,6 +522,7 @@ def unpack(self, buf):
BLOCK_ACK: {
BLOCK_ACK_CODE_REQUEST: ('block_ack_request', IEEE80211.BlockAckActionRequest),
BLOCK_ACK_CODE_RESPONSE: ('block_ack_response', IEEE80211.BlockAckActionResponse),
BLOCK_ACK_CODE_DELBA: ('block_ack_delba', IEEE80211.BlockAckActionDelba),
},
}

Expand Down Expand Up @@ -546,6 +552,14 @@ class BlockAckActionResponse(dpkt.Packet):
('timeout', 'H', 0),
)

class BlockAckActionDelba(dpkt.Packet):
__byte_order__ = '<'
__hdr__ = (
('delba_param_set', 'H', 0),
('reason_code', 'H', 0),
#('gcr_group_addr', '8s', '\x00' * 8), # Standard says it must be there, but it isn't?
)

class Data(dpkt.Packet):
__hdr__ = (
('dst', '6s', '\x00' * 6),
Expand Down Expand Up @@ -781,6 +795,16 @@ def test_action_block_ack_response():
parameters = struct.unpack('<H', b'\x10\x02')[0]
assert ieee.action.block_ack_response.parameters == parameters

def test_action_block_ack_delete():
s = b'\xd0\x00\x2c\x00\x00\xc1\x41\x06\x13\x0d\x6c\xb2\xae\xae\xde\x80\x6c\xb2\xae\xae\xde\x80\xa0\x52\x03\x02\x00\x08\x01\x00\x74\x5d\x0a\xc6'
ieee = IEEE80211(s, fcs=True)
assert ieee.type == MGMT_TYPE
assert ieee.subtype == M_ACTION
assert ieee.action.category == BLOCK_ACK
assert ieee.action.code == BLOCK_ACK_CODE_DELBA
assert ieee.action.block_ack_delba.delba_param_set == 0x0800
assert ieee.action.block_ack_delba.reason_code == 1

if __name__ == '__main__':
# Runs all the test associated with this class/file
test_802211_ack()
Expand All @@ -792,4 +816,5 @@ def test_action_block_ack_response():
test_compressed_block_ack()
test_action_block_ack_request()
test_action_block_ack_response()
test_action_block_ack_delete()
print('Tests Successful...')

0 comments on commit b5efa33

Please sign in to comment.