在 c++ 中使用 pcap_findalldevs_ex 函数时出错 [英] Error in use of the pcap_findalldevs_ex Function in c++

查看:58
本文介绍了在 c++ 中使用 pcap_findalldevs_ex 函数时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这个程序下面检索适配器列表并将其打印在屏幕上:

Below this program to retrieve the list of adapters and print it on the screen :

 #include <stdio.h>
 #include <pcap.h>  

 int main()  
 {  
     pcap_if_t *alldevs;  
     pcap_if_t *d;  
     int i=0;  
     char errbuf[PCAP_ERRBUF_SIZE];  

     if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1)  
     {  
         fprintf(stderr,"Error in pcap_findalldevs_ex: %s/n", errbuf);  
         exit(1);  
     }  


     for(d= alldevs; d != NULL; d= d->next)  
     {  
         printf("%d. %s", ++i, d->name);  
         if (d->description)  
             printf(" (%s)/n", d->description);  
         else  
             printf(" (No description available)/n");  
     }  

     if (i == 0)  
     {  
         printf("/nNo interfaces found! Make sure WinPcap is installed./n");  
         return 0;  
     }  

     pcap_freealldevs(alldevs);  
 }

它是编译但给出错误:

推荐答案

每个人都有这些错误,在使用 pcap.h 时,请转到以下链接并下载 pcap,然后安装它:http://www.winpcap.org/install/default.htm

Every body have These Errors, while using pcap.h, go to bellow link and download pcap, after it Install it : http://www.winpcap.org/install/default.htm

这篇关于在 c++ 中使用 pcap_findalldevs_ex 函数时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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