aya: add doc aliases for maps and programs

pull/1/head
Alessandro Decina 3 years ago
parent 293e66af65
commit 768640dd46

@ -28,6 +28,7 @@ use crate::{
/// assert_eq!(array.get(&1, 0)?, 42);
/// # Ok::<(), aya::BpfError>(())
/// ```
#[doc(alias = "BPF_MAP_TYPE_ARRAY")]
pub struct Array<T: Deref<Target = Map>, V: Pod> {
inner: T,
_v: PhantomData<V>,

@ -47,6 +47,7 @@ use crate::{
/// }
/// # Ok::<(), Error>(())
/// ```
#[doc(alias = "BPF_MAP_TYPE_PERCPU_ARRAY")]
pub struct PerCpuArray<T: Deref<Target = Map>, V: Pod> {
inner: T,
_v: PhantomData<V>,

@ -44,6 +44,7 @@ use crate::{
/// prog_array.set(2, prog_2, flags);
/// # Ok::<(), aya::BpfError>(())
/// ```
#[doc(alias = "BPF_MAP_TYPE_PROG_ARRAY")]
pub struct ProgramArray<T: Deref<Target = Map>> {
inner: T,
}

@ -83,6 +83,7 @@ use crate::maps::{
/// # Ok(())
/// # }
/// ```
#[doc(alias = "BPF_MAP_TYPE_PERF_EVENT_ARRAY")]
pub struct AsyncPerfEventArray<T: DerefMut<Target = Map>> {
perf_map: PerfEventArray<T>,
}

@ -155,6 +155,7 @@ impl<T: DerefMut<Target = Map>> AsRawFd for PerfEventArrayBuffer<T> {
/// [mio]: https://docs.rs/mio
/// [tokio]: https://docs.rs/tokio
/// [async-std]: https://docs.rs/async-std
#[doc(alias = "BPF_MAP_TYPE_PERF_EVENT_ARRAY")]
pub struct PerfEventArray<T: DerefMut<Target = Map>> {
map: Arc<T>,
page_size: usize,

@ -14,6 +14,7 @@ use crate::{
};
/// A FIFO queue.
#[doc(alias = "BPF_MAP_TYPE_QUEUE")]
pub struct Queue<T: Deref<Target = Map>, V: Pod> {
inner: T,
_v: PhantomData<V>,

@ -36,6 +36,7 @@ use crate::{
/// prog.attach(&intercept_ingress)?;
/// # Ok::<(), aya::BpfError>(())
/// ```
#[doc(alias = "BPF_MAP_TYPE_SOCKMAP")]
pub struct SockMap<T: Deref<Target = Map>> {
pub(crate) inner: T,
}

@ -7,7 +7,7 @@ use std::{
};
use crate::{
generated::bpf_map_type::BPF_MAP_TYPE_QUEUE,
generated::bpf_map_type::BPF_MAP_TYPE_STACK,
maps::{Map, MapError, MapRef, MapRefMut},
sys::{bpf_map_lookup_and_delete_elem, bpf_map_update_elem},
Pod,
@ -27,6 +27,7 @@ use crate::{
/// assert_eq!(stack.pop(0)?, 43);
/// # Ok::<(), aya::BpfError>(())
/// ```
#[doc(alias = "BPF_MAP_TYPE_STACK")]
pub struct Stack<T: Deref<Target = Map>, V: Pod> {
inner: T,
_v: PhantomData<V>,
@ -35,7 +36,7 @@ pub struct Stack<T: Deref<Target = Map>, V: Pod> {
impl<T: Deref<Target = Map>, V: Pod> Stack<T, V> {
fn new(map: T) -> Result<Stack<T, V>, MapError> {
let map_type = map.obj.def.map_type;
if map_type != BPF_MAP_TYPE_QUEUE as u32 {
if map_type != BPF_MAP_TYPE_STACK as u32 {
return Err(MapError::InvalidMapType {
map_type: map_type as u32,
})?;

@ -61,6 +61,7 @@ use crate::{
/// ```
///
#[derive(Debug)]
#[doc(alias = "BPF_MAP_TYPE_STACK_TRACE")]
pub struct StackTraceMap<T> {
inner: T,
max_stack_depth: usize,

@ -45,6 +45,7 @@ use super::FdLink;
/// # Ok::<(), Error>(())
/// ```
#[derive(Debug)]
#[doc(alias = "BPF_PROG_TYPE_CGROUP_SKB")]
pub struct CgroupSkb {
pub(crate) data: ProgramData,
pub(crate) expected_attach_type: Option<CgroupSkbAttachType>,

@ -32,6 +32,7 @@ use crate::{
/// # Ok::<(), aya::BpfError>(())
/// ```
#[derive(Debug)]
#[doc(alias = "BPF_PROG_TYPE_KPROBE")]
pub struct KProbe {
pub(crate) data: ProgramData,
pub(crate) kind: ProbeKind,

@ -50,6 +50,7 @@ use crate::{
/// [`SockMap`]: crate::maps::SockMap
/// [`SockHash`]: crate::maps::SockHash
#[derive(Debug)]
#[doc(alias = "BPF_PROG_TYPE_SK_MSG")]
pub struct SkMsg {
pub(crate) data: ProgramData,
}

@ -40,6 +40,7 @@ pub enum SkSkbKind {
/// [`SockMap`]: crate::maps::SockMap
/// [`SockHash`]: crate::maps::SockHash
#[derive(Debug)]
#[doc(alias = "BPF_PROG_TYPE_SK_SKB")]
pub struct SkSkb {
pub(crate) data: ProgramData,
pub(crate) kind: SkSkbKind,

@ -37,6 +37,7 @@ use crate::{
/// prog.attach(file)?;
/// # Ok::<(), Error>(())
#[derive(Debug)]
#[doc(alias = "BPF_PROG_TYPE_SOCK_OPS")]
pub struct SockOps {
pub(crate) data: ProgramData,
}

@ -55,6 +55,7 @@ pub enum SocketFilterError {
/// # Ok::<(), Error>(())
/// ```
#[derive(Debug)]
#[doc(alias = "BPF_PROG_TYPE_SOCKET_FILTER")]
pub struct SocketFilter {
pub(crate) data: ProgramData,
}

@ -59,6 +59,7 @@ pub enum TcAttachType {
/// # Ok::<(), Error>(())
/// ```
#[derive(Debug)]
#[doc(alias = "BPF_PROG_TYPE_SCHED_CLS")]
pub struct SchedClassifier {
pub(crate) data: ProgramData,
}

@ -46,6 +46,7 @@ pub enum TracePointError {
/// # Ok::<(), Error>(())
/// ```
#[derive(Debug)]
#[doc(alias = "BPF_PROG_TYPE_TRACEPOINT")]
pub struct TracePoint {
pub(crate) data: ProgramData,
}

@ -38,6 +38,7 @@ const LD_SO_CACHE_HEADER: &str = "glibc-ld.so.cache1.1";
/// - `uprobe`: get attached to the *start* of the target functions
/// - `uretprobe`: get attached to the *return address* of the target functions
#[derive(Debug)]
#[doc(alias = "BPF_PROG_TYPE_KPROBE")]
pub struct UProbe {
pub(crate) data: ProgramData,
pub(crate) kind: ProbeKind,

@ -58,6 +58,7 @@ bitflags! {
/// # Ok::<(), aya::BpfError>(())
/// ```
#[derive(Debug)]
#[doc(alias = "BPF_PROG_TYPE_XDP")]
pub struct Xdp {
pub(crate) data: ProgramData,
}

Loading…
Cancel
Save