12个版本 (6个重大更新)

0.7.4 2024年2月5日
0.7.2 2022年11月20日

#182编程语言

每月下载量 34次
3 个crate中使用了(通过 bpf-script

MIT 许可证

86KB
1.5K SLoC

bpf-ins

Build Status crates.io mio Lines of Code

用于编码和解码eBPF指令的crate。

用法

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);
    }
}

许可证


lib.rs:

Build Status crates.io mio Lines of Code

用于编码和解码eBPF指令的crate。

用法

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);
    }
}

许可证

依赖项

~270–730KB
~17K SLoC