ARP?如何用C添加arptable? [英] ARP? How to add an arptable by C?

查看:164
本文介绍了ARP?如何用C添加arptable?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用C添加一个arptable,例如,类型喜欢静态,添加ip和mac.then,如果成功,wa可以得到一个新的arptable。



我尝试了什么:



我没有办法解决这个问题。所以我需要帮助。

I want to add an arptable by C,for example,the type likes static,add the ip and mac.then,if success,wa can get a new arptable.

What I have tried:

I don't have a good way to solute the problem.So I need help.

推荐答案

您无法创建ARP表。这些由每个网络适配器的操作系统管理。但是你可以编写一个实用程序来读取和修改现有的ARP表。



因为这些实用程序已经存在(Windows: Arp [ ^ ],Linux: arp(8):更改系统ARP缓存 - Linux手册页 [ ^ ]),您只需从C程序中调用相应的命令,或者查看Linux arp 源,看看它是如何完成的。





最简单的解决方案是使用 system()调用传递 arp 命令。



对于Linux,请查看 arp 实用程序的来源:net-tools:arp.c [ ^ ]



对于Windows,请参阅 CreateIpNetEntry函数(Windows) [ ^ ]。

[/ EDIT]
You can't create an ARP table. These are managed by the operating system for each network adapter. But you can write an utility that reads and modifies existing ARP tables.

Because such utilities exist already (Windows: Arp[^], Linux: arp(8): change system ARP cache - Linux man page[^]), you can just call the corresponding command from your C program or have a look at the Linux arp sources to see how it can be done.


The simplest solution would be using a system() call passing the arp command.

For Linux have a look at the source of the arp utility: net-tools: arp.c[^]

For Windows, see the CreateIpNetEntry function (Windows)[^].
[/EDIT]


这篇关于ARP?如何用C添加arptable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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