aya_obj/programs/
cgroup_sock.rs

1//! Cgroup socket programs.
2use crate::generated::bpf_attach_type;
3
4/// Defines where to attach a `CgroupSock` program.
5#[derive(Copy, Clone, Debug, Default)]
6pub enum CgroupSockAttachType {
7    /// Called after the IPv4 bind events.
8    PostBind4,
9    /// Called after the IPv6 bind events.
10    PostBind6,
11    /// Attach to IPv4 connect events.
12    #[default]
13    SockCreate,
14    /// Attach to IPv6 connect events.
15    SockRelease,
16}
17
18impl From<CgroupSockAttachType> for bpf_attach_type {
19    fn from(s: CgroupSockAttachType) -> Self {
20        match s {
21            CgroupSockAttachType::PostBind4 => Self::BPF_CGROUP_INET4_POST_BIND,
22            CgroupSockAttachType::PostBind6 => Self::BPF_CGROUP_INET6_POST_BIND,
23            CgroupSockAttachType::SockCreate => Self::BPF_CGROUP_INET_SOCK_CREATE,
24            CgroupSockAttachType::SockRelease => Self::BPF_CGROUP_INET_SOCK_RELEASE,
25        }
26    }
27}