Skip to content

Commit

Permalink
[wlan][mlme] Fix AP associate result code to status code mapping
Browse files Browse the repository at this point in the history
The fidl_mlme::AssociateResultCodes values should trivially map one-to-one
with StatusCode values. Prior to this change, the mapping was one-to-one
but not quite trivial. The mapping of AssociateResultCodes::RefusedReasonUnspecified
is changed to StatusCode::REFUSED instead of StatusCode::DENY_OTHER_REASON.

Added an additional test of handle_mlme_assoc_resp() that tests the
new mapping.

Test: fx test wlan-mlme-tests
Change-Id: If0a5ea59be88785717d3aef4fe685338c6ea1a42
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/439138
Reviewed-by: Dylan Swiggett <swiggett@google.com>
Testability-Review: Dylan Swiggett <swiggett@google.com>
Commit-Queue: Charles Celerier <chcl@google.com>
  • Loading branch information
c6c7 authored and CQ Bot committed Oct 28, 2020
1 parent 0409e21 commit b3cc661
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions src/connectivity/wlan/lib/mlme/rust/src/ap/remote_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ impl RemoteClient {
panic!("Success should have already been handled");
}
fidl_mlme::AssociateResultCodes::RefusedReasonUnspecified => {
StatusCode::DENIED_OTHER_REASON
StatusCode::REFUSED
}
fidl_mlme::AssociateResultCodes::RefusedNotAuthenticated => {
StatusCode::REFUSED_UNAUTHENTICATED_ACCESS_NOT_SUPPORTED
Expand Down Expand Up @@ -1334,7 +1334,42 @@ mod tests {
}

#[test]
fn handle_mlme_assoc_resp_failure() {
fn handle_mlme_assoc_resp_failure_reason_unspecified() {
let mut fake_device = FakeDevice::new();
let mut r_sta = make_remote_client();
let mut fake_scheduler = FakeScheduler::new();
let mut ctx = make_context(fake_device.as_device(), fake_scheduler.as_scheduler());
r_sta
.handle_mlme_assoc_resp(
&mut ctx,
false,
1,
CapabilityInfo(0),
fidl_mlme::AssociateResultCodes::RefusedReasonUnspecified,
1, // This AID is ignored in the case of an error.
&[][..],
)
.expect("expected OK");
assert_variant!(r_sta.state.as_ref(), State::Authenticated);
assert_eq!(fake_device.wlan_queue.len(), 1);
#[rustfmt::skip]
assert_eq!(&fake_device.wlan_queue[0].0[..], &[
// Mgmt header
0b00010000, 0, // Frame Control
0, 0, // Duration
1, 1, 1, 1, 1, 1, // addr1
2, 2, 2, 2, 2, 2, // addr2
2, 2, 2, 2, 2, 2, // addr3
0x10, 0, // Sequence Control
// Association response header:
0, 0, // Capabilities
1, 0, // status code
0, 0, // AID
][..]);
}

#[test]
fn handle_mlme_assoc_resp_failure_emergency_services_not_supported() {
let mut fake_device = FakeDevice::new();
let mut r_sta = make_remote_client();
let mut fake_scheduler = FakeScheduler::new();
Expand Down

0 comments on commit b3cc661

Please sign in to comment.