mirror of https://github.com/aya-rs/aya
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.
24 lines
493 B
Rust
24 lines
493 B
Rust
use core::ffi::c_void;
|
|
|
|
use crate::{helpers::bpf_probe_read, BpfContext};
|
|
|
|
pub struct TracePointContext {
|
|
ctx: *mut c_void,
|
|
}
|
|
|
|
impl TracePointContext {
|
|
pub fn new(ctx: *mut c_void) -> TracePointContext {
|
|
TracePointContext { ctx }
|
|
}
|
|
|
|
pub unsafe fn read_at<T>(&self, offset: usize) -> Result<T, i64> {
|
|
bpf_probe_read(self.ctx.add(offset) as *const T)
|
|
}
|
|
}
|
|
|
|
impl BpfContext for TracePointContext {
|
|
fn as_ptr(&self) -> *mut c_void {
|
|
self.ctx
|
|
}
|
|
}
|