Closed etkaar closed 3 months ago
My friend you have not read the documentation correctly.
By default this function will parse a single packet. However, if either ppNext or pNextLen are non-NULL, then the pPacket parameter can point to a batch (>1) of packets (and packetLen can be the total length of the batch). In this case, the function will parse the first packet, and a pointer to the remaining packet(s) will be written to ppNext, and the remaining length will be written to pNextLen. This makes it convenient to loop over every packet in the batch as follows:
while (WinDivertHelperParsePacket(pPacket, packetLen, ..., &pPacket, &packetLen))
{
...
}
In your code you are never updating the location of batch_buffer or recv_bytes_written therefore you always get the first packet in the buffer.
I think majibow's answer is correct.
With following code I always end up with an infinite loop. Shouldn't WinDivertHelperParsePacket return false after the buffer is empty to end the loop?