12 releases (6 breaking)

0.7.4 Feb 5, 2024
0.7.2 Nov 20, 2022

#161 in Programming languages

Download history 11/week @ 2024-03-11 19/week @ 2024-04-01

112 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

~295–760KB
~18K SLoC