pcap_findalldevs_ex Funktion nicht definiert ist
Ich versuche ein Beispiel für den Erhalt erweiterte Informationen über installierte n/w-Geräte von WinPcap.
Habe ich selbst folgte den Anweisungen, einschließlich WinPcap Bibliothek ,noch der compiler beschwert sich, dass pcap_findalldevs_ex
undefined
in Zeile if (pcap_findalldevs_ex(source, NULL, &alldevs, errbuf) == -1)
.
Mein Code :
#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 machine\n"
"rpcap://hostname:port ==> lists interfaces in a remote machine\n"
" (rpcapd daemon must be up and running\n"
" and it must accept 'null' authentication)\n"
"file://foldername ==> lists all pcap files in the give folder\n\n"
"Enter your choice: ");
fgets(source, PCAP_ERRBUF_SIZE, stdin);
source[PCAP_ERRBUF_SIZE] = '\0';
/* Retrieve the interfaces list */
if (pcap_findalldevs_ex(source, NULL, &alldevs, errbuf) == -1)
{
fprintf(stderr,"Error in pcap_findalldevs: %s\n",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, char *address, int addrlen)
{
//Code removed to reduce length
}
Kann jemand mich in die richtige Richtung?
Edit : Wenn ich pcap_findalldevs(&alldevs, errbuf)
im obigen code erfolgreich erstellt. Also ich denke, es ist kein problem, die Verknüpfung zu der dll.
Edit 1 : Fehler
error C3861: 'pcap_findalldevs_ex': Bezeichner wurde nicht gefunden
IntelliSense:identifier "pcap_findalldevs_ex" undefined
Dank.
- Gleiche Antwort für mich gearbeitet, und ich hatte zum Verweis auf 32-bit-Bibliotheken statt x64 eine (WpdPack\Lib\x64), obwohl mein 64-bit OS
Du musst angemeldet sein, um einen Kommentar abzugeben.
pcap_findalldevs_ex
ist nur vorhanden, wenn Sie definierenHAVE_REMOTE
Hinzufügen
HAVE_REMOTE
als ein Präprozessor-definition in den Projekteigenschaften, oder tun Sie das folgende für jeden einschließen, der pcap.h:pcap_findalldevs_ex': identifier not found
. Sollte poste ich die screenshots, wie habe ich die WinPcap-Bibliothek in mein Projekt ? Und das Hauptproblem ist, wenn ich ein Beispiel die enthältpcap_findalldevs
Funktion erfolgreich erstellt, aber es nicht bauen mitpcap_findalldevs_ex
Programme.pcap_findalldevs_ex(source, NULL, &alldevs, errbuf)
und ersetzen Sie es mitpcap_findalldevs(&alldevs, errbuf)
es erfolgreich erstellt. Aber dann funktioniert es nicht wie gewünscht.