开发者

how to determinate destination MAC address

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 address How c开发者_Go百科an I determinate MAC address belongs to a specific target?


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.


In general, MAC addresses don't matter for remote targets. They are not routable; a router here at my office doesn't know the MAC addresses of network cards across the Internet. That's what IP addresses are for. Do you mean local only?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜