質問

I want to create an application by libpcap in Qt in Kali linux. I create similar application in windows & does work.

I download & install libpcap. Now, Qt recognizes pcap.h but some functions & constants does not work. like as:

pcap_open - PCAP_OPENFLAG_PROMISCUOUS - pcap_findalldevs_ex - PCAP_SRC_IF_STRING - _snprintf_s.

The compiler errors similar as 'sth' was not declared in this scope. I use below headers but above errors apppear.

#define HAVE_REMOTE
#define WPCAP
#include <pcap.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
役に立ちましたか?

解決

WinPcap adds some APIs not available in libpcap (and versions of libpcap newer than the version upon which the latest WinPcap release is based have APIs not available in WinPcap).

pcap_open() is one of those APIs; it is NOT available in libpcap. You must either use pcap_open_live() or, in libpcap 1.x, pcap_create() and pcap_activate().

libpcap also doesn't currently support remote packet capture.

他のヒント

add LIBS += -lpcap at the end of your .pro file. It will solve the issue.

I searched & found some functions in winpcap does not work in libpcap (As Guy Harris said).

For Qt programmer in linux, they have to add below code to .pro file:

LIBS += -L/usr/local/lib/ -lpcap
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top