[][src]Trait redbpf_probes::net::NetworkBuffer

pub trait NetworkBuffer where
    Self: Clone + Sized
{ fn data_start(&self) -> usize;
fn data_end(&self) -> usize; fn len(&self) -> usize { ... }
unsafe fn ptr_at<U>(&self, addr: usize) -> NetworkResult<*const U> { ... }
unsafe fn ptr_after<T, U>(&self, prev: *const T) -> NetworkResult<*const U> { ... }
fn check_bounds(&self, start: usize, end: usize) -> NetworkResult<()> { ... }
fn eth(&self) -> NetworkResult<*const ethhdr> { ... }
fn ip(&self) -> NetworkResult<*const iphdr> { ... }
fn transport(&self) -> NetworkResult<Transport> { ... }
fn data(&self) -> NetworkResult<Data<Self>> { ... } }

Required methods

fn data_start(&self) -> usize

fn data_end(&self) -> usize

Loading content...

Provided methods

fn len(&self) -> usize

Returns the packet length.

unsafe fn ptr_at<U>(&self, addr: usize) -> NetworkResult<*const U>

Returns a raw pointer to a given address inside the buffer.

Safety

This method uses NetworkBuffer::check_bounds to ensure the given address addr is within the buffer and allows enough following space to point to something of type U. However no checks are done to ensure the returned pointer points to a valid bit pattern of type U, nor are any alignments checked. Ensuring proper alignment is followed and pointed to address is a valid bit pattern of type U is left up to the caller.

unsafe fn ptr_after<T, U>(&self, prev: *const T) -> NetworkResult<*const U>

Returns a raw pointer to the address following prev plus the size of a T

Safety

This method uses NetworkBuffer::check_bounds to ensure the given address addr is within the buffer and allows enough following space to point to something of type U. However no checks are done to ensure the returned pointer points to a valid bit pattern of type U, nor are any alignments checked. Ensuring proper alignment is followed and pointed to address is a valid bit pattern of type U is left up to the caller.

fn check_bounds(&self, start: usize, end: usize) -> NetworkResult<()>

fn eth(&self) -> NetworkResult<*const ethhdr>

Returns the packet's Ethernet header if present.

fn ip(&self) -> NetworkResult<*const iphdr>

Returns the packet's IP header if present.

fn transport(&self) -> NetworkResult<Transport>

Returns the packet's transport header if present.

fn data(&self) -> NetworkResult<Data<Self>>

Returns the packet's data starting after the transport headers.

Loading content...

Implementors

impl NetworkBuffer for XdpContext[src]

Loading content...