xref: /aosp_15_r20/tools/netsim/rust/daemon/src/wifi/hostapd_cf.rs (revision cf78ab8cffb8fc9207af348f23af247fb04370a6)
1 // Copyright 2024 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 /// Hostapd Interface for Network Simulation
16 use bytes::Bytes;
17 use netsim_packets::ieee80211::{Ieee80211, MacAddress};
18 use netsim_proto::config::HostapdOptions as ProtoHostapdOptions;
19 use std::sync::mpsc;
20 
21 // Provides a stub implementation while the hostapd-rs crate is not integrated into the aosp-main.
22 pub struct Hostapd {}
23 impl Hostapd {
input(&self, _bytes: Bytes) -> anyhow::Result<()>24     pub fn input(&self, _bytes: Bytes) -> anyhow::Result<()> {
25         Ok(())
26     }
27 
28     /// Retrieves the `Hostapd`'s BSSID.
get_bssid(&self) -> MacAddress29     pub fn get_bssid(&self) -> MacAddress {
30         MacAddress::try_from(0).unwrap()
31     }
32 
33     /// Attempt to encrypt the given IEEE 802.11 frame.
try_encrypt(&self, _ieee80211: &Ieee80211) -> Option<Ieee80211>34     pub fn try_encrypt(&self, _ieee80211: &Ieee80211) -> Option<Ieee80211> {
35         None
36     }
37 
38     /// Attempt to decrypt the given IEEE 802.11 frame.
try_decrypt(&self, _ieee80211: &Ieee80211) -> Option<Ieee80211>39     pub fn try_decrypt(&self, _ieee80211: &Ieee80211) -> Option<Ieee80211> {
40         None
41     }
42 }
43 
hostapd_run(_opt: ProtoHostapdOptions, _tx: mpsc::Sender<Bytes>) -> anyhow::Result<Hostapd>44 pub fn hostapd_run(_opt: ProtoHostapdOptions, _tx: mpsc::Sender<Bytes>) -> anyhow::Result<Hostapd> {
45     Ok(Hostapd {})
46 }
47