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.
Is there any equivalent for FreeBSD's ipfw system?
You can try netgraph node ng_bpf.
netgraph with ipfw?
ng_ipfw appears to be very poor :(