12 releases (6 breaking)

0.7.4 Feb 5, 2024
0.7.2 Nov 20, 2022

#162 in Programming languages

Download history 10/week @ 2024-01-23 3/week @ 2024-01-30 1/week @ 2024-02-06 3/week @ 2024-02-13 33/week @ 2024-02-20 20/week @ 2024-02-27 1/week @ 2024-03-05 10/week @ 2024-03-12 1/week @ 2024-03-26 18/week @ 2024-04-02

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

~325–790KB
~19K SLoC