send arbitrary ethernet frames using packet_mmap but can't set up ring

前端 未结 1 1183
醉话见心
醉话见心 2021-01-28 13:21

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

相关标签:
1条回答
  • 2021-01-28 14:18

    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));

    0 讨论(0)
提交回复
热议问题