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.
aya/bpf/aya-bpf/src/programs/sk_msg.rs

40 lines
922 B
Rust

use core::ffi::c_void;
use crate::{
bindings::sk_msg_md,
helpers::{bpf_msg_pop_data, bpf_msg_push_data},
BpfContext,
};
pub struct SkMsgContext {
msg: *mut sk_msg_md,
}
impl SkMsgContext {
pub fn new(msg: *mut sk_msg_md) -> SkMsgContext {
SkMsgContext { msg }
}
pub fn data(&self) -> usize {
unsafe { (*self.msg).__bindgen_anon_1.data as usize }
}
pub fn data_end(&self) -> usize {
unsafe { (*self.msg).__bindgen_anon_2.data_end as usize }
}
pub fn push_data(&self, start: u32, len: u32, flags: u64) -> i64 {
unsafe { bpf_msg_push_data(self.msg, start, len as u32, flags) }
}
pub fn pop_data(&self, start: u32, len: u32, flags: u64) -> i64 {
unsafe { bpf_msg_pop_data(self.msg, start, len as u32, flags) }
}
}
impl BpfContext for SkMsgContext {
fn as_ptr(&self) -> *mut c_void {
self.msg as *mut _
}
}