MCPcopy
hub / github.com/google/gopacket / pcapOpenLive

Function pcapOpenLive

pcap/pcap_windows.go:300–318  ·  view source on GitHub ↗
(device string, snaplen int, pro int, timeout int)

Source from the content-addressed store, hash-verified

298}
299
300func pcapOpenLive(device string, snaplen int, pro int, timeout int) (*Handle, error) {
301 err := LoadWinPCAP()
302 if err != nil {
303 return nil, err
304 }
305
306 buf := make([]byte, errorBufferSize)
307 dev, err := syscall.BytePtrFromString(device)
308 if err != nil {
309 return nil, err
310 }
311
312 cptr, _, _ := syscall.Syscall6(pcapOpenLivePtr, 5, uintptr(unsafe.Pointer(dev)), uintptr(snaplen), uintptr(pro), uintptr(timeout), uintptr(unsafe.Pointer(&buf[0])), 0)
313
314 if cptr == 0 {
315 return nil, errors.New(byteSliceToString(buf))
316 }
317 return &Handle{cptr: pcapTPtr(cptr)}, nil
318}
319
320func openOffline(file string) (handle *Handle, err error) {
321 err = LoadWinPCAP()

Callers

nothing calls this directly

Calls 4

LoadWinPCAPFunction · 0.85
byteSliceToStringFunction · 0.85
pcapTPtrTypeAlias · 0.70
NewMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…