Crates.io | bpf-ins |
lib.rs | bpf-ins |
version | 0.7.4 |
source | src |
created_at | 2022-10-22 13:27:28.249505 |
updated_at | 2024-02-05 18:33:38.638053 |
description | A library for working with eBPF instructions. |
homepage | https://github.com/arcjustin/bpf-ins |
repository | https://github.com/arcjustin/bpf-ins |
max_upload_size | |
id | 694407 |
size | 86,506 |
A crate for encoding and decoding eBPF instructions.
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);
}
}