误差在使用中在c pcap_findalldevs_ex功能++(Error in use of t

2019-10-22 19:08发布

下面这个程序来获取适配器列表,并打印在屏幕上:

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

这是编译,但给出一个错误:

Answer 1:

每一个身体有这些错误,而使用pcap.h,去吼叫链接和下载PCAP,之后安装: http://www.winpcap.org/install/default.htm



文章来源: Error in use of the pcap_findalldevs_ex Function in c++
标签: sockets pcap