use super::{Header, IeSummaryIter, IeType};
use anyhow::format_err;
use std::collections::BTreeMap;
use std::mem::size_of;
use std::ops::Range;
const IES_MERGER_BUFFER_LIMIT: usize = 10000;
#[derive(Debug)]
pub struct IesMerger {
ies_updater: IesUpdater,
buffer_overflow: bool,
merge_ie_failures: usize,
}
impl IesMerger {
pub fn new(ies: Vec<u8>) -> Self {
Self { ies_updater: IesUpdater::new(ies), buffer_overflow: false, merge_ie_failures: 0 }
}
pub fn merge(&mut self, ies: &[u8]) {
for (ie_type, range) in IeSummaryIter::new(ies) {
let add_new = match self.ies_updater.get(&ie_type) {
Some(old) => should_add_new(ie_type, old, &ies[range.clone()]),
None => true,
};
let new_addition_len = range.end - range.start;
if add_new {
if self.ies_updater.buf_len() + new_addition_len <= IES_MERGER_BUFFER_LIMIT {
if let Err(_e) = self.ies_updater.set(ie_type, &ies[range]) {
self.merge_ie_failures += 1;
}
} else {
self.buffer_overflow = true;
}
}
}
}
pub fn finalize(&mut self) -> Vec<u8> {
self.ies_updater.finalize()
}
pub fn buffer_overflow(&mut self) -> bool {
self.buffer_overflow
}
pub fn merge_ie_failures(&self) -> usize {
self.merge_ie_failures
}
}
#[derive(Debug)]
pub struct IesUpdater {
ies_summaries: BTreeMap<IeType, Range<usize>>,
ies_buf: Vec<u8>,
}
impl IesUpdater {
pub fn new(ies: Vec<u8>) -> Self {
let mut ies_summaries = BTreeMap::new();
for (ie_type, range) in IeSummaryIter::new(&ies[..]) {
ies_summaries.insert(ie_type, range);
}
Self { ies_summaries, ies_buf: ies }
}
pub fn remove(&mut self, ie_type: &IeType) {
self.ies_summaries.remove(ie_type);
}
pub fn set(&mut self, ie_type: IeType, ie_content: &[u8]) -> Result<(), anyhow::Error> {
if ie_type.extra_len() + ie_content.len() > std::u8::MAX.into() {
return Err(format_err!("ie_content too large"));
}
let start_idx = self.ies_buf.len();
self.ies_buf.extend_from_slice(ie_content);
self.ies_summaries.insert(ie_type, start_idx..self.ies_buf.len());
Ok(())
}
pub fn set_raw(&mut self, ie: &[u8]) -> Result<(), anyhow::Error> {
if ie.is_empty() {
return Ok(());
}
match IeSummaryIter::new(&ie[..]).next() {
Some((ie_type, range)) => self.set(ie_type, &ie[range]),
None => Err(format_err!("failed parsing `ie`")),
}
}
pub fn get(&self, ie_type: &IeType) -> Option<&[u8]> {
self.ies_summaries.get(ie_type).map(|range| &self.ies_buf[range.clone()])
}
fn buf_len(&self) -> usize {
self.ies_buf.len()
}
pub fn finalize(&mut self) -> Vec<u8> {
let total_len = self
.ies_summaries
.iter()
.map(|(ie_type, r)| size_of::<Header>() + ie_type.extra_len() + (r.end - r.start))
.sum();
let mut ies = Vec::with_capacity(total_len);
for (ie_type, range) in self.ies_summaries.iter() {
let id = ie_type.basic_id().0;
let len = ie_type.extra_len() + (range.end - range.start);
ies.extend_from_slice(&[id, len as u8]);
ies.extend_from_slice(ie_type.extra_bytes());
ies.extend_from_slice(&self.ies_buf[range.clone()]);
}
ies
}
}
fn should_add_new(ie_type: IeType, old: &[u8], new: &[u8]) -> bool {
if old == new {
return false;
}
if ie_type == IeType::SSID {
if new.len() < size_of::<Header>() {
return false;
}
let ssid = &new[2..];
if ssid.iter().all(|c| *c == 0u8) {
return false;
}
}
new.len() >= old.len()
}
#[cfg(test)]
mod tests {
use super::*;
#[rustfmt::skip]
const BEACON_FRAME_IES: &'static [u8] = &[
0x00, 0x08, 0x66, 0x6f, 0x6f, 0x2d, 0x73, 0x73, 0x69, 0x64,
0x01, 0x08, 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c,
0x03, 0x01, 0x9d,
0x05, 0x04, 0x00, 0x01, 0x00, 0x00,
0x20, 0x01, 0x03,
0x2d, 0x1a,
0xef, 0x09, 0x1b, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x14, 0x01, 0x00,
0x00, 0x0f, 0xac, 0x04, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x04, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x02, 0x00, 0x00, 0x3d, 0x16,
0x9d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a, 0x0e, 0x14, 0x00, 0x0a, 0x00, 0x2c, 0x01, 0xc8, 0x00, 0x14, 0x00, 0x05, 0x00, 0x19, 0x00,
0x7f, 0x08, 0x01, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x40,
0xbf, 0x0c,
0xb2, 0x01, 0x80, 0x33, 0xea, 0xff, 0x00, 0x00, 0xea, 0xff, 0x00, 0x00, 0xc0, 0x05, 0x01, 0x9b, 0x00, 0xfc, 0xff,
0xc3, 0x04, 0x02, 0xc4, 0xc4, 0xc4,
0xdd, 0x09, 0x00, 0x03, 0x7f, 0x01, 0x01, 0x00, 0x00, 0xff, 0x7f,
0xdd, 0x18, 0x00, 0x50, 0xf2, 0x02, 0x01, 0x01,
0x80, 0x00,
0x03, 0xa4, 0x00, 0x00, 0x27, 0xa4, 0x00, 0x00, 0x42, 0x43, 0x5e, 0x00, 0x62, 0x32, 0x2f, 0x00, 0xdd, 0x1d, 0x00, 0x50, 0xf2, 0x04, 0x10, 0x4a, 0x00, 0x01, 0x10, 0x10, 0x44, 0x00, 0x01,
0x02, 0x10, 0x3c, 0x00, 0x01, 0x03, 0x10, 0x49, 0x00, 0x06, 0x00, 0x37, 0x2a, 0x00, 0x01,
0x20,
];
#[rustfmt::skip]
const PROBE_RESP_IES: &'static [u8] = &[
0x00, 0x08, 0x66, 0x6f, 0x6f, 0x2d, 0x73, 0x73, 0x69, 0x64,
0x01, 0x08, 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c,
0x03, 0x01, 0x9d,
0x20, 0x01, 0x03,
0x2d, 0x1a,
0xef, 0x09, 0x1b, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x14, 0x01, 0x00,
0x00, 0x0f, 0xac, 0x04, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x04, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x02, 0x00, 0x00, 0x3d, 0x16,
0x9d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a, 0x0e, 0x14, 0x00, 0x0a, 0x00, 0x2c, 0x01, 0xc8, 0x00, 0x14, 0x00, 0x05, 0x00, 0x19, 0x00,
0x7f, 0x08, 0x01, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x40,
0xbf, 0x0c,
0xb2, 0x01, 0x80, 0x33, 0xea, 0xff, 0x00, 0x00, 0xea, 0xff, 0x00, 0x00, 0xc0, 0x05, 0x01, 0x9b, 0x00, 0xfc, 0xff,
0xc3, 0x04, 0x02, 0xc4, 0xc4, 0xc4,
0xdd, 0x09, 0x00, 0x03, 0x7f, 0x01, 0x01, 0x00, 0x00, 0xff, 0x7f,
0xdd, 0x18, 0x00, 0x50, 0xf2, 0x02, 0x01, 0x01,
0x80, 0x00,
0x03, 0xa4, 0x00, 0x00, 0x27, 0xa4, 0x00, 0x00, 0x42, 0x43, 0x5e, 0x00, 0x62, 0x32, 0x2f, 0x00, 0xdd, 0x85, 0x00, 0x50, 0xf2, 0x04, 0x10, 0x4a, 0x00, 0x01, 0x10, 0x10, 0x44, 0x00, 0x01,
0x02, 0x10, 0x3b, 0x00, 0x01, 0x03, 0x10, 0x47, 0x00, 0x10, 0x87, 0x65, 0x43, 0x21, 0x9a,
0xbc, 0xde, 0xf0, 0x12, 0x34, 0x98, 0xda, 0xc4, 0x8e, 0x86, 0xc8, 0x10, 0x21, 0x00, 0x07,
0x54, 0x50, 0x2d, 0x4c, 0x69, 0x6e, 0x6b, 0x10, 0x23, 0x00, 0x09, 0x41, 0x72, 0x63, 0x68,
0x65, 0x72, 0x20, 0x41, 0x37, 0x10, 0x24, 0x00, 0x03, 0x31, 0x2e, 0x30, 0x10, 0x42, 0x00,
0x0c, 0x41, 0x72, 0x63, 0x68, 0x65, 0x72, 0x20, 0x41, 0x37, 0x20, 0x76, 0x35, 0x10, 0x54,
0x00, 0x08, 0x00, 0x06, 0x00, 0x50, 0xf2, 0x04, 0x00, 0x01, 0x10, 0x11, 0x00, 0x0a, 0x41,
0x72, 0x63, 0x68, 0x65, 0x72, 0x41, 0x37, 0x76, 0x35, 0x10, 0x08, 0x00, 0x02, 0x00, 0x04,
0x10, 0x3c, 0x00, 0x01, 0x03, 0x10, 0x49, 0x00, 0x06, 0x00, 0x37, 0x2a, 0x00, 0x01, 0x20,
];
#[rustfmt::skip]
const MERGED_IES: &'static [u8] = &[
0x00, 0x08, 0x66, 0x6f, 0x6f, 0x2d, 0x73, 0x73, 0x69, 0x64,
0x01, 0x08, 0x8c, 0x12, 0x98, 0x24, 0xb0, 0x48, 0x60, 0x6c,
0x03, 0x01, 0x9d,
0x05, 0x04, 0x00, 0x01, 0x00, 0x00,
0x20, 0x01, 0x03,
0x2d, 0x1a,
0xef, 0x09, 0x1b, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x14, 0x01, 0x00,
0x00, 0x0f, 0xac, 0x04, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x04, 0x01, 0x00, 0x00, 0x0f, 0xac, 0x02, 0x00, 0x00, 0x3d, 0x16,
0x9d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a, 0x0e, 0x14, 0x00, 0x0a, 0x00, 0x2c, 0x01, 0xc8, 0x00, 0x14, 0x00, 0x05, 0x00, 0x19, 0x00,
0x7f, 0x08, 0x01, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x40,
0xbf, 0x0c,
0xb2, 0x01, 0x80, 0x33, 0xea, 0xff, 0x00, 0x00, 0xea, 0xff, 0x00, 0x00, 0xc0, 0x05, 0x01, 0x9b, 0x00, 0xfc, 0xff,
0xc3, 0x04, 0x02, 0xc4, 0xc4, 0xc4,
0xdd, 0x09, 0x00, 0x03, 0x7f, 0x01, 0x01, 0x00, 0x00, 0xff, 0x7f,
0xdd, 0x18, 0x00, 0x50, 0xf2, 0x02, 0x01, 0x01,
0x80, 0x00,
0x03, 0xa4, 0x00, 0x00, 0x27, 0xa4, 0x00, 0x00, 0x42, 0x43, 0x5e, 0x00, 0x62, 0x32, 0x2f, 0x00, 0xdd, 0x85, 0x00, 0x50, 0xf2, 0x04, 0x10, 0x4a, 0x00, 0x01, 0x10, 0x10, 0x44, 0x00, 0x01,
0x02, 0x10, 0x3b, 0x00, 0x01, 0x03, 0x10, 0x47, 0x00, 0x10, 0x87, 0x65, 0x43, 0x21, 0x9a,
0xbc, 0xde, 0xf0, 0x12, 0x34, 0x98, 0xda, 0xc4, 0x8e, 0x86, 0xc8, 0x10, 0x21, 0x00, 0x07,
0x54, 0x50, 0x2d, 0x4c, 0x69, 0x6e, 0x6b, 0x10, 0x23, 0x00, 0x09, 0x41, 0x72, 0x63, 0x68,
0x65, 0x72, 0x20, 0x41, 0x37, 0x10, 0x24, 0x00, 0x03, 0x31, 0x2e, 0x30, 0x10, 0x42, 0x00,
0x0c, 0x41, 0x72, 0x63, 0x68, 0x65, 0x72, 0x20, 0x41, 0x37, 0x20, 0x76, 0x35, 0x10, 0x54,
0x00, 0x08, 0x00, 0x06, 0x00, 0x50, 0xf2, 0x04, 0x00, 0x01, 0x10, 0x11, 0x00, 0x0a, 0x41,
0x72, 0x63, 0x68, 0x65, 0x72, 0x41, 0x37, 0x76, 0x35, 0x10, 0x08, 0x00, 0x02, 0x00, 0x04,
0x10, 0x3c, 0x00, 0x01, 0x03, 0x10, 0x49, 0x00, 0x06, 0x00, 0x37, 0x2a, 0x00, 0x01, 0x20,
];
#[test]
fn test_no_merge() {
let ies = IesMerger::new(BEACON_FRAME_IES.to_vec()).finalize();
assert_eq!(&ies[..], BEACON_FRAME_IES);
}
#[test]
fn test_merge_same_ies() {
let mut ies_merger = IesMerger::new(BEACON_FRAME_IES.to_vec());
ies_merger.merge(BEACON_FRAME_IES);
let ies = ies_merger.finalize();
assert_eq!(&ies[..], BEACON_FRAME_IES);
assert!(!ies_merger.buffer_overflow());
}
#[test]
fn test_merge_different_ies() {
let mut ies_merger = IesMerger::new(BEACON_FRAME_IES.to_vec());
ies_merger.merge(PROBE_RESP_IES);
let ies = ies_merger.finalize();
assert_eq!(&ies[..], MERGED_IES);
assert!(!ies_merger.buffer_overflow());
}
#[test]
fn test_merge_different_ies_commutative() {
let mut ies_merger1 = IesMerger::new(BEACON_FRAME_IES.to_vec());
ies_merger1.merge(PROBE_RESP_IES);
let ies1 = ies_merger1.finalize();
let mut ies_merger2 = IesMerger::new(PROBE_RESP_IES.to_vec());
ies_merger2.merge(BEACON_FRAME_IES);
let ies2 = ies_merger2.finalize();
assert_eq!(ies1, ies2);
}
#[test]
fn test_merge_redundant() {
let mut ies_merger = IesMerger::new(BEACON_FRAME_IES.to_vec());
ies_merger.merge(BEACON_FRAME_IES);
ies_merger.merge(PROBE_RESP_IES);
ies_merger.merge(PROBE_RESP_IES);
ies_merger.merge(BEACON_FRAME_IES);
let ies = ies_merger.finalize();
assert_eq!(&ies[..], MERGED_IES);
}
#[test]
fn test_merge_is_resilient() {
const LEN: u8 = 255;
let mut ies = vec![0xdd, LEN];
ies.extend(vec![0xff; LEN as usize].iter());
let mut ies_merger = IesMerger::new(ies.clone());
for i in 0..255 {
let last_idx = ies.len() - 1;
ies[last_idx] = i; ies_merger.merge(&ies[..]);
}
assert!(ies_merger.ies_updater.buf_len() <= IES_MERGER_BUFFER_LIMIT);
assert!(ies_merger.buffer_overflow());
let result_ies = ies_merger.finalize();
assert_eq!(ies.len(), result_ies.len());
assert_eq!(ies[..ies.len() - 1], result_ies[..result_ies.len() - 1]);
}
#[test]
fn test_merge_prioritize_non_hidden_ssid_1() {
let hidden_ssid_ie = vec![0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
let mut ies_merger = IesMerger::new(BEACON_FRAME_IES.to_vec());
ies_merger.merge(&hidden_ssid_ie[..]);
let ies = ies_merger.finalize();
assert_eq!(&ies[..], BEACON_FRAME_IES);
let mut ies_merger = IesMerger::new(hidden_ssid_ie.clone());
assert_eq!(ies_merger.finalize(), hidden_ssid_ie);
let mut ies_merger = IesMerger::new(hidden_ssid_ie);
ies_merger.merge(BEACON_FRAME_IES);
let ies = ies_merger.finalize();
assert_eq!(&ies[..], BEACON_FRAME_IES);
}
#[test]
fn test_ie_updater_get() {
let ies = vec![
0, 2, 10, 20, 0xdd, 0x09, 0x00, 0x03, 0x7f, 0x01, 0x01, 0x00, 0x00, 0xff, 0x7f, 255, 2, 5, 1, ];
let ies_updater = IesUpdater::new(ies);
assert_eq!(ies_updater.get(&IeType::SSID), Some(&[10, 20][..]));
assert_eq!(
ies_updater.get(&IeType::new_vendor([0x00, 0x03, 0x7f, 0x01, 0x01, 0x00])),
Some(&[0x00, 0xff, 0x7f][..])
);
assert_eq!(ies_updater.get(&IeType::new_extended(5)), Some(&[1][..]));
assert_eq!(ies_updater.get(&IeType::SUPPORTED_RATES), None);
assert_eq!(
ies_updater.get(&IeType::new_vendor([0x00, 0x03, 0x7f, 0x01, 0x01, 0x01])),
None
);
assert_eq!(ies_updater.get(&IeType::new_extended(6)), None);
}
#[test]
fn test_ie_updater_set_replace() {
let ies = vec![
0, 2, 10, 20, 0xdd, 0x09, 0x00, 0x03, 0x7f, 0x01, 0x01, 0x00, 0x00, 0xff, 0x7f, 255, 2, 5, 1, ];
let mut ies_updater = IesUpdater::new(ies);
ies_updater.set(IeType::SSID, &[30, 40, 50]).expect("set basic succeeds");
ies_updater
.set(IeType::new_vendor([0x00, 0x03, 0x7f, 0x01, 0x01, 0x00]), &[1, 3, 3, 7])
.expect("set vendor succeeds");
ies_updater.set(IeType::new_extended(5), &[4, 2]).expect("set extended succeeds");
assert_eq!(ies_updater.get(&IeType::SSID), Some(&[30, 40, 50][..]));
assert_eq!(
ies_updater.get(&IeType::new_vendor([0x00, 0x03, 0x7f, 0x01, 0x01, 0x00])),
Some(&[1, 3, 3, 7][..])
);
assert_eq!(ies_updater.get(&IeType::new_extended(5)), Some(&[4, 2][..]));
assert_eq!(
&ies_updater.finalize()[..],
&[
0, 3, 30, 40, 50, 0xdd, 0x0a, 0x00, 0x03, 0x7f, 0x01, 0x01, 0x00, 1, 3, 3, 7, 255, 3, 5, 4, 2, ]
);
}
#[test]
fn test_ie_updater_set_new() {
let ies = vec![
0, 2, 10, 20, 0xdd, 0x09, 0x00, 0x03, 0x7f, 0x01, 0x01, 0x00, 0x00, 0xff, 0x7f, 255, 2, 5, 1, ];
let mut ies_updater = IesUpdater::new(ies);
ies_updater.set(IeType::SUPPORTED_RATES, &[30, 40, 50]).expect("set basic succeeds");
ies_updater
.set(IeType::new_vendor([0x00, 0x03, 0x7f, 0x01, 0x01, 0x01]), &[1, 3, 3, 7])
.expect("set vendor succeeds");
ies_updater.set(IeType::new_extended(6), &[4, 2]).expect("set extended succeeds");
assert_eq!(ies_updater.get(&IeType::SUPPORTED_RATES), Some(&[30, 40, 50][..]));
assert_eq!(
ies_updater.get(&IeType::new_vendor([0x00, 0x03, 0x7f, 0x01, 0x01, 0x01])),
Some(&[1, 3, 3, 7][..])
);
assert_eq!(ies_updater.get(&IeType::new_extended(6)), Some(&[4, 2][..]));
assert_eq!(
&ies_updater.finalize()[..],
&[
0, 2, 10, 20, 1, 3, 30, 40, 50, 0xdd, 0x09, 0x00, 0x03, 0x7f, 0x01, 0x01, 0x00, 0x00, 0xff, 0x7f, 0xdd, 0x0a, 0x00, 0x03, 0x7f, 0x01, 0x01, 0x01, 1, 3, 3, 7, 255, 2, 5, 1, 255, 3, 6, 4, 2, ]
)
}
#[test]
fn test_ie_updater_set_ie_too_large() {
let ies = vec![
0, 2, 10, 20, 0xdd, 0x09, 0x00, 0x03, 0x7f, 0x01, 0x01, 0x00, 0x00, 0xff, 0x7f, 255, 2, 5, 1, ];
let mut ies_updater = IesUpdater::new(ies);
ies_updater.set(IeType::SSID, &[11; 256]).expect_err("set basic fails");
ies_updater
.set(IeType::new_vendor([0x00, 0x03, 0x7f, 0x01, 0x01, 0x00]), &[11; 250])
.expect_err("set vendor fails");
ies_updater.set(IeType::new_extended(5), &[11; 255]).expect_err("set extended fails");
assert_eq!(
&ies_updater.finalize()[..],
&[
0, 2, 10, 20, 0xdd, 0x09, 0x00, 0x03, 0x7f, 0x01, 0x01, 0x00, 0x00, 0xff, 0x7f, 255, 2, 5, 1, ]
);
}
#[test]
fn test_ie_updater_set_raw_ie() {
let ies = vec![];
let mut ies_updater = IesUpdater::new(ies.clone());
ies_updater.set_raw(&[0, 2, 10, 20]).expect("set right length succeeds");
ies_updater.set_raw(&[1, 2, 70]).expect_err("set buffer too small fails");
ies_updater.set_raw(&[]).expect("set empty doesn't return error");
ies_updater.set_raw(&[2, 2, 30, 40, 50, 60]).expect("set truncated succeeds");
assert_eq!(&ies_updater.finalize()[..], &[0, 2, 10, 20, 2, 2, 30, 40])
}
#[test]
fn test_ie_updater_remove() {
let ies = vec![
0, 2, 10, 20, 0xdd, 0x09, 0x00, 0x03, 0x7f, 0x01, 0x01, 0x00, 0x00, 0xff, 0x7f, 255, 2, 5, 1, ];
let mut ies_updater = IesUpdater::new(ies.clone());
ies_updater.remove(&IeType::SSID);
assert_eq!(ies_updater.get(&IeType::SSID), None);
assert_eq!(
ies_updater.finalize(),
&[
0xdd, 0x09, 0x00, 0x03, 0x7f, 0x01, 0x01, 0x00, 0x00, 0xff, 0x7f, 255, 2, 5, 1, ]
);
let mut ies_updater = IesUpdater::new(ies.clone());
ies_updater.remove(&IeType::new_vendor([0x00, 0x03, 0x7f, 0x01, 0x01, 0x00]));
assert_eq!(
ies_updater.get(&IeType::new_vendor([0x00, 0x03, 0x7f, 0x01, 0x01, 0x00])),
None
);
assert_eq!(
ies_updater.finalize(),
&[
0, 2, 10, 20, 255, 2, 5, 1, ],
);
let mut ies_updater = IesUpdater::new(ies);
ies_updater.remove(&IeType::new_extended(5));
assert_eq!(ies_updater.get(&IeType::new_extended(5)), None);
assert_eq!(
ies_updater.finalize(),
&[
0, 2, 10, 20, 0xdd, 0x09, 0x00, 0x03, 0x7f, 0x01, 0x01, 0x00, 0x00, 0xff, 0x7f, ],
);
}
}