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;
34
35#[derive(Debug, Clone)]
36pub enum Event {
37    RsnaCompletionTimeout(RsnaCompletionTimeout),
38    RsnaResponseTimeout(RsnaResponseTimeout),
39    RsnaRetransmissionTimeout(RsnaRetransmissionTimeout),
40    InspectPulseCheck(InspectPulseCheck),
41    SaeTimeout(SaeTimeout),
42    DeauthenticateTimeout(DeauthenticateTimeout),
43}
44impl From<RsnaCompletionTimeout> for Event {
45    fn from(timeout: RsnaCompletionTimeout) -> Self {
46        Event::RsnaCompletionTimeout(timeout)
47    }
48}
49impl From<RsnaResponseTimeout> for Event {
50    fn from(timeout: RsnaResponseTimeout) -> Self {
51        Event::RsnaResponseTimeout(timeout)
52    }
53}
54impl From<RsnaRetransmissionTimeout> for Event {
55    fn from(timeout: RsnaRetransmissionTimeout) -> Self {
56        Event::RsnaRetransmissionTimeout(timeout)
57    }
58}
59impl From<InspectPulseCheck> for Event {
60    fn from(this: InspectPulseCheck) -> Self {
61        Event::InspectPulseCheck(this)
62    }
63}
64impl From<SaeTimeout> for Event {
65    fn from(this: SaeTimeout) -> Self {
66        Event::SaeTimeout(this)
67    }
68}
69impl From<DeauthenticateTimeout> for Event {
70    fn from(this: DeauthenticateTimeout) -> Self {
71        Event::DeauthenticateTimeout(this)
72    }
73}
74
75#[derive(Debug, Clone)]
76pub struct RsnaCompletionTimeout;
77impl TimeoutDuration for RsnaCompletionTimeout {
78    fn timeout_duration(&self) -> zx::MonotonicDuration {
79        zx::MonotonicDuration::from_millis(RSNA_COMPLETION_TIMEOUT_MILLIS)
80    }
81}
82
83#[derive(Debug, Clone)]
84pub struct RsnaResponseTimeout;
85impl TimeoutDuration for RsnaResponseTimeout {
86    fn timeout_duration(&self) -> zx::MonotonicDuration {
87        zx::MonotonicDuration::from_millis(RSNA_RESPONSE_TIMEOUT_MILLIS)
88    }
89}
90
91#[derive(Debug, Clone)]
92pub struct RsnaRetransmissionTimeout {
93    pub bssid: Bssid,
94    pub sta_addr: MacAddr,
95}
96impl TimeoutDuration for RsnaRetransmissionTimeout {
97    fn timeout_duration(&self) -> zx::MonotonicDuration {
98        zx::MonotonicDuration::from_millis(RSNA_RETRANSMISSION_TIMEOUT_MILLIS)
99    }
100}
101
102#[derive(Debug, Clone)]
103pub struct InspectPulseCheck;
104impl TimeoutDuration for InspectPulseCheck {
105    fn timeout_duration(&self) -> zx::MonotonicDuration {
106        zx::MonotonicDuration::from_minutes(INSPECT_PULSE_CHECK_MINUTES)
107    }
108}
109
110#[derive(Debug, Clone)]
111pub struct SaeTimeout(pub u64);
112impl TimeoutDuration for SaeTimeout {
113    fn timeout_duration(&self) -> zx::MonotonicDuration {
114        zx::MonotonicDuration::from_millis(SAE_RETRANSMISSION_TIMEOUT_MILLIS)
115    }
116}
117
118#[derive(Debug, Clone)]
119pub struct DeauthenticateTimeout;
120impl TimeoutDuration for DeauthenticateTimeout {
121    fn timeout_duration(&self) -> zx::MonotonicDuration {
122        zx::MonotonicDuration::from_millis(DEAUTHENTICATE_TIMEOUT_MILLIS)
123    }
124}