how to determinate destination MAC address

前端 未结 2 735
夕颜
夕颜 2021-01-28 22:59

My application is running on CentOS 5.5 I need to send raw packets using libpcap API:

pcap_inject() or pcap_sendpacket()

To the specific IP add

2条回答
  •  一整个雨季
    2021-01-29 00:03

    It looks like what you want is ioctl and SIOCGARP. That should let you query your arp cache. I'm assuming that the host in question is on your local network or all you're going to get is your router.

    You can also read from /proc/net/arp, which seems easier. You'll need to get an arp request returned first but you'll be doing that whether your tool does it or some third-party makes the request.

提交回复
热议问题