[−][src]Struct redbpf_probes::socket::SkBuff
Context object provided to Socket-related programs.
Fields
skb: *const __sk_buff
The low level skb instance.
Implementations
impl SkBuff
[src]
pub fn load<T: FromBe>(&self, offset: usize) -> Result<T, SocketError>
[src]
Loads data from the socket buffer.
Example
use core::mem; use memoffset::offset_of; use redbpf_probes::socket_filter::prelude::*; #[socket_filter] fn forward_tcp(skb: SkBuff) -> SkBuffResult { let eth_len = mem::size_of::<ethhdr>(); let eth_proto: u16 = skb.load(offset_of!(ethhdr, h_proto))?; let ip_proto: u8 = skb.load(eth_len + offset_of!(iphdr, protocol))?; // only parse TCP if !(eth_proto as u32 == ETH_P_IP && ip_proto as u32 == IPPROTO_TCP) { return Ok(SkBuffAction::Ignore); } Ok(SkBuffAction::SendToUserspace) }
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,