如何确定目标MAC地址 [英] how to determinate destination MAC address

查看:276
本文介绍了如何确定目标MAC地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在CentOS 5.5上运行 我需要使用libpcap API发送原始数据包:

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

pcap_inject() or pcap_sendpacket()

到特定的IP地址 如何确定MAC地址属于特定目标?

To the specific IP address How can 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.

您也可以从/proc/net/arp中读取,这似乎更容易.您需要先返回一个arp请求,但是无论您的工具是第三方还是第三方提出请求,您都需要这样做.

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.

这篇关于如何确定目标MAC地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆