visual-c – pcap_findalldevs_ex函数未定义
发布时间:2020-12-16 03:42:38 所属栏目:百科 来源:网络整理
导读:我正在尝试从 WinPcap获取有关已安装的n / w设备的高级信息的示例. 我甚至按照包含WinPcap库的说明,仍然编译器抱怨 pcap_findalldevs_ex 未定义 在行if(pcap_findalldevs_ex(source,NULL, alldevs,errbuf)== -1). 我的代码: #include "stdafx.h"#include st
我正在尝试从
WinPcap获取有关已安装的n / w设备的高级信息的示例.
我甚至按照包含WinPcap库的说明,仍然编译器抱怨 在行if(pcap_findalldevs_ex(source,NULL,& alldevs,errbuf)== -1). 我的代码: #include "stdafx.h" #include <stdio.h> #include "pcap.h" #include <winsock2.h> #pragma comment(lib,"ws2_32") // Function prototypes void ifprint(pcap_if_t *d); char *iptos(u_long in); char* ip6tos(struct sockaddr *sockaddr,char *address,int addrlen); int _tmain(int argc,_TCHAR* argv[]) { pcap_if_t *alldevs; pcap_if_t *d; char errbuf[PCAP_ERRBUF_SIZE+1]; char source[PCAP_ERRBUF_SIZE+1]; printf("Enter the device you want to list:n" "rpcap:// ==> lists interfaces in the local machinen" "rpcap://hostname:port ==> lists interfaces in a remote machinen" " (rpcapd daemon must be up and runningn" " and it must accept 'null' authentication)n" "file://foldername ==> lists all pcap files in the give foldernn" "Enter your choice: "); fgets(source,PCAP_ERRBUF_SIZE,stdin); source[PCAP_ERRBUF_SIZE] = ' '; /* Retrieve the interfaces list */ if (pcap_findalldevs_ex(source,&alldevs,errbuf) == -1) { fprintf(stderr,"Error in pcap_findalldevs: %sn",errbuf); exit(1); } /* Scan the list printing every entry */ for(d=alldevs;d;d=d->next) { ifprint(d); } pcap_freealldevs(alldevs); return 1; return 0; } /* Print all the available information on the given interface */ void ifprint(pcap_if_t *d) { //Code removed to reduce length and it contains no errors. } /* From tcptraceroute,convert a numeric IP address to a string */ #define IPTOSBUFFERS 12 char *iptos(u_long in) { //Code removed to reduce length } char* ip6tos(struct sockaddr *sockaddr,int addrlen) { //Code removed to reduce length } 有人能指出我正确的方向吗? 编辑:如果我在上面的代码中使用pcap_findalldevs(& alldevs,errbuf),它就会成功构建.所以我想连接到dll没有问题. 编辑1:错误 错误C3861:’pcap_findalldevs_ex’:找不到标识符 谢谢. 解决方法
pcap_findalldevs_ex仅在您定义HAVE_REMOTE时才存在
在项目属性中添加HAVE_REMOTE作为预处理器定义,或者对pcap.h的每个包含执行以下操作: #define HAVE_REMOTE #include "pcap.h" (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |