func OpenOffline(file string) (handle *Handle, err error) {
	buf := (*C.char)(C.calloc(errorBufferSize, 1))
	defer C.free(unsafe.Pointer(buf))
	cf := C.CString(file)
	defer C.free(unsafe.Pointer(cf))
	cptr := C.pcap_open_offline(cf, buf)
	if cptr == nil {
		return nil, errors.New(C.GoString(buf))
	}
	return &Handle{cptr: cptr}, nil
}
OpenOffline opens a file and returns its contents as a *Handle.
package pcap
import "C"
import (
	"errors"
	"fmt"
	"io"
	"net"
	"reflect"
	"runtime"
	"strconv"
	"sync"
	"syscall"
	"time"
	"unsafe"
	"github.com/google/gopacket"
	"github.com/google/gopacket/layers"
)
const errorBufferSize = 256
const MaxBpfInstructions = 4096
const bpfInstructionBufferSize = 8 * MaxBpfInstructions
type Handle struct {
	cptr         *C.pcap_t
	blockForever bool
	device       string
	mu           sync.Mutex
	pkthdr  *C.struct_pcap_pkthdr
	buf_ptr *C.u_char
}
type Stats struct {
	PacketsReceived  int
	PacketsDropped   int
	PacketsIfDropped int
}
type Interface struct {
	Name        string
	Description string
	Addresses   []InterfaceAddress
}
type Datalink struct {
	Name        string
	Description string
}
type InterfaceAddress struct {
	IP      net.IP
	Netmask net.IPMask  
}
type BPF struct {
	orig string
	bpf  _Ctype_struct_bpf_program  
}
type BPFInstruction struct {
	Code uint16
	Jt   uint8
	Jf   uint8
	K    uint32
}
const BlockForever = -time.Millisecond * 10
func timeoutMillis(timeout time.Duration) C.int {
	if timeout < 0 {
		timeout *= -1
	}
	if timeout != 0 && timeout < time.Millisecond {
		timeout = time.Millisecond
	}
	return C.int(timeout / time.Millisecond)
}
func OpenLive(device string, snaplen int32, promisc bool, timeout time.Duration) (handle *Handle, _ error) {
	buf := (*C.char)(C.calloc(errorBufferSize, 1))
	defer C.free(unsafe.Pointer(buf))
	var pro C.int
	if promisc {
		pro = 1
	}
	p := &Handle{}
	p.blockForever = timeout < 0
	p.device = device
	dev := C.CString(device)
	defer C.free(unsafe.Pointer(dev))
	p.cptr = C.pcap_open_live(dev, C.int(snaplen), pro, timeoutMillis(timeout), buf)
	if p.cptr == nil {
		return nil, errors.New(C.GoString(buf))
	}
	return p, nil
}