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
31    pub fn new(oui: [u8; 3]) -> Self {
32        Self(oui)
33    }
34}
35
36impl std::ops::Deref for Oui {
37    type Target = [u8];
38
39    fn deref(&self) -> &Self::Target {
40        &self.0[..]
41    }
42}
43
44impl From<Oui> for [u8; 3] {
45    fn from(src: Oui) -> Self {
46        src.0
47    }
48}