pub fn protection(&self) -> Protection {
        if !CapabilityInfo(self.cap).privacy() {
            return Protection::Open;
        }

        let supports_wpa_1 = self
            .wpa_ie()
            .map(|wpa_ie| {
                let rsne = ie::rsn::rsne::Rsne {
                    group_data_cipher_suite: Some(wpa_ie.multicast_cipher),
                    pairwise_cipher_suites: wpa_ie.unicast_cipher_list,
                    akm_suites: wpa_ie.akm_list,
                    ..Default::default()
                };
                suite_filter::WPA1_PERSONAL.is_satisfied(&rsne)
            })
            .unwrap_or(false);

        let rsne = match self.rsne() {
            Some(rsne) => match ie::rsn::rsne::from_bytes(rsne) {
                Ok((_, rsne)) => rsne,
                Err(_e) => {
                    return Protection::Unknown;
                }
            },
            None if self.find_wpa_ie().is_some() => {
                if supports_wpa_1 {
                    return Protection::Wpa1;
                } else {
                    return Protection::Unknown;
                }
            }
            None => return Protection::Wep,
        };

        let rsn_caps = rsne.rsn_capabilities.as_ref().unwrap_or(&ie::rsn::rsne::RsnCapabilities(0));
        let mfp_req = rsn_caps.mgmt_frame_protection_req();
        let mfp_cap = rsn_caps.mgmt_frame_protection_cap();

        if suite_filter::WPA3_PERSONAL.is_satisfied(&rsne) {
            if suite_filter::WPA2_PERSONAL.is_satisfied(&rsne) {
                if mfp_cap {
                    return Protection::Wpa2Wpa3Personal;
                }
            } else if mfp_cap && mfp_req {
                return Protection::Wpa3Personal;
            }
        }
        if suite_filter::WPA2_PERSONAL.is_satisfied(&rsne) {
            if supports_wpa_1 {
                return Protection::Wpa1Wpa2Personal;
            } else {
                return Protection::Wpa2Personal;
            }
        }
        if suite_filter::WPA2_PERSONAL_TKIP_ONLY.is_satisfied(&rsne) {
            if supports_wpa_1 {
                return Protection::Wpa1Wpa2PersonalTkipOnly;
            } else {
                return Protection::Wpa2PersonalTkipOnly;
            }
        }
        if supports_wpa_1 {
            return Protection::Wpa1;
        }
        if suite_filter::WPA3_ENTERPRISE_192_BIT.is_satisfied(&rsne) {
            if mfp_cap && mfp_req {
                return Protection::Wpa3Enterprise;
            }
        }
        if suite_filter::WPA2_ENTERPRISE.is_satisfied(&rsne) {
            return Protection::Wpa2Enterprise;
        }
        Protection::Unknown
    }
/// Categorize BSS on what protection it supports.
Categorize BSS on what protection it supports.
Categorize BSS on what protection it supports .
pub fn protection(&self) -> Protection {
        if !CapabilityInfo(self.cap).privacy() {
            return Protection::Open;
        }
        let supports_wpa_1 = self
            .wpa_ie()
            .map(|wpa_ie| {
                let rsne = ie::rsn::rsne::Rsne {
                    group_data_cipher_suite: Some(wpa_ie.multicast_cipher),
                    pairwise_cipher_suites: wpa_ie.unicast_cipher_list,
                    akm_suites: wpa_ie.akm_list,
                    ..Default::default()
                };
                suite_filter::WPA1_PERSONAL.is_satisfied(&rsne)
            })
            .unwrap_or(false);
        let rsne = match self.rsne() {
            Some(rsne) => match ie::rsn::rsne::from_bytes(rsne) {
                Ok((_, rsne)) => rsne,
                Err(_e) => {
                    return Protection::Unknown;
                }
            },
            None if self.find_wpa_ie().is_some() => {
                if supports_wpa_1 {
                    return Protection::Wpa1;
                } else {
                    return Protection::Unknown;
                }
            }
            None => return Protection::Wep,
        };
        let rsn_caps = rsne.rsn_capabilities.as_ref().unwrap_or(&ie::rsn::rsne::RsnCapabilities(0));
        let mfp_req = rsn_caps.mgmt_frame_protection_req();
        let mfp_cap = rsn_caps.mgmt_frame_protection_cap();
        if suite_filter::WPA3_PERSONAL.is_satisfied(&rsne) {
            if suite_filter::WPA2_PERSONAL.is_satisfied(&rsne) {
                if mfp_cap {
                    return Protection::Wpa2Wpa3Personal;
                }
            } else if mfp_cap && mfp_req {
                return Protection::Wpa3Personal;
            }
        }
        if suite_filter::WPA2_PERSONAL.is_satisfied(&rsne) {
            if supports_wpa_1 {
                return Protection::Wpa1Wpa2Personal;
            } else {
                return Protection::Wpa2Personal;
            }
        }
        if suite_filter::WPA2_PERSONAL_TKIP_ONLY.is_satisfied(&rsne) {
            if supports_wpa_1 {
                return Protection::Wpa1Wpa2PersonalTkipOnly;
            } else {
                return Protection::Wpa2PersonalTkipOnly;
            }
        }
        if supports_wpa_1 {
            return Protection::Wpa1;
        }
        if suite_filter::WPA3_ENTERPRISE_192_BIT.is_satisfied(&rsne) {
            if mfp_cap && mfp_req {
                return Protection::Wpa3Enterprise;
            }
        }
        if suite_filter::WPA2_ENTERPRISE.is_satisfied(&rsne) {
            return Protection::Wpa2Enterprise;
        }
        Protection::Unknown
    }
pub fn protection ( & self ) -> Protection { if ! CapabilityInfo ( self . cap ) . privacy ( ) { return Protection :: Open ; } let supports_wpa_1 = self . wpa_ie ( ) . map ( | wpa_ie | { let rsne = ie :: rsn :: rsne :: Rsne { group_data_cipher_suite : Some ( wpa_ie . multicast_cipher ) , pairwise_cipher_suites : wpa_ie . unicast_cipher_list , akm_suites : wpa_ie . akm_list , .. Default :: default ( ) } ; suite_filter :: WPA1_PERSONAL . is_satisfied ( & rsne ) } ) . unwrap_or ( false ) ; let rsne = match self . rsne ( ) { Some ( rsne ) => match ie :: rsn :: rsne :: from_bytes ( rsne ) { Ok ( ( _ , rsne ) ) => rsne , Err ( _e ) => { return Protection :: Unknown ; } } , None if self . find_wpa_ie ( ) . is_some ( ) => { if supports_wpa_1 { return Protection :: Wpa1 ; } else { return Protection :: Unknown ; } } None => return Protection :: Wep , } ; let rsn_caps = rsne . rsn_capabilities . as_ref ( ) . unwrap_or ( & ie :: rsn :: rsne :: RsnCapabilities ( 0 ) ) ; let mfp_req = rsn_caps . mgmt_frame_protection_req ( ) ; let mfp_cap = rsn_caps . mgmt_frame_protection_cap ( ) ; if suite_filter :: WPA3_PERSONAL . is_satisfied ( & rsne ) { if suite_filter :: WPA2_PERSONAL . is_satisfied ( & rsne ) { if mfp_cap { return Protection :: Wpa2Wpa3Personal ; } } else if mfp_cap && mfp_req { return Protection :: Wpa3Personal ; } } if suite_filter :: WPA2_PERSONAL . is_satisfied ( & rsne ) { if supports_wpa_1 { return Protection :: Wpa1Wpa2Personal ; } else { return Protection :: Wpa2Personal ; } } if suite_filter :: WPA2_PERSONAL_TKIP_ONLY . is_satisfied ( & rsne ) { if supports_wpa_1 { return Protection :: Wpa1Wpa2PersonalTkipOnly ; } else { return Protection :: Wpa2PersonalTkipOnly ; } } if supports_wpa_1 { return Protection :: Wpa1 ; } if suite_filter :: WPA3_ENTERPRISE_192_BIT . is_satisfied ( & rsne ) { if mfp_cap && mfp_req { return Protection :: Wpa3Enterprise ; } } if suite_filter :: WPA2_ENTERPRISE . is_satisfied ( & rsne ) { return Protection :: Wpa2Enterprise ; } Protection :: Unknown }
Categorize BSS on what protection it supports.
Categorize BSS on what protection it supports .
&self
&self