1// Copyright 2018 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
45use ieee80211::{Bssid, MacAddr};
6use wlan_common::timer::TimeoutDuration;
78/// Amount of time in milliseconds an entire RSNA establishment is allowed to take.
9/// Exceeding this time will result in a failure to establish the RSNA.
10pub const RSNA_COMPLETION_TIMEOUT_MILLIS: i64 = 8700;
1112/// Amount of time in milliseconds the supplicant or authenticator has to respond
13/// to a frame used to establish an RSNA, e.g., an EAPOL key frame.
14/// A delayed response exceeding this time will result in a failure to establish
15/// the RSNA.
16pub const RSNA_RESPONSE_TIMEOUT_MILLIS: i64 = 4000;
1718/// Amount of time in milliseconds the supplicant or authenticator will wait for a
19/// response before retransmitting the last transmitted frame for establishing
20/// the RSNA, e.g., the last transmitted EAPOL key frame. The implementation of
21/// the RSNA decides how many retries are allowed. This timeout never triggers
22/// a failure to establish the RSNA.
23pub const RSNA_RETRANSMISSION_TIMEOUT_MILLIS: i64 = 200;
2425/// Amount of time in milliseconds a participant in the SAE handshake will wait for
26/// a response before restransmitting the last transmitted SAE message.
27pub const SAE_RETRANSMISSION_TIMEOUT_MILLIS: i64 = 1000;
2829/// Amount of time in milliseconds we should wait for a deauth response from the
30/// driver before aborting a connection.
31pub const DEAUTHENTICATE_TIMEOUT_MILLIS: i64 = 500;
3233pub const INSPECT_PULSE_CHECK_MINUTES: i64 = 1;
34pub const INSPECT_PULSE_PERSIST_MINUTES: i64 = 5;
3536#[derive(Debug, Clone)]
37pub enum Event {
38 RsnaCompletionTimeout(RsnaCompletionTimeout),
39 RsnaResponseTimeout(RsnaResponseTimeout),
40 RsnaRetransmissionTimeout(RsnaRetransmissionTimeout),
41 InspectPulseCheck(InspectPulseCheck),
42/// From startup, periodically schedule an event to persist the Inspect pulse data
43InspectPulsePersist(InspectPulsePersist),
44 SaeTimeout(SaeTimeout),
45 DeauthenticateTimeout(DeauthenticateTimeout),
46}
47impl From<RsnaCompletionTimeout> for Event {
48fn from(timeout: RsnaCompletionTimeout) -> Self {
49 Event::RsnaCompletionTimeout(timeout)
50 }
51}
52impl From<RsnaResponseTimeout> for Event {
53fn from(timeout: RsnaResponseTimeout) -> Self {
54 Event::RsnaResponseTimeout(timeout)
55 }
56}
57impl From<RsnaRetransmissionTimeout> for Event {
58fn from(timeout: RsnaRetransmissionTimeout) -> Self {
59 Event::RsnaRetransmissionTimeout(timeout)
60 }
61}
62impl From<InspectPulseCheck> for Event {
63fn from(this: InspectPulseCheck) -> Self {
64 Event::InspectPulseCheck(this)
65 }
66}
67impl From<InspectPulsePersist> for Event {
68fn from(this: InspectPulsePersist) -> Self {
69 Event::InspectPulsePersist(this)
70 }
71}
72impl From<SaeTimeout> for Event {
73fn from(this: SaeTimeout) -> Self {
74 Event::SaeTimeout(this)
75 }
76}
77impl From<DeauthenticateTimeout> for Event {
78fn from(this: DeauthenticateTimeout) -> Self {
79 Event::DeauthenticateTimeout(this)
80 }
81}
8283#[derive(Debug, Clone)]
84pub struct RsnaCompletionTimeout;
85impl TimeoutDuration for RsnaCompletionTimeout {
86fn timeout_duration(&self) -> zx::MonotonicDuration {
87 zx::MonotonicDuration::from_millis(RSNA_COMPLETION_TIMEOUT_MILLIS)
88 }
89}
9091#[derive(Debug, Clone)]
92pub struct RsnaResponseTimeout;
93impl TimeoutDuration for RsnaResponseTimeout {
94fn timeout_duration(&self) -> zx::MonotonicDuration {
95 zx::MonotonicDuration::from_millis(RSNA_RESPONSE_TIMEOUT_MILLIS)
96 }
97}
9899#[derive(Debug, Clone)]
100pub struct RsnaRetransmissionTimeout {
101pub bssid: Bssid,
102pub sta_addr: MacAddr,
103}
104impl TimeoutDuration for RsnaRetransmissionTimeout {
105fn timeout_duration(&self) -> zx::MonotonicDuration {
106 zx::MonotonicDuration::from_millis(RSNA_RETRANSMISSION_TIMEOUT_MILLIS)
107 }
108}
109110#[derive(Debug, Clone)]
111pub struct InspectPulseCheck;
112impl TimeoutDuration for InspectPulseCheck {
113fn timeout_duration(&self) -> zx::MonotonicDuration {
114 zx::MonotonicDuration::from_minutes(INSPECT_PULSE_CHECK_MINUTES)
115 }
116}
117118#[derive(Debug, Clone)]
119pub struct InspectPulsePersist;
120impl TimeoutDuration for InspectPulsePersist {
121fn timeout_duration(&self) -> zx::MonotonicDuration {
122 zx::MonotonicDuration::from_minutes(INSPECT_PULSE_PERSIST_MINUTES)
123 }
124}
125126#[derive(Debug, Clone)]
127pub struct SaeTimeout(pub u64);
128impl TimeoutDuration for SaeTimeout {
129fn timeout_duration(&self) -> zx::MonotonicDuration {
130 zx::MonotonicDuration::from_millis(SAE_RETRANSMISSION_TIMEOUT_MILLIS)
131 }
132}
133134#[derive(Debug, Clone)]
135pub struct DeauthenticateTimeout;
136impl TimeoutDuration for DeauthenticateTimeout {
137fn timeout_duration(&self) -> zx::MonotonicDuration {
138 zx::MonotonicDuration::from_millis(DEAUTHENTICATE_TIMEOUT_MILLIS)
139 }
140}