In Linux 3.9 there's a packet filter module called xt_bpf that can take compiled BPF bytecode and use it directly in an iptables rule.
xt_bpf
Is there any equivalent for FreeBSD's ipfw system?
ipfw
You can try netgraph node ng_bpf.