func (f *Filter) Filter(buf []byte) uint {
    cbuf := (*C.char)(unsafe.Pointer(&buf[0]))
    blen := C.uint(len(buf))
    rc := C.bpf_filter(f.program.bf_insns, cbuf, blen, blen)
    return uint(rc)
}
Run filter on the given buffer and return its result.
package filter
import "C"
import "fmt"
import "strings"
import "syscall"
import "unsafe"
type Filter struct {
    program C.struct_bpf_program
}
type Code uint16
const (
    LD Code = syscall.BPF_LD
    LDX     = syscall.BPF_LDX
    ST      = syscall.BPF_ST
    STX     = syscall.BPF_STX
    ALU     = syscall.BPF_ALU
    JMP     = syscall.BPF_JMP
    RET     = syscall.BPF_RET
    MISC    = syscall.BPF_MISC
)
type Size uint16
const (
    Word Size = syscall.BPF_W
    Half      = syscall.BPF_H
    Byte      = syscall.BPF_B
)
type Mode uint16
const (
    IMM Mode = syscall.BPF_IMM
    ABS      = syscall.BPF_ABS
    IND      = syscall.BPF_IND
    MEM      = syscall.BPF_MEM
    LEN      = syscall.BPF_LEN
    MSH      = syscall.BPF_MSH
)
type Src uint16
const (
    Const Src = syscall.BPF_K
    Index     = syscall.BPF_X
    Acc       = syscall.BPF_A
)
func (f *Filter) Match(buf []byte) bool {
    cbuf := (*C.char)(unsafe.Pointer(&buf[0]))
    blen := C.uint(len(buf))
    if C.bpf_filter(f.program.bf_insns, cbuf, blen, blen) > 0 {
        return true
    }
    return false
}