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.
35 lines
635 B
Rust
35 lines
635 B
Rust
4 years ago
|
#![no_std]
|
||
|
|
||
|
pub mod bpf;
|
||
|
pub mod maps;
|
||
|
pub mod programs;
|
||
|
|
||
|
pub use aya_bpf_cty as cty;
|
||
|
|
||
|
use bpf::helpers::{bpf_get_current_comm, bpf_get_current_pid_tgid};
|
||
|
use core::ffi::c_void;
|
||
|
use cty::c_char;
|
||
|
|
||
|
pub use aya_bpf_macros as macros;
|
||
|
|
||
|
pub const TASK_COMM_LEN: usize = 16;
|
||
|
|
||
|
pub trait BpfContext {
|
||
|
fn as_ptr(&self) -> *mut c_void;
|
||
|
|
||
|
#[inline]
|
||
|
fn command(&self) -> Result<[c_char; TASK_COMM_LEN], ()> {
|
||
|
bpf_get_current_comm()
|
||
|
}
|
||
|
|
||
|
#[inline]
|
||
|
fn pid(&self) -> u32 {
|
||
|
bpf_get_current_pid_tgid() as u32
|
||
|
}
|
||
|
|
||
|
#[inline]
|
||
|
fn tgid(&self) -> u32 {
|
||
|
(bpf_get_current_pid_tgid() >> 32) as u32
|
||
|
}
|
||
|
}
|