pub struct BpfCode { /* private fields */ }
Expand description

BPF instruction stack in byte representation

Implementations§

source§

impl BpfCode

source

pub fn new() -> Self

creates new empty BPF instruction stack

source

pub fn add(&mut self, source: Source, arch: Arch) -> Move<'_>

create ADD instruction

source

pub fn sub(&mut self, source: Source, arch: Arch) -> Move<'_>

create SUB instruction

source

pub fn mul(&mut self, source: Source, arch: Arch) -> Move<'_>

create MUL instruction

source

pub fn div(&mut self, source: Source, arch: Arch) -> Move<'_>

create DIV instruction

source

pub fn bit_or(&mut self, source: Source, arch: Arch) -> Move<'_>

create OR instruction

source

pub fn bit_and(&mut self, source: Source, arch: Arch) -> Move<'_>

create AND instruction

source

pub fn left_shift(&mut self, source: Source, arch: Arch) -> Move<'_>

create LSHIFT instruction

source

pub fn right_shift(&mut self, source: Source, arch: Arch) -> Move<'_>

create RSHIFT instruction

source

pub fn negate(&mut self, arch: Arch) -> Move<'_>

create NEGATE instruction

source

pub fn modulo(&mut self, source: Source, arch: Arch) -> Move<'_>

create MOD instruction

source

pub fn bit_xor(&mut self, source: Source, arch: Arch) -> Move<'_>

create XOR instruction

source

pub fn mov(&mut self, source: Source, arch: Arch) -> Move<'_>

create MOV instruction

source

pub fn signed_right_shift(&mut self, source: Source, arch: Arch) -> Move<'_>

create SIGNED RSHIFT instruction

source

pub fn swap_bytes(&mut self, endian: Endian) -> SwapBytes<'_>

create byte swap instruction

source

pub fn load(&mut self, mem_size: MemSize) -> Load<'_>

create LOAD instruction, IMMEDIATE is the source

source

pub fn load_abs(&mut self, mem_size: MemSize) -> Load<'_>

create ABSOLUTE LOAD instruction

source

pub fn load_ind(&mut self, mem_size: MemSize) -> Load<'_>

create INDIRECT LOAD instruction

source

pub fn load_x(&mut self, mem_size: MemSize) -> Load<'_>

create LOAD instruction, MEMORY is the source

source

pub fn store(&mut self, mem_size: MemSize) -> Store<'_>

creates STORE instruction, IMMEDIATE is the source

source

pub fn store_x(&mut self, mem_size: MemSize) -> Store<'_>

creates STORE instruction, MEMORY is the source

source

pub fn jump_unconditional(&mut self) -> Jump<'_>

create unconditional JMP instruction

source

pub fn jump_conditional(&mut self, cond: Cond, src_bit: Source) -> Jump<'_>

create conditional JMP instruction

source

pub fn call(&mut self) -> FunctionCall<'_>

create CALL instruction

source

pub fn exit(&mut self) -> Exit<'_>

create EXIT instruction

Trait Implementations§

source§

impl Default for BpfCode

source§

fn default() -> BpfCode

Returns the “default value” for a type. Read more
source§

impl<'a> IntoBytes for &'a BpfCode

Transform BpfCode into assemble representation

source§

fn into_bytes(self) -> Self::Bytes

returns BpfCode instruction stack as &[u8]

§

type Bytes = &'a [u8]

type of targeted transformation

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V