I have the following setup:
client(eth0)
When I open a RAW socket on linux bridge using
fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
I have a socket associated with eth2. When a client sends a packet to the server, wirehark running on the bridge reports the packet with the source MAC address of the client (eth0) and the destination MAC address of the server (eth1).
When I do read() , the first 6 bytes of the data being read are the destination address, which is correctly read as the server (eth1).
However, when I change the instruction to
fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IP));
When I do read() , the first 6 bytes of the data read indicates that the destination address is linux bridge (eth2).
Why was that? Is the kernel driver or network card putting its own address in the buffer instead of reading using ETH_P_IP?
source share