bpfjit 0.1.1

BPF JIT compiler from FreeBSD
Documentation
  • Coverage
  • 40%
    2 out of 5 items documented0 out of 4 items with examples
  • Size
  • Source code size: 75.31 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 735.23 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • polachok/bpfjit
    8 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • polachok

BPF JIT

BPF to amd64 JIT compiler for rust extracted from FreeBSD 10 tree.

Example usage

extern crate bpfjit;
extern crate pcap;
use std::mem;

fn main() {
    let pcap = pcap::Capture::dead(pcap::Linktype(12 /* raw ip */)).unwrap();
    let bpf_prog = pcap.compile("tcp and dst port 80").unwrap();
    let insns = bpf_prog.get_instructions();
    let filter = bpfjit::BpfJitFilter::compile(unsafe {
        mem::transmute(insns)
    }).unwrap();
    let data = [1,2,3,4];
    if filter.matched(&data[..]) {
        // ...
    }
}