1 #include <stdio.h>
2 #include <sys/types.h>
3 #include <sys/socket.h>
4 #include <netinet/in.h>
5 #include <arpa/inet.h>
6 #include <net/if_arp.h>
7 #include <string.h>
8 #include <linux/sockios.h>
9 int main(int argc,char *argv[])
10 {
11 int s;
12 struct arpreq arpreq;
13 struct sockaddr_in *addr=(struct sockaddr_in*)&arpreq.arp_pa;
14 unsigned char *hw;
15 int err=-1;
16 if(argc<2)
17 {
18 printf("错误的使用方式,格式为:\n myarp ip(myarp 127.0.0.1)\n");
19 return -1;
20 }
21 s=socket(AF_INET,SOCK_DGRAM,0);
22 if(s<0)
23 {
24 printf("socket()出错\n");
25 return -1;
26 }
27 //填充arpr
2 #include <sys/types.h>
3 #include <sys/socket.h>
4 #include <netinet/in.h>
5 #include <arpa/inet.h>
6 #include <net/if_arp.h>
7 #include <string.h>
8 #include <linux/sockios.h>
9 int main(int argc,char *argv[])
10 {
11 int s;
12 struct arpreq arpreq;
13 struct sockaddr_in *addr=(struct sockaddr_in*)&arpreq.arp_pa;
14 unsigned char *hw;
15 int err=-1;
16 if(argc<2)
17 {
18 printf("错误的使用方式,格式为:\n myarp ip(myarp 127.0.0.1)\n");
19 return -1;
20 }
21 s=socket(AF_INET,SOCK_DGRAM,0);
22 if(s<0)
23 {
24 printf("socket()出错\n");
25 return -1;
26 }
27 //填充arpr