wlan_sme/client/
event.rs

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.
4
5use ieee80211::{Bssid, MacAddr};
6use wlan_common::timer::TimeoutDuration;
7
8/// 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;
11
12/// 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;
17
18/// 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;
24
25/// 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;
28
29/// 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;
32
33pub const INSPECT_PULSE_CHECK_MINUTES: i64 = 1;
34pub const INSPECT_PULSE_PERSIST_MINUTES: i64 = 5;
35
36#[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
43    InspectPulsePersist(InspectPulsePersist),
44    SaeTimeout(SaeTimeout),
45    DeauthenticateTimeout(DeauthenticateTimeout),
46}
47impl From<RsnaCompletionTimeout> for Event {
48    fn from(timeout: RsnaCompletionTimeout) -> Self {
49        Event::RsnaCompletionTimeout(timeout)
50    }
51}
52impl From<RsnaResponseTimeout> for Event {
53    fn from(timeout: RsnaResponseTimeout) -> Self {
54        Event::RsnaResponseTimeout(timeout)
55    }
56}
57impl From<RsnaRetransmissionTimeout> for Event {
58    fn from(timeout: RsnaRetransmissionTimeout) -> Self {
59        Event::RsnaRetransmissionTimeout(timeout)
60    }
61}
62impl From<InspectPulseCheck> for Event {
63    fn from(this: InspectPulseCheck) -> Self {
64        Event::InspectPulseCheck(this)
65    }
66}
67impl From<InspectPulsePersist> for Event {
68    fn from(this: InspectPulsePersist) -> Self {
69        Event::InspectPulsePersist(this)
70    }
71}
72impl From<SaeTimeout> for Event {
73    fn from(this: SaeTimeout) -> Self {
74        Event::SaeTimeout(this)
75    }
76}
77impl From<DeauthenticateTimeout> for Event {
78    fn from(this: DeauthenticateTimeout) -> Self {
79        Event::DeauthenticateTimeout(this)
80    }
81}
82
83#[derive(Debug, Clone)]
84pub struct RsnaCompletionTimeout;
85impl TimeoutDuration for RsnaCompletionTimeout {
86    fn timeout_duration(&self) -> zx::MonotonicDuration {
87        zx::MonotonicDuration::from_millis(RSNA_COMPLETION_TIMEOUT_MILLIS)
88    }
89}
90
91#[derive(Debug, Clone)]
92pub struct RsnaResponseTimeout;
93impl TimeoutDuration for RsnaResponseTimeout {
94    fn timeout_duration(&self) -> zx::MonotonicDuration {
95        zx::MonotonicDuration::from_millis(RSNA_RESPONSE_TIMEOUT_MILLIS)
96    }
97}
98
99#[derive(Debug, Clone)]
100pub struct RsnaRetransmissionTimeout {
101    pub bssid: Bssid,
102    pub sta_addr: MacAddr,
103}
104impl TimeoutDuration for RsnaRetransmissionTimeout {
105    fn timeout_duration(&self) -> zx::MonotonicDuration {
106        zx::MonotonicDuration::from_millis(RSNA_RETRANSMISSION_TIMEOUT_MILLIS)
107    }
108}
109
110#[derive(Debug, Clone)]
111pub struct InspectPulseCheck;
112impl TimeoutDuration for InspectPulseCheck {
113    fn timeout_duration(&self) -> zx::MonotonicDuration {
114        zx::MonotonicDuration::from_minutes(INSPECT_PULSE_CHECK_MINUTES)
115    }
116}
117
118#[derive(Debug, Clone)]
119pub struct InspectPulsePersist;
120impl TimeoutDuration for InspectPulsePersist {
121    fn timeout_duration(&self) -> zx::MonotonicDuration {
122        zx::MonotonicDuration::from_minutes(INSPECT_PULSE_PERSIST_MINUTES)
123    }
124}
125
126#[derive(Debug, Clone)]
127pub struct SaeTimeout(pub u64);
128impl TimeoutDuration for SaeTimeout {
129    fn timeout_duration(&self) -> zx::MonotonicDuration {
130        zx::MonotonicDuration::from_millis(SAE_RETRANSMISSION_TIMEOUT_MILLIS)
131    }
132}
133
134#[derive(Debug, Clone)]
135pub struct DeauthenticateTimeout;
136impl TimeoutDuration for DeauthenticateTimeout {
137    fn timeout_duration(&self) -> zx::MonotonicDuration {
138        zx::MonotonicDuration::from_millis(DEAUTHENTICATE_TIMEOUT_MILLIS)
139    }
140}