MCPcopy Create free account
hub / github.com/SamNet-dev/snix / Recv

Function Recv

platform/windows/windivert_api.go:120–133  ·  view source on GitHub ↗

Recv fetches the next packet into buf. Returns the number of bytes and the address metadata. On error, n is undefined.

(h handleRaw, buf []byte)

Source from the content-addressed store, hash-verified

118// Recv fetches the next packet into buf. Returns the number of bytes and
119// the address metadata. On error, n is undefined.
120func Recv(h handleRaw, buf []byte) (n uint32, addr Address, err error) {
121 var recvLen uint32
122 r1, _, e1 := procWinDivertRecv.Call(
123 uintptr(h),
124 uintptr(unsafe.Pointer(&buf[0])),
125 uintptr(uint32(len(buf))),
126 uintptr(unsafe.Pointer(&recvLen)),
127 uintptr(unsafe.Pointer(&addr)),
128 )
129 if r1 == 0 {
130 return 0, addr, fmt.Errorf("WinDivertRecv: %w", translateErr(e1))
131 }
132 return recvLen, addr, nil
133}
134
135// Send writes packet pkt back to the stack using addr as the re-injection
136// metadata. Returns bytes written.

Callers 1

recvLoopMethod · 0.85

Calls 1

translateErrFunction · 0.85

Tested by

no test coverage detected