func (p *Handle) SetBPFInstructionFilter(bpfInstructions []BPFInstruction) (err error) {
	bpf, err := bpfInstructionFilter(bpfInstructions)
	if err != nil {
		return err
	}
	defer bpf.free()
	return p.pcapSetfilter(bpf)
}
SetBPFInstructionFilter may be used to apply a filter in BPF asm byte code format.

Simplest way to generate BPF asm byte code is with tcpdump:
tcpdump -dd 'udp'

The output may be used directly to add a filter, e.g.:
bpfInstructions := []pcap.BpfInstruction{
{0x28, 0, 0, 0x0000000c},
{0x15, 0, 9, 0x00000800},
{0x30, 0, 0, 0x00000017},
{0x15, 0, 7, 0x00000006},
{0x28, 0, 0, 0x00000014},
{0x45, 5, 0, 0x00001fff},
{0xb1, 0, 0, 0x0000000e},
{0x50, 0, 0, 0x0000001b},
{0x54, 0, 0, 0x00000012},
{0x15, 0, 1, 0x00000012},
{0x6, 0, 0, 0x0000ffff},
{0x6, 0, 0, 0x00000000},
}

An other posibility is to write the bpf code in bpf asm.
Documentation: https://www.kernel.org/doc/Documentation/networking/filter.txt

To compile the code use bpf_asm from
https://github.com/torvalds/linux/tree/master/tools/net

The following command may be used to convert bpf_asm output to c/go struct, usable for SetBPFFilterByte:
bpf_asm -c tcp.bpf
package pcap
import (
	"errors"
	"fmt"
	"io"
	"net"
	"os"
	"reflect"
	"runtime"
	"strconv"
	"sync"
	"sync/atomic"
	"syscall"
	"time"
	"unsafe"
	"github.com/google/gopacket"
	"github.com/google/gopacket/layers"
)
const ErrNotActive = pcapErrorNotActivated
const MaxBpfInstructions = 4096
const bpfInstructionBufferSize = 8 * MaxBpfInstructions
type Handle struct {
	stop uint64
	cptr           pcapTPtr
	timeout        time.Duration
	device         string
	deviceIndex    int
	mu             sync.Mutex
	closeMu        sync.Mutex
	nanoSecsFactor int64
	pkthdr *pcapPkthdr
	bufptr *uint8
}
type Stats struct {
	PacketsReceived  int
	PacketsDropped   int
	PacketsIfDropped int
}
type Interface struct {
	Name        string
	Description string
	Flags       uint32
	Addresses   []InterfaceAddress
}
type Datalink struct {
	Name        string
	Description string
}
type InterfaceAddress struct {
	IP        net.IP
	Netmask   net.IPMask  
	Broadaddr net.IP      
	P2P       net.IP      
}
type bpfFilter struct {
	bpf pcapBpfProgram  
}
type BPF struct {
	orig string
	bpf  *bpfFilter
	hdr  pcapPkthdr  
}
type BPFInstruction struct {
	Code uint16
	Jt   uint8
	Jf   uint8
	K    uint32
}
const BlockForever = -time.Millisecond * 10
func timeoutMillis(timeout time.Duration) int {
	if timeout < 0 {
		timeout *= -1
	}
	if timeout != 0 && timeout < time.Millisecond {
		timeout = time.Millisecond
	}
	return int(timeout / time.Millisecond)
}
func OpenLive(device string, snaplen int32, promisc bool, timeout time.Duration) (handle *Handle, _ error) {
	var pro int
	if promisc {
		pro = 1
	}
	p, err := pcapOpenLive(device, int(snaplen), pro, timeoutMillis(timeout))
	if err != nil {
		return nil, err
	}
	p.timeout = timeout
	p.device = device
	ifc, err := net.InterfaceByName(device)
	if err != nil {
		p.deviceIndex = 0
	} else {
		p.deviceIndex = ifc.Index
	}
	p.nanoSecsFactor = 1000
	if p.timeout > 0 {
		if err := p.setNonBlocking(); err != nil {
			p.pcapClose()
			return nil, err
		}
	}
	return p, nil
}
func OpenOffline(file string) (handle *Handle, err error) {
	handle, err = openOffline(file)
	if err != nil {
		return
	}
	if pcapGetTstampPrecision(handle.cptr) == pcapTstampPrecisionNano {
		handle.nanoSecsFactor = 1
	} else {
		handle.nanoSecsFactor = 1000
	}
	return
}
func OpenOfflineFile(file *os.File) (handle *Handle, err error) {
	handle, err = openOfflineFile(file)
	if err != nil {
		return
	}
	if pcapGetTstampPrecision(handle.cptr) == pcapTstampPrecisionNano {
		handle.nanoSecsFactor = 1
	} else {
		handle.nanoSecsFactor = 1000
	}
	return
}
type NextError int32
func (n NextError) Error() string {
	switch n {
	case NextErrorOk:
		return "OK"
	case NextErrorTimeoutExpired:
		return "Timeout Expired"
	case NextErrorReadError:
		return "Read Error"
	case NextErrorNoMorePackets:
		return "No More Packets In File"
	case NextErrorNotActivated:
		return "Not Activated"
	}
	return strconv.Itoa(int(n))
}
const (
	NextErrorOk             NextError = 1
	NextErrorTimeoutExpired NextError = 0
	NextErrorReadError      NextError = -1
	NextErrorNoMorePackets NextError = -2
	NextErrorNotActivated  NextError = -3
)
func (p *Handle) ReadPacketData() (data []byte, ci gopacket.CaptureInfo, err error) {
	p.mu.Lock()
	err = p.getNextBufPtrLocked(&ci)
	if err == nil {
		data = make([]byte, ci.CaptureLength)
		copy(data, (*(*[1 << 30]byte)(unsafe.Pointer(p.bufptr)))[:])
	}
	p.mu.Unlock()
	if err == NextErrorTimeoutExpired {
		runtime.Gosched()
	}
	return
}
type activateError int
const (
	aeNoError      = activateError(0)
	aeActivated    = activateError(pcapErrorActivated)
	aePromisc      = activateError(pcapWarningPromisc)
	aeNoSuchDevice = activateError(pcapErrorNoSuchDevice)
	aeDenied       = activateError(pcapErrorDenied)
	aeNotUp        = activateError(pcapErrorNotUp)
	aeWarning      = activateError(pcapWarning)
	aeError        = activateError(pcapError)
)
func (a activateError) Error() string {
	switch a {
	case aeNoError:
		return "No Error"
	case aeActivated:
		return "Already Activated"
	case aePromisc:
		return "Cannot set as promisc"
	case aeNoSuchDevice:
		return "No Such Device"
	case aeDenied:
		return "Permission Denied"
	case aeNotUp:
		return "Interface Not Up"
	case aeWarning:
		return fmt.Sprintf("Warning: %v", activateErrMsg.Error())
	case aeError:
		return fmt.Sprintf("Error: %v", activateErrMsg.Error())
	default:
		return fmt.Sprintf("unknown activated error: %d", a)
	}
}
func (p *Handle) getNextBufPtrLocked(ci *gopacket.CaptureInfo) error {
	if !p.isOpen() {
		return io.EOF
	}
	var waited bool
	for atomic.LoadUint64(&p.stop) == 0 {
		result := p.pcapNextPacketEx()
		switch result {
		case NextErrorOk:
			sec := p.pkthdr.getSec()
			nanos := int64(p.pkthdr.getUsec()) * p.nanoSecsFactor
			ci.Timestamp = time.Unix(sec, nanos)
			ci.CaptureLength = p.pkthdr.getCaplen()
			ci.Length = p.pkthdr.getLen()
			ci.InterfaceIndex = p.deviceIndex
			return nil
		case NextErrorNoMorePackets:
			return io.EOF
		case NextErrorTimeoutExpired:
			if waited && p.timeout > 0 {
				return result
			}
			p.waitForPacket()
			waited = true
		default:
			return result
		}
	}
	return io.EOF
}
func (p *Handle) ZeroCopyReadPacketData() (data []byte, ci gopacket.CaptureInfo, err error) {
	p.mu.Lock()
	err = p.getNextBufPtrLocked(&ci)
	if err == nil {
		slice := (*reflect.SliceHeader)(unsafe.Pointer(&data))
		slice.Data = uintptr(unsafe.Pointer(p.bufptr))
		slice.Len = ci.CaptureLength
		slice.Cap = ci.CaptureLength
	}
	p.mu.Unlock()
	if err == NextErrorTimeoutExpired {
		runtime.Gosched()
	}
	return
}
func (p *Handle) Close() {
	p.closeMu.Lock()
	defer p.closeMu.Unlock()
	if !p.isOpen() {
		return
	}
	atomic.StoreUint64(&p.stop, 1)
	p.mu.Lock()
	defer p.mu.Unlock()
	p.pcapClose()
}
func (p *Handle) Error() error {
	return p.pcapGeterr()
}
func (p *Handle) Stats() (stat *Stats, err error) {
	return p.pcapStats()
}
func (p *Handle) ListDataLinks() (datalinks []Datalink, err error) {
	return p.pcapListDatalinks()
}
func (p *Handle) compileBPFFilter(expr string) (pcapBpfProgram, error) {
	var maskp = uint32(pcapNetmaskUnknown)
	if len(p.device) > 0 {
		var err error
		_, maskp, err = pcapLookupnet(p.device)
		if err != nil {
			maskp = uint32(pcapNetmaskUnknown)
		}
	}
	return p.pcapCompile(expr, maskp)
}
func CompileBPFFilter(linkType layers.LinkType, captureLength int, expr string) ([]BPFInstruction, error) {
	h, err := pcapOpenDead(linkType, captureLength)
	if err != nil {
		return nil, err
	}
	defer h.Close()
	return h.CompileBPFFilter(expr)
}
func (p *Handle) CompileBPFFilter(expr string) ([]BPFInstruction, error) {
	bpf, err := p.compileBPFFilter(expr)
	defer bpf.free()
	if err != nil {
		return nil, err
	}
	return bpf.toBPFInstruction(), nil
}
func (p *Handle) SetBPFFilter(expr string) (err error) {
	bpf, err := p.compileBPFFilter(expr)
	defer bpf.free()
	if err != nil {
		return err
	}
	return p.pcapSetfilter(bpf)
}