assay_common/
lib.rs

1#![no_std]
2
3#[cfg(feature = "std")]
4extern crate std;
5
6#[cfg(feature = "std")]
7pub mod exports;
8
9pub const EVENT_OPENAT: u32 = 1;
10pub const EVENT_CONNECT: u32 = 2;
11pub const EVENT_FORK: u32 = 3;
12pub const EVENT_EXEC: u32 = 4;
13pub const EVENT_EXIT: u32 = 5;
14
15pub const EVENT_FILE_BLOCKED: u32 = 10;
16pub const EVENT_CONNECT_BLOCKED: u32 = 20;
17
18pub const DATA_LEN: usize = 512;
19
20#[repr(C)]
21#[derive(Clone, Copy, Debug, Eq, PartialEq)]
22pub struct MonitorEvent {
23    pub pid: u32,
24    pub event_type: u32,
25    pub data: [u8; DATA_LEN],
26}
27
28impl MonitorEvent {
29    pub const fn zeroed() -> Self {
30        Self {
31            pid: 0,
32            event_type: 0,
33            data: [0u8; DATA_LEN],
34        }
35    }
36}
37
38impl Default for MonitorEvent {
39    fn default() -> Self {
40        Self::zeroed()
41    }
42}
43
44// -----------------------------
45// Compile-time ABI/layout checks
46// -----------------------------
47
48// Exact size: 4 + 4 + 512 = 520 bytes
49const _: [(); 520] = [(); core::mem::size_of::<MonitorEvent>()];
50
51// Alignment should be 4 on all sane targets; if this fails, your ABI is different.
52const _: [(); 4] = [(); core::mem::align_of::<MonitorEvent>()];