fn parse_extensions(buff: &[u8]) -> Result<Vec<NtpExtension>, std::io::Error> {
    let mut reader = Cursor::new(buff);
    let mut retval = Vec::new();
    while buff.len() - reader.position() as usize >= 4 {
        let ext_type = reader.read_u16::<BigEndian>()?;
        let ext_len = reader.read_u16::<BigEndian>()?;
        if ext_len % 4 != 0 {
            return Err(Error::new(
                ErrorKind::InvalidInput,
                "extension not on word boundary",
            ));
        }
        if ext_len < 4 {
            return Err(Error::new(ErrorKind::InvalidInput, "extension too short"));
        }
        let mut contents: Vec<u8> = vec![0; (ext_len - 4) as usize];
        reader.read(&mut contents)?;
        retval.push(NtpExtension {
            ext_type: type_from_wire(ext_type),
            contents: contents,
        })
    }
    Ok(retval)
}
/// Properly parsing NTP extensions in accordance with RFC 7822 is not necessary
/// since the legacy MAC will never be used by this code.
Properly parsing NTP extensions in accordance with RFC 7822 is not necessary
since the legacy MAC will never be used by this code.
Properly parsing NTP extensions in accordance with RFC 7822 is not necessary since the legacy MAC will never be used by this code .
fn parse_extensions(buff: &[u8]) -> Result<Vec<NtpExtension>, std::io::Error> {
    let mut reader = Cursor::new(buff);
    let mut retval = Vec::new();
    while buff.len() - reader.position() as usize >= 4 {
        let ext_type = reader.read_u16::<BigEndian>()?;
        let ext_len = reader.read_u16::<BigEndian>()?;
        if ext_len % 4 != 0 {
            return Err(Error::new(
                ErrorKind::InvalidInput,
                "extension not on word boundary",
            ));
        }
        if ext_len < 4 {
            return Err(Error::new(ErrorKind::InvalidInput, "extension too short"));
        }
        let mut contents: Vec<u8> = vec![0; (ext_len - 4) as usize];
        reader.read(&mut contents)?;
        retval.push(NtpExtension {
            ext_type: type_from_wire(ext_type),
            contents: contents,
        })
    }
    Ok(retval)
}
fn parse_extensions ( buff : & [ u8 ] ) -> Result < Vec < NtpExtension > , std :: io :: Error > { let mut reader = Cursor :: new ( buff ) ; let mut retval = Vec :: new ( ) ; while buff . len ( ) - reader . position ( ) as usize >= 4 { let ext_type = reader . read_u16 :: < BigEndian > ( ) ? ; let ext_len = reader . read_u16 :: < BigEndian > ( ) ? ; if ext_len % 4 != 0 { return Err ( Error :: new ( ErrorKind :: InvalidInput , " " , ) ) ; } if ext_len < 4 { return Err ( Error :: new ( ErrorKind :: InvalidInput , " " ) ) ; } let mut contents : Vec < u8 > = vec ! [ 0 ( ext_len 4 ) as usize ] ; reader . read ( & mut contents ) ? ; retval . push ( NtpExtension { ext_type : type_from_wire ( ext_type ) , contents : contents , } ) } Ok ( retval ) }
Properly parsing NTP extensions in accordance with RFC 7822 is not necessary
since the legacy MAC will never be used by this code.
Properly parsing NTP extensions in accordance with RFC 7822 is not necessary since the legacy MAC will never be used by this code .
buff
&[u8]
buff
&[u8]