1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use {anyhow::Error, fidl_fuchsia_wlan_tap as wlantap, fuchsia_zircon as zx};
pub struct Wlantap {
proxy: wlantap::WlantapCtlProxy,
}
impl Wlantap {
pub async fn open() -> Result<Self, Error> {
let dir = fuchsia_fs::directory::open_in_namespace("/dev", fuchsia_fs::OpenFlags::empty())?;
let proxy = device_watcher::recursive_wait_and_open::<wlantap::WlantapCtlMarker>(
&dir,
"sys/test/wlantapctl",
)
.await?;
Ok(Self { proxy })
}
pub async fn create_phy(
&self,
mut config: wlantap::WlantapPhyConfig,
) -> Result<wlantap::WlantapPhyProxy, Error> {
let Self { proxy } = self;
let (ours, theirs) = fidl::endpoints::create_proxy()?;
let status = proxy.create_phy(&mut config, theirs).await?;
let () = zx::ok(status)?;
Ok(ours)
}
}