use aya_ebpf_cty::c_long;
use crate::{
bindings::bpf_map_type::BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,
helpers::sk_select_reuseport,
maps::{MapDef, PinningType},
programs::SkReuseportContext,
};
#[repr(transparent)]
pub struct ReusePortSockArray {
def: MapDef,
}
impl ReusePortSockArray {
map_constructors!(u32, u32, BPF_MAP_TYPE_REUSEPORT_SOCKARRAY);
#[inline(always)]
pub(crate) const fn as_ptr(&self) -> *mut aya_ebpf_cty::c_void {
self.def.as_ptr()
}
#[inline]
pub fn select_reuseport(&self, ctx: &SkReuseportContext, key: u32) -> Result<(), c_long> {
sk_select_reuseport(ctx, self, key)
}
}