wlan_sme/ap/
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::MacAddr;
6use wlan_common::timer::TimeoutDuration;
7
8// https://fxbug.dev/42131271 exposed the issue that longer timeout is needed for starting AP while the
9// client iface is scanning, this is not a magic number, but a number we chose after
10// discussion.
11pub const START_TIMEOUT_SECONDS: i64 = 10;
12pub const STOP_TIMEOUT_SECONDS: i64 = 10;
13
14#[derive(Debug, Clone)]
15pub enum Event {
16    Sme { event: SmeEvent },
17    Client { addr: MacAddr, event: ClientEvent },
18}
19
20impl TimeoutDuration for Event {
21    fn timeout_duration(&self) -> zx::MonotonicDuration {
22        match self {
23            Event::Sme { event } => event.timeout_duration(),
24            Event::Client { event, .. } => event.timeout_duration(),
25        }
26    }
27}
28
29#[derive(Debug, Clone)]
30pub enum SmeEvent {
31    StartTimeout,
32    StopTimeout,
33}
34
35impl SmeEvent {
36    pub fn timeout_duration(&self) -> zx::MonotonicDuration {
37        match self {
38            SmeEvent::StartTimeout => zx::MonotonicDuration::from_seconds(START_TIMEOUT_SECONDS),
39            SmeEvent::StopTimeout => zx::MonotonicDuration::from_seconds(STOP_TIMEOUT_SECONDS),
40        }
41    }
42}
43
44#[derive(Debug, Clone)]
45pub enum RsnaTimeout {
46    Request,
47    Negotiation,
48}
49
50#[derive(Debug, Clone)]
51pub enum ClientEvent {
52    AssociationTimeout,
53    RsnaTimeout(RsnaTimeout),
54}
55
56impl ClientEvent {
57    pub fn timeout_duration(&self) -> zx::MonotonicDuration {
58        match self {
59            // We only use schedule_at, so we ignore these timeout durations here.
60            // TODO(tonyy): Switch everything to use schedule_at, maybe?
61            ClientEvent::AssociationTimeout => zx::MonotonicDuration::from_seconds(0),
62            ClientEvent::RsnaTimeout { .. } => zx::MonotonicDuration::from_seconds(0),
63        }
64    }
65}