使用ioctl()函数获取ARP高速缓存例子的c实现

  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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值