| // Copyright 2021 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| library fuchsia.wlan.tap; |
| |
| using fuchsia.wlan.common; |
| using fuchsia.wlan.device; |
| using fuchsia.wlan.internal; |
| using zx; |
| |
| /// Describes the capabilities of the fake wlantap-phy device to be created. |
| type WlantapPhyConfig = struct { |
| // TODO(fxbug.dev/64628): wlantap will configure all of its ifaces to use the same MAC address |
| iface_mac_addr array<uint8, 6>; |
| mac_role fuchsia.wlan.device.MacRole; |
| supported_phys vector<fuchsia.wlan.device.SupportedPhy>:8; |
| driver_features vector<fuchsia.wlan.common.DriverFeature>:8; |
| caps vector<fuchsia.wlan.device.Capability>:8; |
| bands vector<fuchsia.wlan.device.BandInfo>:8; |
| name string:32; // Arbitrary maximum size of 32 chosen to satisfy FidlLint |
| quiet bool; |
| }; |
| |
| /// Instruct the wlantap-ctl device to creates a fake wlantap-phy device based on the |
| /// `WlantapPhyConfig` passed in. The newly created wlantap-phy device will use the channel to |
| /// allow a `WlantapPhy` client to observe and control its behavior. |
| protocol WlantapCtl { |
| CreatePhy(resource struct { |
| config WlantapPhyConfig; |
| proxy server_end:WlantapPhy; |
| }) -> (struct { |
| status zx.status; |
| }); |
| }; |
| |
| /// Information pertaining to incoming packets. One WlanRxInfo is associated with each packet. |
| /// You are encouraged to use the default value in //src/connectivity/wlan/testing/hw-sim/src/lib.rs |
| /// See wlan_rx_info_t for details about each field. |
| type WlanRxInfo = struct { |
| rx_flags uint32; |
| valid_fields uint32; |
| phy uint16; |
| data_rate uint32; |
| channel fuchsia.wlan.common.WlanChannel; |
| mcs uint8; |
| rssi_dbm int8; |
| snr_dbh int16; |
| }; |
| |
| /// Instruction from generic WLAN driver on how to send a packet. One WlanTxInfo per packet. |
| /// These values are populated by the wlantap driver and should not be specified manually. |
| /// See wlan_tx_info_t for details about each field. |
| type WlanTxInfo = struct { |
| tx_flags uint32; |
| valid_fields uint32; |
| tx_vector_idx uint16; |
| phy uint16; |
| cbw uint8; |
| mcs uint8; |
| }; |
| |
| /// An outgoing packet that is to be "sent" by the wlantap device. `data` contains the packet |
| /// in its wire format. |
| type WlanTxPacket = struct { |
| data vector<uint8>; |
| info WlanTxInfo; |
| }; |
| |
| /// Configuration pertaining to security keys, often used by RSN and other secure authentication. |
| /// These values are populated by the wlantap driver and should not be specified manually. |
| /// See wlan_key_config_t for details about each field. |
| type WlanKeyConfig = struct { |
| protection uint8; |
| cipher_oui array<uint8, 3>; |
| cipher_type uint8; |
| key_type uint8; |
| peer_addr array<uint8, 6>; |
| key_idx uint8; |
| key vector<uint8>:32; |
| }; |
| |
| /// One entry in a WlanTxStatus report, 1 report can contain up to 8 entries (see below). |
| /// These values are populated by the wlantap driver and should not be specified manually. |
| /// See wlan_tx_status_entry_t for details about each field. |
| type WlanTxStatusEntry = struct { |
| tx_vec_idx uint16; |
| attempts uint8; |
| }; |
| |
| /// TX status report used by Minstrel rate selection algorithm. One report per packet. |
| /// You are encouraged to use the default value in //src/connectivity/wlan/testing/hw-sim/src/lib.rs |
| /// See wlan_tx_status_t for details about each field. |
| type WlanTxStatus = struct { |
| peer_addr array<uint8, 6>; |
| tx_status_entries array<WlanTxStatusEntry, 8>; |
| success bool; |
| }; |
| |
| /// Country code the device is to switch to. |
| /// These values are populated by the wlantap driver and should not be specified manually. |
| /// See also phy.fidl CountryCode. |
| type SetCountryArgs = struct { |
| alpha2 array<uint8, 2>; |
| }; |
| |
| /// Allow the test program to observe and control the behavior of the wlantap-phy device. |
| /// A wlantap-phy device is a special vendor device and its driver (Fuchsia being the vendor) |
| /// used for testing purpose. |
| /// Implements a subset of `wlanmac_ifc_t` and `wlanmac_protocol_ops_t` in |
| /// //garnet/lib/wlan/protocol/include/wlan/protocol/mac.h |
| /// Implements a subset of `WlanphyImpl` protocol in |
| /// //zircon/system/banjo/fuchsia.hardware.wlanphyimpl/wlanphy-impl.banjo |
| protocol WlantapPhy { |
| /// Shutdown the phy device so that it does not respond to any further calls. |
| /// Once shutdown, there is no way to restart the device. |
| /// It can only be called at the end of a test. |
| Shutdown() -> (); |
| |
| // wlanmac_ifc_t callbacks |
| // simulating events happening at the devices side that are passed up to the driver. |
| |
| /// The device "receives" a frame "over the air" and pass it up to driver. |
| Rx(struct { |
| wlanmac_id uint16; |
| data vector<uint8>; |
| info WlanRxInfo; |
| }); |
| /// The device report its status to the driver. (Not used). |
| Status(struct { |
| wlanmac_id uint16; |
| st uint32; |
| }); |
| /// For rate selection (Minstrel), the device's last frame transmission is a success/failure, |
| /// with a certain number of retries. |
| ReportTxStatus(struct { |
| wlanmac_id uint16; |
| txs WlanTxStatus; |
| }); |
| |
| // wlanmac_protocol_ops_t |
| // events indicating that the wlanmac device received interface request calls from the driver. |
| |
| /// The device is to send a frame "over the air". |
| -> Tx(struct { |
| args TxArgs; |
| }); |
| /// The device created by its parent device (wlantap-phy: wlanphy) is |
| /// detected and being connected by wlanstack/wlancfg. |
| /// The device is to enter the "running" state. |
| -> WlanmacStart(struct { |
| args WlanmacStartArgs; |
| }); |
| /// The device is to switch to the specified channel. |
| -> SetChannel(struct { |
| args SetChannelArgs; |
| }); |
| /// AP: The device is to use args.config as a template for beacon frames. |
| /// Client: The device is to be configured with this BSS as it peer. |
| -> ConfigureBss(struct { |
| args ConfigureBssArgs; |
| }); |
| |
| // TODO: ConfigureBeacon |
| |
| /// The device is to install the keys (often coming from RSN, exceptions apply). |
| -> SetKey(struct { |
| args SetKeyArgs; |
| }); |
| |
| // WlantaphyImpl (defined in banjo) |
| // events indicating that the wlanphy device received interface rquest calls from the driver. |
| |
| /// The device is to change its radio and power settings to conform to the regulation of the |
| /// specified country. |
| -> SetCountry(struct { |
| args SetCountryArgs; |
| }); |
| }; |
| |
| type TxArgs = struct { |
| wlanmac_id uint16; |
| packet WlanTxPacket; |
| }; |
| |
| type SetChannelArgs = struct { |
| wlanmac_id uint16; |
| channel fuchsia.wlan.common.WlanChannel; |
| }; |
| |
| type ConfigureBssArgs = struct { |
| wlanmac_id uint16; |
| config fuchsia.wlan.internal.BssConfig; |
| }; |
| |
| type SetKeyArgs = struct { |
| wlanmac_id uint16; |
| config WlanKeyConfig; |
| }; |
| |
| type WlanmacStartArgs = struct { |
| wlanmac_id uint16; |
| }; |