wlan_common/
organization.rs

1// Copyright 2019 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout, Unaligned};
6
7// IEEE Std 802.11-2016, 9.4.1.32
8// 24-bit organization unique identifier
9#[repr(C, packed)]
10#[derive(
11    Eq,
12    PartialEq,
13    Hash,
14    IntoBytes,
15    KnownLayout,
16    FromBytes,
17    Immutable,
18    Unaligned,
19    Copy,
20    Clone,
21    Debug,
22    PartialOrd,
23    Default,
24)]
25pub struct Oui([u8; 3]);
26
27impl Oui {
28    pub const DOT11: Self = Self([0x00, 0x0F, 0xAC]);
29    pub const MSFT: Self = Self([0x00, 0x50, 0xF2]);
30    pub const WFA: Self = Self([0x50, 0x6F, 0x9A]);
31
32    pub fn new(oui: [u8; 3]) -> Self {
33        Self(oui)
34    }
35}
36
37impl std::ops::Deref for Oui {
38    type Target = [u8];
39
40    fn deref(&self) -> &Self::Target {
41        &self.0[..]
42    }
43}
44
45impl From<Oui> for [u8; 3] {
46    fn from(src: Oui) -> Self {
47        src.0
48    }
49}