ARP 的编程使用

发布于 2024-08-24 21:30:40 字数 341 浏览 4 评论 0原文

我需要一些可在 Linux 下编译的 C 或 C++ 代码,以便能够获取任意数量的远程主机的 IP 地址列表,并为每台主机获取以太网 MAC 地址。这些主机可能位于同一子网上,也可能位于路由器后面的不同子网上。如果部分或全部远程主机的 MAC 地址是路由器上接口的地址,则可以。最终,我想将 IP 地址和 MAC 地址交给 FPGA,FPGA 将使用这些信息来格式化 UDP/IP 数据包并将其通过以太网发送到主机。显然,FPGA也会被赋予自己的MAC地址和IP地址,用于填写数据包中的源MAC和源IP地址。

是否有一些代码可以向我指出,可以创建 ARP 数据包并将其广播到这些远程计算机,并接收回 ARP 响应数据包,以便可以提取目标 MAC 地址?

I have a need for some C or C++ code, compilable under Linux, to be able to take a list of IP addresses of some arbitrary number of remote hosts machines and obtain a ethernet MAC address for each one. These host machines may be on the same subnet or they could be on a different subnet behind a router. Its OK if the MAC address of some or all of the remote hosts is the address of the interface on the router. Ultimately, I want to hand off the IP address and MAC address to an FPGA who will use these pieces of information to format and send UDP/IP packets over ethernet to the hosts. Obviously, the FPGA will also be given its own MAC address and IP address to fill in the source MAC and source IP addresses in the packets.

Is there some code I can be pointed to that can create and broadcast ARP packets to these remote machines and receive back the ARP response packets such that the destination MAC addresses can be extracted?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一世旳自豪 2024-08-31 21:30:40

您想要做的部分工作需要一些原始套接字编程。

http://mixter.void.ru/rawip.html

linux arp 命令的源码将提供您所需的其余内容。这是一个链接:

http://www .comp.nus.edu.sg/~cs4236/readings/out/html/arp_8c-source.html

Part of what you want to do requires some raw socket programming.

http://mixter.void.ru/rawip.html

The source for the linux arp command will give the rest of what you need. Here's a link:

http://www.comp.nus.edu.sg/~cs4236/readings/out/html/arp_8c-source.html

血之狂魔 2024-08-31 21:30:40

我建议研究一下 arping,它的工作有些相似。它需要 IP 和 MAC 并尝试接收其他信息。或者只是对它们进行 ping 操作。

http://freshmeat.net/projects/arping/

I recommend looking into arping which is doing a somewhat identical job. It takes IPs and MACs and tries to receive additional informationen. Or justs pings them.

http://freshmeat.net/projects/arping/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文