use crate::common::ZExtBody;
pub type OamId = u16;
pub mod flag {
pub const T: u8 = 1 << 5; pub const Z: u8 = 1 << 7; }
pub mod id {
use super::OamId;
pub const OAM_LINKSTATE: OamId = 0x0001;
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Oam {
pub id: OamId,
pub body: ZExtBody,
pub ext_qos: ext::QoSType,
pub ext_tstamp: Option<ext::TimestampType>,
}
pub mod ext {
use crate::{zextz64, zextzbuf};
pub type QoS = zextz64!(0x1, false);
pub type QoSType = crate::network::ext::QoSType<{ QoS::ID }>;
pub type Timestamp = zextzbuf!(0x2, false);
pub type TimestampType = crate::network::ext::TimestampType<{ Timestamp::ID }>;
}
impl Oam {
#[cfg(feature = "test")]
#[doc(hidden)]
pub fn rand() -> Self {
use rand::Rng;
let mut rng = rand::thread_rng();
let id: OamId = rng.gen();
let body = ZExtBody::rand();
let ext_qos = ext::QoSType::rand();
let ext_tstamp = rng.gen_bool(0.5).then(ext::TimestampType::rand);
Self {
id,
body,
ext_qos,
ext_tstamp,
}
}
}