1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use super::*;
use byteorder::{ByteOrder, LittleEndian};

pub trait DeauthenticationFixedParametersTrait: FrameTrait {
    const FIXED_PARAMETERS_START: usize = 24;
    const FIXED_PARAMETERS_END: usize = Self::FIXED_PARAMETERS_START + 6;

    fn reason_code(&self) -> ReasonCode {
        ReasonCode::from_u16(LittleEndian::read_u16(
            &self.bytes()[Self::FIXED_PARAMETERS_START..(Self::FIXED_PARAMETERS_START + 2)],
        ))
    }
}

pub trait DeauthenticationFixedParametersBuilderTrait: FrameBuilderTrait {
    const FIXED_PARAMETERS_START: usize = 24;
    const FIXED_PARAMETERS_END: usize = Self::FIXED_PARAMETERS_START + 6;

    fn reason_code(&mut self, reason_code: ReasonCode) {
        LittleEndian::write_u16(
            &mut self.bytes_mut()[Self::FIXED_PARAMETERS_START..(Self::FIXED_PARAMETERS_START + 2)],
            reason_code.into_u16(),
        )
    }
}