orb8_common/
lib.rs

1//! Shared types between eBPF (kernel) and userspace
2//!
3//! This crate defines event structures that must be:
4//! - `#[repr(C)]` for stable memory layout
5//! - `no_std` compatible for eBPF
6//! - Shared between kernel probes and userspace agent
7
8#![cfg_attr(not(feature = "userspace"), no_std)]
9
10#[repr(C)]
11#[derive(Clone, Copy, Debug)]
12#[cfg_attr(feature = "userspace", derive(PartialEq, Eq))]
13pub struct PacketEvent {
14    pub timestamp_ns: u64,
15    pub packet_len: u32,
16    pub _padding: u32,
17}
18
19#[cfg(feature = "userspace")]
20const _: () = {
21    assert!(
22        core::mem::size_of::<PacketEvent>() == 16,
23        "PacketEvent must be exactly 16 bytes"
24    );
25    assert!(
26        core::mem::align_of::<PacketEvent>() == 8,
27        "PacketEvent must be 8-byte aligned"
28    );
29};