I have connected to an existing Tap device using
fd = open(...)
Now i want to read from it packet by packet. if i use
read(fd,buffer,sizeof(buffer));
I wont read exactly 1 packet.
How can i read exactly 1 packet? Is there some kind of header that says the packet length or in the worst case i will have to parse the packet and figure the length myself?
I was wrong about the way read()
reads bytes from a tap device.
It turns out when I use read()
it reads exactly 1 frame, (or n bytes if n is smaller then frame size)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With