Struct solana_rbpf::ebpf::Insn
source · pub struct Insn {
pub ptr: usize,
pub opc: u8,
pub dst: u8,
pub src: u8,
pub off: i16,
pub imm: i64,
}
Expand description
An eBPF instruction.
See https://www.kernel.org/doc/Documentation/networking/filter.txt for the Linux kernel documentation about eBPF, or https://github.com/iovisor/bpf-docs/blob/master/eBPF.md for a more concise version.
Fields§
§ptr: usize
Instruction pointer.
opc: u8
Operation code.
dst: u8
Destination register operand.
src: u8
Source register operand.
off: i16
Offset operand.
imm: i64
Immediate value operand.
Implementations§
source§impl Insn
impl Insn
sourcepub fn to_array(&self) -> [u8; 8]
pub fn to_array(&self) -> [u8; 8]
Turn an Insn
back into an array of bytes.
Examples
use solana_rbpf::ebpf;
let prog: &[u8] = &[
0xb7, 0x12, 0x56, 0x34, 0xde, 0xbc, 0x9a, 0x78,
];
let insn = ebpf::Insn {
ptr: 0x00,
opc: 0xb7,
dst: 2,
src: 1,
off: 0x3456,
imm: 0x789abcde
};
assert_eq!(insn.to_array(), prog);
sourcepub fn to_vec(&self) -> Vec<u8> ⓘ
pub fn to_vec(&self) -> Vec<u8> ⓘ
Turn an Insn
into an vector of bytes.
Examples
use solana_rbpf::ebpf;
let prog: Vec<u8> = vec![
0xb7, 0x12, 0x56, 0x34, 0xde, 0xbc, 0x9a, 0x78,
];
let insn = ebpf::Insn {
ptr: 0x00,
opc: 0xb7,
dst: 2,
src: 1,
off: 0x3456,
imm: 0x789abcde
};
assert_eq!(insn.to_vec(), prog);
Trait Implementations§
source§impl PartialEq for Insn
impl PartialEq for Insn
impl Eq for Insn
impl StructuralEq for Insn
impl StructuralPartialEq for Insn
Auto Trait Implementations§
impl RefUnwindSafe for Insn
impl Send for Insn
impl Sync for Insn
impl Unpin for Insn
impl UnwindSafe for Insn
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more