Error in use of the pcap_findalldevs_ex Function in c++

三世轮回 提交于 2020-01-06 02:35:06

问题


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);  
 }

It is compile But Give an Error :


回答1:


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



来源:https://stackoverflow.com/questions/29822809/error-in-use-of-the-pcap-findalldevs-ex-function-in-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!