#[derive(Debug, PartialEq, Eq)]
pub enum Oui {
ASUSTek,
Siemens,
SiemensN,
SiemensD3,
PnMc,
Sagemcom,
Intel,
Unknown,
}
impl Oui {
pub fn from_bytes(bytes: &[u8]) -> Self {
match bytes {
[0x2C, 0xFD, 0xA1, ..] => Oui::ASUSTek,
[0xE0, 0xDC, 0xA0, ..] => Oui::Siemens,
[0x08, 0x00, 0x06, ..] => Oui::SiemensN,
[0xB0, 0x5B, 0x99, ..] => Oui::Sagemcom,
[0x64, 0x6E, 0xE0, ..] => Oui::Intel, [0x01, 0x0E, 0xCF, ..] => Oui::PnMc,
[0x00, 0x0E, 0x8C, ..] => Oui::SiemensD3,
_ => Oui::Unknown,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_oui_asustek() {
let bytes = [0x2C, 0xFD, 0xA1, 0x12, 0x34, 0x56];
let oui = Oui::from_bytes(&bytes);
assert_eq!(oui, Oui::ASUSTek);
}
#[test]
fn test_oui_siemens() {
let bytes = [0xE0, 0xDC, 0xA0, 0x12, 0x34, 0x56];
let oui = Oui::from_bytes(&bytes);
assert_eq!(oui, Oui::Siemens);
}
#[test]
fn test_oui_sagemcom() {
let bytes = [0xB0, 0x5B, 0x99, 0x12, 0x34, 0x56];
let oui = Oui::from_bytes(&bytes);
assert_eq!(oui, Oui::Sagemcom);
}
#[test]
fn test_oui_intel() {
let bytes = [0x64, 0x6E, 0xE0, 0x12, 0x34, 0x56];
let oui = Oui::from_bytes(&bytes);
assert_eq!(oui, Oui::Intel);
}
#[test]
fn test_oui_unknown() {
let bytes = [0x00, 0x11, 0x22, 0x33, 0x44, 0x55];
let oui = Oui::from_bytes(&bytes);
assert_eq!(oui, Oui::Unknown);
}
}