#![cfg_attr(not(feature = "userspace"), no_std)]
#[cfg(not(target_endian = "little"))]
compile_error!(
"orb8 requires a little-endian target (x86_64, aarch64). \
IP address byte order handling is not compatible with big-endian systems."
);
#[repr(C)]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "userspace", derive(PartialEq, Eq))]
pub struct PacketEvent {
pub timestamp_ns: u64,
pub packet_len: u32,
pub _padding: u32,
}
#[repr(C)]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "userspace", derive(PartialEq, Eq))]
pub struct NetworkFlowEvent {
pub timestamp_ns: u64,
pub cgroup_id: u64,
pub src_ip: u32,
pub dst_ip: u32,
pub src_port: u16,
pub dst_port: u16,
pub protocol: u8,
pub direction: u8,
pub packet_len: u16,
}
pub mod direction {
pub const INGRESS: u8 = 0;
pub const EGRESS: u8 = 1;
}
pub mod protocol {
pub const ICMP: u8 = 1;
pub const TCP: u8 = 6;
pub const UDP: u8 = 17;
}
#[cfg(feature = "userspace")]
const _: () = {
assert!(
core::mem::size_of::<PacketEvent>() == 16,
"PacketEvent must be exactly 16 bytes"
);
assert!(
core::mem::align_of::<PacketEvent>() == 8,
"PacketEvent must be 8-byte aligned"
);
};
#[cfg(feature = "userspace")]
const _: () = {
assert!(
core::mem::size_of::<NetworkFlowEvent>() == 32,
"NetworkFlowEvent must be exactly 32 bytes"
);
assert!(
core::mem::align_of::<NetworkFlowEvent>() == 8,
"NetworkFlowEvent must be 8-byte aligned"
);
};