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

Method Inject

platform/windows/backend.go:171–187  ·  view source on GitHub ↗

Inject emits a raw IPv4 packet back onto the stack. The direction is encoded on the address; if the engine hasn't seen any outbound packet yet (very early in a flow), we build a plausible outbound address from zero.

(pkt []byte, dir snixplatform.Direction)

Source from the content-addressed store, hash-verified

169// encoded on the address; if the engine hasn't seen any outbound packet yet
170// (very early in a flow), we build a plausible outbound address from zero.
171func (b *Backend) Inject(pkt []byte, dir snixplatform.Direction) error {
172 if len(pkt) < 20 {
173 return fmt.Errorf("snix/windows: inject packet too short")
174 }
175 b.mu.Lock()
176 base := b.outboundAddr
177 h := b.handle
178 b.mu.Unlock()
179 var addr Address
180 if base != nil {
181 addr = *base
182 }
183 addr.SetOutbound(dir == snixplatform.DirOutbound)
184
185 _, err := Send(h, pkt, &addr)
186 return err
187}
188
189// Close tears down the WinDivert handle and stops the recv loop.
190func (b *Backend) Close() error {

Callers

nothing calls this directly

Implementers 3

fakeBackendcore/engine/engine_test.go
Backendplatform/windows/backend.go
Backendplatform/linux/nfqueue.go

Calls 2

SetOutboundMethod · 0.95
SendFunction · 0.85

Tested by

no test coverage detected