12 releases (6 breaking)
0.7.4 | Feb 5, 2024 |
---|---|
0.7.2 | Nov 20, 2022 |
#185 in Programming languages
Used in 3 crates
(via bpf-script)
86KB
1.5K
SLoC
bpf-ins
A crate for encoding and decoding eBPF instructions.
Usage
use bpf_ins::{Instruction, Register};
//
// return 0
//
let instructions = [
Instruction::mov32(Register::R0, 0), // mov r0, 0
Instruction::exit(), // exit
];
let mut encoded = vec![];
for instruction in &instructions {
let (x, y) = instruction.encode();
encoded.push(x);
if let Some(y) = y {
encoded.push(y);
}
}
License
lib.rs
:
A crate for encoding and decoding eBPF instructions.
Usage
use bpf_ins::{Instruction, Register};
//
// return 0
//
let instructions = [
Instruction::mov32(Register::R0, 0), // mov r0, 0
Instruction::exit(), // exit
];
let mut encoded = vec![];
for instruction in &instructions {
let (x, y) = instruction.encode();
encoded.push(x);
if let Some(y) = y {
encoded.push(y);
}
}
License
Dependencies
~230–680KB
~16K SLoC