diff options
author | David Su <dysu@google.com> | 2018-09-28 14:51:02 -0700 |
---|---|---|
committer | David Su <dysu@google.com> | 2018-10-03 16:53:44 -0700 |
commit | 1ba343c89039197265c96afdfeff7cec7e3280ec (patch) | |
tree | 949bfb1c94172208a082969ce2d7bff29511d5ae /tests | |
parent | c6078a70cdb74e37111121b9cdc86e458943d05b (diff) |
Added parsing logic for subtypes 0xA and 0xC in dumpsys wifi
Added parsing for disassociation (subtype 0xA) and
deauthentication (subtype 0xC) frames.
Also decode numeric reason code into a more
descriptive string that explains why the
disassociation/deauthentication frames were sent,
per the 2016 802.11 specs.
Bug: 30502480
Fix: 30502480
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Test: manual - connect to an AP using the wrong password,
verify that `adb shell dumpsys wifi` shows failed connection
with last packet type as "Deauthentication".
Change-Id: I75b07e1362f04d8d990facb0f61371a122d0e43b
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/util/FrameParserTest.java | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/util/FrameParserTest.java b/tests/wifitests/src/com/android/server/wifi/util/FrameParserTest.java index 1de6eca00..5a61d0bf8 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/FrameParserTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/FrameParserTest.java @@ -269,4 +269,75 @@ public class FrameParserTest { assertEquals("Association Request", parser.mTypeString); assertEquals("N/A", parser.mResultString); } + + /** Test that we parse the result code of a deauthentication frame */ + @Test + public void parseDeauthenticationResultCode() { + FrameParser parser = new FrameParser( + WifiLoggerHal.FRAME_TYPE_80211_MGMT, + new byte[]{ + (byte) 0xc0, // type + subtype + 0x00, // flags + 0x00, 0x00, // duration (from host; probably to be filled by firmware) + // addr1 (RA): + (byte) 0xa0, 0x63, (byte) 0x91, (byte) 0xa9, (byte) 0xed, (byte) 0xa1, + // addr2 (TA): + (byte) 0xf4, (byte) 0xf5, (byte) 0xe8, 0x51, (byte) 0x9e, 0x09, + // addr3 (BSSID): + (byte) 0xa0, 0x63, (byte) 0x91, (byte) 0xa9, (byte) 0xed, (byte) 0xa1, + 0x70, (byte) 0x80, // sequence + control + 0x03, 0x00, // reason code + }); + assertEquals("802.11 Mgmt", parser.mMostSpecificProtocolString); + assertEquals("Deauthentication", parser.mTypeString); + assertEquals( + "3: Deauthenticated because sending STA is leaving (or has left) IBSS or ESS", + parser.mResultString); + } + + /** Test that we parse the result code of a disassociation frame */ + @Test + public void parseDisassociationResultCode() { + FrameParser parser = new FrameParser( + WifiLoggerHal.FRAME_TYPE_80211_MGMT, + new byte[]{ + (byte) 0xa0, // type + subtype + 0x00, // flags + 0x00, 0x00, // duration (from host; probably to be filled by firmware) + // addr1 (RA): + (byte) 0xa0, 0x63, (byte) 0x91, (byte) 0xa9, (byte) 0xed, (byte) 0xa1, + // addr2 (TA): + (byte) 0xf4, (byte) 0xf5, (byte) 0xe8, 0x51, (byte) 0x9e, 0x09, + // addr3 (BSSID): + (byte) 0xa0, 0x63, (byte) 0x91, (byte) 0xa9, (byte) 0xed, (byte) 0xa1, + 0x70, (byte) 0x80, // sequence + control + 0x04, 0x00, // reason code + }); + assertEquals("802.11 Mgmt", parser.mMostSpecificProtocolString); + assertEquals("Disassociation", parser.mTypeString); + assertEquals("4: Disassociated due to inactivity", parser.mResultString); + } + + /** Test that we parse the subtype of an Action No Ack frame */ + @Test + public void parseActionNoAckSubtype() { + FrameParser parser = new FrameParser( + WifiLoggerHal.FRAME_TYPE_80211_MGMT, + new byte[]{ + (byte) 0xe0, // type + subtype + 0x00, // flags + 0x00, 0x00, // duration (from host; probably to be filled by firmware) + // addr1 (RA): + (byte) 0xa0, 0x63, (byte) 0x91, (byte) 0xa9, (byte) 0xed, (byte) 0xa1, + // addr2 (TA): + (byte) 0xf4, (byte) 0xf5, (byte) 0xe8, 0x51, (byte) 0x9e, 0x09, + // addr3 (BSSID): + (byte) 0xa0, 0x63, (byte) 0x91, (byte) 0xa9, (byte) 0xed, (byte) 0xa1, + 0x70, (byte) 0x80, // sequence + control + 0x00, 0x00, // action + }); + assertEquals("802.11 Mgmt", parser.mMostSpecificProtocolString); + assertEquals("Action No Ack", parser.mTypeString); + assertEquals("N/A", parser.mResultString); + } }
\ No newline at end of file |