pub fn derive_join_capabilities(
    bss_channel: Channel,
    bss_rates: &[SupportedRate],
    device_info: &fidl_mlme::DeviceInfo,
) -> Result<ClientCapabilities, Error> {
    // Step 1 - Extract iface capabilities for this particular band we are joining
    let band_cap = get_device_band_cap(&device_info, bss_channel.primary)
        .ok_or_else(|| format_err!("iface does not support BSS channel {}", bss_channel.primary))?;

    // Step 2.1 - Override CapabilityInfo
    // TODO(fxbug.dev/54923): The WlanSoftmacHardwareCapability type is u32 and used here to override
    // the capability info for joining a BSS. The upper bits are removed but shouldn't have to be.
    let capability_info =
        override_capability_info(CapabilityInfo(device_info.softmac_hardware_capability as u16));

    // Step 2.2 - Derive data rates
    // Both are safe to unwrap because SupportedRate is one byte and will not cause alignment issue.
    let client_rates = band_cap.basic_rates.iter().map(|&r| SupportedRate(r)).collect::<Vec<_>>();
    let rates = intersect_rates(ApRates(bss_rates), ClientRates(&client_rates))
        .map_err(|error| format_err!("could not intersect rates: {:?}", error))
        .context(format!("deriving rates: {:?} + {:?}", band_cap.basic_rates, bss_rates))?;

    // Step 2.3 - Override HT Capabilities and VHT Capabilities
    // Here it is assumed that the channel specified by the BSS will never be invalid.
    let (ht_cap, vht_cap) =
        override_ht_vht(band_cap.ht_cap.as_ref(), band_cap.vht_cap.as_ref(), bss_channel.cbw)?;

    Ok(ClientCapabilities(StaCapabilities { capability_info, rates, ht_cap, vht_cap }))
}
/// The entry point of this module.
/// 1. Extract the band capabilities from the iface device based on BSS channel.
/// 2. Derive/Override capabilities based on iface capabilities, BSS requirements and
/// user overridable channel bandwidths.
The entry point of this module.
1. Extract the band capabilities from the iface device based on BSS channel.
2. Derive/Override capabilities based on iface capabilities, BSS requirements and
user overridable channel bandwidths.
The entry point of this module . 1 . Extract the band capabilities from the iface device based on BSS channel . 2 . Derive / Override capabilities based on iface capabilities BSS requirements and user overridable channel bandwidths .
pub fn derive_join_capabilities(
    bss_channel: Channel,
    bss_rates: &[SupportedRate],
    device_info: &fidl_mlme::DeviceInfo,
) -> Result<ClientCapabilities, Error> {
    // Step 1 - Extract iface capabilities for this particular band we are joining
    let band_cap = get_device_band_cap(&device_info, bss_channel.primary)
        .ok_or_else(|| format_err!("iface does not support BSS channel {}", bss_channel.primary))?;
    // Step 2.1 - Override CapabilityInfo
    // TODO(fxbug.dev/54923): The WlanSoftmacHardwareCapability type is u32 and used here to override
    // the capability info for joining a BSS. The upper bits are removed but shouldn't have to be.
    let capability_info =
        override_capability_info(CapabilityInfo(device_info.softmac_hardware_capability as u16));
    // Step 2.2 - Derive data rates
    // Both are safe to unwrap because SupportedRate is one byte and will not cause alignment issue.
    let client_rates = band_cap.basic_rates.iter().map(|&r| SupportedRate(r)).collect::<Vec<_>>();
    let rates = intersect_rates(ApRates(bss_rates), ClientRates(&client_rates))
        .map_err(|error| format_err!("could not intersect rates: {:?}", error))
        .context(format!("deriving rates: {:?} + {:?}", band_cap.basic_rates, bss_rates))?;
    // Step 2.3 - Override HT Capabilities and VHT Capabilities
    // Here it is assumed that the channel specified by the BSS will never be invalid.
    let (ht_cap, vht_cap) =
        override_ht_vht(band_cap.ht_cap.as_ref(), band_cap.vht_cap.as_ref(), bss_channel.cbw)?;
    Ok(ClientCapabilities(StaCapabilities { capability_info, rates, ht_cap, vht_cap }))
}
pub fn derive_join_capabilities ( bss_channel : Channel , bss_rates : & [ SupportedRate ] , device_info : & fidl_mlme :: DeviceInfo , ) -> Result < ClientCapabilities , Error > { // Step 1 - Extract iface capabilities for this particular band we are joining let band_cap = get_device_band_cap ( & device_info , bss_channel . primary ) . ok_or_else ( | | format_err ! ( " " bss_channel primary ) ) ? ; // Step 2.1 - Override CapabilityInfo // TODO(fxbug.dev/54923): The WlanSoftmacHardwareCapability type is u32 and used here to override // the capability info for joining a BSS. The upper bits are removed but shouldn't have to be. let capability_info = override_capability_info ( CapabilityInfo ( device_info . softmac_hardware_capability as u16 ) ) ; // Step 2.2 - Derive data rates // Both are safe to unwrap because SupportedRate is one byte and will not cause alignment issue. let client_rates = band_cap . basic_rates . iter ( ) . map ( | & r | SupportedRate ( r ) ) . collect :: < Vec < _ > > ( ) ; let rates = intersect_rates ( ApRates ( bss_rates ) , ClientRates ( & client_rates ) ) . map_err ( | error | format_err ! ( " " error ) ) . context ( format ! ( " " band_cap basic_rates bss_rates ) ) ? ; // Step 2.3 - Override HT Capabilities and VHT Capabilities // Here it is assumed that the channel specified by the BSS will never be invalid. let ( ht_cap , vht_cap ) = override_ht_vht ( band_cap . ht_cap . as_ref ( ) , band_cap . vht_cap . as_ref ( ) , bss_channel . cbw ) ? ; Ok ( ClientCapabilities ( StaCapabilities { capability_info , rates , ht_cap , vht_cap } ) ) }
The entry point of this module.
The entry point of this module .
bss_channel
Channel
bss_rates
&[SupportedRate]
device_info
&fidl_mlme::DeviceInfo
bss_channel
Channel
bss_rates
&[SupportedRate]
device_info
&fidl_mlme::DeviceInfo