2 releases

0.1.1 Sep 23, 2016
0.1.0 Aug 17, 2016
Download history 26/week @ 2019-11-20 120/week @ 2019-11-27 66/week @ 2019-12-04 114/week @ 2019-12-11 14/week @ 2019-12-18 5/week @ 2019-12-25 6/week @ 2020-01-08 19/week @ 2020-01-15 11/week @ 2020-01-22 2/week @ 2020-02-12 4/week @ 2020-02-19 4/week @ 2020-02-26 4/week @ 2020-03-04

136 downloads per month

BSD-3-Clause

23KB
643 lines

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[..]) {
        // ...
    }
}

Dependencies