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)
| 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. |
| 171 | func (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. |
| 190 | func (b *Backend) Close() error { |
nothing calls this directly
no test coverage detected