1#![cfg_attr(not(feature = "userspace"), no_std)]
9
10#[repr(C)]
12#[derive(Clone, Copy, Debug)]
13#[cfg_attr(feature = "userspace", derive(PartialEq, Eq))]
14pub struct PacketEvent {
15 pub timestamp_ns: u64,
16 pub packet_len: u32,
17 pub _padding: u32,
18}
19
20#[repr(C)]
33#[derive(Clone, Copy, Debug)]
34#[cfg_attr(feature = "userspace", derive(PartialEq, Eq))]
35pub struct NetworkFlowEvent {
36 pub timestamp_ns: u64,
37 pub cgroup_id: u64,
38 pub src_ip: u32,
39 pub dst_ip: u32,
40 pub src_port: u16,
41 pub dst_port: u16,
42 pub protocol: u8,
43 pub direction: u8,
44 pub packet_len: u16,
45}
46
47pub mod direction {
49 pub const INGRESS: u8 = 0;
50 pub const EGRESS: u8 = 1;
51}
52
53pub mod protocol {
55 pub const ICMP: u8 = 1;
56 pub const TCP: u8 = 6;
57 pub const UDP: u8 = 17;
58}
59
60#[cfg(feature = "userspace")]
61const _: () = {
62 assert!(
63 core::mem::size_of::<PacketEvent>() == 16,
64 "PacketEvent must be exactly 16 bytes"
65 );
66 assert!(
67 core::mem::align_of::<PacketEvent>() == 8,
68 "PacketEvent must be 8-byte aligned"
69 );
70};
71
72#[cfg(feature = "userspace")]
73const _: () = {
74 assert!(
75 core::mem::size_of::<NetworkFlowEvent>() == 32,
76 "NetworkFlowEvent must be exactly 32 bytes"
77 );
78 assert!(
79 core::mem::align_of::<NetworkFlowEvent>() == 8,
80 "NetworkFlowEvent must be 8-byte aligned"
81 );
82};