You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aya/ebpf/aya-ebpf/src/programs/raw_tracepoint.rs

25 lines
590 B
Rust

use core::ffi::c_void;
use crate::{EbpfContext, args::FromRawTracepointArgs, bindings::bpf_raw_tracepoint_args};
pub struct RawTracePointContext {
ctx: *mut bpf_raw_tracepoint_args,
}
impl RawTracePointContext {
pub fn new(ctx: *mut c_void) -> Self {
Self { ctx: ctx.cast() }
}
#[expect(clippy::missing_safety_doc)]
pub unsafe fn arg<T: FromRawTracepointArgs>(&self, n: usize) -> T {
unsafe { T::from_argument(&*self.ctx, n) }
}
}
impl EbpfContext for RawTracePointContext {
fn as_ptr(&self) -> *mut c_void {
self.ctx.cast()
}
}