12 releases (6 breaking)

0.7.4 Feb 5, 2024
0.7.2 Nov 20, 2022

#186 in Programming languages

30 downloads per month
Used in 3 crates (via bpf-script)

MIT license

86KB
1.5K SLoC

bpf-ins

Build Status crates.io mio Lines of Code

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:

Build Status crates.io mio Lines of Code

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

~335–800KB
~19K SLoC