pub fn parse(data: &[u8]) -> Result<RobustSecurityNetwork, Error> {
        if data.len() > 8 {
            let version = u16::unpack_unchecked(data);
            let value = u32::unpack_unchecked(&data[2..]);
            let suite = CipherSuite::from(value);
            let count = u16::unpack_unchecked(&data[6..]);
            let (used, values) = unpack_vec::<u32>(&data[8..], count as usize)?;
            let mut offset = 8 + used;
            let ciphers = values.into_iter().map(CipherSuite::from).collect();
            let (used, count) = u16::unpack_with_size(&data[offset..])?;
            offset += used;
            let (used, values) = unpack_vec::<u32>(&data[offset..], count as usize)?;
            offset += used;
            let akms = values
                .into_iter()
                .map(AuthenticationKeyManagement::from)
                .collect();
            let (_used, count) = u16::unpack_with_size(&data[offset..])?;
            let ptksa_counters = match count & 0x000c {
                0x0004 => 2,
                0x0008 => 4,
                0x000c => 16,
                _ => 1,
            };
            let gtksa_counters = match count & 0x0030 {
                0x0010 => 2,
                0x0020 => 4,
                0x0030 => 16,
                _ => 1,
            };
            return Ok(RobustSecurityNetwork {
                version,
                cipher_suite: suite,
                ciphers,
                akms,
                capabilities: RsnCapabilities::from_bits_truncate(count),
                ptksa_counters,
                gtksa_counters,
            });
        }
        Err(io::Error::new(io::ErrorKind::InvalidData, "Invalid RSN element").into())
    }
/// Parse robust security network from information element payload
Parse robust security network from information element payload
Parse robust security network from information element payload
pub fn parse(data: &[u8]) -> Result<RobustSecurityNetwork, Error> {
        if data.len() > 8 {
            let version = u16::unpack_unchecked(data);
            let value = u32::unpack_unchecked(&data[2..]);
            let suite = CipherSuite::from(value);
            let count = u16::unpack_unchecked(&data[6..]);
            let (used, values) = unpack_vec::<u32>(&data[8..], count as usize)?;
            let mut offset = 8 + used;
            let ciphers = values.into_iter().map(CipherSuite::from).collect();
            let (used, count) = u16::unpack_with_size(&data[offset..])?;
            offset += used;
            let (used, values) = unpack_vec::<u32>(&data[offset..], count as usize)?;
            offset += used;
            let akms = values
                .into_iter()
                .map(AuthenticationKeyManagement::from)
                .collect();
            let (_used, count) = u16::unpack_with_size(&data[offset..])?;
            let ptksa_counters = match count & 0x000c {
                0x0004 => 2,
                0x0008 => 4,
                0x000c => 16,
                _ => 1,
            };
            let gtksa_counters = match count & 0x0030 {
                0x0010 => 2,
                0x0020 => 4,
                0x0030 => 16,
                _ => 1,
            };
            return Ok(RobustSecurityNetwork {
                version,
                cipher_suite: suite,
                ciphers,
                akms,
                capabilities: RsnCapabilities::from_bits_truncate(count),
                ptksa_counters,
                gtksa_counters,
            });
        }
        Err(io::Error::new(io::ErrorKind::InvalidData, "Invalid RSN element").into())
    }
pub fn parse ( data : & [ u8 ] ) -> Result < RobustSecurityNetwork , Error > { if data . len ( ) > 8 { let version = u16 :: unpack_unchecked ( data ) ; let value = u32 :: unpack_unchecked ( & data [ 2 .. ] ) ; let suite = CipherSuite :: from ( value ) ; let count = u16 :: unpack_unchecked ( & data [ 6 .. ] ) ; let ( used , values ) = unpack_vec :: < u32 > ( & data [ 8 .. ] , count as usize ) ? ; let mut offset = 8 + used ; let ciphers = values . into_iter ( ) . map ( CipherSuite :: from ) . collect ( ) ; let ( used , count ) = u16 :: unpack_with_size ( & data [ offset .. ] ) ? ; offset += used ; let ( used , values ) = unpack_vec :: < u32 > ( & data [ offset .. ] , count as usize ) ? ; offset += used ; let akms = values . into_iter ( ) . map ( AuthenticationKeyManagement :: from ) . collect ( ) ; let ( _used , count ) = u16 :: unpack_with_size ( & data [ offset .. ] ) ? ; let ptksa_counters = match count & 0x000c { 0x0004 => 2 , 0x0008 => 4 , 0x000c => 16 , _ => 1 , } ; let gtksa_counters = match count & 0x0030 { 0x0010 => 2 , 0x0020 => 4 , 0x0030 => 16 , _ => 1 , } ; return Ok ( RobustSecurityNetwork { version , cipher_suite : suite , ciphers , akms , capabilities : RsnCapabilities :: from_bits_truncate ( count ) , ptksa_counters , gtksa_counters , } ) ; } Err ( io :: Error :: new ( io :: ErrorKind :: InvalidData , " " ) . into ( ) ) }
Parse robust security network from information element payload
Parse robust security network from information element payload
data
&[u8]
data
&[u8]