Send writes packet pkt back to the stack using addr as the re-injection metadata. Returns bytes written.
(h handleRaw, pkt []byte, addr *Address)
| 135 | // Send writes packet pkt back to the stack using addr as the re-injection |
| 136 | // metadata. Returns bytes written. |
| 137 | func Send(h handleRaw, pkt []byte, addr *Address) (uint32, error) { |
| 138 | if len(pkt) == 0 { |
| 139 | return 0, fmt.Errorf("send: empty packet") |
| 140 | } |
| 141 | var sentLen uint32 |
| 142 | r1, _, e1 := procWinDivertSend.Call( |
| 143 | uintptr(h), |
| 144 | uintptr(unsafe.Pointer(&pkt[0])), |
| 145 | uintptr(uint32(len(pkt))), |
| 146 | uintptr(unsafe.Pointer(&sentLen)), |
| 147 | uintptr(unsafe.Pointer(addr)), |
| 148 | ) |
| 149 | if r1 == 0 { |
| 150 | return 0, fmt.Errorf("WinDivertSend: %w", translateErr(e1)) |
| 151 | } |
| 152 | return sentLen, nil |
| 153 | } |
| 154 | |
| 155 | // Close unloads the WinDivert handle. |
| 156 | func Close(h handleRaw) error { |
no test coverage detected