/// Parse netlink messages returned by the nl80211 command CmdGetStation
Parse netlink messages returned by the nl80211 command CmdGetStation
Parse netlink messages returned by the nl80211 command CmdGetStation
fn from_handle(handle: AttrHandle<Nl80211Attr>) -> Result<Station, NlError> {
        let mut station = Station {
            ..Default::default()
        };
        for attr in handle.iter() {
            match attr.nla_type {
                Nl80211Attr::AttrMac => station.bssid = Some(parse_macaddr(&attr.payload)?),
                Nl80211Attr::AttrStaInfo => {
                    let sub_handle = attr.get_nested_attributes::<Nl80211StaInfo>()?;
                    for sub_attr in sub_handle.iter() {
                        let mut payload = &sub_attr.payload[..];
                        match sub_attr.nla_type {
                            Nl80211StaInfo::StaInfoSignal => {
                                station.signal = Some(payload.read_i8()?);
                            }
                            Nl80211StaInfo::StaInfoSignalAvg => {
                                station.average_signal = Some(payload.read_i8()?);
                            }
                            Nl80211StaInfo::StaInfoBeaconLoss => {
                                station.beacon_loss = Some(payload.read_u32::<LittleEndian>()?);
                            }
                            Nl80211StaInfo::StaInfoConnectedTime => {
                                station.connected_time = Some(payload.read_u32::<LittleEndian>()?)
                            }
                            Nl80211StaInfo::StaInfoRxPackets => {
                                station.rx_packets = Some(payload.read_u32::<LittleEndian>()?)
                            }
                            Nl80211StaInfo::StaInfoTxPackets => {
                                station.tx_packets = Some(payload.read_u32::<LittleEndian>()?)
                            }
                            Nl80211StaInfo::StaInfoTxRetries => {
                                station.tx_retries = Some(payload.read_u32::<LittleEndian>()?)
                            }
                            Nl80211StaInfo::StaInfoTxFailed => {
                                station.tx_failed = Some(payload.read_u32::<LittleEndian>()?)
                            }
                            Nl80211StaInfo::StaInfoRxBitrate => {
                                let bit_rate_handle =
                                    sub_attr.get_nested_attributes::<Nl80211RateInfo>()?;
                                for sub_sub_attr in bit_rate_handle.iter() {
                                    if sub_sub_attr.nla_type != Nl80211RateInfo::RateInfoBitrate32 {
                                        continue;
                                    }
                                    station.rx_bitrate = Some(
                                        (&sub_sub_attr.payload[..]).read_u32::<LittleEndian>()?,
                                    );
                                    break;
                                }
                            }
                            Nl80211StaInfo::StaInfoTxBitrate => {
                                let bit_rate_handle =
                                    sub_attr.get_nested_attributes::<Nl80211RateInfo>()?;
                                for sub_sub_attr in bit_rate_handle.iter() {
                                    if sub_sub_attr.nla_type != Nl80211RateInfo::RateInfoBitrate32 {
                                        continue;
                                    }
                                    station.tx_bitrate = Some(
                                        (&sub_sub_attr.payload[..]).read_u32::<LittleEndian>()?,
                                    );
                                    break;
                                }
                            }
                            _ => (),
                        }
                    }
                }
                _ => (),
            }
        }
        Ok(station)
    }
fn from_handle ( handle : AttrHandle < Nl80211Attr > ) -> Result < Station , NlError > { let mut station = Station { .. Default :: default ( ) } ; for attr in handle . iter ( ) { match attr . nla_type { Nl80211Attr :: AttrMac => station . bssid = Some ( parse_macaddr ( & attr . payload ) ? ) , Nl80211Attr :: AttrStaInfo => { let sub_handle = attr . get_nested_attributes :: < Nl80211StaInfo > ( ) ? ; for sub_attr in sub_handle . iter ( ) { let mut payload = & sub_attr . payload [ .. ] ; match sub_attr . nla_type { Nl80211StaInfo :: StaInfoSignal => { station . signal = Some ( payload . read_i8 ( ) ? ) ; } Nl80211StaInfo :: StaInfoSignalAvg => { station . average_signal = Some ( payload . read_i8 ( ) ? ) ; } Nl80211StaInfo :: StaInfoBeaconLoss => { station . beacon_loss = Some ( payload . read_u32 :: < LittleEndian > ( ) ? ) ; } Nl80211StaInfo :: StaInfoConnectedTime => { station . connected_time = Some ( payload . read_u32 :: < LittleEndian > ( ) ? ) } Nl80211StaInfo :: StaInfoRxPackets => { station . rx_packets = Some ( payload . read_u32 :: < LittleEndian > ( ) ? ) } Nl80211StaInfo :: StaInfoTxPackets => { station . tx_packets = Some ( payload . read_u32 :: < LittleEndian > ( ) ? ) } Nl80211StaInfo :: StaInfoTxRetries => { station . tx_retries = Some ( payload . read_u32 :: < LittleEndian > ( ) ? ) } Nl80211StaInfo :: StaInfoTxFailed => { station . tx_failed = Some ( payload . read_u32 :: < LittleEndian > ( ) ? ) } Nl80211StaInfo :: StaInfoRxBitrate => { let bit_rate_handle = sub_attr . get_nested_attributes :: < Nl80211RateInfo > ( ) ? ; for sub_sub_attr in bit_rate_handle . iter ( ) { if sub_sub_attr . nla_type != Nl80211RateInfo :: RateInfoBitrate32 { continue ; } station . rx_bitrate = Some ( ( & sub_sub_attr . payload [ .. ] ) . read_u32 :: < LittleEndian > ( ) ? , ) ; break ; } } Nl80211StaInfo :: StaInfoTxBitrate => { let bit_rate_handle = sub_attr . get_nested_attributes :: < Nl80211RateInfo > ( ) ? ; for sub_sub_attr in bit_rate_handle . iter ( ) { if sub_sub_attr . nla_type != Nl80211RateInfo :: RateInfoBitrate32 { continue ; } station . tx_bitrate = Some ( ( & sub_sub_attr . payload [ .. ] ) . read_u32 :: < LittleEndian > ( ) ? , ) ; break ; } } _ => ( ) , } } } _ => ( ) , } } Ok ( station ) }
Parse netlink messages returned by the nl80211 command CmdGetStation
Parse netlink messages returned by the nl80211 command CmdGetStation
handle
AttrHandle<Nl80211Attr>