I am trying to send raw ethernet frames using packet_mmap. A good example I found is at this gist. However, this example was using link-level raw socket, so the source ethernet
Well, I did not run your code, but SOCK_PACKET
is deprecated. From man 2 socket
:
SOCK_PACKET: Obsolete and should not be used in new programs; see packet(7).
The lowest level for interface access is actually SOCK_RAW
: it will allow you to create arbitrary packets, including forging the data for the Ethernet layer. Try:
fd = socket(AF_PACKET, SOCK_RAW, IPPROTO_RAW);
or
fd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));