当前位置: 技术问答>linux和unix
谁成功使用过SIOCGARP获取过ARP的一个表项?
来源: 互联网 发布时间:2017-04-26
本文导语: 如题,在 http://www3.amherst.edu/~jwmanly/resnet97/getarp.c 找了个程序: /* getarp.c -- This simple program uses an IOCTL socket call to read an entry */ /* from the ARP cache of the local machine. Original source unknown. */ /* Us...
如题,在 http://www3.amherst.edu/~jwmanly/resnet97/getarp.c 找了个程序:
/* getarp.c -- This simple program uses an IOCTL socket call to read an entry */
/* from the ARP cache of the local machine. Original source unknown. */
/* Usage: getarp */
/* Example: getarp 148.85.2.1 */
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
/* arp_flags and at_flags field values */
#define ATF_INUSE 0x01 /* entry in use */
#define ATF_COM 0x02 /* completed entry (enaddr valid) */
#define ATF_PERM 0x04 /* permanent entry */
#define ATF_PUBL 0x08 /* publish entry (respond for other host) */
#define ATF_USETRAILERS 0x10 /* has requested trailers */
#define ATF_PROXY 0x20 /* Do PROXY arp */
main (int argc, char *argv[]) {
int s;
struct arpreq arpreq;
struct sockaddr_in *sin;
unsigned char *eap;
if (argc sin_family = AF_INET;
sin->sin_addr.s_addr = inet_addr(argv[1]);
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s dev, "eth0");试试