bpf-ins

Crates.iobpf-ins
lib.rsbpf-ins
version0.7.4
sourcesrc
created_at2022-10-22 13:27:28.249505
updated_at2024-02-05 18:33:38.638053
descriptionA library for working with eBPF instructions.
homepagehttps://github.com/arcjustin/bpf-ins
repositoryhttps://github.com/arcjustin/bpf-ins
max_upload_size
id694407
size86,506
(arcjustin)

documentation

README

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

Commit count: 36

cargo fmt