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

查看:12
本文介绍了如何确定目的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?

推荐答案

看起来你想要的是 ioctl 和 SIOCGARP.那应该让您查询您的arp缓存.我假设有问题的主机在您的本地网络上,或者您将获得的只是您的路由器.

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天全站免登陆