use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
#[repr(C)]
#[derive(Debug, Clone, Copy, Default, FromBytes, IntoBytes, Immutable, KnownLayout)]
pub struct BrPortMsg {
pub family: u8,
pub pad: [u8; 3],
pub ifindex: u32,
}
impl BrPortMsg {
pub const SIZE: usize = std::mem::size_of::<Self>();
pub fn new() -> Self {
Self::default()
}
pub fn with_family(mut self, family: u8) -> Self {
self.family = family;
self
}
pub fn with_ifindex(mut self, ifindex: u32) -> Self {
self.ifindex = ifindex;
self
}
}
#[repr(C)]
#[derive(Debug, Clone, Copy, Default, FromBytes, IntoBytes, Immutable, KnownLayout)]
pub struct BrMdbEntry {
pub ifindex: u32,
pub state: u8,
pub flags: u8,
pub vid: u16,
pub addr: [u8; 16],
pub proto: u16,
pub _pad: u16,
}
impl BrMdbEntry {
pub const SIZE: usize = std::mem::size_of::<Self>();
}
const _: () = assert!(BrPortMsg::SIZE == 8);
const _: () = assert!(BrMdbEntry::SIZE == 28);
pub const MDB_TEMPORARY: u8 = 0;
pub const MDB_PERMANENT: u8 = 1;
pub const MDB_FLAGS_OFFLOAD: u8 = 1 << 0;
pub const MDB_FLAGS_FAST_LEAVE: u8 = 1 << 1;
pub const MDB_FLAGS_STAR_EXCL: u8 = 1 << 2;
pub const MDB_FLAGS_BLOCKED: u8 = 1 << 3;
pub mod mdba {
pub const MDBA_MDB: u16 = 1;
pub const MDBA_ROUTER: u16 = 2;
}
pub mod mdba_mdb {
pub const MDBA_MDB_ENTRY: u16 = 1;
}
pub mod mdba_mdb_entry {
pub const MDBA_MDB_ENTRY_INFO: u16 = 1;
}
pub mod mdba_set {
pub const MDBA_SET_ENTRY: u16 = 1;
}
pub mod eth_p {
pub const ETH_P_IP: u16 = 0x0800;
pub const ETH_P_IPV6: u16 = 0x86DD;
}