如何在C中将arp地址添加到/proc/net/arp中
我想将 arp 绑定添加到 C
中的 /proc/net/arp
中。不允许写入文件,因此尝试以其他方式执行此操作。有什么建议吗?我已经知道 net-tools,但还没有尝试过
I would like to add arp bindings into /proc/net/arp
in C
. Writing into file is not allowed, so trying to do it some other way. Any suggestions? I already know about net-tools, but havent tryed yet
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用 netlink 协议 或libnetlink。我建议查看 arp 命令的源代码,以了解它是如何执行的。
You will need to use the netlink protocol or libnetlink. I would recommend looking at the source for the
arp
command to see exactly how it does it.ip neigh add 可以做到这一点:
例如:
这是你想要做的吗?
如果您想直接在 C 中执行此操作,请查看
ip
工具的源代码,该工具是iproute2
包的一部分。ip neigh add can do this:
For example:
Is this what you want to do?
If you want to do this directly in C, look at the source of the
ip
tool, which is part of theiproute2
package.