use crate::prelude::*;
use perf_event_open_sys::bindings;
#[derive(Copy, Clone, Debug)]
#[allow(missing_docs)]
pub struct BpfEvent {
pub ty: BpfEventType,
pub flags: u16,
pub id: u32,
pub tag: [u8; 8],
}
c_enum! {
pub struct BpfEventType : u16 {
const UNKNOWN = bindings::PERF_BPF_EVENT_UNKNOWN as _;
const PROG_LOAD = bindings::PERF_BPF_EVENT_PROG_LOAD as _;
const PROG_UNLOAD = bindings::PERF_BPF_EVENT_PROG_UNLOAD as _;
}
}
impl<'p> Parse<'p> for BpfEventType {
fn parse<B, E>(p: &mut Parser<B, E>) -> ParseResult<Self>
where
E: Endian,
B: ParseBuf<'p>,
{
Ok(Self::new(p.parse()?))
}
}
impl<'p> Parse<'p> for BpfEvent {
fn parse<B, E>(p: &mut Parser<B, E>) -> ParseResult<Self>
where
E: Endian,
B: ParseBuf<'p>,
{
Ok(Self {
ty: p.parse()?,
flags: p.parse()?,
id: p.parse()?,
tag: p.parse()?,
})
}
}